ia64/xen-unstable

view tools/firmware/hvmloader/hypercall.h @ 12651:9164f836943d

[HVMLOADER] Fix CFLAGS.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Nov 29 11:38:17 2006 +0000 (2006-11-29)
parents 963a67ab8130
children 5754173c3d81
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Copyright (c) 2002-2006, K A Fraser
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation; or, when distributed
9 * separately from the Linux kernel or incorporated into other
10 * software packages, subject to the following license:
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy
13 * of this source file (the "Software"), to deal in the Software without
14 * restriction, including without limitation the rights to use, copy, modify,
15 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
16 * and to permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 * IN THE SOFTWARE.
29 */
31 #ifndef __HVMLOADER_HYPERCALL_H__
32 #define __HVMLOADER_HYPERCALL_H__
34 #include <xen/xen.h>
36 /*
37 * NB. Hypercall address needs to be relative to a linkage symbol for
38 * some version of ld to relocate the relative calls properly.
39 * Keep this in sync with HYPERCALL_PHYSICAL_ADDRESS in hvmloader.c!
40 */
41 #define hypercall_pa "_start - 0x80000"
43 #define __STR(x) #x
44 #define STR(x) __STR(x)
46 #define _hypercall0(type, name) \
47 ({ \
48 long __res; \
49 asm volatile ( \
50 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
51 : "=a" (__res) \
52 : \
53 : "memory" ); \
54 (type)__res; \
55 })
57 #define _hypercall1(type, name, a1) \
58 ({ \
59 long __res, __ign1; \
60 asm volatile ( \
61 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
62 : "=a" (__res), "=b" (__ign1) \
63 : "1" ((long)(a1)) \
64 : "memory" ); \
65 (type)__res; \
66 })
68 #define _hypercall2(type, name, a1, a2) \
69 ({ \
70 long __res, __ign1, __ign2; \
71 asm volatile ( \
72 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
73 : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
74 : "1" ((long)(a1)), "2" ((long)(a2)) \
75 : "memory" ); \
76 (type)__res; \
77 })
79 #define _hypercall3(type, name, a1, a2, a3) \
80 ({ \
81 long __res, __ign1, __ign2, __ign3; \
82 asm volatile ( \
83 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
84 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
85 "=d" (__ign3) \
86 : "1" ((long)(a1)), "2" ((long)(a2)), \
87 "3" ((long)(a3)) \
88 : "memory" ); \
89 (type)__res; \
90 })
92 #define _hypercall4(type, name, a1, a2, a3, a4) \
93 ({ \
94 long __res, __ign1, __ign2, __ign3, __ign4; \
95 asm volatile ( \
96 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
97 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
98 "=d" (__ign3), "=S" (__ign4) \
99 : "1" ((long)(a1)), "2" ((long)(a2)), \
100 "3" ((long)(a3)), "4" ((long)(a4)) \
101 : "memory" ); \
102 (type)__res; \
103 })
105 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
106 ({ \
107 long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \
108 asm volatile ( \
109 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
110 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
111 "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
112 : "1" ((long)(a1)), "2" ((long)(a2)), \
113 "3" ((long)(a3)), "4" ((long)(a4)), \
114 "5" ((long)(a5)) \
115 : "memory" ); \
116 (type)__res; \
117 })
119 static inline int
120 hypercall_sched_op(
121 int cmd, void *arg)
122 {
123 return _hypercall2(int, sched_op, cmd, arg);
124 }
126 static inline int
127 hypercall_memory_op(
128 unsigned int cmd, void *arg)
129 {
130 return _hypercall2(int, memory_op, cmd, arg);
131 }
133 static inline int
134 hypercall_multicall(
135 void *call_list, int nr_calls)
136 {
137 return _hypercall2(int, multicall, call_list, nr_calls);
138 }
140 static inline int
141 hypercall_event_channel_op(
142 int cmd, void *arg)
143 {
144 return _hypercall2(int, event_channel_op, cmd, arg);
145 }
147 static inline int
148 hypercall_xen_version(
149 int cmd, void *arg)
150 {
151 return _hypercall2(int, xen_version, cmd, arg);
152 }
154 static inline int
155 hypercall_console_io(
156 int cmd, int count, char *str)
157 {
158 return _hypercall3(int, console_io, cmd, count, str);
159 }
161 static inline int
162 hypercall_vm_assist(
163 unsigned int cmd, unsigned int type)
164 {
165 return _hypercall2(int, vm_assist, cmd, type);
166 }
168 static inline int
169 hypercall_vcpu_op(
170 int cmd, int vcpuid, void *extra_args)
171 {
172 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
173 }
175 static inline int
176 hypercall_hvm_op(
177 int cmd, void *arg)
178 {
179 return _hypercall2(int, hvm_op, cmd, arg);
180 }
182 #endif /* __HVMLOADER_HYPERCALL_H__ */