debuggers.hg

view freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h @ 4628:35357e323f14

bitkeeper revision 1.1338 (4266317ezHysqYzH_WRvfueqwU4i4Q)

Grant tables for FreeBSD.
Signed-off-by: Kip Macy <kmacy@fsmware.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Apr 20 10:39:58 2005 +0000 (2005-04-20)
parents 5fd95a1db011
children f9f8f250228f
line source
1 /******************************************************************************
2 * hypervisor.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002, K A Fraser
7 */
9 #ifndef __HYPERVISOR_H__
10 #define __HYPERVISOR_H__
13 #include <machine/hypervisor-ifs.h>
14 #include <machine/frame.h>
15 #include "opt_xen.h"
17 extern start_info_t *xen_start_info;
19 /* arch/xen/mm/hypervisor.c */
20 /*
21 * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already
22 * be MACHINE addresses.
23 */
26 void MULTICALL_flush_page_update_queue(void);
28 #ifdef CONFIG_XEN_PHYSDEV_ACCESS
29 /* Allocate a contiguous empty region of low memory. Return virtual start. */
30 unsigned long allocate_empty_lowmem_region(unsigned long pages);
31 /* Deallocate a contiguous region of low memory. Return it to the allocator. */
32 void deallocate_lowmem_region(unsigned long vstart, unsigned long pages);
33 #endif
35 typedef struct { unsigned long pte_low, pte_high; } pte_t;
37 /*
38 * Assembler stubs for hyper-calls.
39 */
41 static inline int
42 HYPERVISOR_set_trap_table(trap_info_t *table)
43 {
44 int ret;
45 __asm__ __volatile__ (
46 TRAP_INSTR
47 : "=a" (ret) : "0" (__HYPERVISOR_set_trap_table),
48 "b" (table) : "memory" );
50 return ret;
51 }
53 static inline int
54 HYPERVISOR_mmu_update(mmu_update_t *req, int count,
55 int *success_count, domid_t domid)
56 {
57 int ret;
58 unsigned long ign1, ign2, ign3, ign4;
59 __asm__ __volatile__ (
60 TRAP_INSTR
61 : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
62 : "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
63 "3" (success_count), "4" (domid)
64 : "memory" );
66 return ret;
67 }
69 static inline int
70 HYPERVISOR_mmuext_op(
71 struct mmuext_op *op, int count, int *success_count, domid_t domid)
72 {
73 int ret;
74 unsigned long ign1, ign2, ign3, ign4;
75 __asm__ __volatile__ (
76 TRAP_INSTR
77 : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
78 : "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
79 "3" (success_count), "4" (domid)
80 : "memory" );
82 return ret;
83 }
87 static inline int
88 HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
89 {
90 int ret;
91 __asm__ __volatile__ (
92 TRAP_INSTR
93 : "=a" (ret) : "0" (__HYPERVISOR_set_gdt),
94 "b" (frame_list), "c" (entries) : "memory" );
97 return ret;
98 }
100 static inline int
101 HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
102 {
103 int ret;
104 __asm__ __volatile__ (
105 TRAP_INSTR
106 : "=a" (ret) : "0" (__HYPERVISOR_stack_switch),
107 "b" (ss), "c" (esp) : "memory" );
109 return ret;
110 }
112 static inline int
113 HYPERVISOR_set_callbacks(
114 unsigned long event_selector, unsigned long event_address,
115 unsigned long failsafe_selector, unsigned long failsafe_address)
116 {
117 int ret;
118 __asm__ __volatile__ (
119 TRAP_INSTR
120 : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
121 "b" (event_selector), "c" (event_address),
122 "d" (failsafe_selector), "S" (failsafe_address) : "memory" );
124 return ret;
125 }
127 static inline int
128 HYPERVISOR_fpu_taskswitch(void)
129 {
130 int ret;
131 __asm__ __volatile__ (
132 TRAP_INSTR
133 : "=a" (ret) : "0" (__HYPERVISOR_fpu_taskswitch) : "memory" );
135 return ret;
136 }
138 static inline int
139 HYPERVISOR_yield(void)
140 {
141 int ret;
142 __asm__ __volatile__ (
143 TRAP_INSTR
144 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
145 "b" (SCHEDOP_yield) : "memory" );
147 return ret;
148 }
150 static inline int
151 HYPERVISOR_block(void)
152 {
153 int ret;
154 __asm__ __volatile__ (
155 TRAP_INSTR
156 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
157 "b" (SCHEDOP_block) : "memory" );
159 return ret;
160 }
162 static inline int
163 HYPERVISOR_shutdown(void)
164 {
165 int ret;
166 __asm__ __volatile__ (
167 TRAP_INSTR
168 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
169 "b" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
170 : "memory" );
172 return ret;
173 }
175 static inline int
176 HYPERVISOR_reboot(void)
177 {
178 int ret;
179 __asm__ __volatile__ (
180 TRAP_INSTR
181 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
182 "b" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
183 : "memory" );
185 return ret;
186 }
188 static inline int
189 HYPERVISOR_suspend(unsigned long srec)
190 {
191 int ret;
192 /* NB. On suspend, control software expects a suspend record in %esi. */
193 __asm__ __volatile__ (
194 TRAP_INSTR
195 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
196 "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
197 "S" (srec) : "memory" );
199 return ret;
200 }
202 static inline long
203 HYPERVISOR_set_timer_op(uint64_t timeout)
204 {
205 int ret;
206 unsigned long timeout_hi = (unsigned long)(timeout>>32);
207 unsigned long timeout_lo = (unsigned long)timeout;
208 __asm__ __volatile__ (
209 TRAP_INSTR
210 : "=a" (ret) : "0" (__HYPERVISOR_set_timer_op),
211 "b" (timeout_lo), "c" (timeout_hi) : "memory" );
213 return ret;
214 }
216 static inline int
217 HYPERVISOR_dom0_op(dom0_op_t *dom0_op)
218 {
219 int ret;
220 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
221 __asm__ __volatile__ (
222 TRAP_INSTR
223 : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),
224 "b" (dom0_op) : "memory" );
226 return ret;
227 }
229 static inline int
230 HYPERVISOR_set_debugreg(int reg, unsigned long value)
231 {
232 int ret;
233 __asm__ __volatile__ (
234 TRAP_INSTR
235 : "=a" (ret) : "0" (__HYPERVISOR_set_debugreg),
236 "b" (reg), "c" (value) : "memory" );
238 return ret;
239 }
241 static inline unsigned long
242 HYPERVISOR_get_debugreg(int reg)
243 {
244 unsigned long ret;
245 __asm__ __volatile__ (
246 TRAP_INSTR
247 : "=a" (ret) : "0" (__HYPERVISOR_get_debugreg),
248 "b" (reg) : "memory" );
250 return ret;
251 }
253 static inline int
254 HYPERVISOR_update_descriptor(
255 unsigned long pa, unsigned long word1, unsigned long word2)
256 {
257 int ret;
258 __asm__ __volatile__ (
259 TRAP_INSTR
260 : "=a" (ret) : "0" (__HYPERVISOR_update_descriptor),
261 "b" (pa), "c" (word1), "d" (word2) : "memory" );
263 return ret;
264 }
266 static inline int
267 HYPERVISOR_set_fast_trap(int idx)
268 {
269 int ret;
270 __asm__ __volatile__ (
271 TRAP_INSTR
272 : "=a" (ret) : "0" (__HYPERVISOR_set_fast_trap),
273 "b" (idx) : "memory" );
275 return ret;
276 }
278 static inline int
279 HYPERVISOR_dom_mem_op(unsigned int op,
280 unsigned long *pages,
281 unsigned long nr_pages)
282 {
283 int ret;
284 __asm__ __volatile__ (
285 TRAP_INSTR
286 : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
287 "b" (op), "c" (pages), "d" (nr_pages) : "memory" );
288 return ret;
289 }
291 static inline int
292 HYPERVISOR_multicall(void *call_list, int nr_calls)
293 {
294 int ret;
295 __asm__ __volatile__ (
296 TRAP_INSTR
297 : "=a" (ret) : "0" (__HYPERVISOR_multicall),
298 "b" (call_list), "c" (nr_calls) : "memory" );
300 return ret;
301 }
303 static inline int
304 HYPERVISOR_update_va_mapping(
305 unsigned long page_nr, unsigned long new_val, unsigned long flags)
306 {
307 int ret;
308 __asm__ __volatile__ (
309 TRAP_INSTR
310 : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping),
311 "b" (page_nr), "c" (new_val), "d" (flags):
312 "memory" );
313 /* XXX */
314 #if 0
315 if ( unlikely(ret < 0) )
316 panic("Failed update VA mapping: %08lx, %08lx, %08lx",
317 page_nr, (new_val).pte_low, flags);
318 #endif
319 return ret;
320 }
322 static inline int
323 HYPERVISOR_event_channel_op(void *op)
324 {
325 int ret;
326 __asm__ __volatile__ (
327 TRAP_INSTR
328 : "=a" (ret) : "0" (__HYPERVISOR_event_channel_op),
329 "b" (op) : "memory" );
331 return ret;
332 }
334 static inline int
335 HYPERVISOR_xen_version(int cmd)
336 {
337 int ret;
338 __asm__ __volatile__ (
339 TRAP_INSTR
340 : "=a" (ret) : "0" (__HYPERVISOR_xen_version),
341 "b" (cmd) : "memory" );
343 return ret;
344 }
346 static inline int
347 HYPERVISOR_console_io(int cmd, int count, char *str)
348 {
349 int ret;
350 __asm__ __volatile__ (
351 TRAP_INSTR
352 : "=a" (ret) : "0" (__HYPERVISOR_console_io),
353 "b" (cmd), "c" (count), "d" (str) : "memory" );
355 return ret;
356 }
358 static inline int
359 HYPERVISOR_console_write(char *str, int count)
360 {
361 return HYPERVISOR_console_io(CONSOLEIO_write, count, str);
362 }
364 static inline int
365 HYPERVISOR_physdev_op(void *physdev_op)
366 {
367 int ret;
368 unsigned long ign;
370 __asm__ __volatile__ (
371 TRAP_INSTR
372 : "=a" (ret), "=b" (ign)
373 : "0" (__HYPERVISOR_physdev_op), "1" (physdev_op)
374 : "memory" );
376 return ret;
377 }
379 static inline int
380 HYPERVISOR_grant_table_op(
381 unsigned int cmd, void *uop, unsigned int count)
382 {
383 int ret;
384 unsigned long ign1, ign2, ign3;
386 __asm__ __volatile__ (
387 TRAP_INSTR
388 : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
389 : "0" (__HYPERVISOR_grant_table_op), "1" (cmd), "2" (uop), "3" (count)
390 : "memory" );
392 return ret;
393 }
395 static inline int
396 HYPERVISOR_update_va_mapping_otherdomain(
397 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
398 {
399 int ret;
400 unsigned long ign1, ign2, ign3, ign4;
402 __asm__ __volatile__ (
403 TRAP_INSTR
404 : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
405 : "0" (__HYPERVISOR_update_va_mapping_otherdomain),
406 "1" (va), "2" ((new_val).pte_low), "3" (flags), "4" (domid) :
407 "memory" );
409 return ret;
410 }
412 static inline int
413 HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type)
414 {
415 int ret;
416 __asm__ __volatile__ (
417 TRAP_INSTR
418 : "=a" (ret) : "0" (__HYPERVISOR_vm_assist),
419 "b" (cmd), "c" (type) : "memory" );
421 return ret;
422 }
424 #endif /* __HYPERVISOR_H__ */