ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h @ 8534:da7873110bbb

Tiny bootstrap cleanup.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jan 09 19:46:46 2006 +0100 (2006-01-09)
parents 540d17fe32ce
children 278e536ade72
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 *
8 * This file may be distributed separately from the Linux kernel, or
9 * incorporated into other software packages, subject to the following license:
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this source file (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use, copy, modify,
14 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 * IN THE SOFTWARE.
28 */
30 #ifndef __HYPERCALL_H__
31 #define __HYPERCALL_H__
33 #include <asm-xen/xen-public/xen.h>
34 #include <asm-xen/xen-public/sched.h>
36 #define _hypercall0(type, name) \
37 ({ \
38 long __res; \
39 asm volatile ( \
40 TRAP_INSTR \
41 : "=a" (__res) \
42 : "0" (__HYPERVISOR_##name) \
43 : "memory" ); \
44 (type)__res; \
45 })
47 #define _hypercall1(type, name, a1) \
48 ({ \
49 long __res, __ign1; \
50 asm volatile ( \
51 TRAP_INSTR \
52 : "=a" (__res), "=b" (__ign1) \
53 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)) \
54 : "memory" ); \
55 (type)__res; \
56 })
58 #define _hypercall2(type, name, a1, a2) \
59 ({ \
60 long __res, __ign1, __ign2; \
61 asm volatile ( \
62 TRAP_INSTR \
63 : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
64 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
65 "2" ((long)(a2)) \
66 : "memory" ); \
67 (type)__res; \
68 })
70 #define _hypercall3(type, name, a1, a2, a3) \
71 ({ \
72 long __res, __ign1, __ign2, __ign3; \
73 asm volatile ( \
74 TRAP_INSTR \
75 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
76 "=d" (__ign3) \
77 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
78 "2" ((long)(a2)), "3" ((long)(a3)) \
79 : "memory" ); \
80 (type)__res; \
81 })
83 #define _hypercall4(type, name, a1, a2, a3, a4) \
84 ({ \
85 long __res, __ign1, __ign2, __ign3, __ign4; \
86 asm volatile ( \
87 TRAP_INSTR \
88 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
89 "=d" (__ign3), "=S" (__ign4) \
90 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
91 "2" ((long)(a2)), "3" ((long)(a3)), \
92 "4" ((long)(a4)) \
93 : "memory" ); \
94 (type)__res; \
95 })
97 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
98 ({ \
99 long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \
100 asm volatile ( \
101 TRAP_INSTR \
102 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
103 "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
104 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
105 "2" ((long)(a2)), "3" ((long)(a3)), \
106 "4" ((long)(a4)), "5" ((long)(a5)) \
107 : "memory" ); \
108 (type)__res; \
109 })
111 static inline int
112 HYPERVISOR_set_trap_table(
113 trap_info_t *table)
114 {
115 return _hypercall1(int, set_trap_table, table);
116 }
118 static inline int
119 HYPERVISOR_mmu_update(
120 mmu_update_t *req, int count, int *success_count, domid_t domid)
121 {
122 return _hypercall4(int, mmu_update, req, count, success_count, domid);
123 }
125 static inline int
126 HYPERVISOR_mmuext_op(
127 struct mmuext_op *op, int count, int *success_count, domid_t domid)
128 {
129 return _hypercall4(int, mmuext_op, op, count, success_count, domid);
130 }
132 static inline int
133 HYPERVISOR_set_gdt(
134 unsigned long *frame_list, int entries)
135 {
136 return _hypercall2(int, set_gdt, frame_list, entries);
137 }
139 static inline int
140 HYPERVISOR_stack_switch(
141 unsigned long ss, unsigned long esp)
142 {
143 return _hypercall2(int, stack_switch, ss, esp);
144 }
146 static inline int
147 HYPERVISOR_set_callbacks(
148 unsigned long event_selector, unsigned long event_address,
149 unsigned long failsafe_selector, unsigned long failsafe_address)
150 {
151 return _hypercall4(int, set_callbacks,
152 event_selector, event_address,
153 failsafe_selector, failsafe_address);
154 }
156 static inline int
157 HYPERVISOR_fpu_taskswitch(
158 int set)
159 {
160 return _hypercall1(int, fpu_taskswitch, set);
161 }
163 static inline int
164 HYPERVISOR_sched_op(
165 int cmd, unsigned long arg)
166 {
167 return _hypercall2(int, sched_op, cmd, arg);
168 }
170 static inline long
171 HYPERVISOR_set_timer_op(
172 u64 timeout)
173 {
174 unsigned long timeout_hi = (unsigned long)(timeout>>32);
175 unsigned long timeout_lo = (unsigned long)timeout;
176 return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
177 }
179 static inline int
180 HYPERVISOR_dom0_op(
181 dom0_op_t *dom0_op)
182 {
183 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
184 return _hypercall1(int, dom0_op, dom0_op);
185 }
187 static inline int
188 HYPERVISOR_set_debugreg(
189 int reg, unsigned long value)
190 {
191 return _hypercall2(int, set_debugreg, reg, value);
192 }
194 static inline unsigned long
195 HYPERVISOR_get_debugreg(
196 int reg)
197 {
198 return _hypercall1(unsigned long, get_debugreg, reg);
199 }
201 static inline int
202 HYPERVISOR_update_descriptor(
203 u64 ma, u64 desc)
204 {
205 return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
206 }
208 static inline int
209 HYPERVISOR_memory_op(
210 unsigned int cmd, void *arg)
211 {
212 return _hypercall2(int, memory_op, cmd, arg);
213 }
215 static inline int
216 HYPERVISOR_multicall(
217 void *call_list, int nr_calls)
218 {
219 return _hypercall2(int, multicall, call_list, nr_calls);
220 }
222 static inline int
223 HYPERVISOR_update_va_mapping(
224 unsigned long va, pte_t new_val, unsigned long flags)
225 {
226 unsigned long pte_hi = 0;
227 #ifdef CONFIG_X86_PAE
228 pte_hi = new_val.pte_high;
229 #endif
230 return _hypercall4(int, update_va_mapping, va,
231 new_val.pte_low, pte_hi, flags);
232 }
234 static inline int
235 HYPERVISOR_event_channel_op(
236 void *op)
237 {
238 return _hypercall1(int, event_channel_op, op);
239 }
241 static inline int
242 HYPERVISOR_xen_version(
243 int cmd, void *arg)
244 {
245 return _hypercall2(int, xen_version, cmd, arg);
246 }
248 static inline int
249 HYPERVISOR_console_io(
250 int cmd, int count, char *str)
251 {
252 return _hypercall3(int, console_io, cmd, count, str);
253 }
255 static inline int
256 HYPERVISOR_physdev_op(
257 void *physdev_op)
258 {
259 return _hypercall1(int, physdev_op, physdev_op);
260 }
262 static inline int
263 HYPERVISOR_grant_table_op(
264 unsigned int cmd, void *uop, unsigned int count)
265 {
266 return _hypercall3(int, grant_table_op, cmd, uop, count);
267 }
269 static inline int
270 HYPERVISOR_update_va_mapping_otherdomain(
271 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
272 {
273 unsigned long pte_hi = 0;
274 #ifdef CONFIG_X86_PAE
275 pte_hi = new_val.pte_high;
276 #endif
277 return _hypercall5(int, update_va_mapping_otherdomain, va,
278 new_val.pte_low, pte_hi, flags, domid);
279 }
281 static inline int
282 HYPERVISOR_vm_assist(
283 unsigned int cmd, unsigned int type)
284 {
285 return _hypercall2(int, vm_assist, cmd, type);
286 }
288 static inline int
289 HYPERVISOR_vcpu_op(
290 int cmd, int vcpuid, void *extra_args)
291 {
292 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
293 }
295 static inline int
296 HYPERVISOR_suspend(
297 unsigned long srec)
298 {
299 return _hypercall3(int, sched_op, SCHEDOP_shutdown,
300 SHUTDOWN_suspend, srec);
301 }
303 #endif /* __HYPERCALL_H__ */
305 /*
306 * Local variables:
307 * c-file-style: "linux"
308 * indent-tabs-mode: t
309 * c-indent-level: 8
310 * c-basic-offset: 8
311 * tab-width: 8
312 * End:
313 */