1 #ifndef QEMU_HW_XEN_BACKEND_H 2 #define QEMU_HW_XEN_BACKEND_H 3 4 #include "hw/xen/xen_common.h" 5 #include "hw/xen/xen_pvdev.h" 6 #include "sysemu/sysemu.h" 7 #include "net/net.h" 8 9 #define TYPE_XENSYSDEV "xen-sysdev" 10 #define TYPE_XENSYSBUS "xen-sysbus" 11 #define TYPE_XENBACKEND "xen-backend" 12 13 #define XENBACKEND_DEVICE(obj) \ 14 OBJECT_CHECK(XenLegacyDevice, (obj), TYPE_XENBACKEND) 15 16 /* variables */ 17 extern struct 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 void xenstore_update_fe(char *watch, struct XenLegacyDevice *xendev); 33 void xenstore_update_be(char *watch, char *type, int dom, 34 struct XenDevOps *ops); 35 char *xenstore_read_fe_str(struct XenLegacyDevice *xendev, const char *node); 36 int xenstore_read_fe_int(struct XenLegacyDevice *xendev, const char *node, 37 int *ival); 38 int xenstore_read_fe_uint64(struct XenLegacyDevice *xendev, const char *node, 39 uint64_t *uval); 40 41 void xen_be_check_state(struct XenLegacyDevice *xendev); 42 43 /* xen backend driver bits */ 44 int xen_be_init(void); 45 void xen_be_register_common(void); 46 int xen_be_register(const char *type, struct XenDevOps *ops); 47 int xen_be_set_state(struct XenLegacyDevice *xendev, enum xenbus_state state); 48 int xen_be_bind_evtchn(struct XenLegacyDevice *xendev); 49 void xen_be_set_max_grant_refs(struct XenLegacyDevice *xendev, 50 unsigned int nr_refs); 51 void *xen_be_map_grant_refs(struct XenLegacyDevice *xendev, uint32_t *refs, 52 unsigned int nr_refs, int prot); 53 void xen_be_unmap_grant_refs(struct XenLegacyDevice *xendev, void *ptr, 54 unsigned int nr_refs); 55 56 typedef struct XenGrantCopySegment { 57 union { 58 void *virt; 59 struct { 60 uint32_t ref; 61 off_t offset; 62 } foreign; 63 } source, dest; 64 size_t len; 65 } XenGrantCopySegment; 66 67 int xen_be_copy_grant_refs(struct XenLegacyDevice *xendev, 68 bool to_domain, XenGrantCopySegment segs[], 69 unsigned int nr_segs); 70 71 static inline void *xen_be_map_grant_ref(struct XenLegacyDevice *xendev, 72 uint32_t ref, int prot) 73 { 74 return xen_be_map_grant_refs(xendev, &ref, 1, prot); 75 } 76 77 static inline void xen_be_unmap_grant_ref(struct XenLegacyDevice *xendev, 78 void *ptr) 79 { 80 return xen_be_unmap_grant_refs(xendev, ptr, 1); 81 } 82 83 /* actual backend drivers */ 84 extern struct XenDevOps xen_console_ops; /* xen_console.c */ 85 extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */ 86 extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */ 87 extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */ 88 #ifdef CONFIG_VIRTFS 89 extern struct XenDevOps xen_9pfs_ops; /* xen-9p-backend.c */ 90 #endif 91 extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */ 92 #ifdef CONFIG_USB_LIBUSB 93 extern struct XenDevOps xen_usb_ops; /* xen-usb.c */ 94 #endif 95 96 /* configuration (aka xenbus setup) */ 97 void xen_config_cleanup(void); 98 int xen_config_dev_blk(DriveInfo *disk); 99 int xen_config_dev_nic(NICInfo *nic); 100 int xen_config_dev_vfb(int vdev, const char *type); 101 int xen_config_dev_vkbd(int vdev); 102 int xen_config_dev_console(int vdev); 103 104 #endif /* QEMU_HW_XEN_BACKEND_H */ 105