aboutsummaryrefslogtreecommitdiffstats
path: root/linux-2.6.11-xen-sparse/include/asm-xen/xenbus.h
blob: d97d64cba071272e3d7a057ed04104f027886695 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef _ASM_XEN_XENBUS_H
#define _ASM_XEN_XENBUS_H
/******************************************************************************
 * xenbus.h
 *
 * Talks to Xen Store to figure out what devices we have.
 *
 * Copyright (C) 2005 Rusty Russell, IBM Corporation
 * 
 * This file may be distributed separately from the Linux kernel, or
 * incorporated into other software packages, subject to the following license:
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this source file (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy, modify,
 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */
#include <linux/device.h>
#include <asm/semaphore.h>

/* A xenbus device. */
struct xenbus_device {
	char *devicetype;
	char *subtype;
	char *nodename;
	int id;
	struct device dev;
};

static inline struct xenbus_device *to_xenbus_device(struct device *dev)
{
	return container_of(dev, struct xenbus_device, dev);
}

struct xenbus_device_id
{
	/* .../device/<device_type>/<identifier> */
	char devicetype[32]; 	/* General class of device. */
	char subtype[32];	/* Contents of "subtype" for this device */
};

/* A xenbus driver. */
struct xenbus_driver {
	char *name;
	struct module *owner;
	const struct xenbus_device_id *ids;
        /* Called when xenstore is connected. */
        int  (*connect) (struct xenbus_driver * drv);

	int  (*probe)    (struct xenbus_device * dev, const struct xenbus_device_id * id);
        int  (*remove)   (struct xenbus_device * dev);
        int  (*configure)(struct xenbus_device * dev);

	struct device_driver driver;
};

struct xenbus_evtchn {
        unsigned long dom1;
        unsigned long port1;
        unsigned long dom2;
        unsigned long port2;
};

static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
{
	return container_of(drv, struct xenbus_driver, driver);
}

int xenbus_register_driver(struct xenbus_driver *drv);
void xenbus_unregister_driver(struct xenbus_driver *drv);

int xenbus_register_backend(struct xenbus_driver *drv);
void xenbus_unregister_backend(struct xenbus_driver *drv);

/* Iterator over xenbus devices (frontend). */
int xenbus_for_each_dev(struct xenbus_device * start, void * data,
                        int (*fn)(struct xenbus_device *, void *));

/* Iterator over xenbus drivers (frontend). */
int xenbus_for_each_drv(struct xenbus_driver * start, void * data,
                        int (*fn)(struct xenbus_driver *, void *));

/* Iterator over xenbus drivers (backend). */
int xenbus_for_each_backend(struct xenbus_driver * start, void * data,
                            int (*fn)(struct xenbus_driver *, void *));

/* Caller must hold this lock to call these functions. */
extern struct semaphore xs_lock;

char **xs_directory(const char *path, unsigned int *num);
void *xs_read(const char *path, unsigned int *len);
int xs_write(const char *path,
	     const void *data, unsigned int len, int createflags);
int xs_mkdir(const char *path);
int xs_exists(const char *path);
int xs_mkdirs(const char *path);
int xs_rm(const char *path);
int xs_transaction_start(const char *subtree);
int xs_transaction_end(int abort);
char *xs_get_domain_path(domid_t domid);

/* Register callback to watch this node. */
struct xenbus_watch
{
	struct list_head list;
	char *node;
	unsigned int priority;
	void (*callback)(struct xenbus_watch *, const char *node);
};

int register_xenbus_watch(struct xenbus_watch *watch);
void unregister_xenbus_watch(struct xenbus_watch *watch);

char *xenbus_path(const char *dir, const char *name);
char *xenbus_read(const char *dir, const char *name, unsigned int *data_n);
int xenbus_write(const char *dir, const char *name,
                 const char *data, int data_n);

int xenbus_read_string(const char *dir, const char *name, char **val);
int xenbus_write_string(const char *dir, const char *name, const char *val);
int xenbus_read_ulong(const char *dir, const char *name, unsigned long *val);
int xenbus_write_ulong(const char *dir, const char *name, unsigned long val);
int xenbus_read_long(const char *dir, const char *name, long *val);
int xenbus_write_long(const char *dir, const char *name, long val);
int xenbus_read_mac(const char *dir, const char *name, unsigned char mac[6]);
int xenbus_write_mac(const char *dir, const char *name, const unsigned char mac[6]);
int xenbus_read_evtchn(const char *dir, const char *name, struct xenbus_evtchn *evtchn);
int xenbus_message(const char *dir, const char *val, ...);

#endif /* _ASM_XEN_XENBUS_H */