1 #ifndef QEMU_HW_XEN_PVDEV_H 2 #define QEMU_HW_XEN_PVDEV_H 3 4 #include "hw/xen/xen_common.h" 5 /* ------------------------------------------------------------- */ 6 7 #define XEN_BUFSIZE 1024 8 9 struct XenLegacyDevice; 10 11 /* driver uses grant tables -> open gntdev device (xendev->gnttabdev) */ 12 #define DEVOPS_FLAG_NEED_GNTDEV 1 13 /* don't expect frontend doing correct state transitions (aka console quirk) */ 14 #define DEVOPS_FLAG_IGNORE_STATE 2 15 16 struct XenDevOps { 17 size_t size; 18 uint32_t flags; 19 void (*alloc)(struct XenLegacyDevice *xendev); 20 int (*init)(struct XenLegacyDevice *xendev); 21 int (*initialise)(struct XenLegacyDevice *xendev); 22 void (*connected)(struct XenLegacyDevice *xendev); 23 void (*event)(struct XenLegacyDevice *xendev); 24 void (*disconnect)(struct XenLegacyDevice *xendev); 25 int (*free)(struct XenLegacyDevice *xendev); 26 void (*backend_changed)(struct XenLegacyDevice *xendev, 27 const char *node); 28 void (*frontend_changed)(struct XenLegacyDevice *xendev, 29 const char *node); 30 int (*backend_register)(void); 31 }; 32 33 struct XenLegacyDevice { 34 DeviceState qdev; 35 const char *type; 36 int dom; 37 int dev; 38 char name[64]; 39 int debug; 40 41 enum xenbus_state be_state; 42 enum xenbus_state fe_state; 43 int online; 44 char be[XEN_BUFSIZE]; 45 char *fe; 46 char *protocol; 47 int remote_port; 48 int local_port; 49 50 xenevtchn_handle *evtchndev; 51 xengnttab_handle *gnttabdev; 52 53 struct XenDevOps *ops; 54 QTAILQ_ENTRY(XenLegacyDevice) next; 55 }; 56 57 /* ------------------------------------------------------------- */ 58 59 /* xenstore helper functions */ 60 int xenstore_write_str(const char *base, const char *node, const char *val); 61 int xenstore_write_int(const char *base, const char *node, int ival); 62 int xenstore_write_int64(const char *base, const char *node, int64_t ival); 63 char *xenstore_read_str(const char *base, const char *node); 64 int xenstore_read_int(const char *base, const char *node, int *ival); 65 int xenstore_read_uint64(const char *base, const char *node, uint64_t *uval); 66 void xenstore_update(void *unused); 67 68 const char *xenbus_strstate(enum xenbus_state state); 69 70 void xen_pv_evtchn_event(void *opaque); 71 void xen_pv_insert_xendev(struct XenLegacyDevice *xendev); 72 void xen_pv_del_xendev(struct XenLegacyDevice *xendev); 73 struct XenLegacyDevice *xen_pv_find_xendev(const char *type, int dom, int dev); 74 75 void xen_pv_unbind_evtchn(struct XenLegacyDevice *xendev); 76 int xen_pv_send_notify(struct XenLegacyDevice *xendev); 77 78 void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level, 79 const char *fmt, ...) GCC_FMT_ATTR(3, 4); 80 81 #endif /* QEMU_HW_XEN_PVDEV_H */ 82