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