1
/******************************************************************************
4
* Copied from XenLinux.
6
* Copyright (c) 2002-2004, K A Fraser
9
* Benjamin Liu <benjamin.liu@intel.com>
10
* Jun Nakajima <jun.nakajima@intel.com>
12
* This file may be distributed separately from the Linux kernel, or
13
* incorporated into other software packages, subject to the following license:
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:
22
* The above copyright notice and this permission notice shall be included in
23
* all copies or substantial portions of the Software.
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
34
#ifndef __HYPERCALL_X86_64_H__
35
#define __HYPERCALL_X86_64_H__
38
#include <xen/sched.h>
39
#include <mini-os/mm.h>
42
#define STR(x) __STR(x)
44
extern char hypercall_page[PAGE_SIZE];
46
#define _hypercall0(type, name) \
50
"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
57
#define _hypercall1(type, name, a1) \
61
"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
62
: "=a" (__res), "=D" (__ign1) \
68
#define _hypercall2(type, name, a1, a2) \
70
long __res, __ign1, __ign2; \
72
"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
73
: "=a" (__res), "=D" (__ign1), "=S" (__ign2) \
74
: "1" ((long)(a1)), "2" ((long)(a2)) \
79
#define _hypercall3(type, name, a1, a2, a3) \
81
long __res, __ign1, __ign2, __ign3; \
83
"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
84
: "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
86
: "1" ((long)(a1)), "2" ((long)(a2)), \
92
#define _hypercall4(type, name, a1, a2, a3, a4) \
94
long __res, __ign1, __ign2, __ign3; \
97
"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
98
: "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
100
: "1" ((long)(a1)), "2" ((long)(a2)), \
101
"3" ((long)(a3)), "g" ((long)(a4)) \
102
: "memory", "r10" ); \
106
#define _hypercall5(type, name, a1, a2, a3, a4, a5) \
108
long __res, __ign1, __ign2, __ign3; \
110
"movq %7,%%r10; movq %8,%%r8; " \
111
"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
112
: "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
114
: "1" ((long)(a1)), "2" ((long)(a2)), \
115
"3" ((long)(a3)), "g" ((long)(a4)), \
117
: "memory", "r10", "r8" ); \
122
HYPERVISOR_set_trap_table(
125
return _hypercall1(int, set_trap_table, table);
129
HYPERVISOR_mmu_update(
130
mmu_update_t *req, int count, int *success_count, domid_t domid)
132
return _hypercall4(int, mmu_update, req, count, success_count, domid);
136
HYPERVISOR_mmuext_op(
137
struct mmuext_op *op, int count, int *success_count, domid_t domid)
139
return _hypercall4(int, mmuext_op, op, count, success_count, domid);
144
unsigned long *frame_list, int entries)
146
return _hypercall2(int, set_gdt, frame_list, entries);
150
HYPERVISOR_stack_switch(
151
unsigned long ss, unsigned long esp)
153
return _hypercall2(int, stack_switch, ss, esp);
157
HYPERVISOR_set_callbacks(
158
unsigned long event_address, unsigned long failsafe_address,
159
unsigned long syscall_address)
161
return _hypercall3(int, set_callbacks,
162
event_address, failsafe_address, syscall_address);
166
HYPERVISOR_fpu_taskswitch(
169
return _hypercall1(int, fpu_taskswitch, set);
176
return _hypercall2(int, sched_op, cmd, arg);
180
HYPERVISOR_set_timer_op(
183
return _hypercall1(long, set_timer_op, timeout);
187
HYPERVISOR_set_debugreg(
188
int reg, unsigned long value)
190
return _hypercall2(int, set_debugreg, reg, value);
193
static inline unsigned long
194
HYPERVISOR_get_debugreg(
197
return _hypercall1(unsigned long, get_debugreg, reg);
201
HYPERVISOR_update_descriptor(
202
unsigned long ma, unsigned long word)
204
return _hypercall2(int, update_descriptor, ma, word);
208
HYPERVISOR_memory_op(
209
unsigned int cmd, void *arg)
211
return _hypercall2(int, memory_op, cmd, arg);
215
HYPERVISOR_multicall(
216
void *call_list, int nr_calls)
218
return _hypercall2(int, multicall, call_list, nr_calls);
222
HYPERVISOR_update_va_mapping(
223
unsigned long va, pte_t new_val, unsigned long flags)
225
return _hypercall3(int, update_va_mapping, va, new_val.pte, flags);
229
HYPERVISOR_event_channel_op(
232
return _hypercall2(int, event_channel_op, cmd, op);
236
HYPERVISOR_xen_version(
239
return _hypercall2(int, xen_version, cmd, arg);
243
HYPERVISOR_console_io(
244
int cmd, int count, char *str)
246
return _hypercall3(int, console_io, cmd, count, str);
250
HYPERVISOR_physdev_op(
253
return _hypercall1(int, physdev_op, physdev_op);
257
HYPERVISOR_grant_table_op(
258
unsigned int cmd, void *uop, unsigned int count)
260
return _hypercall3(int, grant_table_op, cmd, uop, count);
264
HYPERVISOR_update_va_mapping_otherdomain(
265
unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
267
return _hypercall4(int, update_va_mapping_otherdomain, va,
268
new_val.pte, flags, domid);
272
HYPERVISOR_vm_assist(
273
unsigned int cmd, unsigned int type)
275
return _hypercall2(int, vm_assist, cmd, type);
280
int cmd, int vcpuid, void *extra_args)
282
return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
286
HYPERVISOR_set_segment_base(
287
int reg, unsigned long value)
289
return _hypercall2(int, set_segment_base, reg, value);
296
return _hypercall3(int, sched_op, SCHEDOP_shutdown,
297
SHUTDOWN_suspend, srec);
305
return _hypercall2(int, nmi_op, op, arg);
312
return _hypercall1(int, sysctl, op);
319
return _hypercall1(int, domctl, op);
322
#endif /* __HYPERCALL_X86_64_H__ */
326
* c-file-style: "linux"
327
* indent-tabs-mode: t