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