ia64/xen-unstable

view extras/mini-os/h/hypervisor.h @ 4072:ee7313088070

bitkeeper revision 1.1159.258.38 (4230628bX3yukmWYtNDh925BckMoHQ)

Merge ssh://xenbk@gandalf.hpl.hp.com//var/bk/xen-2.0-testing.bk
into tetris.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-2.0-testing.bk
author iap10@tetris.cl.cam.ac.uk
date Thu Mar 10 15:06:51 2005 +0000 (2005-03-10)
parents 3f929065a1d1
children 0a4b76b6b5a0
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_
12 #include <types.h>
14 #include <xen-public/xen.h>
15 #include <xen-public/io/domain_controller.h>
17 /*
18 * a placeholder for the start of day information passed up from the hypervisor
19 */
20 union start_info_union
21 {
22 start_info_t start_info;
23 char padding[512];
24 };
25 extern union start_info_union start_info_union;
26 #define start_info (start_info_union.start_info)
29 /* hypervisor.c */
30 void do_hypervisor_callback(struct pt_regs *regs);
31 void enable_hypervisor_event(unsigned int ev);
32 void disable_hypervisor_event(unsigned int ev);
33 void ack_hypervisor_event(unsigned int ev);
35 /*
36 * Assembler stubs for hyper-calls.
37 */
39 static __inline__ int HYPERVISOR_set_trap_table(trap_info_t *table)
40 {
41 int ret;
42 __asm__ __volatile__ (
43 TRAP_INSTR
44 : "=a" (ret) : "0" (__HYPERVISOR_set_trap_table),
45 "b" (table) : "memory" );
47 return ret;
48 }
50 static __inline__ int HYPERVISOR_mmu_update(mmu_update_t *req,
51 int count,
52 int *success_count)
53 {
54 int ret;
55 __asm__ __volatile__ (
56 TRAP_INSTR
57 : "=a" (ret) : "0" (__HYPERVISOR_mmu_update),
58 "b" (req), "c" (count), "d" (success_count) : "memory" );
60 return ret;
61 }
63 static __inline__ int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
64 {
65 int ret;
66 __asm__ __volatile__ (
67 TRAP_INSTR
68 : "=a" (ret) : "0" (__HYPERVISOR_set_gdt),
69 "b" (frame_list), "c" (entries) : "memory" );
72 return ret;
73 }
75 static __inline__ int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
76 {
77 int ret;
78 __asm__ __volatile__ (
79 TRAP_INSTR
80 : "=a" (ret) : "0" (__HYPERVISOR_stack_switch),
81 "b" (ss), "c" (esp) : "memory" );
83 return ret;
84 }
86 static __inline__ int HYPERVISOR_set_callbacks(
87 unsigned long event_selector, unsigned long event_address,
88 unsigned long failsafe_selector, unsigned long failsafe_address)
89 {
90 int ret;
91 __asm__ __volatile__ (
92 TRAP_INSTR
93 : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
94 "b" (event_selector), "c" (event_address),
95 "d" (failsafe_selector), "S" (failsafe_address) : "memory" );
97 return ret;
98 }
100 static __inline__ int HYPERVISOR_fpu_taskswitch(void)
101 {
102 int ret;
103 __asm__ __volatile__ (
104 TRAP_INSTR
105 : "=a" (ret) : "0" (__HYPERVISOR_fpu_taskswitch) : "memory" );
107 return ret;
108 }
110 static __inline__ int HYPERVISOR_yield(void)
111 {
112 int ret;
113 __asm__ __volatile__ (
114 TRAP_INSTR
115 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
116 "b" (SCHEDOP_yield) : "memory" );
118 return ret;
119 }
121 static __inline__ int HYPERVISOR_block(void)
122 {
123 int ret;
124 __asm__ __volatile__ (
125 TRAP_INSTR
126 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
127 "b" (SCHEDOP_block) : "memory" );
129 return ret;
130 }
132 static __inline__ int HYPERVISOR_shutdown(void)
133 {
134 int ret;
135 __asm__ __volatile__ (
136 TRAP_INSTR
137 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
138 "b" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
139 : "memory" );
141 return ret;
142 }
144 static __inline__ int HYPERVISOR_reboot(void)
145 {
146 int ret;
147 __asm__ __volatile__ (
148 TRAP_INSTR
149 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
150 "b" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
151 : "memory" );
153 return ret;
154 }
156 static __inline__ int HYPERVISOR_suspend(unsigned long srec)
157 {
158 int ret;
159 /* NB. On suspend, control software expects a suspend record in %esi. */
160 __asm__ __volatile__ (
161 TRAP_INSTR
162 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
163 "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
164 "S" (srec) : "memory" );
166 return ret;
167 }
169 static __inline__ long HYPERVISOR_set_timer_op(void *timer_arg)
170 {
171 int ret;
172 __asm__ __volatile__ (
173 TRAP_INSTR
174 : "=a" (ret) : "0" (__HYPERVISOR_set_timer_op),
175 "b" (timer_arg) : "memory" );
177 return ret;
178 }
180 static __inline__ int HYPERVISOR_dom0_op(void *dom0_op)
181 {
182 int ret;
183 __asm__ __volatile__ (
184 TRAP_INSTR
185 : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),
186 "b" (dom0_op) : "memory" );
188 return ret;
189 }
191 static __inline__ int HYPERVISOR_set_debugreg(int reg, unsigned long value)
192 {
193 int ret;
194 __asm__ __volatile__ (
195 TRAP_INSTR
196 : "=a" (ret) : "0" (__HYPERVISOR_set_debugreg),
197 "b" (reg), "c" (value) : "memory" );
199 return ret;
200 }
202 static __inline__ unsigned long HYPERVISOR_get_debugreg(int reg)
203 {
204 unsigned long ret;
205 __asm__ __volatile__ (
206 TRAP_INSTR
207 : "=a" (ret) : "0" (__HYPERVISOR_get_debugreg),
208 "b" (reg) : "memory" );
210 return ret;
211 }
213 static __inline__ int HYPERVISOR_update_descriptor(
214 unsigned long pa, unsigned long word1, unsigned long word2)
215 {
216 int ret;
217 __asm__ __volatile__ (
218 TRAP_INSTR
219 : "=a" (ret) : "0" (__HYPERVISOR_update_descriptor),
220 "b" (pa), "c" (word1), "d" (word2) : "memory" );
222 return ret;
223 }
225 static __inline__ int HYPERVISOR_set_fast_trap(int idx)
226 {
227 int ret;
228 __asm__ __volatile__ (
229 TRAP_INSTR
230 : "=a" (ret) : "0" (__HYPERVISOR_set_fast_trap),
231 "b" (idx) : "memory" );
233 return ret;
234 }
236 static __inline__ int HYPERVISOR_dom_mem_op(void *dom_mem_op)
237 {
238 int ret;
239 __asm__ __volatile__ (
240 TRAP_INSTR
241 : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
242 "b" (dom_mem_op) : "memory" );
244 return ret;
245 }
247 static __inline__ int HYPERVISOR_multicall(void *call_list, int nr_calls)
248 {
249 int ret;
250 __asm__ __volatile__ (
251 TRAP_INSTR
252 : "=a" (ret) : "0" (__HYPERVISOR_multicall),
253 "b" (call_list), "c" (nr_calls) : "memory" );
255 return ret;
256 }
258 static __inline__ int HYPERVISOR_update_va_mapping(
259 unsigned long page_nr, unsigned long new_val, unsigned long flags)
260 {
261 int ret;
262 __asm__ __volatile__ (
263 TRAP_INSTR
264 : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping),
265 "b" (page_nr), "c" (new_val), "d" (flags) : "memory" );
267 return ret;
268 }
270 static __inline__ int HYPERVISOR_xen_version(int cmd)
271 {
272 int ret;
273 __asm__ __volatile__ (
274 TRAP_INSTR
275 : "=a" (ret) : "0" (__HYPERVISOR_xen_version),
276 "b" (cmd) : "memory" );
278 return ret;
279 }
281 static __inline__ int HYPERVISOR_console_io(int cmd, int count, char *str)
282 {
283 int ret;
284 __asm__ __volatile__ (
285 TRAP_INSTR
286 : "=a" (ret) : "0" (__HYPERVISOR_console_io),
287 "b" (cmd), "c" (count), "d" (str) : "memory" );
289 return ret;
290 }
292 #endif /* __HYPERVISOR_H__ */