blob: 0ed1e9f23e5ae61e47e58b296b772facf2214c95 [file] [log] [blame]
Ian Campbell74c78782011-06-01 11:00:29 +01001#ifndef __XEN_H
2#define __XEN_H
3
4#include "util.h"
5
6extern u32 xen_cpuid_base;
7
8void xen_probe(void);
9void xen_setup(void);
10void xen_init_hypercalls(void);
11void xen_copy_biostables(void);
12
13static inline int usingXen(void) {
14 if (!CONFIG_XEN)
15 return 0;
16 return (xen_cpuid_base != 0);
17}
18
19unsigned long xen_hypercall_page;
20
21#define _hypercall0(type, name) \
22({ \
23 unsigned long __hentry = xen_hypercall_page+__HYPERVISOR_##name*32; \
24 long __res; \
25 asm volatile ( \
26 "call *%%eax" \
27 : "=a" (__res) \
28 : "0" (__hentry) \
29 : "memory" ); \
30 (type)__res; \
31})
32
33#define _hypercall1(type, name, a1) \
34({ \
35 unsigned long __hentry = xen_hypercall_page+__HYPERVISOR_##name*32; \
36 long __res, __ign1; \
37 asm volatile ( \
38 "call *%%eax" \
39 : "=a" (__res), "=b" (__ign1) \
40 : "0" (__hentry), "1" ((long)(a1)) \
41 : "memory" ); \
42 (type)__res; \
43})
44
45#define _hypercall2(type, name, a1, a2) \
46({ \
47 unsigned long __hentry = xen_hypercall_page+__HYPERVISOR_##name*32; \
48 long __res, __ign1, __ign2; \
49 asm volatile ( \
50 "call *%%eax" \
51 : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
52 : "0" (__hentry), "1" ((long)(a1)), "2" ((long)(a2)) \
53 : "memory" ); \
54 (type)__res; \
55})
56
57#define _hypercall3(type, name, a1, a2, a3) \
58({ \
59 unsigned long __hentry = xen_hypercall_page+__HYPERVISOR_##name*32; \
60 long __res, __ign1, __ign2, __ign3; \
61 asm volatile ( \
62 "call *%%eax" \
63 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
64 "=d" (__ign3) \
65 : "0" (__hentry), "1" ((long)(a1)), "2" ((long)(a2)), \
66 "3" ((long)(a3)) \
67 : "memory" ); \
68 (type)__res; \
69})
70
71#define _hypercall4(type, name, a1, a2, a3, a4) \
72({ \
73 unsigned long __hentry = xen_hypercall_page+__HYPERVISOR_##name*32; \
74 long __res, __ign1, __ign2, __ign3, __ign4; \
75 asm volatile ( \
76 "call *%%eax" \
77 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
78 "=d" (__ign3), "=S" (__ign4) \
79 : "0" (__hentry), "1" ((long)(a1)), "2" ((long)(a2)), \
80 "3" ((long)(a3)), "4" ((long)(a4)) \
81 : "memory" ); \
82 (type)__res; \
83})
84
85#define _hypercall5(type, name, a1, a2, a3, a4, a5) \
86({ \
87 unsigned long __hentry = xen_hypercall_page+__HYPERVISOR_##name*32; \
88 long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \
89 asm volatile ( \
90 "call *%%eax" \
91 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
92 "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
93 : "0" (__hentry), "1" ((long)(a1)), "2" ((long)(a2)), \
94 "3" ((long)(a3)), "4" ((long)(a4)), \
95 "5" ((long)(a5)) \
96 : "memory" ); \
97 (type)__res; \
98})
99
100/******************************************************************************
101 *
102 * The following interface definitions are taken from Xen and have the
103 * following license:
104 *
105 * Permission is hereby granted, free of charge, to any person obtaining a copy
106 * of this software and associated documentation files (the "Software"), to
107 * deal in the Software without restriction, including without limitation the
108 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
109 * sell copies of the Software, and to permit persons to whom the Software is
110 * furnished to do so, subject to the following conditions:
111 *
112 * The above copyright notice and this permission notice shall be included in
113 * all copies or substantial portions of the Software.
114 *
115 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
116 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
117 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
118 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
119 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
120 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
121 * DEALINGS IN THE SOFTWARE.
122 */
123
124/* xen.h */
125
126#define __HYPERVISOR_xen_version 17
127
128/* version.h */
129
130/* arg == xen_extraversion_t. */
131#define XENVER_extraversion 1
132typedef char xen_extraversion_t[16];
133#define XEN_EXTRAVERSION_LEN (sizeof(xen_extraversion_t))
134
135#endif