uhci: dynamic type generation
[qemu/opensuse.git] / hw / xen_backend.h
blobfea86dd78bd0be28bfecb5ec2fe78440238069e8
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"
7 #include "net/hub.h"
9 /* ------------------------------------------------------------- */
11 #define XEN_BUFSIZE 1024
13 struct XenDevice;
15 /* driver uses grant tables -> open gntdev device (xendev->gnttabdev) */
16 #define DEVOPS_FLAG_NEED_GNTDEV 1
17 /* don't expect frontend doing correct state transitions (aka console quirk) */
18 #define DEVOPS_FLAG_IGNORE_STATE 2
20 struct XenDevOps {
21 size_t size;
22 uint32_t flags;
23 void (*alloc)(struct XenDevice *xendev);
24 int (*init)(struct XenDevice *xendev);
25 int (*initialise)(struct XenDevice *xendev);
26 void (*connected)(struct XenDevice *xendev);
27 void (*event)(struct XenDevice *xendev);
28 void (*disconnect)(struct XenDevice *xendev);
29 int (*free)(struct XenDevice *xendev);
30 void (*backend_changed)(struct XenDevice *xendev, const char *node);
31 void (*frontend_changed)(struct XenDevice *xendev, const char *node);
34 struct XenDevice {
35 const char *type;
36 int dom;
37 int dev;
38 char name[64];
39 int debug;
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;
50 XenEvtchn evtchndev;
51 XenGnttab gnttabdev;
53 struct XenDevOps *ops;
54 QTAILQ_ENTRY(XenDevice) next;
57 /* ------------------------------------------------------------- */
59 /* variables */
60 extern XenXC xen_xc;
61 extern struct xs_handle *xenstore;
62 extern const char *xen_protocol;
64 /* xenstore helper functions */
65 int xenstore_write_str(const char *base, const char *node, const char *val);
66 int xenstore_write_int(const char *base, const char *node, int ival);
67 char *xenstore_read_str(const char *base, const char *node);
68 int xenstore_read_int(const char *base, const char *node, int *ival);
70 int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val);
71 int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival);
72 char *xenstore_read_be_str(struct XenDevice *xendev, const char *node);
73 int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival);
74 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
75 int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
77 const char *xenbus_strstate(enum xenbus_state state);
78 struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
79 void xen_be_check_state(struct XenDevice *xendev);
81 /* xen backend driver bits */
82 int xen_be_init(void);
83 int xen_be_register(const char *type, struct XenDevOps *ops);
84 int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state);
85 int xen_be_bind_evtchn(struct XenDevice *xendev);
86 void xen_be_unbind_evtchn(struct XenDevice *xendev);
87 int xen_be_send_notify(struct XenDevice *xendev);
88 void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
89 GCC_FMT_ATTR(3, 4);
91 /* actual backend drivers */
92 extern struct XenDevOps xen_console_ops; /* xen_console.c */
93 extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */
94 extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */
95 extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */
96 extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */
98 void xen_init_display(int domid);
100 /* configuration (aka xenbus setup) */
101 void xen_config_cleanup(void);
102 int xen_config_dev_blk(DriveInfo *disk);
103 int xen_config_dev_nic(NICInfo *nic);
104 int xen_config_dev_vfb(int vdev, const char *type);
105 int xen_config_dev_vkbd(int vdev);
106 int xen_config_dev_console(int vdev);
108 #endif /* QEMU_HW_XEN_BACKEND_H */