xenbusvar.h (e57c2b130f2cd40967cf20698d376cc5ada95871) xenbusvar.h (3a6d1fcf9c8ed864c98e449a0b7696be6c838aea)
1/******************************************************************************
2 * xenbus.h
3 *
4 * Talks to Xen Store to figure out what devices we have.
5 *
6 * Copyright (C) 2005 Rusty Russell, IBM Corporation
7 * Copyright (C) 2005 XenSource Ltd.
8 *

--- 89 unchanged lines hidden (view full) ---

98
99struct xenbus_transaction
100{
101 uint32_t id;
102};
103
104#define XBT_NIL ((struct xenbus_transaction) { 0 })
105
1/******************************************************************************
2 * xenbus.h
3 *
4 * Talks to Xen Store to figure out what devices we have.
5 *
6 * Copyright (C) 2005 Rusty Russell, IBM Corporation
7 * Copyright (C) 2005 XenSource Ltd.
8 *

--- 89 unchanged lines hidden (view full) ---

98
99struct xenbus_transaction
100{
101 uint32_t id;
102};
103
104#define XBT_NIL ((struct xenbus_transaction) { 0 })
105
106char **xenbus_directory(struct xenbus_transaction t,
107 const char *dir, const char *node, unsigned int *num);
108void *xenbus_read(struct xenbus_transaction t,
109 const char *dir, const char *node, unsigned int *len);
110int xenbus_write(struct xenbus_transaction t,
111 const char *dir, const char *node, const char *string);
112int xenbus_mkdir(struct xenbus_transaction t,
113 const char *dir, const char *node);
114int xenbus_exists(struct xenbus_transaction t,
115 const char *dir, const char *node);
106int xenbus_directory(struct xenbus_transaction t, const char *dir,
107 const char *node, unsigned int *num, char ***result);
108int xenbus_read(struct xenbus_transaction t, const char *dir,
109 const char *node, unsigned int *len, void **result);
110int xenbus_write(struct xenbus_transaction t, const char *dir,
111 const char *node, const char *string);
112int xenbus_mkdir(struct xenbus_transaction t, const char *dir,
113 const char *node);
114int xenbus_exists(struct xenbus_transaction t, const char *dir,
115 const char *node);
116int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node);
117int xenbus_transaction_start(struct xenbus_transaction *t);
118int xenbus_transaction_end(struct xenbus_transaction t, int abort);
119
116int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node);
117int xenbus_transaction_start(struct xenbus_transaction *t);
118int xenbus_transaction_end(struct xenbus_transaction t, int abort);
119
120/* Single read and scanf: returns -errno or num scanned if > 0. */
120/*
121 * Single read and scanf: returns errno or zero. If scancountp is
122 * non-null, then number of items scanned is returned in *scanncountp.
123 */
121int xenbus_scanf(struct xenbus_transaction t,
124int xenbus_scanf(struct xenbus_transaction t,
122 const char *dir, const char *node, const char *fmt, ...)
123 __attribute__((format(scanf, 4, 5)));
125 const char *dir, const char *node, int *scancountp, const char *fmt, ...)
126 __attribute__((format(scanf, 5, 6)));
124
127
125/* Single printf and write: returns -errno or 0. */
128/* Single printf and write: returns errno or 0. */
126int xenbus_printf(struct xenbus_transaction t,
127 const char *dir, const char *node, const char *fmt, ...)
128 __attribute__((format(printf, 4, 5)));
129
129int xenbus_printf(struct xenbus_transaction t,
130 const char *dir, const char *node, const char *fmt, ...)
131 __attribute__((format(printf, 4, 5)));
132
130/* Generic read function: NULL-terminated triples of name,
131 * sprintf-style type string, and pointer. Returns 0 or errno.*/
133/*
134 * Generic read function: NULL-terminated triples of name,
135 * sprintf-style type string, and pointer. Returns 0 or errno.
136 */
132int xenbus_gather(struct xenbus_transaction t, const char *dir, ...);
133
134/* notifer routines for when the xenstore comes up */
135int register_xenstore_notifier(xenstore_event_handler_t func, void *arg, int priority);
136#if 0
137void unregister_xenstore_notifier();
138#endif
139int register_xenbus_watch(struct xenbus_watch *watch);
140void unregister_xenbus_watch(struct xenbus_watch *watch);
141void xs_suspend(void);
142void xs_resume(void);
143
144/* Used by xenbus_dev to borrow kernel's store connection. */
137int xenbus_gather(struct xenbus_transaction t, const char *dir, ...);
138
139/* notifer routines for when the xenstore comes up */
140int register_xenstore_notifier(xenstore_event_handler_t func, void *arg, int priority);
141#if 0
142void unregister_xenstore_notifier();
143#endif
144int register_xenbus_watch(struct xenbus_watch *watch);
145void unregister_xenbus_watch(struct xenbus_watch *watch);
146void xs_suspend(void);
147void xs_resume(void);
148
149/* Used by xenbus_dev to borrow kernel's store connection. */
145void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg);
150int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void **result);
146
151
152#if 0
153
147#define XENBUS_IS_ERR_READ(str) ({ \
148 if (!IS_ERR(str) && strlen(str) == 0) { \
149 free(str, M_DEVBUF); \
150 str = ERR_PTR(-ERANGE); \
151 } \
152 IS_ERR(str); \
153})
154
154#define XENBUS_IS_ERR_READ(str) ({ \
155 if (!IS_ERR(str) && strlen(str) == 0) { \
156 free(str, M_DEVBUF); \
157 str = ERR_PTR(-ERANGE); \
158 } \
159 IS_ERR(str); \
160})
161
155#define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE)
162#endif
156
163
164#define XENBUS_EXIST_ERR(err) ((err) == ENOENT || (err) == ERANGE)
165
166
157/**
158 * Register a watch on the given path, using the given xenbus_watch structure
159 * for storage, and the given callback function as the callback. Return 0 on
167/**
168 * Register a watch on the given path, using the given xenbus_watch structure
169 * for storage, and the given callback function as the callback. Return 0 on
160 * success, or -errno on error. On success, the given path will be saved as
170 * success, or errno on error. On success, the given path will be saved as
161 * watch->node, and remains the caller's to free. On error, watch->node will
162 * be NULL, the device will switch to XenbusStateClosing, and the error will
163 * be saved in the store.
164 */
165int xenbus_watch_path(device_t dev, char *path,
166 struct xenbus_watch *watch,
167 void (*callback)(struct xenbus_watch *,
168 const char **, unsigned int));
169
170
171/**
172 * Register a watch on the given path/path2, using the given xenbus_watch
173 * structure for storage, and the given callback function as the callback.
171 * watch->node, and remains the caller's to free. On error, watch->node will
172 * be NULL, the device will switch to XenbusStateClosing, and the error will
173 * be saved in the store.
174 */
175int xenbus_watch_path(device_t dev, char *path,
176 struct xenbus_watch *watch,
177 void (*callback)(struct xenbus_watch *,
178 const char **, unsigned int));
179
180
181/**
182 * Register a watch on the given path/path2, using the given xenbus_watch
183 * structure for storage, and the given callback function as the callback.
174 * Return 0 on success, or -errno on error. On success, the watched path
184 * Return 0 on success, or errno on error. On success, the watched path
175 * (path/path2) will be saved as watch->node, and becomes the caller's to
176 * kfree(). On error, watch->node will be NULL, so the caller has nothing to
177 * free, the device will switch to XenbusStateClosing, and the error will be
178 * saved in the store.
179 */
180int xenbus_watch_path2(device_t dev, const char *path,
181 const char *path2, struct xenbus_watch *watch,
182 void (*callback)(struct xenbus_watch *,
183 const char **, unsigned int));
184
185
186/**
187 * Advertise in the store a change of the given driver to the given new_state.
188 * which case this is performed inside its own transaction. Return 0 on
185 * (path/path2) will be saved as watch->node, and becomes the caller's to
186 * kfree(). On error, watch->node will be NULL, so the caller has nothing to
187 * free, the device will switch to XenbusStateClosing, and the error will be
188 * saved in the store.
189 */
190int xenbus_watch_path2(device_t dev, const char *path,
191 const char *path2, struct xenbus_watch *watch,
192 void (*callback)(struct xenbus_watch *,
193 const char **, unsigned int));
194
195
196/**
197 * Advertise in the store a change of the given driver to the given new_state.
198 * which case this is performed inside its own transaction. Return 0 on
189 * success, or -errno on error. On error, the device will switch to
199 * success, or errno on error. On error, the device will switch to
190 * XenbusStateClosing, and the error will be saved in the store.
191 */
192int xenbus_switch_state(device_t dev,
193 XenbusState new_state);
194
195
196/**
200 * XenbusStateClosing, and the error will be saved in the store.
201 */
202int xenbus_switch_state(device_t dev,
203 XenbusState new_state);
204
205
206/**
197 * Grant access to the given ring_mfn to the peer of the given device. Return
198 * 0 on success, or -errno on error. On error, the device will switch to
199 * XenbusStateClosing, and the error will be saved in the store.
207 * Grant access to the given ring_mfn to the peer of the given device.
208 * Return 0 on success, or errno on error. On error, the device will
209 * switch to XenbusStateClosing, and the error will be saved in the
210 * store. The grant ring reference is returned in *refp.
200 */
211 */
201int xenbus_grant_ring(device_t dev, unsigned long ring_mfn);
212int xenbus_grant_ring(device_t dev, unsigned long ring_mfn, int *refp);
202
203
204/**
205 * Allocate an event channel for the given xenbus_device, assigning the newly
213
214
215/**
216 * Allocate an event channel for the given xenbus_device, assigning the newly
206 * created local port to *port. Return 0 on success, or -errno on error. On
217 * created local port to *port. Return 0 on success, or errno on error. On
207 * error, the device will switch to XenbusStateClosing, and the error will be
208 * saved in the store.
209 */
210int xenbus_alloc_evtchn(device_t dev, int *port);
211
212
213/**
218 * error, the device will switch to XenbusStateClosing, and the error will be
219 * saved in the store.
220 */
221int xenbus_alloc_evtchn(device_t dev, int *port);
222
223
224/**
214 * Free an existing event channel. Returns 0 on success or -errno on error.
225 * Free an existing event channel. Returns 0 on success or errno on error.
215 */
216int xenbus_free_evtchn(device_t dev, int port);
217
218
219/**
220 * Return the state of the driver rooted at the given store path, or
221 * XenbusStateClosed if no state can be read.
222 */

--- 26 unchanged lines hidden ---
226 */
227int xenbus_free_evtchn(device_t dev, int port);
228
229
230/**
231 * Return the state of the driver rooted at the given store path, or
232 * XenbusStateClosed if no state can be read.
233 */

--- 26 unchanged lines hidden ---