Xen Test Framework
hypercall-x86_64.h
Go to the documentation of this file.
1#ifndef XTF_X86_64_HYPERCALL_H
2#define XTF_X86_64_HYPERCALL_H
3
4/*
5 * Hypercall primatives for 64bit
6 *
7 * Inputs: %rdi, %rsi, %rdx, %r10, %r8, %r9 (arguments 1-6)
8 */
9
10#define _hypercall64_0(type, hcall) \
11 ({ \
12 long res; \
13 asm volatile ( \
14 "call hypercall_page + %c[offset]" \
15 : "=a" (res) \
16 : [offset] "i" (hcall * 32) \
17 : "memory" ); \
18 (type)res; \
19 })
20
21#define _hypercall64_1(type, hcall, a1) \
22 ({ \
23 long res, _a1 = (long)(a1); \
24 asm volatile ( \
25 "call hypercall_page + %c[offset]" \
26 : "=a" (res), "+D" (_a1) \
27 : [offset] "i" (hcall * 32) \
28 : "memory" ); \
29 (type)res; \
30 })
31
32#define _hypercall64_2(type, hcall, a1, a2) \
33 ({ \
34 long res, _a1 = (long)(a1), _a2 = (long)(a2); \
35 asm volatile ( \
36 "call hypercall_page + %c[offset]" \
37 : "=a" (res), "+D" (_a1), "+S" (_a2) \
38 : [offset] "i" (hcall * 32) \
39 : "memory" ); \
40 (type)res; \
41 })
42
43#define _hypercall64_3(type, hcall, a1, a2, a3) \
44 ({ \
45 long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3); \
46 asm volatile ( \
47 "call hypercall_page + %c[offset]" \
48 : "=a" (res), "+D" (_a1), "+S" (_a2), "+d" (_a3) \
49 : [offset] "i" (hcall * 32) \
50 : "memory" ); \
51 (type)res; \
52 })
53
54#define _hypercall64_4(type, hcall, a1, a2, a3, a4) \
55 ({ \
56 long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3); \
57 register long _a4 asm ("r10") = (long)(a4); \
58 asm volatile ( \
59 "call hypercall_page + %c[offset]" \
60 : "=a" (res), "+D" (_a1), "+S" (_a2), "+d" (_a3), \
61 "+r" (_a4) \
62 : [offset] "i" (hcall * 32) \
63 : "memory" ); \
64 (type)res; \
65 })
66
67#define _hypercall64_5(type, hcall, a1, a2, a3, a4, a5) \
68 ({ \
69 long res, _a1 = (long)(a1), _a2 = (long)(a2), _a3 = (long)(a3); \
70 register long _a4 asm ("r10") = (long)(a4); \
71 register long _a5 asm ("r8") = (long)(a5); \
72 asm volatile ( \
73 "call hypercall_page + %c[offset]" \
74 : "=a" (res), "+D" (_a1), "+S" (_a2), "+d" (_a3), \
75 "+r" (_a4), "+r" (_a5) \
76 : [offset] "i" (hcall * 32) \
77 : "memory" ); \
78 (type)res; \
79 })
80
81#endif /* XTF_X86_64_HYPERCALL_H */
82
83/*
84 * Local variables:
85 * mode: C
86 * c-file-style: "BSD"
87 * c-basic-offset: 4
88 * tab-width: 4
89 * indent-tabs-mode: nil
90 * End:
91 */