root / hw / xen_common.h @ 37f32f0f
History | View | Annotate | Download (3.2 kB)
1 | d94f9486 | aliguori | #ifndef QEMU_HW_XEN_COMMON_H
|
---|---|---|---|
2 | d94f9486 | aliguori | #define QEMU_HW_XEN_COMMON_H 1 |
3 | d94f9486 | aliguori | |
4 | d5b93ddf | Anthony PERARD | #include "config-host.h" |
5 | d5b93ddf | Anthony PERARD | |
6 | d94f9486 | aliguori | #include <stddef.h> |
7 | d94f9486 | aliguori | #include <inttypes.h> |
8 | d94f9486 | aliguori | |
9 | d94f9486 | aliguori | #include <xenctrl.h> |
10 | d94f9486 | aliguori | #include <xs.h> |
11 | d94f9486 | aliguori | #include <xen/io/xenbus.h> |
12 | d94f9486 | aliguori | |
13 | d94f9486 | aliguori | #include "hw.h" |
14 | d94f9486 | aliguori | #include "xen.h" |
15 | d8becc35 | Jan Kiszka | #include "qemu-queue.h" |
16 | d94f9486 | aliguori | |
17 | d94f9486 | aliguori | /*
|
18 | d5b93ddf | Anthony PERARD | * We don't support Xen prior to 3.3.0.
|
19 | d94f9486 | aliguori | */
|
20 | d5b93ddf | Anthony PERARD | |
21 | d5b93ddf | Anthony PERARD | /* Xen before 4.0 */
|
22 | d5b93ddf | Anthony PERARD | #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 400 |
23 | d5b93ddf | Anthony PERARD | static inline void *xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot, |
24 | d5b93ddf | Anthony PERARD | xen_pfn_t *arr, int *err,
|
25 | d5b93ddf | Anthony PERARD | unsigned int num) |
26 | d5b93ddf | Anthony PERARD | { |
27 | d5b93ddf | Anthony PERARD | return xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
|
28 | d5b93ddf | Anthony PERARD | } |
29 | d94f9486 | aliguori | #endif
|
30 | d5b93ddf | Anthony PERARD | |
31 | d5b93ddf | Anthony PERARD | |
32 | d5b93ddf | Anthony PERARD | /* Xen before 4.1 */
|
33 | d5b93ddf | Anthony PERARD | #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 410 |
34 | d5b93ddf | Anthony PERARD | |
35 | d5b93ddf | Anthony PERARD | typedef int XenXC; |
36 | d5b93ddf | Anthony PERARD | typedef int XenEvtchn; |
37 | d5b93ddf | Anthony PERARD | typedef int XenGnttab; |
38 | d5b93ddf | Anthony PERARD | |
39 | d5b93ddf | Anthony PERARD | # define XC_INTERFACE_FMT "%i" |
40 | d5b93ddf | Anthony PERARD | # define XC_HANDLER_INITIAL_VALUE -1 |
41 | d5b93ddf | Anthony PERARD | |
42 | d5b93ddf | Anthony PERARD | static inline XenEvtchn xen_xc_evtchn_open(void *logger, |
43 | d5b93ddf | Anthony PERARD | unsigned int open_flags) |
44 | d5b93ddf | Anthony PERARD | { |
45 | d5b93ddf | Anthony PERARD | return xc_evtchn_open();
|
46 | d5b93ddf | Anthony PERARD | } |
47 | d5b93ddf | Anthony PERARD | |
48 | d5b93ddf | Anthony PERARD | static inline XenGnttab xen_xc_gnttab_open(void *logger, |
49 | d5b93ddf | Anthony PERARD | unsigned int open_flags) |
50 | d5b93ddf | Anthony PERARD | { |
51 | d5b93ddf | Anthony PERARD | return xc_gnttab_open();
|
52 | d5b93ddf | Anthony PERARD | } |
53 | d5b93ddf | Anthony PERARD | |
54 | d5b93ddf | Anthony PERARD | static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger, |
55 | d5b93ddf | Anthony PERARD | unsigned int open_flags) |
56 | d5b93ddf | Anthony PERARD | { |
57 | d5b93ddf | Anthony PERARD | return xc_interface_open();
|
58 | d5b93ddf | Anthony PERARD | } |
59 | d5b93ddf | Anthony PERARD | |
60 | d5b93ddf | Anthony PERARD | static inline int xc_fd(int xen_xc) |
61 | d5b93ddf | Anthony PERARD | { |
62 | d5b93ddf | Anthony PERARD | return xen_xc;
|
63 | d5b93ddf | Anthony PERARD | } |
64 | d5b93ddf | Anthony PERARD | |
65 | d5b93ddf | Anthony PERARD | |
66 | 432d268c | Jun Nakajima | static inline int xc_domain_populate_physmap_exact |
67 | 432d268c | Jun Nakajima | (XenXC xc_handle, uint32_t domid, unsigned long nr_extents, |
68 | 432d268c | Jun Nakajima | unsigned int extent_order, unsigned int mem_flags, xen_pfn_t *extent_start) |
69 | 432d268c | Jun Nakajima | { |
70 | 432d268c | Jun Nakajima | return xc_domain_memory_populate_physmap
|
71 | 432d268c | Jun Nakajima | (xc_handle, domid, nr_extents, extent_order, mem_flags, extent_start); |
72 | 432d268c | Jun Nakajima | } |
73 | 432d268c | Jun Nakajima | |
74 | b87de24e | Anthony PERARD | static inline int xc_domain_add_to_physmap(int xc_handle, uint32_t domid, |
75 | b87de24e | Anthony PERARD | unsigned int space, unsigned long idx, |
76 | b87de24e | Anthony PERARD | xen_pfn_t gpfn) |
77 | b87de24e | Anthony PERARD | { |
78 | b87de24e | Anthony PERARD | struct xen_add_to_physmap xatp = {
|
79 | b87de24e | Anthony PERARD | .domid = domid, |
80 | b87de24e | Anthony PERARD | .space = space, |
81 | b87de24e | Anthony PERARD | .idx = idx, |
82 | b87de24e | Anthony PERARD | .gpfn = gpfn, |
83 | b87de24e | Anthony PERARD | }; |
84 | b87de24e | Anthony PERARD | |
85 | b87de24e | Anthony PERARD | return xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp);
|
86 | b87de24e | Anthony PERARD | } |
87 | b87de24e | Anthony PERARD | |
88 | 0f51726a | Stefano Stabellini | static inline struct xs_handle *xs_open(unsigned long flags) |
89 | 0f51726a | Stefano Stabellini | { |
90 | 0f51726a | Stefano Stabellini | return xs_daemon_open();
|
91 | 0f51726a | Stefano Stabellini | } |
92 | 0f51726a | Stefano Stabellini | |
93 | 0f51726a | Stefano Stabellini | static inline void xs_close(struct xs_handle *xsh) |
94 | 0f51726a | Stefano Stabellini | { |
95 | 0f51726a | Stefano Stabellini | if (xsh != NULL) { |
96 | 0f51726a | Stefano Stabellini | xs_daemon_close(xsh); |
97 | 0f51726a | Stefano Stabellini | } |
98 | 0f51726a | Stefano Stabellini | } |
99 | 0f51726a | Stefano Stabellini | |
100 | 432d268c | Jun Nakajima | |
101 | d5b93ddf | Anthony PERARD | /* Xen 4.1 */
|
102 | d5b93ddf | Anthony PERARD | #else
|
103 | d5b93ddf | Anthony PERARD | |
104 | d5b93ddf | Anthony PERARD | typedef xc_interface *XenXC;
|
105 | d5b93ddf | Anthony PERARD | typedef xc_evtchn *XenEvtchn;
|
106 | d5b93ddf | Anthony PERARD | typedef xc_gnttab *XenGnttab;
|
107 | d5b93ddf | Anthony PERARD | |
108 | d5b93ddf | Anthony PERARD | # define XC_INTERFACE_FMT "%p" |
109 | d5b93ddf | Anthony PERARD | # define XC_HANDLER_INITIAL_VALUE NULL |
110 | d5b93ddf | Anthony PERARD | |
111 | d5b93ddf | Anthony PERARD | static inline XenEvtchn xen_xc_evtchn_open(void *logger, |
112 | d5b93ddf | Anthony PERARD | unsigned int open_flags) |
113 | d5b93ddf | Anthony PERARD | { |
114 | d5b93ddf | Anthony PERARD | return xc_evtchn_open(logger, open_flags);
|
115 | d5b93ddf | Anthony PERARD | } |
116 | d5b93ddf | Anthony PERARD | |
117 | d5b93ddf | Anthony PERARD | static inline XenGnttab xen_xc_gnttab_open(void *logger, |
118 | d5b93ddf | Anthony PERARD | unsigned int open_flags) |
119 | d5b93ddf | Anthony PERARD | { |
120 | d5b93ddf | Anthony PERARD | return xc_gnttab_open(logger, open_flags);
|
121 | d5b93ddf | Anthony PERARD | } |
122 | d5b93ddf | Anthony PERARD | |
123 | d5b93ddf | Anthony PERARD | static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger, |
124 | d5b93ddf | Anthony PERARD | unsigned int open_flags) |
125 | d5b93ddf | Anthony PERARD | { |
126 | d5b93ddf | Anthony PERARD | return xc_interface_open(logger, dombuild_logger, open_flags);
|
127 | d5b93ddf | Anthony PERARD | } |
128 | d5b93ddf | Anthony PERARD | |
129 | d5b93ddf | Anthony PERARD | /* FIXME There is now way to have the xen fd */
|
130 | d5b93ddf | Anthony PERARD | static inline int xc_fd(xc_interface *xen_xc) |
131 | d5b93ddf | Anthony PERARD | { |
132 | d5b93ddf | Anthony PERARD | return -1; |
133 | d5b93ddf | Anthony PERARD | } |
134 | d94f9486 | aliguori | #endif
|
135 | d94f9486 | aliguori | |
136 | 9ce94e7c | Arun Sharma | void destroy_hvm_domain(void); |
137 | 9ce94e7c | Arun Sharma | |
138 | d94f9486 | aliguori | #endif /* QEMU_HW_XEN_COMMON_H */ |