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