ia64/xen-unstable

view extras/mini-os/include/hypervisor.h @ 6435:b4b3f6be5226

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 17:27:49 2005 +0000 (2005-08-25)
parents 0610add7c3fe 98a6eb458c78
children 8799d14bef77 9312a3e8a6f8
line source
1 /******************************************************************************
2 * hypervisor.h
3 *
4 * Hypervisor handling.
5 *
6 * TODO - x86_64 broken!
7 *
8 * Copyright (c) 2002, K A Fraser
9 * Copyright (c) 2005, Grzegorz Milos
10 */
12 #ifndef _HYPERVISOR_H_
13 #define _HYPERVISOR_H_
15 #include <types.h>
17 #include <xen/xen.h>
18 #include <xen/io/domain_controller.h>
22 /*
23 * a placeholder for the start of day information passed up from the hypervisor
24 */
25 union start_info_union
26 {
27 start_info_t start_info;
28 char padding[512];
29 };
30 extern union start_info_union start_info_union;
31 #define start_info (start_info_union.start_info)
34 /* hypervisor.c */
35 //void do_hypervisor_callback(struct pt_regs *regs);
36 void mask_evtchn(u32 port);
37 void unmask_evtchn(u32 port);
38 void clear_evtchn(u32 port);
40 /*
41 * Assembler stubs for hyper-calls.
42 */
44 #ifdef __i386__
45 #define _a1 "b"
46 #define _a2 "c"
47 #define _a3 "d"
48 #define _a4 "S"
49 #else
50 #define _a1 "D"
51 #define _a2 "S"
52 #define _a3 "d"
53 #define _a4 "b"
54 #endif
56 static __inline__ int HYPERVISOR_event_channel_op(
57 void *op)
58 {
59 int ret;
60 unsigned long ignore;
61 __asm__ __volatile__ (
62 TRAP_INSTR
63 : "=a" (ret), "=b" (ignore)
64 : "0" (__HYPERVISOR_event_channel_op), "1" (op)
65 : "memory" );
67 return ret;
68 }
70 static __inline__ int HYPERVISOR_set_trap_table(trap_info_t *table)
71 {
72 int ret;
73 __asm__ __volatile__ (
74 TRAP_INSTR
75 : "=a" (ret) : "0" (__HYPERVISOR_set_trap_table),
76 _a1 (table) : "memory" );
78 return ret;
79 }
81 static __inline__ int HYPERVISOR_mmu_update(mmu_update_t *req,
82 int count,
83 int *success_count,
84 domid_t domid)
85 {
86 int ret;
87 unsigned long ign1, ign2, ign3, ign4;
89 __asm__ __volatile__ (
90 TRAP_INSTR
91 : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
92 : "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
93 "3" (success_count), "4" (domid)
94 : "memory" );
96 return ret;
97 }
100 static __inline__ int HYPERVISOR_mmuext_op(struct mmuext_op *op,
101 int count,
102 int *success_count,
103 domid_t domid)
104 {
105 int ret;
106 unsigned long ign1, ign2, ign3, ign4;
108 __asm__ __volatile__ (
109 TRAP_INSTR
110 : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
111 : "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
112 "3" (success_count), "4" (domid)
113 : "memory" );
115 return ret;
116 }
120 static __inline__ int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
121 {
122 int ret;
123 __asm__ __volatile__ (
124 TRAP_INSTR
125 : "=a" (ret) : "0" (__HYPERVISOR_set_gdt),
126 _a1 (frame_list), _a2 (entries) : "memory" );
129 return ret;
130 }
132 static __inline__ int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
133 {
134 int ret;
135 __asm__ __volatile__ (
136 TRAP_INSTR
137 : "=a" (ret) : "0" (__HYPERVISOR_stack_switch),
138 _a1 (ss), _a2 (esp) : "memory" );
140 return ret;
141 }
143 #ifdef __i386__
144 static __inline__ int HYPERVISOR_set_callbacks(
145 unsigned long event_selector, unsigned long event_address,
146 unsigned long failsafe_selector, unsigned long failsafe_address)
147 {
148 int ret;
149 __asm__ __volatile__ (
150 TRAP_INSTR
151 : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
152 _a1 (event_selector), _a2 (event_address),
153 _a3 (failsafe_selector), _a4 (failsafe_address) : "memory" );
155 return ret;
156 }
157 #else
158 static __inline__ int HYPERVISOR_set_callbacks(
159 unsigned long event_address,
160 unsigned long failsafe_address,
161 unsigned long syscall_address)
162 {
163 int ret;
164 __asm__ __volatile__ (
165 TRAP_INSTR
166 : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
167 _a1 (event_address), _a2 (failsafe_address),
168 _a3 (syscall_address) : "memory" );
170 return ret;
171 }
172 #endif
174 static __inline__ int
175 HYPERVISOR_fpu_taskswitch(
176 int set)
177 {
178 int ret;
179 unsigned long ign;
181 __asm__ __volatile__ (
182 TRAP_INSTR
183 : "=a" (ret), "=b" (ign)
184 : "0" (__HYPERVISOR_fpu_taskswitch), "1" (set)
185 : "memory" );
187 return ret;
188 }
190 static __inline__ int HYPERVISOR_yield(void)
191 {
192 int ret;
193 __asm__ __volatile__ (
194 TRAP_INSTR
195 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
196 _a1 (SCHEDOP_yield) : "memory" );
198 return ret;
199 }
201 static __inline__ int HYPERVISOR_block(void)
202 {
203 int ret;
204 __asm__ __volatile__ (
205 TRAP_INSTR
206 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
207 _a1 (SCHEDOP_block) : "memory" );
209 return ret;
210 }
212 static __inline__ int HYPERVISOR_shutdown(void)
213 {
214 int ret;
215 __asm__ __volatile__ (
216 TRAP_INSTR
217 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
218 _a1 (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
219 : "memory" );
221 return ret;
222 }
224 static __inline__ int HYPERVISOR_reboot(void)
225 {
226 int ret;
227 __asm__ __volatile__ (
228 TRAP_INSTR
229 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
230 _a1 (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
231 : "memory" );
233 return ret;
234 }
236 static __inline__ int HYPERVISOR_suspend(unsigned long srec)
237 {
238 int ret;
239 /* NB. On suspend, control software expects a suspend record in %esi. */
240 __asm__ __volatile__ (
241 TRAP_INSTR
242 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
243 _a1 (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
244 "S" (srec) : "memory" );
246 return ret;
247 }
249 #ifdef __i386__
250 static __inline__ long HYPERVISOR_set_timer_op( u64 timeout )
251 {
252 int ret;
253 unsigned long timeout_hi = (unsigned long)(timeout>>32);
254 unsigned long timeout_lo = (unsigned long)timeout;
255 unsigned long ign1, ign2;
257 __asm__ __volatile__ (
258 TRAP_INSTR
259 : "=a" (ret), "=b" (ign1), "=c" (ign2)
260 : "0" (__HYPERVISOR_set_timer_op), "b" (timeout_lo), "c" (timeout_hi)
261 : "memory");
263 return ret;
264 }
265 #else
266 static __inline__ long HYPERVISOR_set_timer_op( u64 timeout )
267 {
268 int ret;
270 __asm__ __volatile__ (
271 TRAP_INSTR
272 : "=a" (ret)
273 : "0" ((unsigned long)__HYPERVISOR_set_timer_op),
274 "D" (timeout)
275 : __syscall_clobber );
277 return ret;
278 }
279 #endif
282 static __inline__ int HYPERVISOR_dom0_op(void *dom0_op)
283 {
284 int ret;
285 __asm__ __volatile__ (
286 TRAP_INSTR
287 : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),
288 _a1 (dom0_op) : "memory" );
290 return ret;
291 }
293 static __inline__ int HYPERVISOR_set_debugreg(int reg, unsigned long value)
294 {
295 int ret;
296 __asm__ __volatile__ (
297 TRAP_INSTR
298 : "=a" (ret) : "0" (__HYPERVISOR_set_debugreg),
299 _a1 (reg), _a2 (value) : "memory" );
301 return ret;
302 }
304 static __inline__ unsigned long HYPERVISOR_get_debugreg(int reg)
305 {
306 unsigned long ret;
307 __asm__ __volatile__ (
308 TRAP_INSTR
309 : "=a" (ret) : "0" (__HYPERVISOR_get_debugreg),
310 _a1 (reg) : "memory" );
312 return ret;
313 }
315 static __inline__ int HYPERVISOR_update_descriptor(
316 unsigned long pa, unsigned long word1, unsigned long word2)
317 {
318 int ret;
319 __asm__ __volatile__ (
320 TRAP_INSTR
321 : "=a" (ret) : "0" (__HYPERVISOR_update_descriptor),
322 _a1 (pa), _a2 (word1), _a3 (word2) : "memory" );
324 return ret;
325 }
327 static __inline__ int HYPERVISOR_dom_mem_op(void *dom_mem_op)
328 {
329 int ret;
330 __asm__ __volatile__ (
331 TRAP_INSTR
332 : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
333 _a1 (dom_mem_op) : "memory" );
335 return ret;
336 }
338 static __inline__ int HYPERVISOR_multicall(void *call_list, int nr_calls)
339 {
340 int ret;
341 __asm__ __volatile__ (
342 TRAP_INSTR
343 : "=a" (ret) : "0" (__HYPERVISOR_multicall),
344 _a1 (call_list), _a2 (nr_calls) : "memory" );
346 return ret;
347 }
349 static __inline__ int HYPERVISOR_update_va_mapping(
350 unsigned long page_nr, unsigned long new_val, unsigned long flags)
351 {
352 int ret;
353 __asm__ __volatile__ (
354 TRAP_INSTR
355 : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping),
356 _a1 (page_nr), _a2 (new_val), _a3 (flags) : "memory" );
358 return ret;
359 }
361 static __inline__ int HYPERVISOR_xen_version(int cmd)
362 {
363 int ret;
364 __asm__ __volatile__ (
365 TRAP_INSTR
366 : "=a" (ret) : "0" (__HYPERVISOR_xen_version),
367 _a1 (cmd) : "memory" );
369 return ret;
370 }
372 static __inline__ int HYPERVISOR_console_io(int cmd, int count, char *str)
373 {
374 int ret;
375 __asm__ __volatile__ (
376 TRAP_INSTR
377 : "=a" (ret) : "0" (__HYPERVISOR_console_io),
378 _a1 (cmd), _a2 (count), _a3 (str) : "memory" );
380 return ret;
381 }
383 #endif /* __HYPERVISOR_H__ */