target-microblaze: Drop unused cpu_mb_close() prototype
[qemu/opensuse.git] / hw / xen_common.h
blob95bc9a7825b748c2763df82062bd2cf4904a6ae9
1 #ifndef QEMU_HW_XEN_COMMON_H
2 #define QEMU_HW_XEN_COMMON_H 1
4 #include "config-host.h"
6 #include <stddef.h>
7 #include <inttypes.h>
9 #include <xenctrl.h>
10 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 420
11 # include <xs.h>
12 #else
13 # include <xenstore.h>
14 #endif
15 #include <xen/io/xenbus.h>
17 #include "hw.h"
18 #include "xen.h"
19 #include "qemu/queue.h"
22 * We don't support Xen prior to 3.3.0.
25 /* Xen before 4.0 */
26 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 400
27 static inline void *xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot,
28 xen_pfn_t *arr, int *err,
29 unsigned int num)
31 return xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
33 #endif
36 /* Xen before 4.1 */
37 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 410
39 typedef int XenXC;
40 typedef int XenEvtchn;
41 typedef int XenGnttab;
43 # define XC_INTERFACE_FMT "%i"
44 # define XC_HANDLER_INITIAL_VALUE -1
46 static inline XenEvtchn xen_xc_evtchn_open(void *logger,
47 unsigned int open_flags)
49 return xc_evtchn_open();
52 static inline XenGnttab xen_xc_gnttab_open(void *logger,
53 unsigned int open_flags)
55 return xc_gnttab_open();
58 static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger,
59 unsigned int open_flags)
61 return xc_interface_open();
64 static inline int xc_fd(int xen_xc)
66 return xen_xc;
70 static inline int xc_domain_populate_physmap_exact
71 (XenXC xc_handle, uint32_t domid, unsigned long nr_extents,
72 unsigned int extent_order, unsigned int mem_flags, xen_pfn_t *extent_start)
74 return xc_domain_memory_populate_physmap
75 (xc_handle, domid, nr_extents, extent_order, mem_flags, extent_start);
78 static inline int xc_domain_add_to_physmap(int xc_handle, uint32_t domid,
79 unsigned int space, unsigned long idx,
80 xen_pfn_t gpfn)
82 struct xen_add_to_physmap xatp = {
83 .domid = domid,
84 .space = space,
85 .idx = idx,
86 .gpfn = gpfn,
89 return xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp);
92 static inline struct xs_handle *xs_open(unsigned long flags)
94 return xs_daemon_open();
97 static inline void xs_close(struct xs_handle *xsh)
99 if (xsh != NULL) {
100 xs_daemon_close(xsh);
105 /* Xen 4.1 */
106 #else
108 typedef xc_interface *XenXC;
109 typedef xc_evtchn *XenEvtchn;
110 typedef xc_gnttab *XenGnttab;
112 # define XC_INTERFACE_FMT "%p"
113 # define XC_HANDLER_INITIAL_VALUE NULL
115 static inline XenEvtchn xen_xc_evtchn_open(void *logger,
116 unsigned int open_flags)
118 return xc_evtchn_open(logger, open_flags);
121 static inline XenGnttab xen_xc_gnttab_open(void *logger,
122 unsigned int open_flags)
124 return xc_gnttab_open(logger, open_flags);
127 static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger,
128 unsigned int open_flags)
130 return xc_interface_open(logger, dombuild_logger, open_flags);
133 /* FIXME There is now way to have the xen fd */
134 static inline int xc_fd(xc_interface *xen_xc)
136 return -1;
138 #endif
140 /* Xen before 4.2 */
141 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 420
142 static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
143 uint64_t addr, uint32_t data)
145 return -ENOSYS;
147 #else
148 static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
149 uint64_t addr, uint32_t data)
151 return xc_hvm_inject_msi(xen_xc, dom, addr, data);
153 #endif
155 void destroy_hvm_domain(bool reboot);
157 /* shutdown/destroy current domain because of an error */
158 void xen_shutdown_fatal_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
160 #endif /* QEMU_HW_XEN_COMMON_H */