No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / xen / include / amd64 / hypercalls.h
blobf2570118212793b2e3e78ad14c94c126b6a018d2
1 /* $NetBSD: hypercalls.h,v 1.4 2008/10/24 22:06:06 jym Exp $ */
2 /******************************************************************************
3 * hypercall.h
4 *
5 * Linux-specific hypervisor handling.
6 *
7 * Copyright (c) 2002-2004, K A Fraser
8 *
9 * 64-bit updates:
10 * Benjamin Liu <benjamin.liu@intel.com>
11 * Jun Nakajima <jun.nakajima@intel.com>
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation; or, when distributed
16 * separately from the Linux kernel or incorporated into other
17 * software packages, subject to the following license:
19 * Permission is hereby granted, free of charge, to any person obtaining a copy
20 * of this source file (the "Software"), to deal in the Software without
21 * restriction, including without limitation the rights to use, copy, modify,
22 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
23 * and to permit persons to whom the Software is furnished to do so, subject to
24 * the following conditions:
26 * The above copyright notice and this permission notice shall be included in
27 * all copies or substantial portions of the Software.
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
35 * IN THE SOFTWARE.
38 #ifndef __HYPERCALL_H__
39 #define __HYPERCALL_H__
41 #define __STR(x) #x
42 #define STR(x) __STR(x)
44 #define HYPERCALL_STR(name) \
45 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
47 #define _hypercall0(type, name) \
48 ({ \
49 long __res; \
50 asm volatile ( \
51 HYPERCALL_STR(name) \
52 : "=a" (__res) \
53 : \
54 : "memory" ); \
55 (type)__res; \
58 #define _hypercall1(type, name, a1) \
59 ({ \
60 long __res, __ign1; \
61 asm volatile ( \
62 HYPERCALL_STR(name) \
63 : "=a" (__res), "=D" (__ign1) \
64 : "1" ((long)(a1)) \
65 : "memory" ); \
66 (type)__res; \
69 #define _hypercall2(type, name, a1, a2) \
70 ({ \
71 long __res, __ign1, __ign2; \
72 asm volatile ( \
73 HYPERCALL_STR(name) \
74 : "=a" (__res), "=D" (__ign1), "=S" (__ign2) \
75 : "1" ((long)(a1)), "2" ((long)(a2)) \
76 : "memory" ); \
77 (type)__res; \
80 #define _hypercall3(type, name, a1, a2, a3) \
81 ({ \
82 long __res, __ign1, __ign2, __ign3; \
83 asm volatile ( \
84 HYPERCALL_STR(name) \
85 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
86 "=d" (__ign3) \
87 : "1" ((long)(a1)), "2" ((long)(a2)), \
88 "3" ((long)(a3)) \
89 : "memory" ); \
90 (type)__res; \
93 #define _hypercall4(type, name, a1, a2, a3, a4) \
94 ({ \
95 long __res, __ign1, __ign2, __ign3; \
96 asm volatile ( \
97 "movq %7,%%r10; " \
98 HYPERCALL_STR(name) \
99 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
100 "=d" (__ign3) \
101 : "1" ((long)(a1)), "2" ((long)(a2)), \
102 "3" ((long)(a3)), "g" ((long)(a4)) \
103 : "memory", "r10" ); \
104 (type)__res; \
107 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
108 ({ \
109 long __res, __ign1, __ign2, __ign3; \
110 asm volatile ( \
111 "movq %7,%%r10; movq %8,%%r8; " \
112 HYPERCALL_STR(name) \
113 : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
114 "=d" (__ign3) \
115 : "1" ((long)(a1)), "2" ((long)(a2)), \
116 "3" ((long)(a3)), "g" ((long)(a4)), \
117 "g" ((long)(a5)) \
118 : "memory", "r10", "r8" ); \
119 (type)__res; \
122 static inline int
123 HYPERVISOR_set_trap_table(
124 trap_info_t *table)
126 return _hypercall1(int, set_trap_table, table);
129 static inline int
130 HYPERVISOR_mmu_update(
131 mmu_update_t *req, int count, int *success_count, domid_t domid)
133 return _hypercall4(int, mmu_update, req, count, success_count, domid);
136 static inline int
137 HYPERVISOR_mmuext_op(
138 struct mmuext_op *op, int count, int *success_count, domid_t domid)
140 return _hypercall4(int, mmuext_op, op, count, success_count, domid);
143 static inline int
144 HYPERVISOR_set_gdt(
145 unsigned long *frame_list, int entries)
147 return _hypercall2(int, set_gdt, frame_list, entries);
150 static inline int
151 HYPERVISOR_stack_switch(
152 unsigned long ss, unsigned long esp)
154 return _hypercall2(int, stack_switch, ss, esp);
157 static inline int
158 HYPERVISOR_set_callbacks(
159 unsigned long event_address, unsigned long failsafe_address,
160 unsigned long syscall_address)
162 return _hypercall3(int, set_callbacks,
163 event_address, failsafe_address, syscall_address);
166 static inline int
167 HYPERVISOR_fpu_taskswitch(
168 int set)
170 return _hypercall1(int, fpu_taskswitch, set);
173 static inline int
174 HYPERVISOR_sched_op_compat(
175 int cmd, unsigned long arg)
177 return _hypercall2(int, sched_op_compat, cmd, arg);
180 static inline int
181 HYPERVISOR_sched_op(
182 int cmd, void *arg)
184 return _hypercall2(int, sched_op, cmd, arg);
187 static inline long
188 HYPERVISOR_set_timer_op(
189 u64 timeout)
191 return _hypercall1(long, set_timer_op, timeout);
194 static inline int
195 HYPERVISOR_platform_op(
196 struct xen_platform_op *platform_op)
198 platform_op->interface_version = XENPF_INTERFACE_VERSION;
199 return _hypercall1(int, platform_op, platform_op);
202 static inline int
203 HYPERVISOR_set_debugreg(
204 int reg, unsigned long value)
206 return _hypercall2(int, set_debugreg, reg, value);
209 static inline unsigned long
210 HYPERVISOR_get_debugreg(
211 int reg)
213 return _hypercall1(unsigned long, get_debugreg, reg);
216 static inline int
217 HYPERVISOR_update_descriptor(
218 unsigned long ma, unsigned long word)
220 return _hypercall2(int, update_descriptor, ma, word);
223 static inline int
224 HYPERVISOR_memory_op(
225 unsigned int cmd, void *arg)
227 return _hypercall2(int, memory_op, cmd, arg);
230 static inline int
231 HYPERVISOR_multicall(
232 multicall_entry_t *call_list, int nr_calls)
234 return _hypercall2(int, multicall, call_list, nr_calls);
237 static inline int
238 HYPERVISOR_update_va_mapping(
239 unsigned long va, unsigned long new_val, unsigned long flags)
241 return _hypercall3(int, update_va_mapping, va, new_val, flags);
244 static inline int
245 HYPERVISOR_event_channel_op(void *op)
247 return _hypercall1(int, event_channel_op, op);
250 static inline int
251 HYPERVISOR_acm_op(
252 int cmd, void *arg)
254 return _hypercall2(int, acm_op, cmd, arg);
257 static inline int
258 HYPERVISOR_xen_version(
259 int cmd, void *arg)
261 return _hypercall2(int, xen_version, cmd, arg);
264 static inline int
265 HYPERVISOR_console_io(
266 int cmd, int count, char *str)
268 return _hypercall3(int, console_io, cmd, count, str);
271 static inline int
272 HYPERVISOR_physdev_op(void *op)
274 return _hypercall1(int, physdev_op_compat, op);
277 static inline int
278 HYPERVISOR_grant_table_op(
279 unsigned int cmd, void *uop, unsigned int count)
281 return _hypercall3(int, grant_table_op, cmd, uop, count);
284 static inline int
285 HYPERVISOR_update_va_mapping_otherdomain(
286 unsigned long va, unsigned long new_val, unsigned long flags,
287 domid_t domid)
289 return _hypercall4(int, update_va_mapping_otherdomain, va,
290 new_val, flags, domid);
293 static inline int
294 HYPERVISOR_vm_assist(
295 unsigned int cmd, unsigned int type)
297 return _hypercall2(int, vm_assist, cmd, type);
300 static inline int
301 HYPERVISOR_vcpu_op(
302 int cmd, int vcpuid, void *extra_args)
304 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
307 static inline int
308 HYPERVISOR_set_segment_base(
309 int reg, unsigned long value)
311 return _hypercall2(int, set_segment_base, reg, value);
314 static inline int
315 HYPERVISOR_suspend(
316 unsigned long srec)
318 return _hypercall3(int, sched_op, SCHEDOP_shutdown,
319 SHUTDOWN_suspend, srec);
322 static inline long
323 HYPERVISOR_yield(
324 void)
326 return _hypercall2(int, sched_op, SCHEDOP_yield, 0);
329 static inline long
330 HYPERVISOR_block(
331 void)
333 return _hypercall2(int, sched_op, SCHEDOP_block, 0);
336 static inline long
337 HYPERVISOR_shutdown(
338 void)
340 return _hypercall2(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_poweroff);
343 static inline long
344 HYPERVISOR_crash(
345 void)
347 return _hypercall2(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_crash);
350 static inline long
351 HYPERVISOR_reboot(
352 void)
354 return _hypercall2(int, sched_op, SCHEDOP_shutdown, SHUTDOWN_reboot);
357 static inline int
358 HYPERVISOR_nmi_op(
359 unsigned long op, void *arg)
361 return _hypercall2(int, nmi_op, op, arg);
364 static inline unsigned long
365 HYPERVISOR_hvm_op(
366 int op, void *arg)
368 return _hypercall2(unsigned long, hvm_op, op, arg);
371 static inline int
372 HYPERVISOR_callback_op(
373 int cmd, void *arg)
375 return _hypercall2(int, callback_op, cmd, arg);
378 static inline int
379 HYPERVISOR_xenoprof_op(
380 int op, void *arg)
382 return _hypercall2(int, xenoprof_op, op, arg);
385 static inline int
386 HYPERVISOR_kexec_op(
387 unsigned long op, void *args)
389 return _hypercall2(int, kexec_op, op, args);
392 #if __XEN_INTERFACE_VERSION__ < 0x00030204
393 static inline int
394 HYPERVISOR_dom0_op(
395 dom0_op_t *dom0_op)
397 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
398 return _hypercall1(int, dom0_op, dom0_op);
400 #endif /* __XEN_INTERFACE_VERSION__ */
402 static inline int
403 HYPERVISOR_machine_check(struct xen_mc *mc)
405 mc->interface_version = XEN_MCA_INTERFACE_VERSION;
406 return _hypercall1(int, mca, mc);
409 #endif /* __HYPERCALL_H__ */