root / hw / xen_backend.h @ b4b784fe
History | View | Annotate | Download (3.8 kB)
1 | d94f9486 | aliguori | #ifndef QEMU_HW_XEN_BACKEND_H
|
---|---|---|---|
2 | d94f9486 | aliguori | #define QEMU_HW_XEN_BACKEND_H 1 |
3 | d94f9486 | aliguori | |
4 | d94f9486 | aliguori | #include "xen_common.h" |
5 | 62d23efa | aliguori | #include "sysemu.h" |
6 | 2c8b24a3 | aliguori | #include "net.h" |
7 | 2c8b24a3 | aliguori | #include "block_int.h" |
8 | d94f9486 | aliguori | |
9 | d94f9486 | aliguori | /* ------------------------------------------------------------- */
|
10 | d94f9486 | aliguori | |
11 | d94f9486 | aliguori | #define XEN_BUFSIZE 1024 |
12 | d94f9486 | aliguori | |
13 | d94f9486 | aliguori | struct XenDevice;
|
14 | d94f9486 | aliguori | |
15 | d94f9486 | aliguori | /* driver uses grant tables -> open gntdev device (xendev->gnttabdev) */
|
16 | d94f9486 | aliguori | #define DEVOPS_FLAG_NEED_GNTDEV 1 |
17 | d94f9486 | aliguori | /* don't expect frontend doing correct state transitions (aka console quirk) */
|
18 | d94f9486 | aliguori | #define DEVOPS_FLAG_IGNORE_STATE 2 |
19 | d94f9486 | aliguori | |
20 | d94f9486 | aliguori | struct XenDevOps {
|
21 | d94f9486 | aliguori | size_t size; |
22 | d94f9486 | aliguori | uint32_t flags; |
23 | d94f9486 | aliguori | void (*alloc)(struct XenDevice *xendev); |
24 | d94f9486 | aliguori | int (*init)(struct XenDevice *xendev); |
25 | d94f9486 | aliguori | int (*connect)(struct XenDevice *xendev); |
26 | d94f9486 | aliguori | void (*event)(struct XenDevice *xendev); |
27 | d94f9486 | aliguori | void (*disconnect)(struct XenDevice *xendev); |
28 | d94f9486 | aliguori | int (*free)(struct XenDevice *xendev); |
29 | d94f9486 | aliguori | void (*backend_changed)(struct XenDevice *xendev, const char *node); |
30 | d94f9486 | aliguori | void (*frontend_changed)(struct XenDevice *xendev, const char *node); |
31 | d94f9486 | aliguori | }; |
32 | d94f9486 | aliguori | |
33 | d94f9486 | aliguori | struct XenDevice {
|
34 | d94f9486 | aliguori | const char *type; |
35 | d94f9486 | aliguori | int dom;
|
36 | d94f9486 | aliguori | int dev;
|
37 | d94f9486 | aliguori | char name[64]; |
38 | d94f9486 | aliguori | int debug;
|
39 | d94f9486 | aliguori | |
40 | d94f9486 | aliguori | enum xenbus_state be_state;
|
41 | d94f9486 | aliguori | enum xenbus_state fe_state;
|
42 | d94f9486 | aliguori | int online;
|
43 | d94f9486 | aliguori | char be[XEN_BUFSIZE];
|
44 | d94f9486 | aliguori | char *fe;
|
45 | d94f9486 | aliguori | char *protocol;
|
46 | d94f9486 | aliguori | int remote_port;
|
47 | d94f9486 | aliguori | int local_port;
|
48 | d94f9486 | aliguori | |
49 | d94f9486 | aliguori | int evtchndev;
|
50 | d94f9486 | aliguori | int gnttabdev;
|
51 | d94f9486 | aliguori | |
52 | d94f9486 | aliguori | struct XenDevOps *ops;
|
53 | 72cf2d4f | Blue Swirl | QTAILQ_ENTRY(XenDevice) next; |
54 | d94f9486 | aliguori | }; |
55 | d94f9486 | aliguori | |
56 | d94f9486 | aliguori | /* ------------------------------------------------------------- */
|
57 | d94f9486 | aliguori | |
58 | d94f9486 | aliguori | /* variables */
|
59 | d94f9486 | aliguori | extern int xen_xc; |
60 | d94f9486 | aliguori | extern struct xs_handle *xenstore; |
61 | 2c8b24a3 | aliguori | extern const char *xen_protocol; |
62 | d94f9486 | aliguori | |
63 | d94f9486 | aliguori | /* xenstore helper functions */
|
64 | d94f9486 | aliguori | int xenstore_write_str(const char *base, const char *node, const char *val); |
65 | d94f9486 | aliguori | int xenstore_write_int(const char *base, const char *node, int ival); |
66 | d94f9486 | aliguori | char *xenstore_read_str(const char *base, const char *node); |
67 | d94f9486 | aliguori | int xenstore_read_int(const char *base, const char *node, int *ival); |
68 | d94f9486 | aliguori | |
69 | d94f9486 | aliguori | int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val); |
70 | d94f9486 | aliguori | int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival); |
71 | d94f9486 | aliguori | char *xenstore_read_be_str(struct XenDevice *xendev, const char *node); |
72 | d94f9486 | aliguori | int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival); |
73 | d94f9486 | aliguori | char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node); |
74 | d94f9486 | aliguori | int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival); |
75 | d94f9486 | aliguori | |
76 | d94f9486 | aliguori | const char *xenbus_strstate(enum xenbus_state state); |
77 | d94f9486 | aliguori | struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev); |
78 | d94f9486 | aliguori | void xen_be_check_state(struct XenDevice *xendev); |
79 | d94f9486 | aliguori | |
80 | d94f9486 | aliguori | /* xen backend driver bits */
|
81 | d94f9486 | aliguori | int xen_be_init(void); |
82 | d94f9486 | aliguori | int xen_be_register(const char *type, struct XenDevOps *ops); |
83 | d94f9486 | aliguori | int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state); |
84 | d94f9486 | aliguori | int xen_be_bind_evtchn(struct XenDevice *xendev); |
85 | d94f9486 | aliguori | void xen_be_unbind_evtchn(struct XenDevice *xendev); |
86 | d94f9486 | aliguori | int xen_be_send_notify(struct XenDevice *xendev); |
87 | d94f9486 | aliguori | void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...) |
88 | d94f9486 | aliguori | __attribute__ ((format(printf, 3, 4))); |
89 | d94f9486 | aliguori | |
90 | e57dd20b | aliguori | /* actual backend drivers */
|
91 | e57dd20b | aliguori | extern struct XenDevOps xen_console_ops; /* xen_console.c */ |
92 | e7151f83 | aliguori | extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */ |
93 | e7151f83 | aliguori | extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */ |
94 | 62d23efa | aliguori | extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */ |
95 | e613b064 | aliguori | extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */ |
96 | e7151f83 | aliguori | |
97 | e7151f83 | aliguori | void xen_init_display(int domid); |
98 | e57dd20b | aliguori | |
99 | 2c8b24a3 | aliguori | /* configuration (aka xenbus setup) */
|
100 | 2c8b24a3 | aliguori | void xen_config_cleanup(void); |
101 | 2c8b24a3 | aliguori | int xen_config_dev_blk(DriveInfo *disk);
|
102 | 2c8b24a3 | aliguori | int xen_config_dev_nic(NICInfo *nic);
|
103 | 9306acb5 | aliguori | int xen_config_dev_vfb(int vdev, const char *type); |
104 | 9306acb5 | aliguori | int xen_config_dev_vkbd(int vdev); |
105 | 9306acb5 | aliguori | int xen_config_dev_console(int vdev); |
106 | 2c8b24a3 | aliguori | |
107 | d94f9486 | aliguori | #endif /* QEMU_HW_XEN_BACKEND_H */ |