ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-ia64/hypercall.h @ 9762:a3cc276f2e87

[IA64] dma paravirtualization

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@localhost
date Tue Apr 25 16:53:27 2006 -0600 (2006-04-25)
parents d63c6ba11c65
children 42a8e3101c6c
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation; or, when distributed
11 * separately from the Linux kernel or incorporated into other
12 * software packages, subject to the following license:
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this source file (the "Software"), to deal in the Software without
16 * restriction, including without limitation the rights to use, copy, modify,
17 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18 * and to permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 */
33 #ifndef __HYPERCALL_H__
34 #define __HYPERCALL_H__
36 #ifndef __HYPERVISOR_H__
37 # error "please don't include this file directly"
38 #endif
40 /*
41 * Assembler stubs for hyper-calls.
42 */
44 #define _hypercall0(type, name) \
45 ({ \
46 long __res; \
47 __asm__ __volatile__ (";;\n" \
48 "mov r2=%1\n" \
49 "break 0x1000 ;;\n" \
50 "mov %0=r8 ;;\n" \
51 : "=r" (__res) \
52 : "i" (__HYPERVISOR_##name) \
53 : "r2","r8", \
54 "memory" ); \
55 (type)__res; \
56 })
58 #define _hypercall1(type, name, a1) \
59 ({ \
60 long __res; \
61 __asm__ __volatile__ (";;\n" \
62 "mov r14=%2\n" \
63 "mov r2=%1\n" \
64 "break 0x1000 ;;\n" \
65 "mov %0=r8 ;;\n" \
66 : "=r" (__res) \
67 : "i" (__HYPERVISOR_##name), \
68 "r" ((unsigned long)(a1)) \
69 : "r14","r2","r8", \
70 "memory" ); \
71 (type)__res; \
72 })
74 #define _hypercall2(type, name, a1, a2) \
75 ({ \
76 long __res; \
77 __asm__ __volatile__ (";;\n" \
78 "mov r14=%2\n" \
79 "mov r15=%3\n" \
80 "mov r2=%1\n" \
81 "break 0x1000 ;;\n" \
82 "mov %0=r8 ;;\n" \
83 : "=r" (__res) \
84 : "i" (__HYPERVISOR_##name), \
85 "r" ((unsigned long)(a1)), \
86 "r" ((unsigned long)(a2)) \
87 : "r14","r15","r2","r8", \
88 "memory" ); \
89 (type)__res; \
90 })
92 #define _hypercall3(type, name, a1, a2, a3) \
93 ({ \
94 long __res; \
95 __asm__ __volatile__ (";;\n" \
96 "mov r14=%2\n" \
97 "mov r15=%3\n" \
98 "mov r16=%4\n" \
99 "mov r2=%1\n" \
100 "break 0x1000 ;;\n" \
101 "mov %0=r8 ;;\n" \
102 : "=r" (__res) \
103 : "i" (__HYPERVISOR_##name), \
104 "r" ((unsigned long)(a1)), \
105 "r" ((unsigned long)(a2)), \
106 "r" ((unsigned long)(a3)) \
107 : "r14","r15","r16","r2","r8", \
108 "memory" ); \
109 (type)__res; \
110 })
112 #define _hypercall4(type, name, a1, a2, a3, a4) \
113 ({ \
114 long __res; \
115 __asm__ __volatile__ (";;\n" \
116 "mov r14=%2\n" \
117 "mov r15=%3\n" \
118 "mov r16=%4\n" \
119 "mov r17=%5\n" \
120 "mov r2=%1\n" \
121 "break 0x1000 ;;\n" \
122 "mov %0=r8 ;;\n" \
123 : "=r" (__res) \
124 : "i" (__HYPERVISOR_##name), \
125 "r" ((unsigned long)(a1)), \
126 "r" ((unsigned long)(a2)), \
127 "r" ((unsigned long)(a3)), \
128 "r" ((unsigned long)(a4)) \
129 : "r14","r15","r16","r2","r8", \
130 "r17","memory" ); \
131 (type)__res; \
132 })
134 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
135 ({ \
136 long __res; \
137 __asm__ __volatile__ (";;\n" \
138 "mov r14=%2\n" \
139 "mov r15=%3\n" \
140 "mov r16=%4\n" \
141 "mov r17=%5\n" \
142 "mov r18=%6\n" \
143 "mov r2=%1\n" \
144 "break 0x1000 ;;\n" \
145 "mov %0=r8 ;;\n" \
146 : "=r" (__res) \
147 : "i" (__HYPERVISOR_##name), \
148 "r" ((unsigned long)(a1)), \
149 "r" ((unsigned long)(a2)), \
150 "r" ((unsigned long)(a3)), \
151 "r" ((unsigned long)(a4)), \
152 "r" ((unsigned long)(a5)) \
153 : "r14","r15","r16","r2","r8", \
154 "r17","r18","memory" ); \
155 (type)__res; \
156 })
158 static inline int
159 HYPERVISOR_sched_op_compat(
160 int cmd, unsigned long arg)
161 {
162 return _hypercall2(int, sched_op_compat, cmd, arg);
163 }
165 static inline int
166 HYPERVISOR_sched_op(
167 int cmd, void *arg)
168 {
169 return _hypercall2(int, sched_op, cmd, arg);
170 }
172 static inline long
173 HYPERVISOR_set_timer_op(
174 u64 timeout)
175 {
176 unsigned long timeout_hi = (unsigned long)(timeout>>32);
177 unsigned long timeout_lo = (unsigned long)timeout;
178 return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
179 }
181 static inline int
182 HYPERVISOR_dom0_op(
183 dom0_op_t *dom0_op)
184 {
185 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
186 return _hypercall1(int, dom0_op, dom0_op);
187 }
189 static inline int
190 HYPERVISOR_multicall(
191 void *call_list, int nr_calls)
192 {
193 return _hypercall2(int, multicall, call_list, nr_calls);
194 }
196 static inline int
197 HYPERVISOR_memory_op(
198 unsigned int cmd, void *arg)
199 {
200 return _hypercall2(int, memory_op, cmd, arg);
201 }
203 static inline int
204 HYPERVISOR_event_channel_op(
205 void *op)
206 {
207 return _hypercall1(int, event_channel_op, op);
208 }
210 static inline int
211 HYPERVISOR_xen_version(
212 int cmd, void *arg)
213 {
214 return _hypercall2(int, xen_version, cmd, arg);
215 }
217 static inline int
218 HYPERVISOR_console_io(
219 int cmd, int count, char *str)
220 {
221 return _hypercall3(int, console_io, cmd, count, str);
222 }
224 static inline int
225 HYPERVISOR_physdev_op(
226 void *physdev_op)
227 {
228 return _hypercall1(int, physdev_op, physdev_op);
229 }
231 static inline int
232 HYPERVISOR_grant_table_op(
233 unsigned int cmd, void *uop, unsigned int count)
234 {
235 return _hypercall3(int, grant_table_op, cmd, uop, count);
236 }
238 static inline int
239 HYPERVISOR_vcpu_op(
240 int cmd, int vcpuid, void *extra_args)
241 {
242 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
243 }
245 static inline int
246 HYPERVISOR_suspend(
247 unsigned long srec)
248 {
249 struct sched_shutdown sched_shutdown = {
250 .reason = SHUTDOWN_suspend
251 };
253 int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
254 &sched_shutdown, srec);
256 if (rc == -ENOSYS)
257 rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
258 SHUTDOWN_suspend, srec);
260 return rc;
261 }
263 extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
264 static inline void exit_idle(void) {}
265 #define do_IRQ(irq, regs) __do_IRQ((irq), (regs))
267 #ifdef CONFIG_XEN_IA64_DOM0_VP
268 #include <asm/xen/privop.h>
270 #define _hypercall_imm1(type, name, imm, a1) \
271 ({ \
272 long __res; \
273 __asm__ __volatile__ (";;\n" \
274 "mov r14=%2\n" \
275 "mov r15=%3\n" \
276 "mov r2=%1\n" \
277 "break 0x1000 ;;\n" \
278 "mov %0=r8 ;;\n" \
279 : "=r" (__res) \
280 : "i" (__HYPERVISOR_##name), \
281 "i" (imm), \
282 "r" ((unsigned long)(a1)) \
283 : "r14","r15","r2","r8", \
284 "memory" ); \
285 (type)__res; \
286 })
288 #define _hypercall_imm2(type, name, imm, a1, a2) \
289 ({ \
290 long __res; \
291 __asm__ __volatile__ (";;\n" \
292 "mov r14=%2\n" \
293 "mov r15=%3\n" \
294 "mov r16=%4\n" \
295 "mov r2=%1\n" \
296 "break 0x1000 ;;\n" \
297 "mov %0=r8 ;;\n" \
298 : "=r" (__res) \
299 : "i" (__HYPERVISOR_##name), \
300 "i" (imm), \
301 "r" ((unsigned long)(a1)), \
302 "r" ((unsigned long)(a2)) \
303 : "r14","r15","r16","r2","r8", \
304 "memory" ); \
305 (type)__res; \
306 })
308 #define _hypercall_imm3(type, name, imm, a1, a2, a3) \
309 ({ \
310 long __res; \
311 __asm__ __volatile__ (";;\n" \
312 "mov r14=%2\n" \
313 "mov r15=%3\n" \
314 "mov r16=%4\n" \
315 "mov r17=%5\n" \
316 "mov r2=%1\n" \
317 "break 0x1000 ;;\n" \
318 "mov %0=r8 ;;\n" \
319 : "=r" (__res) \
320 : "i" (__HYPERVISOR_##name), \
321 "i" (imm), \
322 "r" ((unsigned long)(a1)), \
323 "r" ((unsigned long)(a2)), \
324 "r" ((unsigned long)(a3)) \
325 : "r14","r15","r16","r17", \
326 "r2","r8", \
327 "memory" ); \
328 (type)__res; \
329 })
331 #define _hypercall_imm4(type, name, imm, a1, a2, a3, a4) \
332 ({ \
333 long __res; \
334 __asm__ __volatile__ (";;\n" \
335 "mov r14=%2\n" \
336 "mov r15=%3\n" \
337 "mov r16=%4\n" \
338 "mov r17=%5\n" \
339 "mov r18=%6\n" \
340 "mov r2=%1\n" \
341 "break 0x1000 ;;\n" \
342 "mov %0=r8 ;;\n" \
343 : "=r" (__res) \
344 : "i" (__HYPERVISOR_##name), \
345 "i" (imm), \
346 "r" ((unsigned long)(a1)), \
347 "r" ((unsigned long)(a2)), \
348 "r" ((unsigned long)(a3)), \
349 "r" ((unsigned long)(a4)) \
350 : "r14","r15","r16","r17","r18", \
351 "r2","r8", \
352 "memory" ); \
353 (type)__res; \
354 })
356 static inline unsigned long
357 __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
358 {
359 return _hypercall_imm2(unsigned long, ia64_dom0vp_op,
360 IA64_DOM0VP_ioremap, ioaddr, size);
361 }
363 static inline unsigned long
364 HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
365 {
366 unsigned long ret = ioaddr;
367 if (running_on_xen) {
368 ret = __HYPERVISOR_ioremap(ioaddr, size);
369 }
370 return ret;
371 }
373 static inline unsigned long
374 __HYPERVISOR_phystomach(unsigned long gpfn)
375 {
376 return _hypercall_imm1(unsigned long, ia64_dom0vp_op,
377 IA64_DOM0VP_phystomach, gpfn);
378 }
380 static inline unsigned long
381 HYPERVISOR_phystomach(unsigned long gpfn)
382 {
383 unsigned long ret = gpfn;
384 if (running_on_xen) {
385 ret = __HYPERVISOR_phystomach(gpfn);
386 }
387 return ret;
388 }
390 static inline unsigned long
391 __HYPERVISOR_machtophys(unsigned long mfn)
392 {
393 return _hypercall_imm1(unsigned long, ia64_dom0vp_op,
394 IA64_DOM0VP_machtophys, mfn);
395 }
397 static inline unsigned long
398 HYPERVISOR_machtophys(unsigned long mfn)
399 {
400 unsigned long ret = mfn;
401 if (running_on_xen) {
402 ret = __HYPERVISOR_machtophys(mfn);
403 }
404 return ret;
405 }
407 static inline unsigned long
408 __HYPERVISOR_populate_physmap(unsigned long gpfn, unsigned int extent_order,
409 unsigned int address_bits)
410 {
411 return _hypercall_imm3(unsigned long, ia64_dom0vp_op,
412 IA64_DOM0VP_populate_physmap, gpfn,
413 extent_order, address_bits);
414 }
416 static inline unsigned long
417 HYPERVISOR_populate_physmap(unsigned long gpfn, unsigned int extent_order,
418 unsigned int address_bits)
419 {
420 unsigned long ret = 0;
421 if (running_on_xen) {
422 ret = __HYPERVISOR_populate_physmap(gpfn, extent_order,
423 address_bits);
424 }
425 return ret;
426 }
428 static inline unsigned long
429 __HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
430 {
431 return _hypercall_imm2(unsigned long, ia64_dom0vp_op,
432 IA64_DOM0VP_zap_physmap, gpfn, extent_order);
433 }
435 static inline unsigned long
436 HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
437 {
438 unsigned long ret = 0;
439 if (running_on_xen) {
440 ret = __HYPERVISOR_zap_physmap(gpfn, extent_order);
441 }
442 return ret;
443 }
445 static inline unsigned long
446 __HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
447 unsigned int flags, domid_t domid)
448 {
449 return _hypercall_imm4(unsigned long, ia64_dom0vp_op,
450 IA64_DOM0VP_add_physmap, gpfn, mfn, flags,
451 domid);
452 }
453 static inline unsigned long
454 HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
455 unsigned int flags, domid_t domid)
456 {
457 unsigned long ret = 0;
458 BUG_ON(!running_on_xen);//XXX
459 if (running_on_xen) {
460 ret = __HYPERVISOR_add_physmap(gpfn, mfn, flags, domid);
461 }
462 return ret;
463 }
464 #else
465 #define HYPERVISOR_ioremap(ioaddr, size) ({ioaddr;})
466 #define HYPERVISOR_phystomach(gpfn) ({gpfn;})
467 #define HYPERVISOR_machtophys(mfn) ({mfn;})
468 #define HYPERVISOR_populate_physmap(gpfn, extent_order, address_bits) \
469 ({0;})
470 #define HYPERVISOR_zap_physmap(gpfn, extent_order) ({0;})
471 #define HYPERVISOR_add_physmap(gpfn, mfn, flags) ({0;})
472 #endif
473 #endif /* __HYPERCALL_H__ */