]>
Commit | Line | Data |
---|---|---|
332f791d JG |
1 | /* |
2 | * Private include for xenbus communications. | |
4bac07c9 JF |
3 | * |
4 | * Copyright (C) 2005 Rusty Russell, IBM Corporation | |
5 | * Copyright (C) 2005 XenSource Ltd. | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public License version 2 | |
9 | * as published by the Free Software Foundation; or, when distributed | |
10 | * separately from the Linux kernel or incorporated into other | |
11 | * software packages, subject to the following license: | |
12 | * | |
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
14 | * of this source file (the "Software"), to deal in the Software without | |
15 | * restriction, including without limitation the rights to use, copy, modify, | |
16 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, | |
17 | * and to permit persons to whom the Software is furnished to do so, subject to | |
18 | * the following conditions: | |
19 | * | |
20 | * The above copyright notice and this permission notice shall be included in | |
21 | * all copies or substantial portions of the Software. | |
22 | * | |
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
28 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
29 | * IN THE SOFTWARE. | |
30 | */ | |
31 | ||
332f791d JG |
32 | #ifndef _XENBUS_XENBUS_H |
33 | #define _XENBUS_XENBUS_H | |
4bac07c9 | 34 | |
fd8aa909 JG |
35 | #include <linux/mutex.h> |
36 | #include <linux/uio.h> | |
37 | #include <xen/xenbus.h> | |
38 | ||
2a678cc5 KS |
39 | #define XEN_BUS_ID_SIZE 20 |
40 | ||
822a259a | 41 | struct xen_bus_type { |
4bac07c9 JF |
42 | char *root; |
43 | unsigned int levels; | |
2a678cc5 | 44 | int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename); |
6bac7f9f IC |
45 | int (*probe)(struct xen_bus_type *bus, const char *type, |
46 | const char *dir); | |
5584ea25 JG |
47 | void (*otherend_changed)(struct xenbus_watch *watch, const char *path, |
48 | const char *token); | |
4bac07c9 JF |
49 | struct bus_type bus; |
50 | }; | |
51 | ||
33c1174b AC |
52 | enum xenstore_init { |
53 | XS_UNKNOWN, | |
54 | XS_PV, | |
55 | XS_HVM, | |
56 | XS_LOCAL, | |
57 | }; | |
58 | ||
fd8aa909 JG |
59 | struct 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 | ||
68 | enum 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 | ||
75 | struct xb_req_data { | |
76 | struct list_head list; | |
77 | wait_queue_head_t wq; | |
78 | struct xsd_sockmsg msg; | |
79 | enum xsd_sockmsg_type type; | |
80 | char *body; | |
81 | const struct kvec *vec; | |
82 | int num_vecs; | |
83 | int err; | |
84 | enum xb_req_state state; | |
85 | void (*cb)(struct xb_req_data *); | |
86 | void *par; | |
87 | }; | |
88 | ||
332f791d | 89 | extern enum xenstore_init xen_store_domain_type; |
85dd9268 | 90 | extern const struct attribute_group *xenbus_dev_groups[]; |
fd8aa909 JG |
91 | extern struct mutex xs_response_mutex; |
92 | extern struct list_head xs_reply_list; | |
93 | extern struct list_head xb_write_list; | |
94 | extern wait_queue_head_t xb_waitq; | |
95 | extern struct mutex xb_write_mutex; | |
cc85e933 | 96 | |
332f791d JG |
97 | int xs_init(void); |
98 | int xb_init_comms(void); | |
99 | void xb_deinit_comms(void); | |
fd8aa909 JG |
100 | int xs_watch_msg(struct xs_watch_event *event); |
101 | void xs_request_exit(struct xb_req_data *req); | |
332f791d JG |
102 | |
103 | int xenbus_match(struct device *_dev, struct device_driver *_drv); | |
104 | int xenbus_dev_probe(struct device *_dev); | |
105 | int xenbus_dev_remove(struct device *_dev); | |
106 | int xenbus_register_driver_common(struct xenbus_driver *drv, | |
107 | struct xen_bus_type *bus, | |
108 | struct module *owner, | |
109 | const char *mod_name); | |
110 | int xenbus_probe_node(struct xen_bus_type *bus, | |
111 | const char *type, | |
112 | const char *nodename); | |
113 | int xenbus_probe_devices(struct xen_bus_type *bus); | |
4bac07c9 | 114 | |
332f791d | 115 | void xenbus_dev_changed(const char *node, struct xen_bus_type *bus); |
4bac07c9 | 116 | |
332f791d | 117 | void xenbus_dev_shutdown(struct device *_dev); |
2de06cc1 | 118 | |
332f791d JG |
119 | int xenbus_dev_suspend(struct device *dev); |
120 | int xenbus_dev_resume(struct device *dev); | |
121 | int xenbus_dev_cancel(struct device *dev); | |
2de06cc1 | 122 | |
332f791d | 123 | void xenbus_otherend_changed(struct xenbus_watch *watch, |
5584ea25 | 124 | const char *path, const char *token, |
332f791d | 125 | int ignore_on_shutdown); |
2de06cc1 | 126 | |
332f791d JG |
127 | int xenbus_read_otherend_details(struct xenbus_device *xendev, |
128 | char *id_node, char *path_node); | |
2de06cc1 | 129 | |
2c5d37d3 DDG |
130 | void xenbus_ring_ops_init(void); |
131 | ||
fd8aa909 JG |
132 | int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par); |
133 | void xenbus_dev_queue_reply(struct xb_req_data *req); | |
332f791d | 134 | |
4bac07c9 | 135 | #endif |