debuggers.hg

view tools/firmware/hvmloader/hypercall.h @ 10986:49dcd838b7df

[HVMLOADER] HVM loader initialises hypercall shim and uses
it to interrogate Xen version information. Also add support
for HVM hypercall execution on 64-bit host.

Signed-off-by: Steven Smith <ssmith@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Aug 04 20:30:12 2006 +0100 (2006-08-04)
parents
children 963a67ab8130
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 /*
35 * NB. Hypercall address needs to be relative to a linkage symbol for
36 * some version of ld to relocate the relative calls properly.
37 * Keep this in sync with HYPERCALL_PHYSICAL_ADDRESS in hvmloader.c!
38 */
39 #define hypercall_pa "_start - 0x80000"
41 #define __STR(x) #x
42 #define STR(x) __STR(x)
44 #define _hypercall0(type, name) \
45 ({ \
46 long __res; \
47 asm volatile ( \
48 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
49 : "=a" (__res) \
50 : \
51 : "memory" ); \
52 (type)__res; \
53 })
55 #define _hypercall1(type, name, a1) \
56 ({ \
57 long __res, __ign1; \
58 asm volatile ( \
59 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
60 : "=a" (__res), "=b" (__ign1) \
61 : "1" ((long)(a1)) \
62 : "memory" ); \
63 (type)__res; \
64 })
66 #define _hypercall2(type, name, a1, a2) \
67 ({ \
68 long __res, __ign1, __ign2; \
69 asm volatile ( \
70 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
71 : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
72 : "1" ((long)(a1)), "2" ((long)(a2)) \
73 : "memory" ); \
74 (type)__res; \
75 })
77 #define _hypercall3(type, name, a1, a2, a3) \
78 ({ \
79 long __res, __ign1, __ign2, __ign3; \
80 asm volatile ( \
81 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
82 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
83 "=d" (__ign3) \
84 : "1" ((long)(a1)), "2" ((long)(a2)), \
85 "3" ((long)(a3)) \
86 : "memory" ); \
87 (type)__res; \
88 })
90 #define _hypercall4(type, name, a1, a2, a3, a4) \
91 ({ \
92 long __res, __ign1, __ign2, __ign3, __ign4; \
93 asm volatile ( \
94 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
95 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
96 "=d" (__ign3), "=S" (__ign4) \
97 : "1" ((long)(a1)), "2" ((long)(a2)), \
98 "3" ((long)(a3)), "4" ((long)(a4)) \
99 : "memory" ); \
100 (type)__res; \
101 })
103 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
104 ({ \
105 long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \
106 asm volatile ( \
107 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
108 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
109 "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
110 : "1" ((long)(a1)), "2" ((long)(a2)), \
111 "3" ((long)(a3)), "4" ((long)(a4)), \
112 "5" ((long)(a5)) \
113 : "memory" ); \
114 (type)__res; \
115 })
117 static inline int
118 hypercall_sched_op(
119 int cmd, void *arg)
120 {
121 return _hypercall2(int, sched_op, cmd, arg);
122 }
124 static inline int
125 hypercall_memory_op(
126 unsigned int cmd, void *arg)
127 {
128 return _hypercall2(int, memory_op, cmd, arg);
129 }
131 static inline int
132 hypercall_multicall(
133 void *call_list, int nr_calls)
134 {
135 return _hypercall2(int, multicall, call_list, nr_calls);
136 }
138 static inline int
139 hypercall_event_channel_op(
140 int cmd, void *arg)
141 {
142 return _hypercall2(int, event_channel_op, cmd, arg);
143 }
145 static inline int
146 hypercall_xen_version(
147 int cmd, void *arg)
148 {
149 return _hypercall2(int, xen_version, cmd, arg);
150 }
152 static inline int
153 hypercall_console_io(
154 int cmd, int count, char *str)
155 {
156 return _hypercall3(int, console_io, cmd, count, str);
157 }
159 static inline int
160 hypercall_vm_assist(
161 unsigned int cmd, unsigned int type)
162 {
163 return _hypercall2(int, vm_assist, cmd, type);
164 }
166 static inline int
167 hypercall_vcpu_op(
168 int cmd, int vcpuid, void *extra_args)
169 {
170 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
171 }
173 static inline int
174 hypercall_hvm_op(
175 int cmd, void *arg)
176 {
177 return _hypercall2(int, hvm_op, cmd, arg);
178 }
180 #endif /* __HVMLOADER_HYPERCALL_H__ */