debuggers.hg

view extras/mini-os/include/ia64/hypercall-ia64.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 5c0bf00e371d
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Mini-OS-specific hypervisor handling for ia64.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 * Changes: Dietmar Hahn <dietmar.hahn@fujiti-siemens.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation; or, when distributed
12 * separately from the Linux kernel or incorporated into other
13 * software packages, subject to the following license:
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a copy
16 * of this source file (the "Software"), to deal in the Software without
17 * restriction, including without limitation the rights to use, copy, modify,
18 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
19 * and to permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
21 *
22 * The above copyright notice and this permission notice shall be included in
23 * all copies or substantial portions of the Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 * IN THE SOFTWARE.
32 */
34 #ifndef __HYPERCALL_H__
35 #define __HYPERCALL_H__
37 #include "lib.h" /* memcpy() */
38 #include "errno.h" /* ENOSYS() */
39 #include <xen/event_channel.h>
40 #include <xen/sched.h>
41 #include <xen/version.h>
43 #ifndef _HYPERVISOR_H_
44 # error "please don't include this file directly"
45 #endif
47 // See linux/compiler.h
48 #define likely(x) __builtin_expect(!!(x), 1)
49 #define unlikely(x) __builtin_expect(!!(x), 0)
51 extern unsigned long __hypercall(unsigned long a1, unsigned long a2,
52 unsigned long a3, unsigned long a4,
53 unsigned long a5, unsigned long cmd);
54 /*
55 * Assembler stubs for hyper-calls.
56 */
58 #define _hypercall0(type, name) \
59 ({ \
60 long __res; \
61 __res = __hypercall(0, 0, 0, 0, 0, \
62 __HYPERVISOR_##name); \
63 (type)__res; \
64 })
66 #define _hypercall1(type, name, a1) \
67 ({ \
68 long __res; \
69 __res = __hypercall((unsigned long)a1, \
70 0, 0, 0, 0, __HYPERVISOR_##name); \
71 (type)__res; \
72 })
74 #define _hypercall2(type, name, a1, a2) \
75 ({ \
76 long __res; \
77 __res = __hypercall((unsigned long)a1, \
78 (unsigned long)a2, \
79 0, 0, 0, __HYPERVISOR_##name); \
80 (type)__res; \
81 })
83 #define _hypercall3(type, name, a1, a2, a3) \
84 ({ \
85 long __res; \
86 __res = __hypercall((unsigned long)a1, \
87 (unsigned long)a2, \
88 (unsigned long)a3, \
89 0, 0, __HYPERVISOR_##name); \
90 (type)__res; \
91 })
93 #define _hypercall4(type, name, a1, a2, a3, a4) \
94 ({ \
95 long __res; \
96 __res = __hypercall((unsigned long)a1, \
97 (unsigned long)a2, \
98 (unsigned long)a3, \
99 (unsigned long)a4, \
100 0, __HYPERVISOR_##name); \
101 (type)__res; \
102 })
104 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
105 ({ \
106 long __res; \
107 __res = __hypercall((unsigned long)a1, \
108 (unsigned long)a2, \
109 (unsigned long)a3, \
110 (unsigned long)a4, \
111 (unsigned long)a5, \
112 __HYPERVISOR_##name); \
113 (type)__res; \
114 })
117 extern unsigned long xencomm_vaddr_to_paddr(unsigned long vaddr);
118 struct xencomm_handle;
120 /* Inline version. To be used only on linear space (kernel space). */
121 static inline struct xencomm_handle *
122 xencomm_create_inline(void *buffer)
123 {
124 unsigned long paddr;
126 paddr = xencomm_vaddr_to_paddr((unsigned long)buffer);
127 return (struct xencomm_handle *)(paddr | XENCOMM_INLINE_FLAG);
128 }
130 static inline int
131 xencomm_arch_event_channel_op(int cmd, void *arg)
132 {
133 int rc;
134 struct xencomm_handle *newArg;
136 newArg = xencomm_create_inline(arg);
137 rc = _hypercall2(int, event_channel_op, cmd, newArg);
138 if (unlikely(rc == -ENOSYS)) {
139 struct evtchn_op op;
141 op.cmd = SWAP(cmd);
142 memcpy(&op.u, arg, sizeof(op.u));
143 rc = _hypercall1(int, event_channel_op_compat, &op);
144 }
145 return rc;
146 }
147 #define HYPERVISOR_event_channel_op xencomm_arch_event_channel_op
149 static inline int
150 xencomm_arch_xen_version(int cmd, struct xencomm_handle *arg)
151 {
152 return _hypercall2(int, xen_version, cmd, arg);
153 }
155 static inline int
156 xencomm_arch_xen_feature(int cmd, struct xencomm_handle *arg)
157 {
158 struct xencomm_handle *newArg;
160 newArg = xencomm_create_inline(arg);
161 return _hypercall2(int, xen_version, cmd, newArg);
162 }
164 static inline int
165 HYPERVISOR_xen_version(int cmd, void *arg)
166 {
167 switch(cmd) {
168 case XENVER_version:
169 return xencomm_arch_xen_version(cmd, 0);
170 case XENVER_get_features:
171 return xencomm_arch_xen_feature(cmd, arg);
172 default:
173 return -1;
174 }
175 }
177 static inline int
178 xencomm_arch_console_io(int cmd, int count, char *str)
179 {
180 struct xencomm_handle *newStr;
182 newStr = xencomm_create_inline(str);
183 return _hypercall3(int, console_io, cmd, count, newStr);
184 }
187 #define HYPERVISOR_console_io xencomm_arch_console_io
189 static inline int
190 HYPERVISOR_sched_op_compat(int cmd, unsigned long arg)
191 {
192 return _hypercall2(int, sched_op_compat, cmd, arg);
193 }
195 static inline int
196 xencomm_arch_sched_op(int cmd, void *arg)
197 {
198 struct xencomm_handle *newArg;
200 newArg = xencomm_create_inline(arg);
201 return _hypercall2(int, sched_op, cmd, newArg);
202 }
204 #define HYPERVISOR_sched_op xencomm_arch_sched_op
206 static inline int
207 xencomm_arch_callback_op(int cmd, void *arg)
208 {
209 struct xencomm_handle *newArg;
211 newArg = xencomm_create_inline(arg);
212 return _hypercall2(int, callback_op, cmd, newArg);
213 }
214 #define HYPERVISOR_callback_op xencomm_arch_callback_op
216 static inline int
217 xencomm_arch_hypercall_grant_table_op(unsigned int cmd,
218 struct xencomm_handle *uop,
219 unsigned int count)
220 {
221 return _hypercall3(int, grant_table_op, cmd, uop, count);
222 }
224 int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
226 static inline int
227 HYPERVISOR_opt_feature(void *arg)
228 {
229 struct xencomm_handle *new_arg;
231 new_arg = xencomm_create_inline(arg);
233 return _hypercall1(int, opt_feature, new_arg);
234 }
236 #endif /* __HYPERCALL_H__ */