[efi] Do not raise TPL within EFI_DRIVER_BINDING_PROTOCOL.Supported()
[ipxe.git] / src / arch / arm / include / bits / xen.h
1 #ifndef _BITS_XEN_H
2 #define _BITS_XEN_H
3
4 /** @file
5 *
6 * Xen interface
7 *
8 */
9
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12 /* Hypercall registers */
13 #ifdef __aarch64__
14 #define XEN_HC "x16"
15 #define XEN_REG1 "x0"
16 #define XEN_REG2 "x1"
17 #define XEN_REG3 "x2"
18 #define XEN_REG4 "x3"
19 #define XEN_REG5 "x4"
20 #else
21 #define XEN_HC "r12"
22 #define XEN_REG1 "r0"
23 #define XEN_REG2 "r1"
24 #define XEN_REG3 "r2"
25 #define XEN_REG4 "r3"
26 #define XEN_REG5 "r4"
27 #endif
28
29 /**
30 * Issue hypercall with one argument
31 *
32 * @v xen Xen hypervisor
33 * @v hypercall Hypercall number
34 * @v arg1 First argument
35 * @ret retval Return value
36 */
37 static inline __attribute__ (( always_inline )) unsigned long
38 xen_hypercall_1 ( struct xen_hypervisor *xen __unused, unsigned int hypercall,
39 unsigned long arg1 ) {
40 register unsigned long hc asm ( XEN_HC ) = hypercall;
41 register unsigned long reg1 asm ( XEN_REG1 ) = arg1;
42
43 __asm__ __volatile__ ( "hvc %1"
44 : "+r" ( reg1 )
45 : "i" ( XEN_HYPERCALL_TAG ), "r" ( hc )
46 : "memory", "cc" );
47 return reg1;
48 }
49
50 /**
51 * Issue hypercall with two arguments
52 *
53 * @v xen Xen hypervisor
54 * @v hypercall Hypercall number
55 * @v arg1 First argument
56 * @v arg2 Second argument
57 * @ret retval Return value
58 */
59 static inline __attribute__ (( always_inline )) unsigned long
60 xen_hypercall_2 ( struct xen_hypervisor *xen __unused, unsigned int hypercall,
61 unsigned long arg1, unsigned long arg2 ) {
62 register unsigned long hc asm ( XEN_HC ) = hypercall;
63 register unsigned long reg1 asm ( XEN_REG1 ) = arg1;
64 register unsigned long reg2 asm ( XEN_REG2 ) = arg2;
65
66 __asm__ __volatile__ ( "hvc %2"
67 : "+r" ( reg1 ), "+r" ( reg2 )
68 : "i" ( XEN_HYPERCALL_TAG ), "r" ( hc )
69 : "memory", "cc" );
70 return reg1;
71 }
72
73 /**
74 * Issue hypercall with three arguments
75 *
76 * @v xen Xen hypervisor
77 * @v hypercall Hypercall number
78 * @v arg1 First argument
79 * @v arg2 Second argument
80 * @v arg3 Third argument
81 * @ret retval Return value
82 */
83 static inline __attribute__ (( always_inline )) unsigned long
84 xen_hypercall_3 ( struct xen_hypervisor *xen __unused, unsigned int hypercall,
85 unsigned long arg1, unsigned long arg2, unsigned long arg3 ) {
86 register unsigned long hc asm ( XEN_HC ) = hypercall;
87 register unsigned long reg1 asm ( XEN_REG1 ) = arg1;
88 register unsigned long reg2 asm ( XEN_REG2 ) = arg2;
89 register unsigned long reg3 asm ( XEN_REG3 ) = arg3;
90
91 __asm__ __volatile__ ( "hvc %3"
92 : "+r" ( reg1 ), "+r" ( reg2 ), "+r" ( reg3 )
93 : "i" ( XEN_HYPERCALL_TAG ), "r" ( hc )
94 : "memory", "cc" );
95 return reg1;
96 }
97
98 /**
99 * Issue hypercall with four arguments
100 *
101 * @v xen Xen hypervisor
102 * @v hypercall Hypercall number
103 * @v arg1 First argument
104 * @v arg2 Second argument
105 * @v arg3 Third argument
106 * @v arg4 Fourth argument
107 * @ret retval Return value
108 */
109 static inline __attribute__ (( always_inline )) unsigned long
110 xen_hypercall_4 ( struct xen_hypervisor *xen __unused, unsigned int hypercall,
111 unsigned long arg1, unsigned long arg2, unsigned long arg3,
112 unsigned long arg4 ) {
113 register unsigned long hc asm ( XEN_HC ) = hypercall;
114 register unsigned long reg1 asm ( XEN_REG1 ) = arg1;
115 register unsigned long reg2 asm ( XEN_REG2 ) = arg2;
116 register unsigned long reg3 asm ( XEN_REG3 ) = arg3;
117 register unsigned long reg4 asm ( XEN_REG4 ) = arg4;
118
119 __asm__ __volatile__ ( "hvc %4"
120 : "+r" ( reg1 ), "+r" ( reg2 ), "+r" ( reg3 ),
121 "+r" ( reg4 )
122 : "i" ( XEN_HYPERCALL_TAG ), "r" ( hc )
123 : "memory", "cc" );
124 return reg1;
125 }
126
127 /**
128 * Issue hypercall with five arguments
129 *
130 * @v xen Xen hypervisor
131 * @v hypercall Hypercall number
132 * @v arg1 First argument
133 * @v arg2 Second argument
134 * @v arg3 Third argument
135 * @v arg4 Fourth argument
136 * @v arg5 Fifth argument
137 * @ret retval Return value
138 */
139 static inline __attribute__ (( always_inline )) unsigned long
140 xen_hypercall_5 ( struct xen_hypervisor *xen __unused, unsigned int hypercall,
141 unsigned long arg1, unsigned long arg2, unsigned long arg3,
142 unsigned long arg4, unsigned long arg5 ) {
143 register unsigned long hc asm ( XEN_HC ) = hypercall;
144 register unsigned long reg1 asm ( XEN_REG1 ) = arg1;
145 register unsigned long reg2 asm ( XEN_REG2 ) = arg2;
146 register unsigned long reg3 asm ( XEN_REG3 ) = arg3;
147 register unsigned long reg4 asm ( XEN_REG4 ) = arg4;
148 register unsigned long reg5 asm ( XEN_REG5 ) = arg5;
149
150 __asm__ __volatile__ ( "hvc %5"
151 : "+r" ( reg1 ), "+r" ( reg2 ), "+r" ( reg3 ),
152 "+r" ( reg4 ), "+r" ( reg5 )
153 : "i" ( XEN_HYPERCALL_TAG ), "r" ( hc )
154 : "memory", "cc" );
155 return reg1;
156 }
157
158 #endif /* _BITS_XEN_H */