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.
11 #include "hw/xen/xen_backend_ops.h"
12 #include "hw/sysbus.h"
13 #include "qemu/notify.h"
14 #include "qom/object.h"
16 typedef struct XenEventChannel XenEventChannel
;
22 struct qemu_xs_handle
*xsh
;
23 char *backend_path
, *frontend_path
;
24 enum xenbus_state backend_state
, frontend_state
;
26 struct qemu_xs_watch
*backend_state_watch
, *frontend_state_watch
;
28 struct qemu_xs_watch
*backend_online_watch
;
29 xengnttab_handle
*xgth
;
31 QLIST_HEAD(, XenEventChannel
) event_channels
;
32 QLIST_ENTRY(XenDevice
) list
;
34 typedef struct XenDevice XenDevice
;
36 typedef char *(*XenDeviceGetName
)(XenDevice
*xendev
, Error
**errp
);
37 typedef void (*XenDeviceRealize
)(XenDevice
*xendev
, Error
**errp
);
38 typedef void (*XenDeviceFrontendChanged
)(XenDevice
*xendev
,
39 enum xenbus_state frontend_state
,
41 typedef void (*XenDeviceUnrealize
)(XenDevice
*xendev
);
43 struct XenDeviceClass
{
45 DeviceClass parent_class
;
49 XenDeviceGetName get_name
;
50 XenDeviceRealize realize
;
51 XenDeviceFrontendChanged frontend_changed
;
52 XenDeviceUnrealize unrealize
;
55 #define TYPE_XEN_DEVICE "xen-device"
56 OBJECT_DECLARE_TYPE(XenDevice
, XenDeviceClass
, XEN_DEVICE
)
61 struct qemu_xs_handle
*xsh
;
62 unsigned int backend_types
;
63 struct qemu_xs_watch
**backend_watch
;
64 QLIST_HEAD(, XenDevice
) inactive_devices
;
69 BusClass parent_class
;
72 #define TYPE_XEN_BUS "xen-bus"
73 OBJECT_DECLARE_TYPE(XenBus
, XenBusClass
,
76 void xen_bus_init(void);
78 void xen_device_backend_set_state(XenDevice
*xendev
,
79 enum xenbus_state state
);
80 enum xenbus_state
xen_device_backend_get_state(XenDevice
*xendev
);
82 void xen_device_backend_printf(XenDevice
*xendev
, const char *key
,
85 void xen_device_frontend_printf(XenDevice
*xendev
, const char *key
,
89 int xen_device_frontend_scanf(XenDevice
*xendev
, const char *key
,
93 void xen_device_set_max_grant_refs(XenDevice
*xendev
, unsigned int nr_refs
,
95 void *xen_device_map_grant_refs(XenDevice
*xendev
, uint32_t *refs
,
96 unsigned int nr_refs
, int prot
,
98 void xen_device_unmap_grant_refs(XenDevice
*xendev
, void *map
, uint32_t *refs
,
99 unsigned int nr_refs
, Error
**errp
);
101 typedef struct XenDeviceGrantCopySegment
{
110 } XenDeviceGrantCopySegment
;
112 void xen_device_copy_grant_refs(XenDevice
*xendev
, bool to_domain
,
113 XenDeviceGrantCopySegment segs
[],
114 unsigned int nr_segs
, Error
**errp
);
116 typedef bool (*XenEventHandler
)(void *opaque
);
118 XenEventChannel
*xen_device_bind_event_channel(XenDevice
*xendev
,
120 XenEventHandler handler
,
121 void *opaque
, Error
**errp
);
122 void xen_device_set_event_channel_context(XenDevice
*xendev
,
123 XenEventChannel
*channel
,
126 void xen_device_notify_event_channel(XenDevice
*xendev
,
127 XenEventChannel
*channel
,
129 void xen_device_unbind_event_channel(XenDevice
*xendev
,
130 XenEventChannel
*channel
,
133 #endif /* HW_XEN_BUS_H */