~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to extras/mini-os/include/x86/x86_64/hypercall-x86_64.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * hypercall-x86_64.h
 
3
 * 
 
4
 * Copied from XenLinux.
 
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
 */
 
33
 
 
34
#ifndef __HYPERCALL_X86_64_H__
 
35
#define __HYPERCALL_X86_64_H__
 
36
 
 
37
#include <xen/xen.h>
 
38
#include <xen/sched.h>
 
39
#include <mini-os/mm.h>
 
40
 
 
41
#define __STR(x) #x
 
42
#define STR(x) __STR(x)
 
43
 
 
44
extern char hypercall_page[PAGE_SIZE];
 
45
 
 
46
#define _hypercall0(type, name)                 \
 
47
({                                              \
 
48
        long __res;                             \
 
49
        asm volatile (                          \
 
50
                "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
 
51
                : "=a" (__res)                  \
 
52
                :                               \
 
53
                : "memory" );                   \
 
54
        (type)__res;                            \
 
55
})
 
56
 
 
57
#define _hypercall1(type, name, a1)                             \
 
58
({                                                              \
 
59
        long __res, __ign1;                                     \
 
60
        asm volatile (                                          \
 
61
                "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
 
62
                : "=a" (__res), "=D" (__ign1)                   \
 
63
                : "1" ((long)(a1))                              \
 
64
                : "memory" );                                   \
 
65
        (type)__res;                                            \
 
66
})
 
67
 
 
68
#define _hypercall2(type, name, a1, a2)                         \
 
69
({                                                              \
 
70
        long __res, __ign1, __ign2;                             \
 
71
        asm volatile (                                          \
 
72
                "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
 
73
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2)    \
 
74
                : "1" ((long)(a1)), "2" ((long)(a2))            \
 
75
                : "memory" );                                   \
 
76
        (type)__res;                                            \
 
77
})
 
78
 
 
79
#define _hypercall3(type, name, a1, a2, a3)                     \
 
80
({                                                              \
 
81
        long __res, __ign1, __ign2, __ign3;                     \
 
82
        asm volatile (                                          \
 
83
                "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
 
84
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
 
85
                "=d" (__ign3)                                   \
 
86
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
 
87
                "3" ((long)(a3))                                \
 
88
                : "memory" );                                   \
 
89
        (type)__res;                                            \
 
90
})
 
91
 
 
92
#define _hypercall4(type, name, a1, a2, a3, a4)                 \
 
93
({                                                              \
 
94
        long __res, __ign1, __ign2, __ign3;                     \
 
95
        asm volatile (                                          \
 
96
                "movq %7,%%r10; "                               \
 
97
                "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
 
98
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
 
99
                "=d" (__ign3)                                   \
 
100
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
 
101
                "3" ((long)(a3)), "g" ((long)(a4))              \
 
102
                : "memory", "r10" );                            \
 
103
        (type)__res;                                            \
 
104
})
 
105
 
 
106
#define _hypercall5(type, name, a1, a2, a3, a4, a5)             \
 
107
({                                                              \
 
108
        long __res, __ign1, __ign2, __ign3;                     \
 
109
        asm volatile (                                          \
 
110
                "movq %7,%%r10; movq %8,%%r8; "                 \
 
111
                "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
 
112
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
 
113
                "=d" (__ign3)                                   \
 
114
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
 
115
                "3" ((long)(a3)), "g" ((long)(a4)),             \
 
116
                "g" ((long)(a5))                                \
 
117
                : "memory", "r10", "r8" );                      \
 
118
        (type)__res;                                            \
 
119
})
 
120
 
 
121
static inline int
 
122
HYPERVISOR_set_trap_table(
 
123
        trap_info_t *table)
 
124
{
 
125
        return _hypercall1(int, set_trap_table, table);
 
126
}
 
127
 
 
128
static inline int
 
129
HYPERVISOR_mmu_update(
 
130
        mmu_update_t *req, int count, int *success_count, domid_t domid)
 
131
{
 
132
        return _hypercall4(int, mmu_update, req, count, success_count, domid);
 
133
}
 
134
 
 
135
static inline int
 
136
HYPERVISOR_mmuext_op(
 
137
        struct mmuext_op *op, int count, int *success_count, domid_t domid)
 
138
{
 
139
        return _hypercall4(int, mmuext_op, op, count, success_count, domid);
 
140
}
 
141
 
 
142
static inline int
 
143
HYPERVISOR_set_gdt(
 
144
        unsigned long *frame_list, int entries)
 
145
{
 
146
        return _hypercall2(int, set_gdt, frame_list, entries);
 
147
}
 
148
 
 
149
static inline int
 
150
HYPERVISOR_stack_switch(
 
151
        unsigned long ss, unsigned long esp)
 
152
{
 
153
        return _hypercall2(int, stack_switch, ss, esp);
 
154
}
 
155
 
 
156
static inline int
 
157
HYPERVISOR_set_callbacks(
 
158
        unsigned long event_address, unsigned long failsafe_address, 
 
159
        unsigned long syscall_address)
 
160
{
 
161
        return _hypercall3(int, set_callbacks,
 
162
                           event_address, failsafe_address, syscall_address);
 
163
}
 
164
 
 
165
static inline int
 
166
HYPERVISOR_fpu_taskswitch(
 
167
        int set)
 
168
{
 
169
        return _hypercall1(int, fpu_taskswitch, set);
 
170
}
 
171
 
 
172
static inline int
 
173
HYPERVISOR_sched_op(
 
174
        int cmd, void *arg)
 
175
{
 
176
        return _hypercall2(int, sched_op, cmd, arg);
 
177
}
 
178
 
 
179
static inline long
 
180
HYPERVISOR_set_timer_op(
 
181
        uint64_t timeout)
 
182
{
 
183
        return _hypercall1(long, set_timer_op, timeout);
 
184
}
 
185
 
 
186
static inline int
 
187
HYPERVISOR_set_debugreg(
 
188
        int reg, unsigned long value)
 
189
{
 
190
        return _hypercall2(int, set_debugreg, reg, value);
 
191
}
 
192
 
 
193
static inline unsigned long
 
194
HYPERVISOR_get_debugreg(
 
195
        int reg)
 
196
{
 
197
        return _hypercall1(unsigned long, get_debugreg, reg);
 
198
}
 
199
 
 
200
static inline int
 
201
HYPERVISOR_update_descriptor(
 
202
        unsigned long ma, unsigned long word)
 
203
{
 
204
        return _hypercall2(int, update_descriptor, ma, word);
 
205
}
 
206
 
 
207
static inline int
 
208
HYPERVISOR_memory_op(
 
209
        unsigned int cmd, void *arg)
 
210
{
 
211
        return _hypercall2(int, memory_op, cmd, arg);
 
212
}
 
213
 
 
214
static inline int
 
215
HYPERVISOR_multicall(
 
216
        void *call_list, int nr_calls)
 
217
{
 
218
        return _hypercall2(int, multicall, call_list, nr_calls);
 
219
}
 
220
 
 
221
static inline int
 
222
HYPERVISOR_update_va_mapping(
 
223
        unsigned long va, pte_t new_val, unsigned long flags)
 
224
{
 
225
        return _hypercall3(int, update_va_mapping, va, new_val.pte, flags);
 
226
}
 
227
 
 
228
static inline int
 
229
HYPERVISOR_event_channel_op(
 
230
       int cmd, void *op)
 
231
{
 
232
    return _hypercall2(int, event_channel_op, cmd, op);
 
233
}
 
234
 
 
235
static inline int
 
236
HYPERVISOR_xen_version(
 
237
        int cmd, void *arg)
 
238
{
 
239
        return _hypercall2(int, xen_version, cmd, arg);
 
240
}
 
241
 
 
242
static inline int
 
243
HYPERVISOR_console_io(
 
244
        int cmd, int count, char *str)
 
245
{
 
246
        return _hypercall3(int, console_io, cmd, count, str);
 
247
}
 
248
 
 
249
static inline int
 
250
HYPERVISOR_physdev_op(
 
251
        void *physdev_op)
 
252
{
 
253
        return _hypercall1(int, physdev_op, physdev_op);
 
254
}
 
255
 
 
256
static inline int
 
257
HYPERVISOR_grant_table_op(
 
258
        unsigned int cmd, void *uop, unsigned int count)
 
259
{
 
260
        return _hypercall3(int, grant_table_op, cmd, uop, count);
 
261
}
 
262
 
 
263
static inline int
 
264
HYPERVISOR_update_va_mapping_otherdomain(
 
265
        unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
 
266
{
 
267
        return _hypercall4(int, update_va_mapping_otherdomain, va,
 
268
                           new_val.pte, flags, domid);
 
269
}
 
270
 
 
271
static inline int
 
272
HYPERVISOR_vm_assist(
 
273
        unsigned int cmd, unsigned int type)
 
274
{
 
275
        return _hypercall2(int, vm_assist, cmd, type);
 
276
}
 
277
 
 
278
static inline int
 
279
HYPERVISOR_vcpu_op(
 
280
        int cmd, int vcpuid, void *extra_args)
 
281
{
 
282
        return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
 
283
}
 
284
 
 
285
static inline int
 
286
HYPERVISOR_set_segment_base(
 
287
        int reg, unsigned long value)
 
288
{
 
289
        return _hypercall2(int, set_segment_base, reg, value);
 
290
}
 
291
 
 
292
static inline int
 
293
HYPERVISOR_suspend(
 
294
        unsigned long srec)
 
295
{
 
296
        return _hypercall3(int, sched_op, SCHEDOP_shutdown,
 
297
                           SHUTDOWN_suspend, srec);
 
298
}
 
299
 
 
300
static inline int
 
301
HYPERVISOR_nmi_op(
 
302
        unsigned long op,
 
303
        unsigned long arg)
 
304
{
 
305
        return _hypercall2(int, nmi_op, op, arg);
 
306
}
 
307
 
 
308
static inline int
 
309
HYPERVISOR_sysctl(
 
310
        unsigned long op)
 
311
{
 
312
        return _hypercall1(int, sysctl, op);
 
313
}
 
314
 
 
315
static inline int
 
316
HYPERVISOR_domctl(
 
317
        unsigned long op)
 
318
{
 
319
        return _hypercall1(int, domctl, op);
 
320
}
 
321
 
 
322
#endif /* __HYPERCALL_X86_64_H__ */
 
323
 
 
324
/*
 
325
 * Local variables:
 
326
 *  c-file-style: "linux"
 
327
 *  indent-tabs-mode: t
 
328
 *  c-indent-level: 8
 
329
 *  c-basic-offset: 8
 
330
 *  tab-width: 8
 
331
 * End:
 
332
 */