ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-ia64/hypercall.h @ 9262:c445d4a0dd76

Define a new sched_op hypercall called sched_op_new, which differs from the
legacy hypercall in that it takes a pointer to a block of extra arguments
rather than an opaque unsigned long. The old hypercall still exists, for
backwards compatibility.

The new hypercall supports new sub-command SCHEDOP_poll, which can be used to
wait on a set of event-channel ports with an optional timeout. This is exported
in XenLinux as HYPERVISOR_poll, and used in the pcifront driver to wait on a
response from the pciback driver.

Can also be used for debuggers. :-)

Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: John Levon <john.levon@sun.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Mar 14 19:33:45 2006 +0100 (2006-03-14)
parents b5a6da522577
children 0ed4a312765b
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 *
8 * This file may be distributed separately from the Linux kernel, or
9 * incorporated into other software packages, subject to the following license:
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this source file (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use, copy, modify,
14 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 * IN THE SOFTWARE.
28 */
30 #ifndef __HYPERCALL_H__
31 #define __HYPERCALL_H__
33 #include <xen/interface/xen.h>
34 #include <xen/interface/sched.h>
35 #include <linux/errno.h>
37 /* FIXME: temp place to hold these page related macros */
38 #include <asm/page.h>
39 #define virt_to_machine(v) __pa(v)
40 #define machine_to_virt(m) __va(m)
41 #define virt_to_mfn(v) ((__pa(v)) >> PAGE_SHIFT)
42 #define mfn_to_virt(m) (__va((m) << PAGE_SHIFT))
44 /*
45 * Assembler stubs for hyper-calls.
46 */
48 #define _hypercall0(type, name) \
49 ({ \
50 long __res; \
51 __asm__ __volatile__ (";;\n" \
52 "mov r2=%1\n" \
53 "break 0x1000 ;;\n" \
54 "mov %0=r8 ;;\n" \
55 : "=r" (__res) \
56 : "i" (__HYPERVISOR_##name) \
57 : "r2","r8", \
58 "memory" ); \
59 (type)__res; \
60 })
62 #define _hypercall1(type, name, a1) \
63 ({ \
64 long __res; \
65 __asm__ __volatile__ (";;\n" \
66 "mov r14=%2\n" \
67 "mov r2=%1\n" \
68 "break 0x1000 ;;\n" \
69 "mov %0=r8 ;;\n" \
70 : "=r" (__res) \
71 : "i" (__HYPERVISOR_##name), \
72 "r" ((unsigned long)(a1)) \
73 : "r14","r2","r8", \
74 "memory" ); \
75 (type)__res; \
76 })
78 #define _hypercall2(type, name, a1, a2) \
79 ({ \
80 long __res; \
81 __asm__ __volatile__ (";;\n" \
82 "mov r14=%2\n" \
83 "mov r15=%3\n" \
84 "mov r2=%1\n" \
85 "break 0x1000 ;;\n" \
86 "mov %0=r8 ;;\n" \
87 : "=r" (__res) \
88 : "i" (__HYPERVISOR_##name), \
89 "r" ((unsigned long)(a1)), \
90 "r" ((unsigned long)(a2)) \
91 : "r14","r15","r2","r8", \
92 "memory" ); \
93 (type)__res; \
94 })
96 #define _hypercall3(type, name, a1, a2, a3) \
97 ({ \
98 long __res; \
99 __asm__ __volatile__ (";;\n" \
100 "mov r14=%2\n" \
101 "mov r15=%3\n" \
102 "mov r16=%4\n" \
103 "mov r2=%1\n" \
104 "break 0x1000 ;;\n" \
105 "mov %0=r8 ;;\n" \
106 : "=r" (__res) \
107 : "i" (__HYPERVISOR_##name), \
108 "r" ((unsigned long)(a1)), \
109 "r" ((unsigned long)(a2)), \
110 "r" ((unsigned long)(a3)) \
111 : "r14","r15","r16","r2","r8", \
112 "memory" ); \
113 (type)__res; \
114 })
116 #define _hypercall4(type, name, a1, a2, a3, a4) \
117 ({ \
118 long __res; \
119 __asm__ __volatile__ (";;\n" \
120 "mov r14=%2\n" \
121 "mov r15=%3\n" \
122 "mov r16=%4\n" \
123 "mov r17=%5\n" \
124 "mov r2=%1\n" \
125 "break 0x1000 ;;\n" \
126 "mov %0=r8 ;;\n" \
127 : "=r" (__res) \
128 : "i" (__HYPERVISOR_##name), \
129 "r" ((unsigned long)(a1)), \
130 "r" ((unsigned long)(a2)), \
131 "r" ((unsigned long)(a3)), \
132 "r" ((unsigned long)(a4)) \
133 : "r14","r15","r16","r2","r8", \
134 "r17","memory" ); \
135 (type)__res; \
136 })
138 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
139 ({ \
140 long __res; \
141 __asm__ __volatile__ (";;\n" \
142 "mov r14=%2\n" \
143 "mov r15=%3\n" \
144 "mov r16=%4\n" \
145 "mov r17=%5\n" \
146 "mov r18=%6\n" \
147 "mov r2=%1\n" \
148 "break 0x1000 ;;\n" \
149 "mov %0=r8 ;;\n" \
150 : "=r" (__res) \
151 : "i" (__HYPERVISOR_##name), \
152 "r" ((unsigned long)(a1)), \
153 "r" ((unsigned long)(a2)), \
154 "r" ((unsigned long)(a3)), \
155 "r" ((unsigned long)(a4)), \
156 "r" ((unsigned long)(a5)) \
157 : "r14","r15","r16","r2","r8", \
158 "r17","r18","memory" ); \
159 (type)__res; \
160 })
162 static inline int
163 HYPERVISOR_sched_op(
164 int cmd, unsigned long arg)
165 {
166 return _hypercall2(int, sched_op, cmd, arg);
167 }
169 static inline int
170 HYPERVISOR_sched_op_new(
171 int cmd, void *arg)
172 {
173 return _hypercall2(int, sched_op_new, cmd, arg);
174 }
176 static inline int
177 HYPERVISOR_poll(
178 evtchn_port_t *ports, unsigned int nr_ports, unsigned long timeout)
179 {
180 struct sched_poll sched_poll = {
181 .ports = ports,
182 .nr_ports = nr_ports,
183 .timeout = jiffies_to_st(timeout)
184 };
186 int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
188 if (rc == -ENOSYS)
189 rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
191 return rc;
192 }
194 static inline long
195 HYPERVISOR_set_timer_op(
196 u64 timeout)
197 {
198 unsigned long timeout_hi = (unsigned long)(timeout>>32);
199 unsigned long timeout_lo = (unsigned long)timeout;
200 return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
201 }
203 static inline int
204 HYPERVISOR_dom0_op(
205 dom0_op_t *dom0_op)
206 {
207 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
208 return _hypercall1(int, dom0_op, dom0_op);
209 }
211 static inline int
212 HYPERVISOR_multicall(
213 void *call_list, int nr_calls)
214 {
215 return _hypercall2(int, multicall, call_list, nr_calls);
216 }
218 static inline int
219 HYPERVISOR_memory_op(
220 unsigned int cmd, void *arg)
221 {
222 return _hypercall2(int, memory_op, cmd, arg);
223 }
225 static inline int
226 HYPERVISOR_event_channel_op(
227 void *op)
228 {
229 return _hypercall1(int, event_channel_op, op);
230 }
232 static inline int
233 HYPERVISOR_xen_version(
234 int cmd, void *arg)
235 {
236 return _hypercall2(int, xen_version, cmd, arg);
237 }
239 static inline int
240 HYPERVISOR_console_io(
241 int cmd, int count, char *str)
242 {
243 return _hypercall3(int, console_io, cmd, count, str);
244 }
246 static inline int
247 HYPERVISOR_physdev_op(
248 void *physdev_op)
249 {
250 return _hypercall1(int, physdev_op, physdev_op);
251 }
253 static inline int
254 HYPERVISOR_grant_table_op(
255 unsigned int cmd, void *uop, unsigned int count)
256 {
257 return _hypercall3(int, grant_table_op, cmd, uop, count);
258 }
260 static inline int
261 HYPERVISOR_vcpu_op(
262 int cmd, int vcpuid, void *extra_args)
263 {
264 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
265 }
267 static inline int
268 HYPERVISOR_suspend(
269 unsigned long srec)
270 {
271 return _hypercall3(int, sched_op, SCHEDOP_shutdown,
272 SHUTDOWN_suspend, srec);
273 }
275 extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
276 static inline void exit_idle(void) {}
277 #define do_IRQ(irq, regs) __do_IRQ((irq), (regs))
279 #endif /* __HYPERCALL_H__ */