]>
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" |
d94f9486 AL |
6 | |
7 | /* ------------------------------------------------------------- */ | |
8 | ||
9 | #define XEN_BUFSIZE 1024 | |
10 | ||
11 | struct XenDevice; | |
12 | ||
13 | /* driver uses grant tables -> open gntdev device (xendev->gnttabdev) */ | |
14 | #define DEVOPS_FLAG_NEED_GNTDEV 1 | |
15 | /* don't expect frontend doing correct state transitions (aka console quirk) */ | |
16 | #define DEVOPS_FLAG_IGNORE_STATE 2 | |
17 | ||
18 | struct XenDevOps { | |
19 | size_t size; | |
20 | uint32_t flags; | |
21 | void (*alloc)(struct XenDevice *xendev); | |
22 | int (*init)(struct XenDevice *xendev); | |
23 | int (*connect)(struct XenDevice *xendev); | |
24 | void (*event)(struct XenDevice *xendev); | |
25 | void (*disconnect)(struct XenDevice *xendev); | |
26 | int (*free)(struct XenDevice *xendev); | |
27 | void (*backend_changed)(struct XenDevice *xendev, const char *node); | |
28 | void (*frontend_changed)(struct XenDevice *xendev, const char *node); | |
29 | }; | |
30 | ||
31 | struct XenDevice { | |
32 | const char *type; | |
33 | int dom; | |
34 | int dev; | |
35 | char name[64]; | |
36 | int debug; | |
37 | ||
38 | enum xenbus_state be_state; | |
39 | enum xenbus_state fe_state; | |
40 | int online; | |
41 | char be[XEN_BUFSIZE]; | |
42 | char *fe; | |
43 | char *protocol; | |
44 | int remote_port; | |
45 | int local_port; | |
46 | ||
47 | int evtchndev; | |
48 | int gnttabdev; | |
49 | ||
50 | struct XenDevOps *ops; | |
51 | TAILQ_ENTRY(XenDevice) next; | |
52 | }; | |
53 | ||
54 | /* ------------------------------------------------------------- */ | |
55 | ||
56 | /* variables */ | |
57 | extern int xen_xc; | |
58 | extern struct xs_handle *xenstore; | |
59 | ||
60 | /* xenstore helper functions */ | |
61 | int xenstore_write_str(const char *base, const char *node, const char *val); | |
62 | int xenstore_write_int(const char *base, const char *node, int ival); | |
63 | char *xenstore_read_str(const char *base, const char *node); | |
64 | int xenstore_read_int(const char *base, const char *node, int *ival); | |
65 | ||
66 | int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val); | |
67 | int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival); | |
68 | char *xenstore_read_be_str(struct XenDevice *xendev, const char *node); | |
69 | int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival); | |
70 | char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node); | |
71 | int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival); | |
72 | ||
73 | const char *xenbus_strstate(enum xenbus_state state); | |
74 | struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev); | |
75 | void xen_be_check_state(struct XenDevice *xendev); | |
76 | ||
77 | /* xen backend driver bits */ | |
78 | int xen_be_init(void); | |
79 | int xen_be_register(const char *type, struct XenDevOps *ops); | |
80 | int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state); | |
81 | int xen_be_bind_evtchn(struct XenDevice *xendev); | |
82 | void xen_be_unbind_evtchn(struct XenDevice *xendev); | |
83 | int xen_be_send_notify(struct XenDevice *xendev); | |
84 | void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...) | |
85 | __attribute__ ((format(printf, 3, 4))); | |
86 | ||
e57dd20b AL |
87 | /* actual backend drivers */ |
88 | extern struct XenDevOps xen_console_ops; /* xen_console.c */ | |
e7151f83 AL |
89 | extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */ |
90 | extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */ | |
62d23efa | 91 | extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */ |
e7151f83 AL |
92 | |
93 | void xen_init_display(int domid); | |
e57dd20b | 94 | |
d94f9486 | 95 | #endif /* QEMU_HW_XEN_BACKEND_H */ |