VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/sys/vbi.h@ 33540

最後變更 在這個檔案從33540是 27727,由 vboxsync 提交於 15 年 前

vbi.h: missing function prototype.

  • 屬性 svn:eol-style 設為 native
檔案大小: 11.4 KB
 
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#ifndef _SYS_VBI_H
28#define _SYS_VBI_H
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/*
35 * Must be the called to initialize the VBI structures and code paths.
36 *
37 * return value is 0 on success, non-zero on failure.
38 */
39int vbi_init(void);
40
41/*
42 * Private interfaces for VirtualBox access to Solaris kernel internal
43 * facilities. The interface uses limited types when crossing the kernel
44 * to hypervisor boundary. (void *) is for handles and function and other
45 * pointers. uint64 for physical addresses, size_t and int elsewhere.
46 * The goal is for this module to eventually be part of OpenSolaris once
47 * interfaces have become more stable.
48 */
49
50/*
51 * Allocate and free physically contiguous, page aligned memory.
52 *
53 *
54 * return value is a) NULL if contig memory not available or
55 * b) virtual address of memory in kernel heap
56 *
57 * *phys on input is set to the upper boundary of acceptable memory
58 * *phys on output returns the starting physical address
59 *
60 * size is the amount to allocate and must be a multiple of PAGESIZE
61 */
62extern void *vbi_contig_alloc(uint64_t *phys, size_t size);
63
64/*
65 * va is from vbi_contig_alloc() return value
66 * size must match from vbi_contig_alloc()
67 */
68extern void vbi_contig_free(void *va, size_t size);
69
70
71/*
72 * Map physical page into kernel heap space
73 *
74 * return value is a) NULL if out of kernel virtual address space or
75 * on success b) virtual address of memory in kernel heap
76 *
77 * pa is the starting physical address, must be PAGESIZE aligned
78 *
79 * size is the amount to map and must be a multiple of PAGESIZE
80 */
81extern void *vbi_kernel_map(uint64_t pa, size_t size, uint_t prot);
82
83/*
84 * Map physical pages into user part of the address space.
85 *
86 * returns 0 on success, non-zero on failure
87 */
88extern int vbi_user_map(caddr_t *va, uint_t prot, uint64_t *palist, size_t len);
89
90/*
91 * Unmap physical memory from virtual address space. No freeing of physical
92 * memory is done.
93 *
94 * va is from a call to vbi_kernel_map() or vbi_user_map() that used sz
95 */
96extern void vbi_unmap(void *va, size_t size);
97
98
99/*
100 * return value is an OS handle for the current thread.
101 */
102extern void *vbi_curthread(void);
103
104
105/*
106 * Yield thread.
107 * return value is an inexact value for:
108 * 0 - the thread probably didn't yield
109 * 1 - the thread probably did yield
110 */
111extern int vbi_yield(void);
112
113
114/*
115 * Timer functions, times expressed in nanoseconds.
116 */
117extern uint64_t vbi_timer_granularity(void);
118
119/* old timer funcs */
120extern void *vbi_timer_create(void *callback, void *arg1, void *arg2,
121 uint64_t interval);
122extern void vbi_timer_destroy(void *timer);
123extern void vbi_timer_start(void *timer, uint64_t when);
124extern void vbi_timer_stop(void *timer);
125
126/*
127 * Returns current time of day in nanoseconds.
128 */
129extern uint64_t vbi_tod(void);
130
131/*
132 * Process handle
133 */
134extern void *vbi_proc(void);
135
136/*
137 * thread functions
138 */
139extern void vbi_set_priority(void *thread, int priority);
140extern void *vbi_thread_create(void *func, void *arg, size_t len, int priority);
141extern void vbi_thread_exit(void);
142
143/*
144 * Allocate and free kernel heap suitable for use as executable text
145 *
146 * return value is a) NULL if memory not available or
147 * b) virtual address of memory in kernel heap
148 *
149 * size is the amount to allocate
150 *
151 * Note that the virtual mappings to memory allocated by this interface are
152 * locked.
153 */
154extern void *vbi_text_alloc(size_t size);
155
156/*
157 * va is from vbi_text_alloc() return value
158 * size must match from vbi_text_alloc()
159 */
160extern void vbi_text_free(void *va, size_t size);
161
162/*
163 * CPU and cross call related functionality
164 *
165 * return current cpu identifier
166 */
167extern int vbi_cpu_id(void);
168
169/*
170 * return maximum possible cpu identifier
171 */
172extern int vbi_max_cpu_id(void);
173
174/*
175 * return max number of CPUs supported by OS
176 */
177extern int vbi_cpu_maxcount(void);
178
179/*
180 * return number of CPUs actually in system
181 */
182extern int vbi_cpu_count(void);
183
184/*
185 * returns 0 if cpu is offline, 1 if online
186 */
187extern int vbi_cpu_online(int c);
188
189/*
190 * disable/enable thread preemption
191 */
192extern void vbi_preempt_disable(void);
193extern void vbi_preempt_enable(void);
194
195/*
196 * causes "func(arg)" to be invoked on all online CPUs.
197 */
198extern void vbi_execute_on_all(void *func, void *arg);
199
200/*
201 * causes "func(arg)" to be invoked on all CPUs except the current one.
202 * should be called with preemption disabled.
203 */
204extern void vbi_execute_on_others(void *func, void *arg);
205
206/*
207 * causes "func(arg)" to be invoked on just one CPU
208 */
209extern void vbi_execute_on_one(void *func, void *arg, int c);
210
211
212/*
213 * Lock/unlock pages in virtual address space. Pages behind the virtual
214 * mappings are pinned and virtual mappings are locked. Handles to the
215 * pages are returned in the array.
216 *
217 * returns 0 for success, non-zero errno on failure
218 */
219extern int vbi_lock_va(void *addr, size_t len, int access, void **handle);
220extern void vbi_unlock_va(void *addr, size_t len, int access, void *handle);
221
222/*
223 * Return the physical address of memory behind a VA. If the
224 * memory is not locked, it may return -(uint64_t)1 to indicate that
225 * no physical page is at the address currently.
226 */
227extern uint64_t vbi_va_to_pa(void *addr);
228
229/* end of interfaces defined for version 1 */
230
231extern uint_t vbi_revision_level;
232
233/* begin interfaces defined for version 2 */
234
235/*
236 * Install/remove a call back for CPU online/offline event notification.
237 *
238 * The call back func is invoked with 3 arguments:
239 * void func(void *arg, int icpu, int online);
240 * - arg is passed through from vbi_watch_cpus()
241 * - cpu is the CPU id involved
242 * - online is non-zero for a CPU that comes online and 0 for a CPU that is
243 * going offline.
244 *
245 * If current_too is non-zero, then a cpu online event will be invoked for all
246 * currently online CPUs.
247 *
248 * Note there is no guarantee about which CPU the function is invoked on.
249 */
250typedef struct vbi_cpu_watch vbi_cpu_watch_t;
251extern vbi_cpu_watch_t *vbi_watch_cpus(void (*func)(void), void *arg,
252 int current_too);
253extern void vbi_ignore_cpus(vbi_cpu_watch_t *);
254#pragma weak vbi_watch_cpus
255#pragma weak vbi_ignore_cpus
256
257/*
258 * New timer interfaces
259 *
260 * A simple timer fires just once and on only one cpu. It may be repeating or
261 * a one shot.
262 *
263 * Support for one shot (ie interval == 0) global timers is optional.
264 *
265 * For simple timers, if cpu is VBI_ANY_CPU, the timer may fire on any
266 * available cpu otherwise the timer will fire only on the given cpu
267 *
268 * The repeating call back, func, is invoked with 2 arguments:
269 * - arg is just passed through
270 * - a uint64_t counter that starts at 0 and increments with each timer event.
271 * The count is per-cpu and resets whenever a cpu goes offline and comes back
272 * online.
273 *
274 * The when parameter is time relative to now.
275 *
276 * vbi_stimer_begin() may return NULL if there was an error in
277 * creating the timer, for example if a requested cpu is not online.
278 *
279 * vbi_gtimer_begin() may return NULL when called if it does not
280 * support the requested kind of timer (ie interval == 0)
281 */
282#define VBI_ANY_CPU (-1)
283
284typedef struct vbi_stimer vbi_stimer_t;
285extern vbi_stimer_t *vbi_stimer_begin(void (*func)(void *, uint64_t), void *arg,
286 uint64_t when, uint64_t interval, int icpu);
287extern void vbi_stimer_end(vbi_stimer_t *);
288#pragma weak vbi_stimer_begin
289#pragma weak vbi_stimer_end
290
291typedef struct vbi_gtimer vbi_gtimer_t;
292extern vbi_gtimer_t *vbi_gtimer_begin(void (*func)(void *, uint64_t), void *arg,
293 uint64_t when, uint64_t interval);
294extern void vbi_gtimer_end(vbi_gtimer_t *);
295#pragma weak vbi_gtimer_begin
296#pragma weak vbi_gtimer_end
297
298
299/* end of interfaces defined for version 2 */
300
301/* begin interfaces defined for version 3 */
302
303/*
304 * returns non-zero if the thread might be preempted at any time
305 */
306extern int vbi_is_preempt_enabled(void);
307
308/* end of interfaces defined for version 3 */
309
310/* begin interfaces defined for version 4 */
311
312/*
313 * poke the given cpu with an IPI
314 */
315extern void vbi_poke_cpu(int);
316
317/* end of interfaces defined for version 4 */
318
319/* begin interfaces defined for version 5 */
320/*
321 * Allocate and free physically limited, page aligned memory. Note that
322 * the allocated pages are not physically contiguous.
323 *
324 * return value is a) NULL if memory below "phys" not available or
325 * b) virtual address of memory in kernel heap
326 *
327 * phys on input is set to the upper boundary of acceptable memory
328 *
329 * size is the amount to allocate and must be a multiple of PAGESIZE
330 */
331extern void *vbi_lowmem_alloc(uint64_t phys, size_t size);
332
333/*
334 * va is from vbi_lowmem_alloc() return value
335 * size must match from vbi_lowmem_alloc()
336 */
337extern void vbi_lowmem_free(void *va, size_t size);
338/* end of interfaces defined for version 5 */
339
340/* begin interfaces defined for version 6 */
341extern int vbi_is_preempt_pending(void);
342
343/* end of interfaces defined for version 6 */
344
345/* begin interfaces defined for version 7 */
346/*
347 * Allocate and free physically limited, aligned as specified continuous or non-continuous memory.
348 *
349 * return value is a) NULL if memory below "phys" not available or
350 * b) virtual address of memory in kernel heap
351 *
352 * phys on input is set to the upper boundary of acceptable memory
353 *
354 * size is the amount to allocate and must be a multiple of PAGESIZE
355 */
356extern void *vbi_phys_alloc(uint64_t *phys, size_t size, uint64_t alignment, int contig);
357extern void vbi_phys_free(void *va, size_t size);
358/* end of interfaces defined for version 7 */
359
360/* begin interfaces defined for version 8 */
361
362/*
363 * Allocate pages from the free/cache list without creating
364 * any kernel mapping of the memory.
365 *
366 * return value is a) NULL if memory unavailable or
367 * b) an allocated array of page_t structures to each page allocated.
368 *
369 * phys on input is set to the physical address of the first page allocated.
370 *
371 * size is the amount to allocate and must be a multiple of PAGESIZE
372 */
373extern page_t **vbi_pages_alloc(uint64_t *phys, size_t size);
374
375/*
376 * Free pages allocated using vbi_pages_alloc()
377 */
378extern void vbi_pages_free(page_t **pp_pages, size_t size);
379
380/*
381 * Prepare pages allocated via vbi_pages_alloc() to be mapped into
382 * user or kernel space.
383 *
384 * return value is 0 on success, non-zero on failure.
385 *
386 * size is the amount allocated from which number of pages in the page array
387 * will be computed.
388 *
389 * physaddrs on input is filled with the physical address of each corresponding page
390 * that can be mapped in. Size of the array pointed to by physaddrs must correspond
391 * to size.
392 */
393extern int vbi_pages_premap(page_t **pp_pages, size_t size, uint64_t *physaddrs);
394
395/*
396 * Returns the physical address for the 'i'th page in the array of page
397 * structures in 'pp_pages'
398 */
399extern uint64_t vbi_page_to_pa(page_t **pp_pages, pgcnt_t i);
400/* end of interfaces defined for version 8 */
401
402#ifdef __cplusplus
403}
404#endif
405
406#endif /* _SYS_VBI_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette