ia64/xen-unstable

view tools/firmware/hvmloader/hypercall.h @ 19709:011948e1b5a7

hvmloader: Scan for gpxe-capable NICs until one is found.

Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 03 16:12:34 2009 +0100 (2009-06-03)
parents 5754173c3d81
children
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 <stdint.h>
35 #include <xen/xen.h>
36 #include "config.h"
38 #define __STR(...) #__VA_ARGS__
39 #define STR(...) __STR(__VA_ARGS__)
41 /*
42 * NB. Hypercall address needs to be relative to a linkage symbol for
43 * some version of ld to relocate the relative calls properly.
44 */
45 #define hypercall_pa "_start - " STR(HYPERCALL_PHYSICAL_ADDRESS)
47 #define _hypercall0(type, name) \
48 ({ \
49 long __res; \
50 asm volatile ( \
51 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
52 : "=a" (__res) \
53 : \
54 : "memory" ); \
55 (type)__res; \
56 })
58 #define _hypercall1(type, name, a1) \
59 ({ \
60 long __res, __ign1; \
61 asm volatile ( \
62 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
63 : "=a" (__res), "=b" (__ign1) \
64 : "1" ((long)(a1)) \
65 : "memory" ); \
66 (type)__res; \
67 })
69 #define _hypercall2(type, name, a1, a2) \
70 ({ \
71 long __res, __ign1, __ign2; \
72 asm volatile ( \
73 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
74 : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
75 : "1" ((long)(a1)), "2" ((long)(a2)) \
76 : "memory" ); \
77 (type)__res; \
78 })
80 #define _hypercall3(type, name, a1, a2, a3) \
81 ({ \
82 long __res, __ign1, __ign2, __ign3; \
83 asm volatile ( \
84 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
85 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
86 "=d" (__ign3) \
87 : "1" ((long)(a1)), "2" ((long)(a2)), \
88 "3" ((long)(a3)) \
89 : "memory" ); \
90 (type)__res; \
91 })
93 #define _hypercall4(type, name, a1, a2, a3, a4) \
94 ({ \
95 long __res, __ign1, __ign2, __ign3, __ign4; \
96 asm volatile ( \
97 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
98 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
99 "=d" (__ign3), "=S" (__ign4) \
100 : "1" ((long)(a1)), "2" ((long)(a2)), \
101 "3" ((long)(a3)), "4" ((long)(a4)) \
102 : "memory" ); \
103 (type)__res; \
104 })
106 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
107 ({ \
108 long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \
109 asm volatile ( \
110 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
111 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
112 "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
113 : "1" ((long)(a1)), "2" ((long)(a2)), \
114 "3" ((long)(a3)), "4" ((long)(a4)), \
115 "5" ((long)(a5)) \
116 : "memory" ); \
117 (type)__res; \
118 })
120 static inline int
121 hypercall_sched_op(
122 int cmd, void *arg)
123 {
124 return _hypercall2(int, sched_op, cmd, arg);
125 }
127 static inline int
128 hypercall_memory_op(
129 unsigned int cmd, void *arg)
130 {
131 return _hypercall2(int, memory_op, cmd, arg);
132 }
134 static inline int
135 hypercall_multicall(
136 void *call_list, int nr_calls)
137 {
138 return _hypercall2(int, multicall, call_list, nr_calls);
139 }
141 static inline int
142 hypercall_event_channel_op(
143 int cmd, void *arg)
144 {
145 return _hypercall2(int, event_channel_op, cmd, arg);
146 }
148 static inline int
149 hypercall_xen_version(
150 int cmd, void *arg)
151 {
152 return _hypercall2(int, xen_version, cmd, arg);
153 }
155 static inline int
156 hypercall_console_io(
157 int cmd, int count, char *str)
158 {
159 return _hypercall3(int, console_io, cmd, count, str);
160 }
162 static inline int
163 hypercall_vm_assist(
164 unsigned int cmd, unsigned int type)
165 {
166 return _hypercall2(int, vm_assist, cmd, type);
167 }
169 static inline int
170 hypercall_vcpu_op(
171 int cmd, int vcpuid, void *extra_args)
172 {
173 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
174 }
176 static inline int
177 hypercall_hvm_op(
178 int cmd, void *arg)
179 {
180 return _hypercall2(int, hvm_op, cmd, arg);
181 }
183 #endif /* __HVMLOADER_HYPERCALL_H__ */