ia64/xen-unstable

view extras/mini-os/h/hypervisor.h @ 1510:50ebf96e89bf

bitkeeper revision 1.987 (40d595643wZIEtMwb3hHvNEGMAu8gQ)

Fix the getdomaininfo dom0_op.
author kaf24@scramble.cl.cam.ac.uk
date Sun Jun 20 13:47:16 2004 +0000 (2004-06-20)
parents ead91151a0e6
children 7ce227b8b740 cbee10dcdd93
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 the hypervisor interface */
15 #include <hypervisor-ifs/hypervisor-if.h>
16 #include "../../../tools/xend/lib/domain_controller.h"
18 /*
19 * a placeholder for the start of day information passed up from the hypervisor
20 */
21 union start_info_union
22 {
23 start_info_t start_info;
24 char padding[512];
25 };
26 extern union start_info_union start_info_union;
27 #define start_info (start_info_union.start_info)
30 /* hypervisor.c */
31 void do_hypervisor_callback(struct pt_regs *regs);
32 void enable_hypervisor_event(unsigned int ev);
33 void disable_hypervisor_event(unsigned int ev);
34 void ack_hypervisor_event(unsigned int ev);
36 /*
37 * Assembler stubs for hyper-calls.
38 */
40 static __inline__ int HYPERVISOR_set_trap_table(trap_info_t *table)
41 {
42 int ret;
43 __asm__ __volatile__ (
44 TRAP_INSTR
45 : "=a" (ret) : "0" (__HYPERVISOR_set_trap_table),
46 "b" (table) : "memory" );
48 return ret;
49 }
51 static __inline__ int HYPERVISOR_mmu_update(mmu_update_t *req,
52 int count,
53 int *success_count)
54 {
55 int ret;
56 __asm__ __volatile__ (
57 TRAP_INSTR
58 : "=a" (ret) : "0" (__HYPERVISOR_mmu_update),
59 "b" (req), "c" (count), "d" (success_count) : "memory" );
61 return ret;
62 }
64 static __inline__ int HYPERVISOR_console_write(const char *str, int count)
65 {
66 int ret;
67 __asm__ __volatile__ (
68 TRAP_INSTR
69 : "=a" (ret) : "0" (__HYPERVISOR_console_write),
70 "b" (str), "c" (count) : "memory" );
73 return ret;
74 }
76 static __inline__ int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
77 {
78 int ret;
79 __asm__ __volatile__ (
80 TRAP_INSTR
81 : "=a" (ret) : "0" (__HYPERVISOR_set_gdt),
82 "b" (frame_list), "c" (entries) : "memory" );
85 return ret;
86 }
88 static __inline__ int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
89 {
90 int ret;
91 __asm__ __volatile__ (
92 TRAP_INSTR
93 : "=a" (ret) : "0" (__HYPERVISOR_stack_switch),
94 "b" (ss), "c" (esp) : "memory" );
96 return ret;
97 }
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 "b" (event_selector), "c" (event_address),
108 "d" (failsafe_selector), "S" (failsafe_address) : "memory" );
110 return ret;
111 }
113 static __inline__ int HYPERVISOR_fpu_taskswitch(void)
114 {
115 int ret;
116 __asm__ __volatile__ (
117 TRAP_INSTR
118 : "=a" (ret) : "0" (__HYPERVISOR_fpu_taskswitch) : "memory" );
120 return ret;
121 }
123 static __inline__ int HYPERVISOR_yield(void)
124 {
125 int ret;
126 __asm__ __volatile__ (
127 TRAP_INSTR
128 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
129 "b" (SCHEDOP_yield) : "memory" );
131 return ret;
132 }
134 static __inline__ int HYPERVISOR_block(void)
135 {
136 int ret;
137 __asm__ __volatile__ (
138 TRAP_INSTR
139 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
140 "b" (SCHEDOP_block) : "memory" );
142 return ret;
143 }
145 static inline int HYPERVISOR_shutdown(void)
146 {
147 int ret;
148 __asm__ __volatile__ (
149 TRAP_INSTR
150 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
151 "b" (SCHEDOP_suspend | (STOPCODE_shutdown << SCHEDOP_reasonshift))
152 : "memory" );
154 return ret;
155 }
157 static inline int HYPERVISOR_reboot(void)
158 {
159 int ret;
160 __asm__ __volatile__ (
161 TRAP_INSTR
162 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
163 "b" (SCHEDOP_suspend | (STOPCODE_reboot << SCHEDOP_reasonshift))
164 : "memory" );
166 return ret;
167 }
169 static inline int HYPERVISOR_suspend(unsigned long srec)
170 {
171 int ret;
172 /* NB. On suspend, control software expects a suspend record in %esi. */
173 __asm__ __volatile__ (
174 TRAP_INSTR
175 : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
176 "b" (SCHEDOP_suspend | (STOPCODE_suspend << SCHEDOP_reasonshift)),
177 "S" (srec) : "memory" );
179 return ret;
180 }
182 static __inline__ long HYPERVISOR_set_timer_op(void *timer_arg)
183 {
184 int ret;
185 __asm__ __volatile__ (
186 TRAP_INSTR
187 : "=a" (ret) : "0" (__HYPERVISOR_set_timer_op),
188 "b" (timer_arg) : "memory" );
190 return ret;
191 }
193 static __inline__ int HYPERVISOR_dom0_op(void *dom0_op)
194 {
195 int ret;
196 __asm__ __volatile__ (
197 TRAP_INSTR
198 : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),
199 "b" (dom0_op) : "memory" );
201 return ret;
202 }
204 static __inline__ int HYPERVISOR_set_debugreg(int reg, unsigned long value)
205 {
206 int ret;
207 __asm__ __volatile__ (
208 TRAP_INSTR
209 : "=a" (ret) : "0" (__HYPERVISOR_set_debugreg),
210 "b" (reg), "c" (value) : "memory" );
212 return ret;
213 }
215 static __inline__ unsigned long HYPERVISOR_get_debugreg(int reg)
216 {
217 unsigned long ret;
218 __asm__ __volatile__ (
219 TRAP_INSTR
220 : "=a" (ret) : "0" (__HYPERVISOR_get_debugreg),
221 "b" (reg) : "memory" );
223 return ret;
224 }
226 static __inline__ int HYPERVISOR_update_descriptor(
227 unsigned long pa, unsigned long word1, unsigned long word2)
228 {
229 int ret;
230 __asm__ __volatile__ (
231 TRAP_INSTR
232 : "=a" (ret) : "0" (__HYPERVISOR_update_descriptor),
233 "b" (pa), "c" (word1), "d" (word2) : "memory" );
235 return ret;
236 }
238 static __inline__ int HYPERVISOR_set_fast_trap(int idx)
239 {
240 int ret;
241 __asm__ __volatile__ (
242 TRAP_INSTR
243 : "=a" (ret) : "0" (__HYPERVISOR_set_fast_trap),
244 "b" (idx) : "memory" );
246 return ret;
247 }
249 static __inline__ int HYPERVISOR_dom_mem_op(void *dom_mem_op)
250 {
251 int ret;
252 __asm__ __volatile__ (
253 TRAP_INSTR
254 : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
255 "b" (dom_mem_op) : "memory" );
257 return ret;
258 }
260 static __inline__ int HYPERVISOR_multicall(void *call_list, int nr_calls)
261 {
262 int ret;
263 __asm__ __volatile__ (
264 TRAP_INSTR
265 : "=a" (ret) : "0" (__HYPERVISOR_multicall),
266 "b" (call_list), "c" (nr_calls) : "memory" );
268 return ret;
269 }
271 static __inline__ int HYPERVISOR_update_va_mapping(
272 unsigned long page_nr, unsigned long new_val, unsigned long flags)
273 {
274 int ret;
275 __asm__ __volatile__ (
276 TRAP_INSTR
277 : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping),
278 "b" (page_nr), "c" (new_val), "d" (flags) : "memory" );
280 return ret;
281 }
283 #endif /* __HYPERVISOR_H__ */