ia64/xen-unstable

view extras/mini-os/include/hypervisor.h @ 6106:a64ac7fafbf0

PAE page directories must be below 4GB. Based on a patch
from Gerd Knorr.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Aug 11 10:34:32 2005 +0000 (2005-08-11)
parents a83ac0806d6b
children 98a6eb458c78 0610add7c3fe 8799d14bef77 a9873d384da4
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 {
85 int ret;
86 __asm__ __volatile__ (
87 TRAP_INSTR
88 : "=a" (ret) : "0" (__HYPERVISOR_mmu_update),
89 _a1 (req), _a2 (count), _a3 (success_count) : "memory" );
91 return ret;
92 }
94 static __inline__ int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
95 {
96 int ret;
97 __asm__ __volatile__ (
98 TRAP_INSTR
99 : "=a" (ret) : "0" (__HYPERVISOR_set_gdt),
100 _a1 (frame_list), _a2 (entries) : "memory" );
103 return ret;
104 }
106 static __inline__ int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
107 {
108 int ret;
109 __asm__ __volatile__ (
110 TRAP_INSTR
111 : "=a" (ret) : "0" (__HYPERVISOR_stack_switch),
112 _a1 (ss), _a2 (esp) : "memory" );
114 return ret;
115 }
117 #ifdef __i386__
118 static __inline__ int HYPERVISOR_set_callbacks(
119 unsigned long event_selector, unsigned long event_address,
120 unsigned long failsafe_selector, unsigned long failsafe_address)
121 {
122 int ret;
123 __asm__ __volatile__ (
124 TRAP_INSTR
125 : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
126 _a1 (event_selector), _a2 (event_address),
127 _a3 (failsafe_selector), _a4 (failsafe_address) : "memory" );
129 return ret;
130 }
131 #else
132 static __inline__ int HYPERVISOR_set_callbacks(
133 unsigned long event_address,
134 unsigned long failsafe_address,
135 unsigned long syscall_address)
136 {
137 int ret;
138 __asm__ __volatile__ (
139 TRAP_INSTR
140 : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
141 _a1 (event_address), _a2 (failsafe_address),
142 _a3 (syscall_address) : "memory" );
144 return ret;
145 }
146 #endif
148 static __inline__ int
149 HYPERVISOR_fpu_taskswitch(
150 int set)
151 {
152 int ret;
153 unsigned long ign;
155 __asm__ __volatile__ (
156 TRAP_INSTR
157 : "=a" (ret), "=b" (ign)
158 : "0" (__HYPERVISOR_fpu_taskswitch), "1" (set)
159 : "memory" );
161 return ret;
162 }
164 static __inline__ int HYPERVISOR_yield(void)
165 {
166 int ret;
167 __asm__ __volatile__ (
168 TRAP_INSTR
169 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
170 _a1 (SCHEDOP_yield) : "memory" );
172 return ret;
173 }
175 static __inline__ int HYPERVISOR_block(void)
176 {
177 int ret;
178 __asm__ __volatile__ (
179 TRAP_INSTR
180 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
181 _a1 (SCHEDOP_block) : "memory" );
183 return ret;
184 }
186 static __inline__ int HYPERVISOR_shutdown(void)
187 {
188 int ret;
189 __asm__ __volatile__ (
190 TRAP_INSTR
191 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
192 _a1 (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
193 : "memory" );
195 return ret;
196 }
198 static __inline__ int HYPERVISOR_reboot(void)
199 {
200 int ret;
201 __asm__ __volatile__ (
202 TRAP_INSTR
203 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
204 _a1 (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
205 : "memory" );
207 return ret;
208 }
210 static __inline__ int HYPERVISOR_suspend(unsigned long srec)
211 {
212 int ret;
213 /* NB. On suspend, control software expects a suspend record in %esi. */
214 __asm__ __volatile__ (
215 TRAP_INSTR
216 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
217 _a1 (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
218 "S" (srec) : "memory" );
220 return ret;
221 }
223 #ifdef __i386__
224 static __inline__ long HYPERVISOR_set_timer_op( u64 timeout )
225 {
226 int ret;
227 unsigned long timeout_hi = (unsigned long)(timeout>>32);
228 unsigned long timeout_lo = (unsigned long)timeout;
229 unsigned long ign1, ign2;
231 __asm__ __volatile__ (
232 TRAP_INSTR
233 : "=a" (ret), "=b" (ign1), "=c" (ign2)
234 : "0" (__HYPERVISOR_set_timer_op), "b" (timeout_lo), "c" (timeout_hi)
235 : "memory");
237 return ret;
238 }
239 #else
240 static __inline__ long HYPERVISOR_set_timer_op( u64 timeout )
241 {
242 int ret;
244 __asm__ __volatile__ (
245 TRAP_INSTR
246 : "=a" (ret)
247 : "0" ((unsigned long)__HYPERVISOR_set_timer_op),
248 "D" (timeout)
249 : __syscall_clobber );
251 return ret;
252 }
253 #endif
256 static __inline__ int HYPERVISOR_dom0_op(void *dom0_op)
257 {
258 int ret;
259 __asm__ __volatile__ (
260 TRAP_INSTR
261 : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),
262 _a1 (dom0_op) : "memory" );
264 return ret;
265 }
267 static __inline__ int HYPERVISOR_set_debugreg(int reg, unsigned long value)
268 {
269 int ret;
270 __asm__ __volatile__ (
271 TRAP_INSTR
272 : "=a" (ret) : "0" (__HYPERVISOR_set_debugreg),
273 _a1 (reg), _a2 (value) : "memory" );
275 return ret;
276 }
278 static __inline__ unsigned long HYPERVISOR_get_debugreg(int reg)
279 {
280 unsigned long ret;
281 __asm__ __volatile__ (
282 TRAP_INSTR
283 : "=a" (ret) : "0" (__HYPERVISOR_get_debugreg),
284 _a1 (reg) : "memory" );
286 return ret;
287 }
289 static __inline__ int HYPERVISOR_update_descriptor(
290 unsigned long pa, unsigned long word1, unsigned long word2)
291 {
292 int ret;
293 __asm__ __volatile__ (
294 TRAP_INSTR
295 : "=a" (ret) : "0" (__HYPERVISOR_update_descriptor),
296 _a1 (pa), _a2 (word1), _a3 (word2) : "memory" );
298 return ret;
299 }
301 static __inline__ int HYPERVISOR_dom_mem_op(void *dom_mem_op)
302 {
303 int ret;
304 __asm__ __volatile__ (
305 TRAP_INSTR
306 : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
307 _a1 (dom_mem_op) : "memory" );
309 return ret;
310 }
312 static __inline__ int HYPERVISOR_multicall(void *call_list, int nr_calls)
313 {
314 int ret;
315 __asm__ __volatile__ (
316 TRAP_INSTR
317 : "=a" (ret) : "0" (__HYPERVISOR_multicall),
318 _a1 (call_list), _a2 (nr_calls) : "memory" );
320 return ret;
321 }
323 static __inline__ int HYPERVISOR_update_va_mapping(
324 unsigned long page_nr, unsigned long new_val, unsigned long flags)
325 {
326 int ret;
327 __asm__ __volatile__ (
328 TRAP_INSTR
329 : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping),
330 _a1 (page_nr), _a2 (new_val), _a3 (flags) : "memory" );
332 return ret;
333 }
335 static __inline__ int HYPERVISOR_xen_version(int cmd)
336 {
337 int ret;
338 __asm__ __volatile__ (
339 TRAP_INSTR
340 : "=a" (ret) : "0" (__HYPERVISOR_xen_version),
341 _a1 (cmd) : "memory" );
343 return ret;
344 }
346 static __inline__ int HYPERVISOR_console_io(int cmd, int count, char *str)
347 {
348 int ret;
349 __asm__ __volatile__ (
350 TRAP_INSTR
351 : "=a" (ret) : "0" (__HYPERVISOR_console_io),
352 _a1 (cmd), _a2 (count), _a3 (str) : "memory" );
354 return ret;
355 }
357 #endif /* __HYPERVISOR_H__ */