ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-ia64/hypercall.h @ 10931:c3e20511c745

[IA64] Remove P==M support

Remove the old P==M dom0 memory model support. It's likely
broken by now anyway.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author awilliam@xenbuild.aw
date Fri Aug 04 09:32:00 2006 -0600 (2006-08-04)
parents 306d7857928c
children bef360142b62
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 #include <linux/string.h> /* memcpy() */
38 #ifndef __HYPERVISOR_H__
39 # error "please don't include this file directly"
40 #endif
42 /*
43 * Assembler stubs for hyper-calls.
44 */
46 #define _hypercall0(type, name) \
47 ({ \
48 long __res; \
49 __asm__ __volatile__ (";;\n" \
50 "mov r2=%1\n" \
51 "break 0x1000 ;;\n" \
52 "mov %0=r8 ;;\n" \
53 : "=r" (__res) \
54 : "i" (__HYPERVISOR_##name) \
55 : "r2","r8", \
56 "memory" ); \
57 (type)__res; \
58 })
60 #define _hypercall1(type, name, a1) \
61 ({ \
62 long __res; \
63 __asm__ __volatile__ (";;\n" \
64 "mov r14=%2\n" \
65 "mov r2=%1\n" \
66 "break 0x1000 ;;\n" \
67 "mov %0=r8 ;;\n" \
68 : "=r" (__res) \
69 : "i" (__HYPERVISOR_##name), \
70 "r" ((unsigned long)(a1)) \
71 : "r14","r2","r8", \
72 "memory" ); \
73 (type)__res; \
74 })
76 #define _hypercall2(type, name, a1, a2) \
77 ({ \
78 long __res; \
79 __asm__ __volatile__ (";;\n" \
80 "mov r14=%2\n" \
81 "mov r15=%3\n" \
82 "mov r2=%1\n" \
83 "break 0x1000 ;;\n" \
84 "mov %0=r8 ;;\n" \
85 : "=r" (__res) \
86 : "i" (__HYPERVISOR_##name), \
87 "r" ((unsigned long)(a1)), \
88 "r" ((unsigned long)(a2)) \
89 : "r14","r15","r2","r8", \
90 "memory" ); \
91 (type)__res; \
92 })
94 #define _hypercall3(type, name, a1, a2, a3) \
95 ({ \
96 long __res; \
97 __asm__ __volatile__ (";;\n" \
98 "mov r14=%2\n" \
99 "mov r15=%3\n" \
100 "mov r16=%4\n" \
101 "mov r2=%1\n" \
102 "break 0x1000 ;;\n" \
103 "mov %0=r8 ;;\n" \
104 : "=r" (__res) \
105 : "i" (__HYPERVISOR_##name), \
106 "r" ((unsigned long)(a1)), \
107 "r" ((unsigned long)(a2)), \
108 "r" ((unsigned long)(a3)) \
109 : "r14","r15","r16","r2","r8", \
110 "memory" ); \
111 (type)__res; \
112 })
114 #define _hypercall4(type, name, a1, a2, a3, a4) \
115 ({ \
116 long __res; \
117 __asm__ __volatile__ (";;\n" \
118 "mov r14=%2\n" \
119 "mov r15=%3\n" \
120 "mov r16=%4\n" \
121 "mov r17=%5\n" \
122 "mov r2=%1\n" \
123 "break 0x1000 ;;\n" \
124 "mov %0=r8 ;;\n" \
125 : "=r" (__res) \
126 : "i" (__HYPERVISOR_##name), \
127 "r" ((unsigned long)(a1)), \
128 "r" ((unsigned long)(a2)), \
129 "r" ((unsigned long)(a3)), \
130 "r" ((unsigned long)(a4)) \
131 : "r14","r15","r16","r2","r8", \
132 "r17","memory" ); \
133 (type)__res; \
134 })
136 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
137 ({ \
138 long __res; \
139 __asm__ __volatile__ (";;\n" \
140 "mov r14=%2\n" \
141 "mov r15=%3\n" \
142 "mov r16=%4\n" \
143 "mov r17=%5\n" \
144 "mov r18=%6\n" \
145 "mov r2=%1\n" \
146 "break 0x1000 ;;\n" \
147 "mov %0=r8 ;;\n" \
148 : "=r" (__res) \
149 : "i" (__HYPERVISOR_##name), \
150 "r" ((unsigned long)(a1)), \
151 "r" ((unsigned long)(a2)), \
152 "r" ((unsigned long)(a3)), \
153 "r" ((unsigned long)(a4)), \
154 "r" ((unsigned long)(a5)) \
155 : "r14","r15","r16","r2","r8", \
156 "r17","r18","memory" ); \
157 (type)__res; \
158 })
160 static inline int
161 HYPERVISOR_sched_op_compat(
162 int cmd, unsigned long arg)
163 {
164 return _hypercall2(int, sched_op_compat, cmd, arg);
165 }
167 static inline int
168 HYPERVISOR_sched_op(
169 int cmd, void *arg)
170 {
171 return _hypercall2(int, sched_op, cmd, arg);
172 }
174 static inline long
175 HYPERVISOR_set_timer_op(
176 u64 timeout)
177 {
178 unsigned long timeout_hi = (unsigned long)(timeout>>32);
179 unsigned long timeout_lo = (unsigned long)timeout;
180 return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
181 }
183 static inline int
184 HYPERVISOR_dom0_op(
185 dom0_op_t *dom0_op)
186 {
187 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
188 return _hypercall1(int, dom0_op, dom0_op);
189 }
191 static inline int
192 HYPERVISOR_multicall(
193 void *call_list, int nr_calls)
194 {
195 return _hypercall2(int, multicall, call_list, nr_calls);
196 }
198 //XXX xen/ia64 copy_from_guest() is broken.
199 // This is a temporal work around until it is fixed.
200 static inline int
201 ____HYPERVISOR_memory_op(
202 unsigned int cmd, void *arg)
203 {
204 return _hypercall2(int, memory_op, cmd, arg);
205 }
207 #include <xen/interface/memory.h>
208 int ia64_xenmem_reservation_op(unsigned long op,
209 struct xen_memory_reservation* reservation__);
210 static inline int
211 HYPERVISOR_memory_op(
212 unsigned int cmd, void *arg)
213 {
214 switch (cmd) {
215 case XENMEM_increase_reservation:
216 case XENMEM_decrease_reservation:
217 case XENMEM_populate_physmap:
218 return ia64_xenmem_reservation_op(cmd,
219 (struct xen_memory_reservation*)arg);
220 default:
221 return ____HYPERVISOR_memory_op(cmd, arg);
222 }
223 /* NOTREACHED */
224 }
226 static inline int
227 HYPERVISOR_event_channel_op(
228 int cmd, void *arg)
229 {
230 int rc = _hypercall2(int, event_channel_op, cmd, arg);
231 if (unlikely(rc == -ENOSYS)) {
232 struct evtchn_op op;
233 op.cmd = cmd;
234 memcpy(&op.u, arg, sizeof(op.u));
235 rc = _hypercall1(int, event_channel_op_compat, &op);
236 }
237 return rc;
238 }
240 static inline int
241 HYPERVISOR_acm_op(
242 unsigned int cmd, void *arg)
243 {
244 return _hypercall2(int, acm_op, cmd, arg);
245 }
247 static inline int
248 HYPERVISOR_xen_version(
249 int cmd, void *arg)
250 {
251 return _hypercall2(int, xen_version, cmd, arg);
252 }
254 static inline int
255 HYPERVISOR_console_io(
256 int cmd, int count, char *str)
257 {
258 return _hypercall3(int, console_io, cmd, count, str);
259 }
261 static inline int
262 HYPERVISOR_physdev_op(
263 int cmd, void *arg)
264 {
265 int rc = _hypercall2(int, physdev_op, cmd, arg);
266 if (unlikely(rc == -ENOSYS)) {
267 struct physdev_op op;
268 op.cmd = cmd;
269 memcpy(&op.u, arg, sizeof(op.u));
270 rc = _hypercall1(int, physdev_op_compat, &op);
271 }
272 return rc;
273 }
275 //XXX __HYPERVISOR_grant_table_op is used for this hypercall constant.
276 static inline int
277 ____HYPERVISOR_grant_table_op(
278 unsigned int cmd, void *uop, unsigned int count)
279 {
280 return _hypercall3(int, grant_table_op, cmd, uop, count);
281 }
283 int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
285 static inline int
286 HYPERVISOR_vcpu_op(
287 int cmd, int vcpuid, void *extra_args)
288 {
289 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
290 }
292 extern int HYPERVISOR_suspend(unsigned long srec);
294 static inline int
295 HYPERVISOR_callback_op(
296 int cmd, void *arg)
297 {
298 return _hypercall2(int, callback_op, cmd, arg);
299 }
301 extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
302 static inline void exit_idle(void) {}
303 #define do_IRQ(irq, regs) ({ \
304 irq_enter(); \
305 __do_IRQ((irq), (regs)); \
306 irq_exit(); \
307 })
309 #include <linux/err.h>
310 #include <asm/xen/privop.h>
312 #define _hypercall_imm1(type, name, imm, a1) \
313 ({ \
314 long __res; \
315 __asm__ __volatile__ (";;\n" \
316 "mov r14=%2\n" \
317 "mov r15=%3\n" \
318 "mov r2=%1\n" \
319 "break 0x1000 ;;\n" \
320 "mov %0=r8 ;;\n" \
321 : "=r" (__res) \
322 : "i" (__HYPERVISOR_##name), \
323 "i" (imm), \
324 "r" ((unsigned long)(a1)) \
325 : "r14","r15","r2","r8", \
326 "memory" ); \
327 (type)__res; \
328 })
330 #define _hypercall_imm2(type, name, imm, a1, a2) \
331 ({ \
332 long __res; \
333 __asm__ __volatile__ (";;\n" \
334 "mov r14=%2\n" \
335 "mov r15=%3\n" \
336 "mov r16=%4\n" \
337 "mov r2=%1\n" \
338 "break 0x1000 ;;\n" \
339 "mov %0=r8 ;;\n" \
340 : "=r" (__res) \
341 : "i" (__HYPERVISOR_##name), \
342 "i" (imm), \
343 "r" ((unsigned long)(a1)), \
344 "r" ((unsigned long)(a2)) \
345 : "r14","r15","r16","r2","r8", \
346 "memory" ); \
347 (type)__res; \
348 })
350 #define _hypercall_imm3(type, name, imm, a1, a2, a3) \
351 ({ \
352 long __res; \
353 __asm__ __volatile__ (";;\n" \
354 "mov r14=%2\n" \
355 "mov r15=%3\n" \
356 "mov r16=%4\n" \
357 "mov r17=%5\n" \
358 "mov r2=%1\n" \
359 "break 0x1000 ;;\n" \
360 "mov %0=r8 ;;\n" \
361 : "=r" (__res) \
362 : "i" (__HYPERVISOR_##name), \
363 "i" (imm), \
364 "r" ((unsigned long)(a1)), \
365 "r" ((unsigned long)(a2)), \
366 "r" ((unsigned long)(a3)) \
367 : "r14","r15","r16","r17", \
368 "r2","r8", \
369 "memory" ); \
370 (type)__res; \
371 })
373 #define _hypercall_imm4(type, name, imm, a1, a2, a3, a4) \
374 ({ \
375 long __res; \
376 __asm__ __volatile__ (";;\n" \
377 "mov r14=%2\n" \
378 "mov r15=%3\n" \
379 "mov r16=%4\n" \
380 "mov r17=%5\n" \
381 "mov r18=%6\n" \
382 "mov r2=%1\n" \
383 "break 0x1000 ;;\n" \
384 "mov %0=r8 ;;\n" \
385 : "=r" (__res) \
386 : "i" (__HYPERVISOR_##name), \
387 "i" (imm), \
388 "r" ((unsigned long)(a1)), \
389 "r" ((unsigned long)(a2)), \
390 "r" ((unsigned long)(a3)), \
391 "r" ((unsigned long)(a4)) \
392 : "r14","r15","r16","r17","r18", \
393 "r2","r8", \
394 "memory" ); \
395 (type)__res; \
396 })
398 static inline unsigned long
399 __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
400 {
401 return _hypercall_imm2(unsigned long, ia64_dom0vp_op,
402 IA64_DOM0VP_ioremap, ioaddr, size);
403 }
405 static inline unsigned long
406 HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
407 {
408 unsigned long ret = ioaddr;
409 if (is_running_on_xen()) {
410 ret = __HYPERVISOR_ioremap(ioaddr, size);
411 if (unlikely(ret == -ENOSYS))
412 panic("hypercall %s failed with %ld. "
413 "Please check Xen and Linux config mismatch\n",
414 __func__, -ret);
415 else if (unlikely(IS_ERR_VALUE(ret)))
416 ret = ioaddr;
417 }
418 return ret;
419 }
421 static inline unsigned long
422 __HYPERVISOR_phystomach(unsigned long gpfn)
423 {
424 return _hypercall_imm1(unsigned long, ia64_dom0vp_op,
425 IA64_DOM0VP_phystomach, gpfn);
426 }
428 static inline unsigned long
429 HYPERVISOR_phystomach(unsigned long gpfn)
430 {
431 unsigned long ret = gpfn;
432 if (is_running_on_xen()) {
433 ret = __HYPERVISOR_phystomach(gpfn);
434 }
435 return ret;
436 }
438 static inline unsigned long
439 __HYPERVISOR_machtophys(unsigned long mfn)
440 {
441 return _hypercall_imm1(unsigned long, ia64_dom0vp_op,
442 IA64_DOM0VP_machtophys, mfn);
443 }
445 static inline unsigned long
446 HYPERVISOR_machtophys(unsigned long mfn)
447 {
448 unsigned long ret = mfn;
449 if (is_running_on_xen()) {
450 ret = __HYPERVISOR_machtophys(mfn);
451 }
452 return ret;
453 }
455 static inline unsigned long
456 __HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
457 {
458 return _hypercall_imm2(unsigned long, ia64_dom0vp_op,
459 IA64_DOM0VP_zap_physmap, gpfn, extent_order);
460 }
462 static inline unsigned long
463 HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
464 {
465 unsigned long ret = 0;
466 if (is_running_on_xen()) {
467 ret = __HYPERVISOR_zap_physmap(gpfn, extent_order);
468 }
469 return ret;
470 }
472 static inline unsigned long
473 __HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
474 unsigned long flags, domid_t domid)
475 {
476 return _hypercall_imm4(unsigned long, ia64_dom0vp_op,
477 IA64_DOM0VP_add_physmap, gpfn, mfn, flags,
478 domid);
479 }
481 static inline unsigned long
482 HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
483 unsigned long flags, domid_t domid)
484 {
485 unsigned long ret = 0;
486 BUG_ON(!is_running_on_xen());//XXX
487 if (is_running_on_xen()) {
488 ret = __HYPERVISOR_add_physmap(gpfn, mfn, flags, domid);
489 }
490 return ret;
491 }
493 // for balloon driver
494 #define HYPERVISOR_update_va_mapping(va, new_val, flags) (0)
496 #endif /* __HYPERCALL_H__ */