1 #ifndef HW_XEN_LEGACY_BACKEND_H
2 #define HW_XEN_LEGACY_BACKEND_H
4 #include "hw/xen/xen_backend_ops.h"
5 #include "hw/xen/xen_pvdev.h"
7 #include "qom/object.h"
9 #define TYPE_XENSYSDEV "xen-sysdev"
10 #define TYPE_XENSYSBUS "xen-sysbus"
11 #define TYPE_XENBACKEND "xen-backend"
13 typedef struct XenLegacyDevice XenLegacyDevice
;
14 DECLARE_INSTANCE_CHECKER(XenLegacyDevice
, XENBACKEND
,
18 extern struct qemu_xs_handle
*xenstore
;
19 extern const char *xen_protocol
;
20 extern DeviceState
*xen_sysdev
;
21 extern BusState
*xen_sysbus
;
23 int xenstore_mkdir(char *path
, int p
);
24 int xenstore_write_be_str(struct XenLegacyDevice
*xendev
, const char *node
,
26 int xenstore_write_be_int(struct XenLegacyDevice
*xendev
, const char *node
,
28 int xenstore_write_be_int64(struct XenLegacyDevice
*xendev
, const char *node
,
30 char *xenstore_read_be_str(struct XenLegacyDevice
*xendev
, const char *node
);
31 int xenstore_read_be_int(struct XenLegacyDevice
*xendev
, const char *node
,
33 char *xenstore_read_fe_str(struct XenLegacyDevice
*xendev
, const char *node
);
34 int xenstore_read_fe_int(struct XenLegacyDevice
*xendev
, const char *node
,
36 int xenstore_read_fe_uint64(struct XenLegacyDevice
*xendev
, const char *node
,
39 void xen_be_check_state(struct XenLegacyDevice
*xendev
);
41 /* xen backend driver bits */
42 void xen_be_init(void);
43 int xen_be_register(const char *type
, struct XenDevOps
*ops
);
44 int xen_be_set_state(struct XenLegacyDevice
*xendev
, enum xenbus_state state
);
45 int xen_be_bind_evtchn(struct XenLegacyDevice
*xendev
);
46 void xen_be_set_max_grant_refs(struct XenLegacyDevice
*xendev
,
47 unsigned int nr_refs
);
48 void *xen_be_map_grant_refs(struct XenLegacyDevice
*xendev
, uint32_t *refs
,
49 unsigned int nr_refs
, int prot
);
50 void xen_be_unmap_grant_refs(struct XenLegacyDevice
*xendev
, void *ptr
,
51 uint32_t *refs
, unsigned int nr_refs
);
53 int xen_be_copy_grant_refs(struct XenLegacyDevice
*xendev
,
54 bool to_domain
, XenGrantCopySegment segs
[],
55 unsigned int nr_segs
);
57 static inline void *xen_be_map_grant_ref(struct XenLegacyDevice
*xendev
,
58 uint32_t ref
, int prot
)
60 return xen_be_map_grant_refs(xendev
, &ref
, 1, prot
);
63 static inline void xen_be_unmap_grant_ref(struct XenLegacyDevice
*xendev
,
64 void *ptr
, uint32_t ref
)
66 return xen_be_unmap_grant_refs(xendev
, ptr
, &ref
, 1);
69 /* actual backend drivers */
70 extern struct XenDevOps xen_console_ops
; /* xen_console.c */
71 extern struct XenDevOps xen_kbdmouse_ops
; /* xen_framebuffer.c */
72 extern struct XenDevOps xen_framebuffer_ops
; /* xen_framebuffer.c */
73 extern struct XenDevOps xen_blkdev_ops
; /* xen_disk.c */
75 extern struct XenDevOps xen_9pfs_ops
; /* xen-9p-backend.c */
77 extern struct XenDevOps xen_netdev_ops
; /* xen_nic.c */
78 #ifdef CONFIG_USB_LIBUSB
79 extern struct XenDevOps xen_usb_ops
; /* xen-usb.c */
82 /* configuration (aka xenbus setup) */
83 void xen_config_cleanup(void);
84 int xen_config_dev_nic(NICInfo
*nic
);
85 int xen_config_dev_vfb(int vdev
, const char *type
);
86 int xen_config_dev_vkbd(int vdev
);
87 int xen_config_dev_console(int vdev
);
89 #endif /* HW_XEN_LEGACY_BACKEND_H */