tests: Fixes test-io-channel-file by mask only owner file state mask bits
[qemu/ar7.git] / include / hw / xen / xen-bus.h
blobe0e67505b8d0ca976add0f47bde3f56dff631189
1 /*
2 * Copyright (c) 2018 Citrix Systems Inc.
4 * This work is licensed under the terms of the GNU GPL, version 2 or later.
5 * See the COPYING file in the top-level directory.
6 */
8 #ifndef HW_XEN_BUS_H
9 #define HW_XEN_BUS_H
11 #include "hw/xen/xen_common.h"
12 #include "hw/sysbus.h"
13 #include "qemu/notify.h"
14 #include "qom/object.h"
16 typedef void (*XenWatchHandler)(void *opaque);
18 typedef struct XenWatchList XenWatchList;
19 typedef struct XenWatch XenWatch;
20 typedef struct XenEventChannel XenEventChannel;
22 struct XenDevice {
23 DeviceState qdev;
24 domid_t frontend_id;
25 char *name;
26 struct xs_handle *xsh;
27 XenWatchList *watch_list;
28 char *backend_path, *frontend_path;
29 enum xenbus_state backend_state, frontend_state;
30 Notifier exit;
31 XenWatch *backend_state_watch, *frontend_state_watch;
32 bool backend_online;
33 XenWatch *backend_online_watch;
34 xengnttab_handle *xgth;
35 bool feature_grant_copy;
36 bool inactive;
37 QLIST_HEAD(, XenEventChannel) event_channels;
38 QLIST_ENTRY(XenDevice) list;
40 typedef struct XenDevice XenDevice;
42 typedef char *(*XenDeviceGetName)(XenDevice *xendev, Error **errp);
43 typedef void (*XenDeviceRealize)(XenDevice *xendev, Error **errp);
44 typedef void (*XenDeviceFrontendChanged)(XenDevice *xendev,
45 enum xenbus_state frontend_state,
46 Error **errp);
47 typedef void (*XenDeviceUnrealize)(XenDevice *xendev);
49 struct XenDeviceClass {
50 /*< private >*/
51 DeviceClass parent_class;
52 /*< public >*/
53 const char *backend;
54 const char *device;
55 XenDeviceGetName get_name;
56 XenDeviceRealize realize;
57 XenDeviceFrontendChanged frontend_changed;
58 XenDeviceUnrealize unrealize;
60 typedef struct XenDeviceClass XenDeviceClass;
62 #define TYPE_XEN_DEVICE "xen-device"
63 DECLARE_OBJ_CHECKERS(XenDevice, XenDeviceClass,
64 XEN_DEVICE, TYPE_XEN_DEVICE)
66 struct XenBus {
67 BusState qbus;
68 domid_t backend_id;
69 struct xs_handle *xsh;
70 XenWatchList *watch_list;
71 XenWatch *backend_watch;
72 QLIST_HEAD(, XenDevice) inactive_devices;
75 struct XenBusClass {
76 /*< private >*/
77 BusClass parent_class;
80 #define TYPE_XEN_BUS "xen-bus"
81 OBJECT_DECLARE_TYPE(XenBus, XenBusClass,
82 xen_bus, XEN_BUS)
84 void xen_bus_init(void);
86 void xen_device_backend_set_state(XenDevice *xendev,
87 enum xenbus_state state);
88 enum xenbus_state xen_device_backend_get_state(XenDevice *xendev);
90 void xen_device_backend_printf(XenDevice *xendev, const char *key,
91 const char *fmt, ...)
92 GCC_FMT_ATTR(3, 4);
93 void xen_device_frontend_printf(XenDevice *xendev, const char *key,
94 const char *fmt, ...)
95 GCC_FMT_ATTR(3, 4);
97 int xen_device_frontend_scanf(XenDevice *xendev, const char *key,
98 const char *fmt, ...);
100 void xen_device_set_max_grant_refs(XenDevice *xendev, unsigned int nr_refs,
101 Error **errp);
102 void *xen_device_map_grant_refs(XenDevice *xendev, uint32_t *refs,
103 unsigned int nr_refs, int prot,
104 Error **errp);
105 void xen_device_unmap_grant_refs(XenDevice *xendev, void *map,
106 unsigned int nr_refs, Error **errp);
108 typedef struct XenDeviceGrantCopySegment {
109 union {
110 void *virt;
111 struct {
112 uint32_t ref;
113 off_t offset;
114 } foreign;
115 } source, dest;
116 size_t len;
117 } XenDeviceGrantCopySegment;
119 void xen_device_copy_grant_refs(XenDevice *xendev, bool to_domain,
120 XenDeviceGrantCopySegment segs[],
121 unsigned int nr_segs, Error **errp);
123 typedef bool (*XenEventHandler)(void *opaque);
125 XenEventChannel *xen_device_bind_event_channel(XenDevice *xendev,
126 unsigned int port,
127 XenEventHandler handler,
128 void *opaque, Error **errp);
129 void xen_device_set_event_channel_context(XenDevice *xendev,
130 XenEventChannel *channel,
131 AioContext *ctx,
132 Error **errp);
133 void xen_device_notify_event_channel(XenDevice *xendev,
134 XenEventChannel *channel,
135 Error **errp);
136 void xen_device_unbind_event_channel(XenDevice *xendev,
137 XenEventChannel *channel,
138 Error **errp);
140 #endif /* HW_XEN_BUS_H */