ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/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 0ffd94a02318
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 *
8 * 64-bit updates:
9 * Benjamin Liu <benjamin.liu@intel.com>
10 * Jun Nakajima <jun.nakajima@intel.com>
11 *
12 * This file may be distributed separately from the Linux kernel, or
13 * incorporated into other software packages, subject to the following license:
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a copy
16 * of this source file (the "Software"), to deal in the Software without
17 * restriction, including without limitation the rights to use, copy, modify,
18 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
19 * and to permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
21 *
22 * The above copyright notice and this permission notice shall be included in
23 * all copies or substantial portions of the Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 * IN THE SOFTWARE.
32 */
34 #ifndef __HYPERCALL_H__
35 #define __HYPERCALL_H__
37 #include <asm-xen/xen-public/xen.h>
38 #include <asm-xen/xen-public/sched.h>
40 #define __syscall_clobber "r11","rcx","memory"
42 #define _hypercall0(type, name) \
43 ({ \
44 long __res; \
45 asm volatile ( \
46 TRAP_INSTR \
47 : "=a" (__res) \
48 : "0" (__HYPERVISOR_##name) \
49 : __syscall_clobber ); \
50 (type)__res; \
51 })
53 #define _hypercall1(type, name, a1) \
54 ({ \
55 long __res, __ign1; \
56 asm volatile ( \
57 TRAP_INSTR \
58 : "=a" (__res), "=D" (__ign1) \
59 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)) \
60 : __syscall_clobber ); \
61 (type)__res; \
62 })
64 #define _hypercall2(type, name, a1, a2) \
65 ({ \
66 long __res, __ign1, __ign2; \
67 asm volatile ( \
68 TRAP_INSTR \
69 : "=a" (__res), "=D" (__ign1), "=S" (__ign2) \
70 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
71 "2" ((long)(a2)) \
72 : __syscall_clobber ); \
73 (type)__res; \
74 })
76 #define _hypercall3(type, name, a1, a2, a3) \
77 ({ \
78 long __res, __ign1, __ign2, __ign3; \
79 asm volatile ( \
80 TRAP_INSTR \
81 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
82 "=d" (__ign3) \
83 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
84 "2" ((long)(a2)), "3" ((long)(a3)) \
85 : __syscall_clobber ); \
86 (type)__res; \
87 })
89 #define _hypercall4(type, name, a1, a2, a3, a4) \
90 ({ \
91 long __res, __ign1, __ign2, __ign3; \
92 asm volatile ( \
93 "movq %8,%%r10; " TRAP_INSTR \
94 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
95 "=d" (__ign3) \
96 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
97 "2" ((long)(a2)), "3" ((long)(a3)), \
98 "g" ((long)(a4)) \
99 : __syscall_clobber, "r10" ); \
100 (type)__res; \
101 })
103 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
104 ({ \
105 long __res, __ign1, __ign2, __ign3; \
106 asm volatile ( \
107 "movq %8,%%r10; movq %9,%%r8; " TRAP_INSTR \
108 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
109 "=d" (__ign3) \
110 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
111 "2" ((long)(a2)), "3" ((long)(a3)), \
112 "g" ((long)(a4)), "g" ((long)(a5)) \
113 : __syscall_clobber, "r10", "r8" ); \
114 (type)__res; \
115 })
117 static inline int
118 HYPERVISOR_set_trap_table(
119 trap_info_t *table)
120 {
121 return _hypercall1(int, set_trap_table, table);
122 }
124 static inline int
125 HYPERVISOR_mmu_update(
126 mmu_update_t *req, int count, int *success_count, domid_t domid)
127 {
128 return _hypercall4(int, mmu_update, req, count, success_count, domid);
129 }
131 static inline int
132 HYPERVISOR_mmuext_op(
133 struct mmuext_op *op, int count, int *success_count, domid_t domid)
134 {
135 return _hypercall4(int, mmuext_op, op, count, success_count, domid);
136 }
138 static inline int
139 HYPERVISOR_set_gdt(
140 unsigned long *frame_list, int entries)
141 {
142 return _hypercall2(int, set_gdt, frame_list, entries);
143 }
145 static inline int
146 HYPERVISOR_stack_switch(
147 unsigned long ss, unsigned long esp)
148 {
149 return _hypercall2(int, stack_switch, ss, esp);
150 }
152 static inline int
153 HYPERVISOR_set_callbacks(
154 unsigned long event_address, unsigned long failsafe_address,
155 unsigned long syscall_address)
156 {
157 return _hypercall3(int, set_callbacks,
158 event_address, failsafe_address, syscall_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(
170 int cmd, unsigned long arg)
171 {
172 return _hypercall2(int, sched_op, cmd, arg);
173 }
175 static inline long
176 HYPERVISOR_set_timer_op(
177 u64 timeout)
178 {
179 return _hypercall1(long, set_timer_op, timeout);
180 }
182 static inline int
183 HYPERVISOR_dom0_op(
184 dom0_op_t *dom0_op)
185 {
186 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
187 return _hypercall1(int, dom0_op, dom0_op);
188 }
190 static inline int
191 HYPERVISOR_set_debugreg(
192 int reg, unsigned long value)
193 {
194 return _hypercall2(int, set_debugreg, reg, value);
195 }
197 static inline unsigned long
198 HYPERVISOR_get_debugreg(
199 int reg)
200 {
201 return _hypercall1(unsigned long, get_debugreg, reg);
202 }
204 static inline int
205 HYPERVISOR_update_descriptor(
206 unsigned long ma, unsigned long word)
207 {
208 return _hypercall2(int, update_descriptor, ma, word);
209 }
211 static inline int
212 HYPERVISOR_memory_op(
213 unsigned int cmd, void *arg)
214 {
215 return _hypercall2(int, memory_op, cmd, arg);
216 }
218 static inline int
219 HYPERVISOR_multicall(
220 void *call_list, int nr_calls)
221 {
222 return _hypercall2(int, multicall, call_list, nr_calls);
223 }
225 static inline int
226 HYPERVISOR_update_va_mapping(
227 unsigned long va, pte_t new_val, unsigned long flags)
228 {
229 return _hypercall3(int, update_va_mapping, va, new_val.pte, flags);
230 }
232 static inline int
233 HYPERVISOR_event_channel_op(
234 void *op)
235 {
236 return _hypercall1(int, event_channel_op, op);
237 }
239 static inline int
240 HYPERVISOR_xen_version(
241 int cmd, void *arg)
242 {
243 return _hypercall2(int, xen_version, cmd, arg);
244 }
246 static inline int
247 HYPERVISOR_console_io(
248 int cmd, int count, char *str)
249 {
250 return _hypercall3(int, console_io, cmd, count, str);
251 }
253 static inline int
254 HYPERVISOR_physdev_op(
255 void *physdev_op)
256 {
257 return _hypercall1(int, physdev_op, physdev_op);
258 }
260 static inline int
261 HYPERVISOR_grant_table_op(
262 unsigned int cmd, void *uop, unsigned int count)
263 {
264 return _hypercall3(int, grant_table_op, cmd, uop, count);
265 }
267 static inline int
268 HYPERVISOR_update_va_mapping_otherdomain(
269 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
270 {
271 return _hypercall4(int, update_va_mapping_otherdomain, va,
272 new_val.pte, flags, domid);
273 }
275 static inline int
276 HYPERVISOR_vm_assist(
277 unsigned int cmd, unsigned int type)
278 {
279 return _hypercall2(int, vm_assist, cmd, type);
280 }
282 static inline int
283 HYPERVISOR_vcpu_op(
284 int cmd, int vcpuid, void *extra_args)
285 {
286 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
287 }
289 static inline int
290 HYPERVISOR_switch_to_user(void)
291 {
292 return _hypercall0(int, switch_to_user);
293 }
295 static inline int
296 HYPERVISOR_set_segment_base(
297 int reg, unsigned long value)
298 {
299 return _hypercall2(int, set_segment_base, reg, value);
300 }
302 static inline int
303 HYPERVISOR_suspend(
304 unsigned long srec)
305 {
306 return _hypercall3(int, sched_op, SCHEDOP_shutdown,
307 SHUTDOWN_suspend, srec);
308 }
310 #endif /* __HYPERCALL_H__ */
312 /*
313 * Local variables:
314 * c-file-style: "linux"
315 * indent-tabs-mode: t
316 * c-indent-level: 8
317 * c-basic-offset: 8
318 * tab-width: 8
319 * End:
320 */