ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h @ 6756:f752e0c873a6

merge?
author cl349@firebug.cl.cam.ac.uk
date Mon Sep 12 12:32:20 2005 +0000 (2005-09-12)
parents dd668f7527cb 939fd35d58da
children 4d899a738d59 8ca0f98ba8e2
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>
39 #define __syscall_clobber "r11","rcx","memory"
41 #define _hypercall0(type, name) \
42 ({ \
43 long __res; \
44 asm volatile ( \
45 TRAP_INSTR \
46 : "=a" (__res) \
47 : "0" (__HYPERVISOR_##name) \
48 : __syscall_clobber ); \
49 (type)__res; \
50 })
52 #define _hypercall1(type, name, a1) \
53 ({ \
54 long __res, __ign1; \
55 asm volatile ( \
56 TRAP_INSTR \
57 : "=a" (__res), "=D" (__ign1) \
58 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)) \
59 : __syscall_clobber ); \
60 (type)__res; \
61 })
63 #define _hypercall2(type, name, a1, a2) \
64 ({ \
65 long __res, __ign1, __ign2; \
66 asm volatile ( \
67 TRAP_INSTR \
68 : "=a" (__res), "=D" (__ign1), "=S" (__ign2) \
69 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
70 "2" ((long)(a2)) \
71 : __syscall_clobber ); \
72 (type)__res; \
73 })
75 #define _hypercall3(type, name, a1, a2, a3) \
76 ({ \
77 long __res, __ign1, __ign2, __ign3; \
78 asm volatile ( \
79 TRAP_INSTR \
80 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
81 "=d" (__ign3) \
82 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
83 "2" ((long)(a2)), "3" ((long)(a3)) \
84 : __syscall_clobber ); \
85 (type)__res; \
86 })
88 #define _hypercall4(type, name, a1, a2, a3, a4) \
89 ({ \
90 long __res, __ign1, __ign2, __ign3; \
91 asm volatile ( \
92 "movq %8,%%r10; " TRAP_INSTR \
93 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
94 "=d" (__ign3) \
95 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
96 "2" ((long)(a2)), "3" ((long)(a3)), \
97 "g" ((long)(a4)) \
98 : __syscall_clobber, "r10" ); \
99 (type)__res; \
100 })
102 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
103 ({ \
104 long __res, __ign1, __ign2, __ign3; \
105 asm volatile ( \
106 "movq %8,%%r10; movq %9,%%r8; " TRAP_INSTR \
107 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
108 "=d" (__ign3) \
109 : "0" (__HYPERVISOR_##name), "1" ((long)(a1)), \
110 "2" ((long)(a2)), "3" ((long)(a3)), \
111 "g" ((long)(a4)), "g" ((long)(a5)) \
112 : __syscall_clobber, "r10", "r8" ); \
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_address, unsigned long failsafe_address,
154 unsigned long syscall_address)
155 {
156 return _hypercall3(int, set_callbacks,
157 event_address, failsafe_address, syscall_address);
158 }
160 static inline int
161 HYPERVISOR_fpu_taskswitch(
162 int set)
163 {
164 return _hypercall1(int, fpu_taskswitch, set);
165 }
167 static inline int
168 HYPERVISOR_yield(
169 void)
170 {
171 return _hypercall2(int, sched_op, SCHEDOP_yield, 0);
172 }
174 static inline int
175 HYPERVISOR_block(
176 void)
177 {
178 return _hypercall2(int, sched_op, SCHEDOP_block, 0);
179 }
181 static inline int
182 HYPERVISOR_shutdown(
183 void)
184 {
185 return _hypercall2(int, sched_op, SCHEDOP_shutdown |
186 (SHUTDOWN_poweroff << SCHEDOP_reasonshift), 0);
187 }
189 static inline int
190 HYPERVISOR_reboot(
191 void)
192 {
193 return _hypercall2(int, sched_op, SCHEDOP_shutdown |
194 (SHUTDOWN_reboot << SCHEDOP_reasonshift), 0);
195 }
197 static inline long
198 HYPERVISOR_set_timer_op(
199 u64 timeout)
200 {
201 return _hypercall1(long, set_timer_op, timeout);
202 }
204 static inline int
205 HYPERVISOR_dom0_op(
206 dom0_op_t *dom0_op)
207 {
208 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
209 return _hypercall1(int, dom0_op, dom0_op);
210 }
212 static inline int
213 HYPERVISOR_set_debugreg(
214 int reg, unsigned long value)
215 {
216 return _hypercall2(int, set_debugreg, reg, value);
217 }
219 static inline unsigned long
220 HYPERVISOR_get_debugreg(
221 int reg)
222 {
223 return _hypercall1(unsigned long, get_debugreg, reg);
224 }
226 static inline int
227 HYPERVISOR_update_descriptor(
228 unsigned long ma, unsigned long word)
229 {
230 return _hypercall2(int, update_descriptor, ma, word);
231 }
233 static inline int
234 HYPERVISOR_memory_op(
235 unsigned int cmd, void *arg)
236 {
237 return _hypercall2(int, memory_op, cmd, arg);
238 }
240 static inline int
241 HYPERVISOR_multicall(
242 void *call_list, int nr_calls)
243 {
244 return _hypercall2(int, multicall, call_list, nr_calls);
245 }
247 static inline int
248 HYPERVISOR_update_va_mapping(
249 unsigned long va, pte_t new_val, unsigned long flags)
250 {
251 return _hypercall3(int, update_va_mapping, va, new_val.pte, flags);
252 }
254 static inline int
255 HYPERVISOR_event_channel_op(
256 void *op)
257 {
258 return _hypercall1(int, event_channel_op, op);
259 }
261 static inline int
262 HYPERVISOR_xen_version(
263 int cmd, void *arg)
264 {
265 return _hypercall2(int, xen_version, cmd, arg);
266 }
268 static inline int
269 HYPERVISOR_console_io(
270 int cmd, int count, char *str)
271 {
272 return _hypercall3(int, console_io, cmd, count, str);
273 }
275 static inline int
276 HYPERVISOR_physdev_op(
277 void *physdev_op)
278 {
279 return _hypercall1(int, physdev_op, physdev_op);
280 }
282 static inline int
283 HYPERVISOR_grant_table_op(
284 unsigned int cmd, void *uop, unsigned int count)
285 {
286 return _hypercall3(int, grant_table_op, cmd, uop, count);
287 }
289 static inline int
290 HYPERVISOR_update_va_mapping_otherdomain(
291 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
292 {
293 return _hypercall4(int, update_va_mapping_otherdomain, va,
294 new_val.pte, flags, domid);
295 }
297 static inline int
298 HYPERVISOR_vm_assist(
299 unsigned int cmd, unsigned int type)
300 {
301 return _hypercall2(int, vm_assist, cmd, type);
302 }
304 static inline int
305 HYPERVISOR_boot_vcpu(
306 unsigned long vcpu, vcpu_guest_context_t *ctxt)
307 {
308 return _hypercall2(int, boot_vcpu, vcpu, ctxt);
309 }
311 static inline int
312 HYPERVISOR_vcpu_up(
313 int vcpu)
314 {
315 return _hypercall2(int, sched_op, SCHEDOP_vcpu_up |
316 (vcpu << SCHEDOP_vcpushift), 0);
317 }
319 static inline int
320 HYPERVISOR_vcpu_pickle(
321 int vcpu, vcpu_guest_context_t *ctxt)
322 {
323 return _hypercall2(int, sched_op, SCHEDOP_vcpu_pickle |
324 (vcpu << SCHEDOP_vcpushift), ctxt);
325 }
327 static inline int
328 HYPERVISOR_switch_to_user(void)
329 {
330 return _hypercall0(int, switch_to_user);
331 }
333 static inline int
334 HYPERVISOR_set_segment_base(
335 int reg, unsigned long value)
336 {
337 return _hypercall2(int, set_segment_base, reg, value);
338 }
340 static inline int
341 HYPERVISOR_suspend(
342 unsigned long srec)
343 {
344 return _hypercall2(int, sched_op, SCHEDOP_shutdown |
345 (SHUTDOWN_suspend << SCHEDOP_reasonshift), srec);
346 }
348 #endif /* __HYPERCALL_H__ */
350 /*
351 * Local variables:
352 * c-file-style: "linux"
353 * indent-tabs-mode: t
354 * c-indent-level: 8
355 * c-basic-offset: 8
356 * tab-width: 8
357 * End:
358 */