ditto for etraxfs_ser.c
[qemu/aliguori.git] / hw / xen_backend.h
blob6401c85a7eaadc2e791a7598a19baa2fc00a411b
1 #ifndef QEMU_HW_XEN_BACKEND_H
2 #define QEMU_HW_XEN_BACKEND_H 1
4 #include "xen_common.h"
5 #include "sysemu.h"
6 #include "net.h"
8 /* ------------------------------------------------------------- */
10 #define XEN_BUFSIZE 1024
12 struct XenDevice;
14 /* driver uses grant tables -> open gntdev device (xendev->gnttabdev) */
15 #define DEVOPS_FLAG_NEED_GNTDEV 1
16 /* don't expect frontend doing correct state transitions (aka console quirk) */
17 #define DEVOPS_FLAG_IGNORE_STATE 2
19 struct XenDevOps {
20 size_t size;
21 uint32_t flags;
22 void (*alloc)(struct XenDevice *xendev);
23 int (*init)(struct XenDevice *xendev);
24 int (*connect)(struct XenDevice *xendev);
25 void (*event)(struct XenDevice *xendev);
26 void (*disconnect)(struct XenDevice *xendev);
27 int (*free)(struct XenDevice *xendev);
28 void (*backend_changed)(struct XenDevice *xendev, const char *node);
29 void (*frontend_changed)(struct XenDevice *xendev, const char *node);
32 struct XenDevice {
33 const char *type;
34 int dom;
35 int dev;
36 char name[64];
37 int debug;
39 enum xenbus_state be_state;
40 enum xenbus_state fe_state;
41 int online;
42 char be[XEN_BUFSIZE];
43 char *fe;
44 char *protocol;
45 int remote_port;
46 int local_port;
48 XenEvtchn evtchndev;
49 XenGnttab gnttabdev;
51 struct XenDevOps *ops;
52 QTAILQ_ENTRY(XenDevice) next;
55 /* ------------------------------------------------------------- */
57 /* variables */
58 extern XenXC xen_xc;
59 extern struct xs_handle *xenstore;
60 extern const char *xen_protocol;
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 char *xenstore_read_str(const char *base, const char *node);
66 int xenstore_read_int(const char *base, const char *node, int *ival);
68 int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val);
69 int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival);
70 char *xenstore_read_be_str(struct XenDevice *xendev, const char *node);
71 int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival);
72 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
73 int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
75 const char *xenbus_strstate(enum xenbus_state state);
76 struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
77 void xen_be_check_state(struct XenDevice *xendev);
79 /* xen backend driver bits */
80 int xen_be_init(void);
81 int xen_be_register(const char *type, struct XenDevOps *ops);
82 int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state);
83 int xen_be_bind_evtchn(struct XenDevice *xendev);
84 void xen_be_unbind_evtchn(struct XenDevice *xendev);
85 int xen_be_send_notify(struct XenDevice *xendev);
86 void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
87 GCC_FMT_ATTR(3, 4);
89 /* actual backend drivers */
90 extern struct XenDevOps xen_console_ops; /* xen_console.c */
91 extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */
92 extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */
93 extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */
94 extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */
96 void xen_init_display(int domid);
98 /* configuration (aka xenbus setup) */
99 void xen_config_cleanup(void);
100 int xen_config_dev_blk(DriveInfo *disk);
101 int xen_config_dev_nic(NICInfo *nic);
102 int xen_config_dev_vfb(int vdev, const char *type);
103 int xen_config_dev_vkbd(int vdev);
104 int xen_config_dev_console(int vdev);
106 #endif /* QEMU_HW_XEN_BACKEND_H */