ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-xen/xenbus.h @ 6538:84ee014ebd41

Merge xen-vtx-unstable.hg
author adsharma@los-vmm.sc.intel.com
date Wed Aug 17 12:34:38 2005 -0800 (2005-08-17)
parents 23979fb12c49 8203b7d536d3
children 99914b54f7bf
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 *
8 * This file may be distributed separately from the Linux kernel, or
9 * incorporated into other software packages, subject to the following license:
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this source file (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use, copy, modify,
14 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 * IN THE SOFTWARE.
28 */
30 #ifndef _ASM_XEN_XENBUS_H
31 #define _ASM_XEN_XENBUS_H
33 #include <linux/device.h>
34 #include <linux/notifier.h>
35 #include <asm/semaphore.h>
37 /* A xenbus device. */
38 struct xenbus_device {
39 char *devicetype;
40 char *subtype;
41 char *nodename;
42 struct device dev;
43 int has_error;
44 void *data;
45 };
47 static inline struct xenbus_device *to_xenbus_device(struct device *dev)
48 {
49 return container_of(dev, struct xenbus_device, dev);
50 }
52 struct xenbus_device_id
53 {
54 /* .../device/<device_type>/<identifier> */
55 char devicetype[32]; /* General class of device. */
56 char subtype[32]; /* Contents of "subtype" for this device */
57 };
59 /* A xenbus driver. */
60 struct xenbus_driver {
61 char *name;
62 struct module *owner;
63 const struct xenbus_device_id *ids;
64 int (*probe) (struct xenbus_device * dev,
65 const struct xenbus_device_id * id);
66 int (*remove) (struct xenbus_device * dev);
67 struct device_driver driver;
68 };
70 static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
71 {
72 return container_of(drv, struct xenbus_driver, driver);
73 }
75 int xenbus_register_driver(struct xenbus_driver *drv);
76 void xenbus_unregister_driver(struct xenbus_driver *drv);
78 /* Caller must hold this lock to call these functions: it's also held
79 * across watch callbacks. */
80 extern struct semaphore xenbus_lock;
82 char **xenbus_directory(const char *dir, const char *node, unsigned int *num);
83 void *xenbus_read(const char *dir, const char *node, unsigned int *len);
84 int xenbus_write(const char *dir, const char *node,
85 const char *string, int createflags);
86 int xenbus_mkdir(const char *dir, const char *node);
87 int xenbus_exists(const char *dir, const char *node);
88 int xenbus_rm(const char *dir, const char *node);
89 int xenbus_transaction_start(const char *subtree);
90 int xenbus_transaction_end(int abort);
92 /* Single read and scanf: returns -errno or num scanned if > 0. */
93 int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...)
94 __attribute__((format(scanf, 3, 4)));
96 /* Single printf and write: returns -errno or 0. */
97 int xenbus_printf(const char *dir, const char *node, const char *fmt, ...)
98 __attribute__((format(printf, 3, 4)));
100 /* Generic read function: NULL-terminated triples of name,
101 * sprintf-style type string, and pointer. Returns 0 or errno.*/
102 int xenbus_gather(const char *dir, ...);
104 /* Report a (negative) errno into the store, with explanation. */
105 void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt,...);
107 /* Clear any error. */
108 void xenbus_dev_ok(struct xenbus_device *dev);
110 /* Register callback to watch this node. */
111 struct xenbus_watch
112 {
113 struct list_head list;
114 char *node;
115 void (*callback)(struct xenbus_watch *, const char *node);
116 };
118 /* notifer routines for when the xenstore comes up */
119 int register_xenstore_notifier(struct notifier_block *nb);
120 void unregister_xenstore_notifier(struct notifier_block *nb);
122 int register_xenbus_watch(struct xenbus_watch *watch);
123 void unregister_xenbus_watch(struct xenbus_watch *watch);
124 void reregister_xenbus_watches(void);
126 /* Called from xen core code. */
127 void xenbus_suspend(void);
128 void xenbus_resume(void);
130 #endif /* _ASM_XEN_XENBUS_H */