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 | #pragma ident "@(#)vbi.h 1.1 08/05/26 SMI"
|
---|
31 |
|
---|
32 | #ifdef __cplusplus
|
---|
33 | extern "C" {
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | /*
|
---|
37 | * Private interfaces for VirtualBox access to Solaris kernel internal
|
---|
38 | * facilities. The interface uses limited types when crossing the kernel
|
---|
39 | * to hypervisor boundary. (void *) is for handles and function and other
|
---|
40 | * pointers. uint64 for physical addresses, size_t and int elsewhere.
|
---|
41 | */
|
---|
42 |
|
---|
43 | /*
|
---|
44 | * Allocate and free physically contiguous, page aligned memory.
|
---|
45 | *
|
---|
46 | *
|
---|
47 | * return value is a) NULL if contig memory not available or
|
---|
48 | * b) virtual address of memory in kernel heap
|
---|
49 | *
|
---|
50 | * *phys on input is set to the upper boundary of acceptable memory
|
---|
51 | * *phys on output returns the starting physical address
|
---|
52 | *
|
---|
53 | * size is the amount to allocate and must be a multiple of PAGESIZE
|
---|
54 | */
|
---|
55 | extern void *vbi_contig_alloc(uint64_t *phys, size_t size);
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * va is from vbi_contig_alloc() return value
|
---|
59 | * size must match from vbi_contig_alloc()
|
---|
60 | */
|
---|
61 | extern void vbi_contig_free(void *va, size_t size);
|
---|
62 |
|
---|
63 |
|
---|
64 | /*
|
---|
65 | * Map physical page into kernel heap space
|
---|
66 | *
|
---|
67 | * return value is a) NULL if out of kernel virtual address space or
|
---|
68 | * on success b) virtual address of memory in kernel heap
|
---|
69 | *
|
---|
70 | * pa is the starting physical address, must be PAGESIZE aligned
|
---|
71 | *
|
---|
72 | * size is the amount to map and must be a multiple of PAGESIZE
|
---|
73 | */
|
---|
74 | extern void *vbi_kernel_map(uint64_t pa, size_t size, uint_t prot);
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * Map physical pages into user part of the address space.
|
---|
78 | *
|
---|
79 | * returns 0 on success, non-zero on failure
|
---|
80 | */
|
---|
81 | extern int vbi_user_map(caddr_t *va, uint_t prot, uint64_t *palist, size_t len);
|
---|
82 |
|
---|
83 | /*
|
---|
84 | * Unmap physical memory from virtual address space. No freeing of physical
|
---|
85 | * memory is done.
|
---|
86 | *
|
---|
87 | * va is from a call to vbi_kernel_map() or vbi_user_map() that used sz
|
---|
88 | */
|
---|
89 | extern void vbi_unmap(void *va, size_t size);
|
---|
90 |
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * return value is an OS handle for the current thread.
|
---|
94 | */
|
---|
95 | extern void *vbi_curthread(void);
|
---|
96 |
|
---|
97 |
|
---|
98 | /*
|
---|
99 | * Yield thread.
|
---|
100 | * return value is an inexact value for:
|
---|
101 | * 0 - the thread probably didn't yield
|
---|
102 | * 1 - the thread probably did yield
|
---|
103 | */
|
---|
104 | extern int vbi_yield(void);
|
---|
105 |
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * Timer functions, times expressed in nanoseconds.
|
---|
109 | */
|
---|
110 | extern uint64_t vbi_timer_granularity(void);
|
---|
111 | extern void *vbi_timer_create(void *callback, void *arg1, void *arg2,
|
---|
112 | uint64_t interval);
|
---|
113 | extern void vbi_timer_destroy(void *timer);
|
---|
114 | extern void vbi_timer_start(void *timer, uint64_t when);
|
---|
115 | extern void vbi_timer_stop(void *timer);
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * Returns current time of day in nanoseconds.
|
---|
119 | */
|
---|
120 | extern uint64_t vbi_tod(void);
|
---|
121 |
|
---|
122 | /*
|
---|
123 | * Process handle
|
---|
124 | */
|
---|
125 | extern void *vbi_proc(void);
|
---|
126 |
|
---|
127 | /*
|
---|
128 | * thread functions
|
---|
129 | */
|
---|
130 | extern void vbi_set_priority(void *thread, int priority);
|
---|
131 | extern void *vbi_thread_create(void *func, void *arg, size_t len, int priority);
|
---|
132 | extern void vbi_thread_exit(void);
|
---|
133 |
|
---|
134 | /*
|
---|
135 | * Allocate and free kernel heap suitable for use as executable text
|
---|
136 | *
|
---|
137 | * return value is a) NULL if memory not available or
|
---|
138 | * b) virtual address of memory in kernel heap
|
---|
139 | *
|
---|
140 | * size is the amount to allocate
|
---|
141 | *
|
---|
142 | * Note that the virtual mappings to memory allocated by this interface are
|
---|
143 | * locked.
|
---|
144 | */
|
---|
145 | extern void *vbi_text_alloc(size_t size);
|
---|
146 |
|
---|
147 | /*
|
---|
148 | * va is from vbi_text_alloc() return value
|
---|
149 | * size must match from vbi_text_alloc()
|
---|
150 | */
|
---|
151 | extern void vbi_text_free(void *va, size_t size);
|
---|
152 |
|
---|
153 | /*
|
---|
154 | * CPU and cross call related functionality
|
---|
155 | *
|
---|
156 | * return current cpu identifier
|
---|
157 | */
|
---|
158 | extern int vbi_cpu_id(void);
|
---|
159 |
|
---|
160 | /*
|
---|
161 | * return maximum possible cpu identifier
|
---|
162 | */
|
---|
163 | extern int vbi_max_cpu_id(void);
|
---|
164 |
|
---|
165 | /*
|
---|
166 | * return max number of CPUs supported by OS
|
---|
167 | */
|
---|
168 | extern int vbi_cpu_maxcount(void);
|
---|
169 |
|
---|
170 | /*
|
---|
171 | * return number of CPUs actually in system
|
---|
172 | */
|
---|
173 | extern int vbi_cpu_count(void);
|
---|
174 |
|
---|
175 | /*
|
---|
176 | * returns 0 if cpu is offline, 1 if online
|
---|
177 | */
|
---|
178 | extern int vbi_cpu_online(int c);
|
---|
179 |
|
---|
180 | /*
|
---|
181 | * disable/enable thread preemption
|
---|
182 | */
|
---|
183 | extern void vbi_preempt_disable(void);
|
---|
184 | extern void vbi_preempt_enable(void);
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * causes "func(arg)" to be invoked on all online CPUs.
|
---|
188 | */
|
---|
189 | extern void vbi_execute_on_all(void *func, void *arg);
|
---|
190 |
|
---|
191 | /*
|
---|
192 | * causes "func(arg)" to be invoked on all CPUs except the current one.
|
---|
193 | * should be called with preemption disabled.
|
---|
194 | */
|
---|
195 | extern void vbi_execute_on_others(void *func, void *arg);
|
---|
196 |
|
---|
197 | /*
|
---|
198 | * causes "func(arg)" to be invoked on just one CPU
|
---|
199 | */
|
---|
200 | extern void vbi_execute_on_one(void *func, void *arg, int c);
|
---|
201 |
|
---|
202 |
|
---|
203 | /*
|
---|
204 | * Lock/unlock pages in virtual address space. Pages behind the virtual
|
---|
205 | * mappings are pinned and virtual mappings are locked. Handles to the
|
---|
206 | * pages are returned in the array.
|
---|
207 | *
|
---|
208 | * returns 0 for success, non-zero errno on failure
|
---|
209 | */
|
---|
210 | extern int vbi_lock_va(void *addr, size_t len, void **handle);
|
---|
211 | extern void vbi_unlock_va(void *addr, size_t len, void *handle);
|
---|
212 |
|
---|
213 | /*
|
---|
214 | * Return the physical address of memory behind a VA. If the
|
---|
215 | * memory is not locked, it may return -(uint64_t)1 to indicate that
|
---|
216 | * no physical page is at the address currently.
|
---|
217 | */
|
---|
218 | extern uint64_t vbi_va_to_pa(void *addr);
|
---|
219 |
|
---|
220 | /* end of interfaces defined for version 1 */
|
---|
221 |
|
---|
222 | extern uint_t vbi_revision_level;
|
---|
223 |
|
---|
224 | #ifdef __cplusplus
|
---|
225 | }
|
---|
226 | #endif
|
---|
227 |
|
---|
228 | #endif /* _SYS_VBI_H */
|
---|