ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h @ 9618:db44b783fe09

Cleanups to do_callback_op() new hypercall changeset.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Apr 06 17:25:24 2006 +0100 (2006-04-06)
parents 67de34c062b5
children e049baa9055d
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation; or, when distributed
11 * separately from the Linux kernel or incorporated into other
12 * software packages, subject to the following license:
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this source file (the "Software"), to deal in the Software without
16 * restriction, including without limitation the rights to use, copy, modify,
17 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18 * and to permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 */
33 #ifndef __HYPERCALL_H__
34 #define __HYPERCALL_H__
36 #ifndef __HYPERVISOR_H__
37 # error "please don't include this file directly"
38 #endif
40 #define __STR(x) #x
41 #define STR(x) __STR(x)
43 #define _hypercall0(type, name) \
44 ({ \
45 long __res; \
46 asm volatile ( \
47 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
48 : "=a" (__res) \
49 : \
50 : "memory" ); \
51 (type)__res; \
52 })
54 #define _hypercall1(type, name, a1) \
55 ({ \
56 long __res, __ign1; \
57 asm volatile ( \
58 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
59 : "=a" (__res), "=b" (__ign1) \
60 : "1" ((long)(a1)) \
61 : "memory" ); \
62 (type)__res; \
63 })
65 #define _hypercall2(type, name, a1, a2) \
66 ({ \
67 long __res, __ign1, __ign2; \
68 asm volatile ( \
69 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
70 : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
71 : "1" ((long)(a1)), "2" ((long)(a2)) \
72 : "memory" ); \
73 (type)__res; \
74 })
76 #define _hypercall3(type, name, a1, a2, a3) \
77 ({ \
78 long __res, __ign1, __ign2, __ign3; \
79 asm volatile ( \
80 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
81 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
82 "=d" (__ign3) \
83 : "1" ((long)(a1)), "2" ((long)(a2)), \
84 "3" ((long)(a3)) \
85 : "memory" ); \
86 (type)__res; \
87 })
89 #define _hypercall4(type, name, a1, a2, a3, a4) \
90 ({ \
91 long __res, __ign1, __ign2, __ign3, __ign4; \
92 asm volatile ( \
93 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
94 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
95 "=d" (__ign3), "=S" (__ign4) \
96 : "1" ((long)(a1)), "2" ((long)(a2)), \
97 "3" ((long)(a3)), "4" ((long)(a4)) \
98 : "memory" ); \
99 (type)__res; \
100 })
102 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
103 ({ \
104 long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \
105 asm volatile ( \
106 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
107 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
108 "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
109 : "1" ((long)(a1)), "2" ((long)(a2)), \
110 "3" ((long)(a3)), "4" ((long)(a4)), \
111 "5" ((long)(a5)) \
112 : "memory" ); \
113 (type)__res; \
114 })
116 static inline int
117 HYPERVISOR_set_trap_table(
118 trap_info_t *table)
119 {
120 return _hypercall1(int, set_trap_table, table);
121 }
123 static inline int
124 HYPERVISOR_mmu_update(
125 mmu_update_t *req, int count, int *success_count, domid_t domid)
126 {
127 return _hypercall4(int, mmu_update, req, count, success_count, domid);
128 }
130 static inline int
131 HYPERVISOR_mmuext_op(
132 struct mmuext_op *op, int count, int *success_count, domid_t domid)
133 {
134 return _hypercall4(int, mmuext_op, op, count, success_count, domid);
135 }
137 static inline int
138 HYPERVISOR_set_gdt(
139 unsigned long *frame_list, int entries)
140 {
141 return _hypercall2(int, set_gdt, frame_list, entries);
142 }
144 static inline int
145 HYPERVISOR_stack_switch(
146 unsigned long ss, unsigned long esp)
147 {
148 return _hypercall2(int, stack_switch, ss, esp);
149 }
151 static inline int
152 HYPERVISOR_set_callbacks(
153 unsigned long event_selector, unsigned long event_address,
154 unsigned long failsafe_selector, unsigned long failsafe_address)
155 {
156 return _hypercall4(int, set_callbacks,
157 event_selector, event_address,
158 failsafe_selector, failsafe_address);
159 }
161 static inline int
162 HYPERVISOR_fpu_taskswitch(
163 int set)
164 {
165 return _hypercall1(int, fpu_taskswitch, set);
166 }
168 static inline int
169 HYPERVISOR_sched_op_compat(
170 int cmd, unsigned long arg)
171 {
172 return _hypercall2(int, sched_op_compat, cmd, arg);
173 }
175 static inline int
176 HYPERVISOR_sched_op(
177 int cmd, void *arg)
178 {
179 return _hypercall2(int, sched_op, cmd, arg);
180 }
182 static inline long
183 HYPERVISOR_set_timer_op(
184 u64 timeout)
185 {
186 unsigned long timeout_hi = (unsigned long)(timeout>>32);
187 unsigned long timeout_lo = (unsigned long)timeout;
188 return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
189 }
191 static inline int
192 HYPERVISOR_dom0_op(
193 dom0_op_t *dom0_op)
194 {
195 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
196 return _hypercall1(int, dom0_op, dom0_op);
197 }
199 static inline int
200 HYPERVISOR_set_debugreg(
201 int reg, unsigned long value)
202 {
203 return _hypercall2(int, set_debugreg, reg, value);
204 }
206 static inline unsigned long
207 HYPERVISOR_get_debugreg(
208 int reg)
209 {
210 return _hypercall1(unsigned long, get_debugreg, reg);
211 }
213 static inline int
214 HYPERVISOR_update_descriptor(
215 u64 ma, u64 desc)
216 {
217 return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
218 }
220 static inline int
221 HYPERVISOR_memory_op(
222 unsigned int cmd, void *arg)
223 {
224 return _hypercall2(int, memory_op, cmd, arg);
225 }
227 static inline int
228 HYPERVISOR_multicall(
229 void *call_list, int nr_calls)
230 {
231 return _hypercall2(int, multicall, call_list, nr_calls);
232 }
234 static inline int
235 HYPERVISOR_update_va_mapping(
236 unsigned long va, pte_t new_val, unsigned long flags)
237 {
238 unsigned long pte_hi = 0;
239 #ifdef CONFIG_X86_PAE
240 pte_hi = new_val.pte_high;
241 #endif
242 return _hypercall4(int, update_va_mapping, va,
243 new_val.pte_low, pte_hi, flags);
244 }
246 static inline int
247 HYPERVISOR_event_channel_op(
248 void *op)
249 {
250 return _hypercall1(int, event_channel_op, op);
251 }
253 static inline int
254 HYPERVISOR_xen_version(
255 int cmd, void *arg)
256 {
257 return _hypercall2(int, xen_version, cmd, arg);
258 }
260 static inline int
261 HYPERVISOR_console_io(
262 int cmd, int count, char *str)
263 {
264 return _hypercall3(int, console_io, cmd, count, str);
265 }
267 static inline int
268 HYPERVISOR_physdev_op(
269 void *physdev_op)
270 {
271 return _hypercall1(int, physdev_op, physdev_op);
272 }
274 static inline int
275 HYPERVISOR_grant_table_op(
276 unsigned int cmd, void *uop, unsigned int count)
277 {
278 return _hypercall3(int, grant_table_op, cmd, uop, count);
279 }
281 static inline int
282 HYPERVISOR_update_va_mapping_otherdomain(
283 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
284 {
285 unsigned long pte_hi = 0;
286 #ifdef CONFIG_X86_PAE
287 pte_hi = new_val.pte_high;
288 #endif
289 return _hypercall5(int, update_va_mapping_otherdomain, va,
290 new_val.pte_low, pte_hi, flags, domid);
291 }
293 static inline int
294 HYPERVISOR_vm_assist(
295 unsigned int cmd, unsigned int type)
296 {
297 return _hypercall2(int, vm_assist, cmd, type);
298 }
300 static inline int
301 HYPERVISOR_vcpu_op(
302 int cmd, int vcpuid, void *extra_args)
303 {
304 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
305 }
307 static inline int
308 HYPERVISOR_suspend(
309 unsigned long srec)
310 {
311 struct sched_shutdown sched_shutdown = {
312 .reason = SHUTDOWN_suspend
313 };
315 int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
316 &sched_shutdown, srec);
318 if (rc == -ENOSYS)
319 rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
320 SHUTDOWN_suspend, srec);
322 return rc;
323 }
325 static inline int
326 HYPERVISOR_nmi_op(
327 unsigned long op, void *arg)
328 {
329 return _hypercall2(int, nmi_op, op, arg);
330 }
332 static inline int
333 HYPERVISOR_callback_op(
334 int cmd, void *arg)
335 {
336 return _hypercall2(int, callback_op, cmd, arg);
337 }
339 #endif /* __HYPERCALL_H__ */
341 /*
342 * Local variables:
343 * c-file-style: "linux"
344 * indent-tabs-mode: t
345 * c-indent-level: 8
346 * c-basic-offset: 8
347 * tab-width: 8
348 * End:
349 */