1 #ifndef QEMU_HW_XEN_PVDEV_H
2 #define QEMU_HW_XEN_PVDEV_H
4 #include "hw/qdev-core.h"
5 #include "hw/xen/xen_backend_ops.h"
7 /* ------------------------------------------------------------- */
9 #define XEN_BUFSIZE 1024
11 struct XenLegacyDevice
;
13 /* driver uses grant tables -> open gntdev device (xendev->gnttabdev) */
14 #define DEVOPS_FLAG_NEED_GNTDEV 1
15 /* don't expect frontend doing correct state transitions (aka console quirk) */
16 #define DEVOPS_FLAG_IGNORE_STATE 2
21 void (*alloc
)(struct XenLegacyDevice
*xendev
);
22 int (*init
)(struct XenLegacyDevice
*xendev
);
23 int (*initialise
)(struct XenLegacyDevice
*xendev
);
24 void (*connected
)(struct XenLegacyDevice
*xendev
);
25 void (*event
)(struct XenLegacyDevice
*xendev
);
26 void (*disconnect
)(struct XenLegacyDevice
*xendev
);
27 int (*free
)(struct XenLegacyDevice
*xendev
);
28 void (*backend_changed
)(struct XenLegacyDevice
*xendev
,
30 void (*frontend_changed
)(struct XenLegacyDevice
*xendev
,
32 int (*backend_register
)(void);
35 struct XenLegacyDevice
{
43 struct qemu_xs_watch
*watch
;
44 enum xenbus_state be_state
;
45 enum xenbus_state fe_state
;
53 xenevtchn_handle
*evtchndev
;
54 xengnttab_handle
*gnttabdev
;
56 struct XenDevOps
*ops
;
57 QTAILQ_ENTRY(XenLegacyDevice
) next
;
60 /* ------------------------------------------------------------- */
62 /* xenstore helper functions */
63 int xenstore_write_str(const char *base
, const char *node
, const char *val
);
64 int xenstore_write_int(const char *base
, const char *node
, int ival
);
65 int xenstore_write_int64(const char *base
, const char *node
, int64_t ival
);
66 char *xenstore_read_str(const char *base
, const char *node
);
67 int xenstore_read_int(const char *base
, const char *node
, int *ival
);
68 int xenstore_read_uint64(const char *base
, const char *node
, uint64_t *uval
);
70 const char *xenbus_strstate(enum xenbus_state state
);
72 void xen_pv_evtchn_event(void *opaque
);
73 void xen_pv_insert_xendev(struct XenLegacyDevice
*xendev
);
74 void xen_pv_del_xendev(struct XenLegacyDevice
*xendev
);
75 struct XenLegacyDevice
*xen_pv_find_xendev(const char *type
, int dom
, int dev
);
77 void xen_pv_unbind_evtchn(struct XenLegacyDevice
*xendev
);
78 int xen_pv_send_notify(struct XenLegacyDevice
*xendev
);
80 void xen_pv_printf(struct XenLegacyDevice
*xendev
, int msg_level
,
81 const char *fmt
, ...) G_GNUC_PRINTF(3, 4);
83 #endif /* QEMU_HW_XEN_PVDEV_H */