1 #ifndef QEMU_HW_XEN_COMMON_H
2 #define QEMU_HW_XEN_COMMON_H 1
4 #include "config-host.h"
10 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 420
13 # include <xenstore.h>
15 #include <xen/io/xenbus.h>
19 #include "qemu-queue.h"
22 * We don't support Xen prior to 3.3.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
,
31 return xc_map_foreign_batch(xc_handle
, dom
, prot
, arr
, num
);
37 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 410
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
)
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
,
82 struct xen_add_to_physmap xatp
= {
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
)
100 xs_daemon_close(xsh
);
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
)
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
)
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
);
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 */