ia64/xen-unstable

view extras/mini-os/h/hypervisor.h @ 4146:f2d61710e4d9

bitkeeper revision 1.1236.25.24 (42366e9aQ71LQ8uCB-Y1IwVNqx5eqA)

Merge djm@kirby.fc.hp.com://home/djm/src/xen/xeno-unstable-ia64.bk
into sportsman.spdomain:/home/djm/xeno-unstable-ia64.bk
author djm@sportsman.spdomain
date Tue Mar 15 05:11:54 2005 +0000 (2005-03-15)
parents 86b610094dd0
children a5931595eca4
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 #ifdef __i386__
40 #define _a1 "b"
41 #define _a2 "c"
42 #define _a3 "d"
43 #define _a4 "S"
44 #else
45 #define _a1 "D"
46 #define _a2 "S"
47 #define _a3 "d"
48 #define _a4 "b"
49 #endif
51 static __inline__ int HYPERVISOR_set_trap_table(trap_info_t *table)
52 {
53 int ret;
54 __asm__ __volatile__ (
55 TRAP_INSTR
56 : "=a" (ret) : "0" (__HYPERVISOR_set_trap_table),
57 _a1 (table) : "memory" );
59 return ret;
60 }
62 static __inline__ int HYPERVISOR_mmu_update(mmu_update_t *req,
63 int count,
64 int *success_count)
65 {
66 int ret;
67 __asm__ __volatile__ (
68 TRAP_INSTR
69 : "=a" (ret) : "0" (__HYPERVISOR_mmu_update),
70 _a1 (req), _a2 (count), _a3 (success_count) : "memory" );
72 return ret;
73 }
75 static __inline__ int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
76 {
77 int ret;
78 __asm__ __volatile__ (
79 TRAP_INSTR
80 : "=a" (ret) : "0" (__HYPERVISOR_set_gdt),
81 _a1 (frame_list), _a2 (entries) : "memory" );
84 return ret;
85 }
87 static __inline__ int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
88 {
89 int ret;
90 __asm__ __volatile__ (
91 TRAP_INSTR
92 : "=a" (ret) : "0" (__HYPERVISOR_stack_switch),
93 _a1 (ss), _a2 (esp) : "memory" );
95 return ret;
96 }
98 #ifdef __i386__
99 static __inline__ int HYPERVISOR_set_callbacks(
100 unsigned long event_selector, unsigned long event_address,
101 unsigned long failsafe_selector, unsigned long failsafe_address)
102 {
103 int ret;
104 __asm__ __volatile__ (
105 TRAP_INSTR
106 : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
107 _a1 (event_selector), _a2 (event_address),
108 _a3 (failsafe_selector), _a4 (failsafe_address) : "memory" );
110 return ret;
111 }
112 #else
113 static __inline__ int HYPERVISOR_set_callbacks(
114 unsigned long event_address,
115 unsigned long failsafe_address,
116 unsigned long syscall_address)
117 {
118 int ret;
119 __asm__ __volatile__ (
120 TRAP_INSTR
121 : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
122 _a1 (event_address), _a2 (failsafe_address),
123 _a3 (syscall_address) : "memory" );
125 return ret;
126 }
127 #endif
129 static __inline__ int
130 HYPERVISOR_fpu_taskswitch(
131 int set)
132 {
133 int ret;
134 unsigned long ign;
136 __asm__ __volatile__ (
137 TRAP_INSTR
138 : "=a" (ret), "=b" (ign)
139 : "0" (__HYPERVISOR_fpu_taskswitch), "1" (set)
140 : "memory" );
142 return ret;
143 }
145 static __inline__ int HYPERVISOR_yield(void)
146 {
147 int ret;
148 __asm__ __volatile__ (
149 TRAP_INSTR
150 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
151 _a1 (SCHEDOP_yield) : "memory" );
153 return ret;
154 }
156 static __inline__ int HYPERVISOR_block(void)
157 {
158 int ret;
159 __asm__ __volatile__ (
160 TRAP_INSTR
161 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
162 _a1 (SCHEDOP_block) : "memory" );
164 return ret;
165 }
167 static __inline__ int HYPERVISOR_shutdown(void)
168 {
169 int ret;
170 __asm__ __volatile__ (
171 TRAP_INSTR
172 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
173 _a1 (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
174 : "memory" );
176 return ret;
177 }
179 static __inline__ int HYPERVISOR_reboot(void)
180 {
181 int ret;
182 __asm__ __volatile__ (
183 TRAP_INSTR
184 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
185 _a1 (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
186 : "memory" );
188 return ret;
189 }
191 static __inline__ int HYPERVISOR_suspend(unsigned long srec)
192 {
193 int ret;
194 /* NB. On suspend, control software expects a suspend record in %esi. */
195 __asm__ __volatile__ (
196 TRAP_INSTR
197 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
198 _a1 (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
199 "S" (srec) : "memory" );
201 return ret;
202 }
204 static __inline__ long HYPERVISOR_set_timer_op(void *timer_arg)
205 {
206 int ret;
207 __asm__ __volatile__ (
208 TRAP_INSTR
209 : "=a" (ret) : "0" (__HYPERVISOR_set_timer_op),
210 _a1 (timer_arg) : "memory" );
212 return ret;
213 }
215 static __inline__ int HYPERVISOR_dom0_op(void *dom0_op)
216 {
217 int ret;
218 __asm__ __volatile__ (
219 TRAP_INSTR
220 : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),
221 _a1 (dom0_op) : "memory" );
223 return ret;
224 }
226 static __inline__ int HYPERVISOR_set_debugreg(int reg, unsigned long value)
227 {
228 int ret;
229 __asm__ __volatile__ (
230 TRAP_INSTR
231 : "=a" (ret) : "0" (__HYPERVISOR_set_debugreg),
232 _a1 (reg), _a2 (value) : "memory" );
234 return ret;
235 }
237 static __inline__ unsigned long HYPERVISOR_get_debugreg(int reg)
238 {
239 unsigned long ret;
240 __asm__ __volatile__ (
241 TRAP_INSTR
242 : "=a" (ret) : "0" (__HYPERVISOR_get_debugreg),
243 _a1 (reg) : "memory" );
245 return ret;
246 }
248 static __inline__ int HYPERVISOR_update_descriptor(
249 unsigned long pa, unsigned long word1, unsigned long word2)
250 {
251 int ret;
252 __asm__ __volatile__ (
253 TRAP_INSTR
254 : "=a" (ret) : "0" (__HYPERVISOR_update_descriptor),
255 _a1 (pa), _a2 (word1), _a3 (word2) : "memory" );
257 return ret;
258 }
260 static __inline__ int HYPERVISOR_set_fast_trap(int idx)
261 {
262 int ret;
263 __asm__ __volatile__ (
264 TRAP_INSTR
265 : "=a" (ret) : "0" (__HYPERVISOR_set_fast_trap),
266 _a1 (idx) : "memory" );
268 return ret;
269 }
271 static __inline__ int HYPERVISOR_dom_mem_op(void *dom_mem_op)
272 {
273 int ret;
274 __asm__ __volatile__ (
275 TRAP_INSTR
276 : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
277 _a1 (dom_mem_op) : "memory" );
279 return ret;
280 }
282 static __inline__ int HYPERVISOR_multicall(void *call_list, int nr_calls)
283 {
284 int ret;
285 __asm__ __volatile__ (
286 TRAP_INSTR
287 : "=a" (ret) : "0" (__HYPERVISOR_multicall),
288 _a1 (call_list), _a2 (nr_calls) : "memory" );
290 return ret;
291 }
293 static __inline__ int HYPERVISOR_update_va_mapping(
294 unsigned long page_nr, unsigned long new_val, unsigned long flags)
295 {
296 int ret;
297 __asm__ __volatile__ (
298 TRAP_INSTR
299 : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping),
300 _a1 (page_nr), _a2 (new_val), _a3 (flags) : "memory" );
302 return ret;
303 }
305 static __inline__ int HYPERVISOR_xen_version(int cmd)
306 {
307 int ret;
308 __asm__ __volatile__ (
309 TRAP_INSTR
310 : "=a" (ret) : "0" (__HYPERVISOR_xen_version),
311 _a1 (cmd) : "memory" );
313 return ret;
314 }
316 static __inline__ int HYPERVISOR_console_io(int cmd, int count, char *str)
317 {
318 int ret;
319 __asm__ __volatile__ (
320 TRAP_INSTR
321 : "=a" (ret) : "0" (__HYPERVISOR_console_io),
322 _a1 (cmd), _a2 (count), _a3 (str) : "memory" );
324 return ret;
325 }
327 #endif /* __HYPERVISOR_H__ */