1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#ifndef _XENBUS_XENBUS_H
33#define _XENBUS_XENBUS_H
34
35#include <linux/mutex.h>
36#include <linux/uio.h>
37#include <xen/xenbus.h>
38
39#define XEN_BUS_ID_SIZE 20
40
41struct xen_bus_type {
42 char *root;
43 unsigned int levels;
44 int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename);
45 int (*probe)(struct xen_bus_type *bus, const char *type,
46 const char *dir);
47 void (*otherend_changed)(struct xenbus_watch *watch, const char *path,
48 const char *token);
49 struct bus_type bus;
50};
51
52enum xenstore_init {
53 XS_UNKNOWN,
54 XS_PV,
55 XS_HVM,
56 XS_LOCAL,
57};
58
59struct xs_watch_event {
60 struct list_head list;
61 unsigned int len;
62 struct xenbus_watch *handle;
63 const char *path;
64 const char *token;
65 char body[];
66};
67
68enum xb_req_state {
69 xb_req_state_queued,
70 xb_req_state_wait_reply,
71 xb_req_state_got_reply,
72 xb_req_state_aborted
73};
74
75struct xb_req_data {
76 struct list_head list;
77 wait_queue_head_t wq;
78 struct xsd_sockmsg msg;
79 uint32_t caller_req_id;
80 enum xsd_sockmsg_type type;
81 char *body;
82 const struct kvec *vec;
83 int num_vecs;
84 int err;
85 enum xb_req_state state;
86 bool user_req;
87 void (*cb)(struct xb_req_data *);
88 void *par;
89};
90
91extern enum xenstore_init xen_store_domain_type;
92extern const struct attribute_group *xenbus_dev_groups[];
93extern struct mutex xs_response_mutex;
94extern struct list_head xs_reply_list;
95extern struct list_head xb_write_list;
96extern wait_queue_head_t xb_waitq;
97extern struct mutex xb_write_mutex;
98
99int xs_init(void);
100int xb_init_comms(void);
101void xb_deinit_comms(void);
102int xs_watch_msg(struct xs_watch_event *event);
103void xs_request_exit(struct xb_req_data *req);
104
105int xenbus_match(struct device *_dev, struct device_driver *_drv);
106int xenbus_dev_probe(struct device *_dev);
107int xenbus_dev_remove(struct device *_dev);
108int xenbus_register_driver_common(struct xenbus_driver *drv,
109 struct xen_bus_type *bus,
110 struct module *owner,
111 const char *mod_name);
112int xenbus_probe_node(struct xen_bus_type *bus,
113 const char *type,
114 const char *nodename);
115int xenbus_probe_devices(struct xen_bus_type *bus);
116
117void xenbus_dev_changed(const char *node, struct xen_bus_type *bus);
118
119int xenbus_dev_suspend(struct device *dev);
120int xenbus_dev_resume(struct device *dev);
121int xenbus_dev_cancel(struct device *dev);
122
123void xenbus_otherend_changed(struct xenbus_watch *watch,
124 const char *path, const char *token,
125 int ignore_on_shutdown);
126
127int xenbus_read_otherend_details(struct xenbus_device *xendev,
128 char *id_node, char *path_node);
129
130void xenbus_ring_ops_init(void);
131
132int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par);
133void xenbus_dev_queue_reply(struct xb_req_data *req);
134
135extern unsigned int xb_dev_generation_id;
136
137#endif
138