ia64/linux-2.6.18-xen.hg

view include/xen/xenbus.h @ 452:c7ed6fe5dca0

kexec: dont initialise regions in reserve_memory()

There is no need to initialise efi_memmap_res and boot_param_res in
reserve_memory() for the initial xen domain as it is done in
machine_kexec_setup_resources() using values from the kexec hypercall.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 28 10:55:18 2008 +0000 (2008-02-28)
parents 5ce5bd383ea9
children
line source
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 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation; or, when distributed
12 * separately from the Linux kernel or incorporated into other
13 * software packages, subject to the following license:
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a copy
16 * of this source file (the "Software"), to deal in the Software without
17 * restriction, including without limitation the rights to use, copy, modify,
18 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
19 * and to permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
21 *
22 * The above copyright notice and this permission notice shall be included in
23 * all copies or substantial portions of the Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 * IN THE SOFTWARE.
32 */
34 #ifndef _XEN_XENBUS_H
35 #define _XEN_XENBUS_H
37 #include <linux/device.h>
38 #include <linux/notifier.h>
39 #include <linux/mutex.h>
40 #include <linux/completion.h>
41 #include <linux/init.h>
42 #include <linux/err.h>
43 #include <xen/interface/xen.h>
44 #include <xen/interface/grant_table.h>
45 #include <xen/interface/io/xenbus.h>
46 #include <xen/interface/io/xs_wire.h>
48 /* Register callback to watch this node. */
49 struct xenbus_watch
50 {
51 struct list_head list;
53 /* Path being watched. */
54 const char *node;
56 /* Callback (executed in a process context with no locks held). */
57 void (*callback)(struct xenbus_watch *,
58 const char **vec, unsigned int len);
60 /* See XBWF_ definitions below. */
61 unsigned long flags;
62 };
64 /*
65 * Execute callback in its own kthread. Useful if the callback is long
66 * running or heavily serialised, to avoid taking out the main xenwatch thread
67 * for a long period of time (or even unwittingly causing a deadlock).
68 */
69 #define XBWF_new_thread 1
71 /* A xenbus device. */
72 struct xenbus_device {
73 const char *devicetype;
74 const char *nodename;
75 const char *otherend;
76 int otherend_id;
77 struct xenbus_watch otherend_watch;
78 struct device dev;
79 enum xenbus_state state;
80 struct completion down;
81 };
83 static inline struct xenbus_device *to_xenbus_device(struct device *dev)
84 {
85 return container_of(dev, struct xenbus_device, dev);
86 }
88 struct xenbus_device_id
89 {
90 /* .../device/<device_type>/<identifier> */
91 char devicetype[32]; /* General class of device. */
92 };
94 /* A xenbus driver. */
95 struct xenbus_driver {
96 char *name;
97 struct module *owner;
98 const struct xenbus_device_id *ids;
99 int (*probe)(struct xenbus_device *dev,
100 const struct xenbus_device_id *id);
101 void (*otherend_changed)(struct xenbus_device *dev,
102 enum xenbus_state backend_state);
103 int (*remove)(struct xenbus_device *dev);
104 int (*suspend)(struct xenbus_device *dev);
105 int (*suspend_cancel)(struct xenbus_device *dev);
106 int (*resume)(struct xenbus_device *dev);
107 int (*uevent)(struct xenbus_device *, char **, int, char *, int);
108 struct device_driver driver;
109 int (*read_otherend_details)(struct xenbus_device *dev);
110 int (*is_ready)(struct xenbus_device *dev);
111 };
113 static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
114 {
115 return container_of(drv, struct xenbus_driver, driver);
116 }
118 int xenbus_register_frontend(struct xenbus_driver *drv);
119 int xenbus_register_backend(struct xenbus_driver *drv);
120 void xenbus_unregister_driver(struct xenbus_driver *drv);
122 struct xenbus_transaction
123 {
124 u32 id;
125 };
127 /* Nil transaction ID. */
128 #define XBT_NIL ((struct xenbus_transaction) { 0 })
130 char **xenbus_directory(struct xenbus_transaction t,
131 const char *dir, const char *node, unsigned int *num);
132 void *xenbus_read(struct xenbus_transaction t,
133 const char *dir, const char *node, unsigned int *len);
134 int xenbus_write(struct xenbus_transaction t,
135 const char *dir, const char *node, const char *string);
136 int xenbus_mkdir(struct xenbus_transaction t,
137 const char *dir, const char *node);
138 int xenbus_exists(struct xenbus_transaction t,
139 const char *dir, const char *node);
140 int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node);
141 int xenbus_transaction_start(struct xenbus_transaction *t);
142 int xenbus_transaction_end(struct xenbus_transaction t, int abort);
144 /* Single read and scanf: returns -errno or num scanned if > 0. */
145 int xenbus_scanf(struct xenbus_transaction t,
146 const char *dir, const char *node, const char *fmt, ...)
147 __attribute__((format(scanf, 4, 5)));
149 /* Single printf and write: returns -errno or 0. */
150 int xenbus_printf(struct xenbus_transaction t,
151 const char *dir, const char *node, const char *fmt, ...)
152 __attribute__((format(printf, 4, 5)));
154 /* Generic read function: NULL-terminated triples of name,
155 * sprintf-style type string, and pointer. Returns 0 or errno.*/
156 int xenbus_gather(struct xenbus_transaction t, const char *dir, ...);
158 /* notifer routines for when the xenstore comes up */
159 int register_xenstore_notifier(struct notifier_block *nb);
160 void unregister_xenstore_notifier(struct notifier_block *nb);
162 int register_xenbus_watch(struct xenbus_watch *watch);
163 void unregister_xenbus_watch(struct xenbus_watch *watch);
164 void xs_suspend(void);
165 void xs_resume(void);
166 void xs_suspend_cancel(void);
168 /* Used by xenbus_dev to borrow kernel's store connection. */
169 void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg);
171 /* Prepare for domain suspend: then resume or cancel the suspend. */
172 void xenbus_suspend(void);
173 void xenbus_resume(void);
174 void xenbus_suspend_cancel(void);
176 #define XENBUS_IS_ERR_READ(str) ({ \
177 if (!IS_ERR(str) && strlen(str) == 0) { \
178 kfree(str); \
179 str = ERR_PTR(-ERANGE); \
180 } \
181 IS_ERR(str); \
182 })
184 #define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE)
187 /**
188 * Register a watch on the given path, using the given xenbus_watch structure
189 * for storage, and the given callback function as the callback. Return 0 on
190 * success, or -errno on error. On success, the given path will be saved as
191 * watch->node, and remains the caller's to free. On error, watch->node will
192 * be NULL, the device will switch to XenbusStateClosing, and the error will
193 * be saved in the store.
194 */
195 int xenbus_watch_path(struct xenbus_device *dev, const char *path,
196 struct xenbus_watch *watch,
197 void (*callback)(struct xenbus_watch *,
198 const char **, unsigned int));
201 /**
202 * Register a watch on the given path/path2, using the given xenbus_watch
203 * structure for storage, and the given callback function as the callback.
204 * Return 0 on success, or -errno on error. On success, the watched path
205 * (path/path2) will be saved as watch->node, and becomes the caller's to
206 * kfree(). On error, watch->node will be NULL, so the caller has nothing to
207 * free, the device will switch to XenbusStateClosing, and the error will be
208 * saved in the store.
209 */
210 int xenbus_watch_path2(struct xenbus_device *dev, const char *path,
211 const char *path2, struct xenbus_watch *watch,
212 void (*callback)(struct xenbus_watch *,
213 const char **, unsigned int));
216 /**
217 * Advertise in the store a change of the given driver to the given new_state.
218 * Return 0 on success, or -errno on error. On error, the device will switch
219 * to XenbusStateClosing, and the error will be saved in the store.
220 */
221 int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state);
224 /**
225 * Grant access to the given ring_mfn to the peer of the given device. Return
226 * 0 on success, or -errno on error. On error, the device will switch to
227 * XenbusStateClosing, and the error will be saved in the store.
228 */
229 int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn);
232 /**
233 * Map a page of memory into this domain from another domain's grant table.
234 * xenbus_map_ring_valloc allocates a page of virtual address space, maps the
235 * page to that address, and sets *vaddr to that address.
236 * xenbus_map_ring does not allocate the virtual address space (you must do
237 * this yourself!). It only maps in the page to the specified address.
238 * Returns 0 on success, and GNTST_* (see xen/include/interface/grant_table.h)
239 * or -ENOMEM on error. If an error is returned, device will switch to
240 * XenbusStateClosing and the error message will be saved in XenStore.
241 */
242 struct vm_struct *xenbus_map_ring_valloc(struct xenbus_device *dev,
243 int gnt_ref);
244 int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
245 grant_handle_t *handle, void *vaddr);
248 /**
249 * Unmap a page of memory in this domain that was imported from another domain.
250 * Use xenbus_unmap_ring_vfree if you mapped in your memory with
251 * xenbus_map_ring_valloc (it will free the virtual address space).
252 * Returns 0 on success and returns GNTST_* on error
253 * (see xen/include/interface/grant_table.h).
254 */
255 int xenbus_unmap_ring_vfree(struct xenbus_device *dev, struct vm_struct *);
256 int xenbus_unmap_ring(struct xenbus_device *dev,
257 grant_handle_t handle, void *vaddr);
260 /**
261 * Allocate an event channel for the given xenbus_device, assigning the newly
262 * created local port to *port. Return 0 on success, or -errno on error. On
263 * error, the device will switch to XenbusStateClosing, and the error will be
264 * saved in the store.
265 */
266 int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port);
269 /**
270 * Free an existing event channel. Returns 0 on success or -errno on error.
271 */
272 int xenbus_free_evtchn(struct xenbus_device *dev, int port);
275 /**
276 * Return the state of the driver rooted at the given store path, or
277 * XenbusStateUnknown if no state can be read.
278 */
279 enum xenbus_state xenbus_read_driver_state(const char *path);
282 /***
283 * Report the given negative errno into the store, along with the given
284 * formatted message.
285 */
286 void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt,
287 ...);
290 /***
291 * Equivalent to xenbus_dev_error(dev, err, fmt, args), followed by
292 * xenbus_switch_state(dev, NULL, XenbusStateClosing) to schedule an orderly
293 * closedown of this driver and its peer.
294 */
295 void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt,
296 ...);
298 int xenbus_dev_init(void);
300 const char *xenbus_strstate(enum xenbus_state state);
301 int xenbus_dev_is_online(struct xenbus_device *dev);
302 int xenbus_frontend_closed(struct xenbus_device *dev);
304 int xenbus_for_each_backend(void *arg, int (*fn)(struct device *, void *));
305 int xenbus_for_each_frontend(void *arg, int (*fn)(struct device *, void *));
307 #endif /* _XEN_XENBUS_H */