| 1 | #ifndef HW_XEN_LEGACY_BACKEND_H |
| 2 | #define HW_XEN_LEGACY_BACKEND_H |
| 3 | |
| 4 | #include "hw/xen/xen_backend_ops.h" |
| 5 | #include "hw/xen/xen_pvdev.h" |
| 6 | #include "qom/object.h" |
| 7 | |
| 8 | #define TYPE_XENSYSDEV "xen-sysdev" |
| 9 | #define TYPE_XENSYSBUS "xen-sysbus" |
| 10 | #define TYPE_XENBACKEND "xen-backend" |
| 11 | |
| 12 | typedef struct XenLegacyDevice XenLegacyDevice; |
| 13 | DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND, |
| 14 | TYPE_XENBACKEND) |
| 15 | |
| 16 | /* variables */ |
| 17 | extern struct qemu_xs_handle *xenstore; |
| 18 | extern const char *xen_protocol; |
| 19 | extern DeviceState *xen_sysdev; |
| 20 | extern BusState *xen_sysbus; |
| 21 | |
| 22 | int xenstore_mkdir(char *path, int p); |
| 23 | int xenstore_write_be_str(struct XenLegacyDevice *xendev, const char *node, |
| 24 | const char *val); |
| 25 | int xenstore_write_be_int(struct XenLegacyDevice *xendev, const char *node, |
| 26 | int ival); |
| 27 | int xenstore_write_be_int64(struct XenLegacyDevice *xendev, const char *node, |
| 28 | int64_t ival); |
| 29 | char *xenstore_read_be_str(struct XenLegacyDevice *xendev, const char *node); |
| 30 | int xenstore_read_be_int(struct XenLegacyDevice *xendev, const char *node, |
| 31 | int *ival); |
| 32 | char *xenstore_read_fe_str(struct XenLegacyDevice *xendev, const char *node); |
| 33 | int xenstore_read_fe_int(struct XenLegacyDevice *xendev, const char *node, |
| 34 | int *ival); |
| 35 | int xenstore_read_fe_uint64(struct XenLegacyDevice *xendev, const char *node, |
| 36 | uint64_t *uval); |
| 37 | |
| 38 | void xen_be_check_state(struct XenLegacyDevice *xendev); |
| 39 | |
| 40 | /* xen backend driver bits */ |
| 41 | void xen_be_init(void); |
| 42 | int xen_be_register(const char *type, const struct XenDevOps *ops); |
| 43 | int xen_be_set_state(struct XenLegacyDevice *xendev, enum xenbus_state state); |
| 44 | int xen_be_bind_evtchn(struct XenLegacyDevice *xendev); |
| 45 | void xen_be_set_max_grant_refs(struct XenLegacyDevice *xendev, |
| 46 | unsigned int nr_refs); |
| 47 | void *xen_be_map_grant_refs(struct XenLegacyDevice *xendev, uint32_t *refs, |
| 48 | unsigned int nr_refs, int prot); |
| 49 | void xen_be_unmap_grant_refs(struct XenLegacyDevice *xendev, void *ptr, |
| 50 | uint32_t *refs, unsigned int nr_refs); |
| 51 | |
| 52 | static inline void *xen_be_map_grant_ref(struct XenLegacyDevice *xendev, |
| 53 | uint32_t ref, int prot) |
| 54 | { |
| 55 | return xen_be_map_grant_refs(xendev, &ref, 1, prot); |
| 56 | } |
| 57 | |
| 58 | static inline void xen_be_unmap_grant_ref(struct XenLegacyDevice *xendev, |
| 59 | void *ptr, uint32_t ref) |
| 60 | { |
| 61 | return xen_be_unmap_grant_refs(xendev, ptr, &ref, 1); |
| 62 | } |
| 63 | |
| 64 | /* configuration (aka xenbus setup) */ |
| 65 | void xen_config_cleanup(void); |
| 66 | int xen_config_dev_vfb(int vdev, const char *type); |
| 67 | int xen_config_dev_vkbd(int vdev); |
| 68 | |
| 69 | #endif /* HW_XEN_LEGACY_BACKEND_H */ |