ia64/linux-2.6.18-xen.hg

view include/asm-ia64/hypercall.h @ 687:7d2d7b1deda4

[IA64] xencomm: support DOM0VP_get_memmap

add xencomm support for DOM0VP_get_memmap.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Fri Oct 03 13:08:44 2008 +0900 (2008-10-03)
parents 50bfa53b4a93
children 55ec2b18fe7f
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 #include <asm/xen/xcom_hcall.h>
41 struct xencomm_handle;
42 extern unsigned long __hypercall(unsigned long a1, unsigned long a2,
43 unsigned long a3, unsigned long a4,
44 unsigned long a5, unsigned long cmd);
46 /*
47 * Assembler stubs for hyper-calls.
48 */
50 #define _hypercall0(type, name) \
51 ({ \
52 long __res; \
53 __res=__hypercall(0, 0, 0, 0, 0, __HYPERVISOR_##name); \
54 (type)__res; \
55 })
57 #define _hypercall1(type, name, a1) \
58 ({ \
59 long __res; \
60 __res = __hypercall((unsigned long)a1, \
61 0, 0, 0, 0, __HYPERVISOR_##name); \
62 (type)__res; \
63 })
65 #define _hypercall2(type, name, a1, a2) \
66 ({ \
67 long __res; \
68 __res = __hypercall((unsigned long)a1, \
69 (unsigned long)a2, \
70 0, 0, 0, __HYPERVISOR_##name); \
71 (type)__res; \
72 })
74 #define _hypercall3(type, name, a1, a2, a3) \
75 ({ \
76 long __res; \
77 __res = __hypercall((unsigned long)a1, \
78 (unsigned long)a2, \
79 (unsigned long)a3, \
80 0, 0, __HYPERVISOR_##name); \
81 (type)__res; \
82 })
84 #define _hypercall4(type, name, a1, a2, a3, a4) \
85 ({ \
86 long __res; \
87 __res = __hypercall((unsigned long)a1, \
88 (unsigned long)a2, \
89 (unsigned long)a3, \
90 (unsigned long)a4, \
91 0, __HYPERVISOR_##name); \
92 (type)__res; \
93 })
95 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
96 ({ \
97 long __res; \
98 __res = __hypercall((unsigned long)a1, \
99 (unsigned long)a2, \
100 (unsigned long)a3, \
101 (unsigned long)a4, \
102 (unsigned long)a5, \
103 __HYPERVISOR_##name); \
104 (type)__res; \
105 })
108 static inline int
109 xencomm_arch_hypercall_sched_op(int cmd, struct xencomm_handle *arg)
110 {
111 return _hypercall2(int, sched_op, cmd, arg);
112 }
114 static inline long
115 HYPERVISOR_set_timer_op(u64 timeout)
116 {
117 unsigned long timeout_hi = (unsigned long)(timeout >> 32);
118 unsigned long timeout_lo = (unsigned long)timeout;
119 return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
120 }
122 static inline int
123 xencomm_arch_hypercall_platform_op(struct xencomm_handle *op)
124 {
125 return _hypercall1(int, platform_op, op);
126 }
128 static inline int
129 xencomm_arch_hypercall_sysctl(struct xencomm_handle *op)
130 {
131 return _hypercall1(int, sysctl, op);
132 }
134 static inline int
135 xencomm_arch_hypercall_domctl(struct xencomm_handle *op)
136 {
137 return _hypercall1(int, domctl, op);
138 }
140 static inline int
141 xencomm_arch_hypercall_multicall(struct xencomm_handle *call_list,
142 int nr_calls)
143 {
144 return _hypercall2(int, multicall, call_list, nr_calls);
145 }
147 static inline int
148 xencomm_arch_hypercall_memory_op(unsigned int cmd, struct xencomm_handle *arg)
149 {
150 return _hypercall2(int, memory_op, cmd, arg);
151 }
153 static inline int
154 xencomm_arch_hypercall_event_channel_op(int cmd, struct xencomm_handle *arg)
155 {
156 return _hypercall2(int, event_channel_op, cmd, arg);
157 }
159 static inline int
160 xencomm_arch_hypercall_xsm_op(struct xencomm_handle *arg)
161 {
162 return _hypercall1(int, xsm_op, arg);
163 }
165 static inline int
166 xencomm_arch_hypercall_xen_version(int cmd, struct xencomm_handle *arg)
167 {
168 return _hypercall2(int, xen_version, cmd, arg);
169 }
171 static inline int
172 xencomm_arch_hypercall_console_io(int cmd, int count,
173 struct xencomm_handle *str)
174 {
175 return _hypercall3(int, console_io, cmd, count, str);
176 }
178 static inline int
179 xencomm_arch_hypercall_physdev_op(int cmd, struct xencomm_handle *arg)
180 {
181 return _hypercall2(int, physdev_op, cmd, arg);
182 }
184 static inline int
185 xencomm_arch_hypercall_grant_table_op(unsigned int cmd,
186 struct xencomm_handle *uop,
187 unsigned int count)
188 {
189 return _hypercall3(int, grant_table_op, cmd, uop, count);
190 }
192 int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
194 extern int xencomm_arch_hypercall_suspend(struct xencomm_handle *arg);
196 static inline int
197 xencomm_arch_hypercall_callback_op(int cmd, struct xencomm_handle *arg)
198 {
199 return _hypercall2(int, callback_op, cmd, arg);
200 }
202 static inline unsigned long
203 xencomm_arch_hypercall_hvm_op(int cmd, void *arg)
204 {
205 return _hypercall2(unsigned long, hvm_op, cmd, arg);
206 }
208 static inline long
209 xencomm_arch_hypercall_vcpu_op(int cmd, int cpu, void *arg)
210 {
211 return _hypercall3(long, vcpu_op, cmd, cpu, arg);
212 }
214 static inline int
215 HYPERVISOR_physdev_op(int cmd, void *arg)
216 {
217 switch (cmd) {
218 case PHYSDEVOP_eoi:
219 return _hypercall1(int, ia64_fast_eoi,
220 ((struct physdev_eoi *)arg)->irq);
221 default:
222 return xencomm_hypercall_physdev_op(cmd, arg);
223 }
224 }
226 static inline int
227 xencomm_arch_hypercall_xenoprof_op(int op, struct xencomm_handle *arg)
228 {
229 return _hypercall2(int, xenoprof_op, op, arg);
230 }
232 static inline long
233 xencomm_arch_hypercall_opt_feature(struct xencomm_handle *arg)
234 {
235 return _hypercall1(long, opt_feature, arg);
236 }
238 extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
239 static inline void exit_idle(void) {}
240 #define do_IRQ(irq, regs) ({ \
241 irq_enter(); \
242 __do_IRQ((irq), (regs)); \
243 irq_exit(); \
244 })
246 #include <linux/err.h>
247 #ifdef HAVE_XEN_PLATFORM_COMPAT_H
248 #include <xen/platform-compat.h>
249 #endif
251 static inline unsigned long
252 __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
253 {
254 return _hypercall3(unsigned long, ia64_dom0vp_op,
255 IA64_DOM0VP_ioremap, ioaddr, size);
256 }
258 static inline unsigned long
259 HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
260 {
261 unsigned long ret = ioaddr;
262 if (is_running_on_xen()) {
263 ret = __HYPERVISOR_ioremap(ioaddr, size);
264 if (unlikely(ret == -ENOSYS))
265 panic("hypercall %s failed with %ld. "
266 "Please check Xen and Linux config mismatch\n",
267 __func__, -ret);
268 else if (unlikely(IS_ERR_VALUE(ret)))
269 ret = ioaddr;
270 }
271 return ret;
272 }
274 static inline unsigned long
275 __HYPERVISOR_phystomach(unsigned long gpfn)
276 {
277 return _hypercall2(unsigned long, ia64_dom0vp_op,
278 IA64_DOM0VP_phystomach, gpfn);
279 }
281 static inline unsigned long
282 HYPERVISOR_phystomach(unsigned long gpfn)
283 {
284 unsigned long ret = gpfn;
285 if (is_running_on_xen()) {
286 ret = __HYPERVISOR_phystomach(gpfn);
287 }
288 return ret;
289 }
291 static inline unsigned long
292 __HYPERVISOR_machtophys(unsigned long mfn)
293 {
294 return _hypercall2(unsigned long, ia64_dom0vp_op,
295 IA64_DOM0VP_machtophys, mfn);
296 }
298 static inline unsigned long
299 HYPERVISOR_machtophys(unsigned long mfn)
300 {
301 unsigned long ret = mfn;
302 if (is_running_on_xen()) {
303 ret = __HYPERVISOR_machtophys(mfn);
304 }
305 return ret;
306 }
308 static inline unsigned long
309 __HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
310 {
311 return _hypercall3(unsigned long, ia64_dom0vp_op,
312 IA64_DOM0VP_zap_physmap, gpfn, extent_order);
313 }
315 static inline unsigned long
316 HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
317 {
318 unsigned long ret = 0;
319 if (is_running_on_xen()) {
320 ret = __HYPERVISOR_zap_physmap(gpfn, extent_order);
321 }
322 return ret;
323 }
325 static inline unsigned long
326 __HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
327 unsigned long flags, domid_t domid)
328 {
329 return _hypercall5(unsigned long, ia64_dom0vp_op,
330 IA64_DOM0VP_add_physmap, gpfn, mfn, flags, domid);
331 }
333 static inline unsigned long
334 HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
335 unsigned long flags, domid_t domid)
336 {
337 unsigned long ret = 0;
338 BUG_ON(!is_running_on_xen());//XXX
339 if (is_running_on_xen()) {
340 ret = __HYPERVISOR_add_physmap(gpfn, mfn, flags, domid);
341 }
342 return ret;
343 }
345 static inline unsigned long
346 __HYPERVISOR_add_physmap_with_gmfn(unsigned long gpfn, unsigned long gmfn,
347 unsigned long flags, domid_t domid)
348 {
349 return _hypercall5(unsigned long, ia64_dom0vp_op,
350 IA64_DOM0VP_add_physmap_with_gmfn,
351 gpfn, gmfn, flags, domid);
352 }
354 static inline unsigned long
355 HYPERVISOR_add_physmap_with_gmfn(unsigned long gpfn, unsigned long gmfn,
356 unsigned long flags, domid_t domid)
357 {
358 unsigned long ret = 0;
359 BUG_ON(!is_running_on_xen());//XXX
360 if (is_running_on_xen()) {
361 ret = __HYPERVISOR_add_physmap_with_gmfn(gpfn, gmfn,
362 flags, domid);
363 }
364 return ret;
365 }
367 #ifdef CONFIG_XEN_IA64_EXPOSE_P2M
368 static inline unsigned long
369 HYPERVISOR_expose_p2m(unsigned long conv_start_gpfn,
370 unsigned long assign_start_gpfn,
371 unsigned long expose_size, unsigned long granule_pfn)
372 {
373 return _hypercall5(unsigned long, ia64_dom0vp_op,
374 IA64_DOM0VP_expose_p2m, conv_start_gpfn,
375 assign_start_gpfn, expose_size, granule_pfn);
376 }
378 static inline int
379 xencomm_arch_expose_foreign_p2m(unsigned long gpfn,
380 domid_t domid, struct xencomm_handle *arg,
381 unsigned long flags)
382 {
383 return _hypercall5(int, ia64_dom0vp_op,
384 IA64_DOM0VP_expose_foreign_p2m,
385 gpfn, domid, arg, flags);
386 }
388 static inline int
389 HYPERVISOR_unexpose_foreign_p2m(unsigned long gpfn, domid_t domid)
390 {
391 return _hypercall3(int, ia64_dom0vp_op,
392 IA64_DOM0VP_unexpose_foreign_p2m, gpfn, domid);
393 }
395 static inline int
396 xencomm_arch_hypercall_get_memmap(domid_t domid, struct xencomm_handle *arg)
397 {
398 return _hypercall3(int, ia64_dom0vp_op,
399 IA64_DOM0VP_get_memmap, domid, arg);
400 }
401 #endif
403 static inline int
404 xencomm_arch_hypercall_perfmon_op(unsigned long cmd,
405 struct xencomm_handle *arg,
406 unsigned long count)
407 {
408 return _hypercall4(int, ia64_dom0vp_op,
409 IA64_DOM0VP_perfmon, cmd, arg, count);
410 }
412 static inline int
413 xencomm_arch_hypercall_fpswa_revision(struct xencomm_handle *arg)
414 {
415 return _hypercall2(int, ia64_dom0vp_op,
416 IA64_DOM0VP_fpswa_revision, arg);
417 }
419 static inline int
420 xencomm_arch_hypercall_ia64_debug_op(unsigned long cmd,
421 unsigned long domain,
422 struct xencomm_handle *arg)
423 {
424 return _hypercall3(int, ia64_debug_op, cmd, domain, arg);
425 }
427 static inline int
428 HYPERVISOR_add_io_space(unsigned long phys_base,
429 unsigned long sparse,
430 unsigned long space_number)
431 {
432 return _hypercall4(int, ia64_dom0vp_op, IA64_DOM0VP_add_io_space,
433 phys_base, sparse, space_number);
434 }
436 static inline int
437 xencomm_arch_hypercall_kexec_op(int cmd, struct xencomm_handle *arg)
438 {
439 return _hypercall2(int, kexec_op, cmd, arg);
440 }
442 // for balloon driver
443 #define HYPERVISOR_update_va_mapping(va, new_val, flags) (0)
445 /* Use xencomm to do hypercalls. */
446 #define HYPERVISOR_sched_op xencomm_hypercall_sched_op
447 #define HYPERVISOR_event_channel_op xencomm_hypercall_event_channel_op
448 #define HYPERVISOR_callback_op xencomm_hypercall_callback_op
449 #define HYPERVISOR_multicall xencomm_hypercall_multicall
450 #define HYPERVISOR_xen_version xencomm_hypercall_xen_version
451 #define HYPERVISOR_console_io xencomm_hypercall_console_io
452 #define HYPERVISOR_hvm_op xencomm_hypercall_hvm_op
453 #define HYPERVISOR_memory_op xencomm_hypercall_memory_op
454 #define HYPERVISOR_xenoprof_op xencomm_hypercall_xenoprof_op
455 #define HYPERVISOR_perfmon_op xencomm_hypercall_perfmon_op
456 #define HYPERVISOR_fpswa_revision xencomm_hypercall_fpswa_revision
457 #define HYPERVISOR_suspend xencomm_hypercall_suspend
458 #define HYPERVISOR_vcpu_op xencomm_hypercall_vcpu_op
459 #define HYPERVISOR_opt_feature xencomm_hypercall_opt_feature
460 #define HYPERVISOR_kexec_op xencomm_hypercall_kexec_op
462 /* to compile gnttab_copy_grant_page() in drivers/xen/core/gnttab.c */
463 #define HYPERVISOR_mmu_update(req, count, success_count, domid) ({BUG();0;})
465 #endif /* __HYPERCALL_H__ */