2 * Private include for xenbus communications.
4 * Copyright (C) 2005 Rusty Russell, IBM Corporation
6 * This file may be distributed separately from the Linux kernel, or
7 * incorporated into other software packages, subject to the following license:
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this source file (the "Software"), to deal in the Software without
11 * restriction, including without limitation the rights to use, copy, modify,
12 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
13 * and to permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #ifndef _XENBUS_COMMS_H
31 #define _XENBUS_COMMS_H
34 int xb_init_comms(void);
36 /* Low level routines. */
37 int xb_write(const void *data, unsigned len);
38 int xb_read(void *data, unsigned len);
39 int xs_input_avail(void);
42 #define __wait_event_interruptible(wchan, condition, ret) \
47 if ((ret = !tsleep(wchan, PWAIT | PCATCH, "waitev", hz/10))) \
53 #define wait_event_interruptible(wchan, condition) \
57 __wait_event_interruptible(wchan, condition, __ret); \
63 #define DECLARE_MUTEX(lock) struct sema lock
64 #define semaphore sema
65 #define rw_semaphore sema
67 #define down sema_wait
69 #define down_read sema_wait
70 #define up_read sema_post
71 #define down_write sema_wait
72 #define up_write sema_post
75 * container_of - cast a member of a structure out to the containing structure
77 * @ptr: the pointer to the member.
78 * @type: the type of the container struct this is embedded in.
79 * @member: the name of the member within the struct.
82 #define container_of(ptr, type, member) ({ \
83 __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
84 (type *)( (char *)__mptr - offsetof(type,member) );})
93 #define EXPORT_SYMBOL(x)
94 #define kmalloc(size, unused) malloc(size, M_DEVBUF, M_WAITOK)
95 #define kfree(ptr) free((void *)(uintptr_t)ptr, M_DEVBUF)
96 #define BUG_ON PANIC_IF
97 #define semaphore sema
98 #define rw_semaphore sema
99 typedef struct mtx spinlock_t;
100 #define spin_lock mtx_lock
101 #define spin_unlock mtx_unlock
102 #define DEFINE_SPINLOCK(lock) struct mtx lock
103 #define DECLARE_MUTEX(lock) struct sema lock
105 #define list_del(head, ent) TAILQ_REMOVE(head, ent, list)
106 #define simple_strtoul strtoul
107 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
108 #define list_empty TAILQ_EMPTY
109 #define wake_up wakeup
110 #define BUS_ID_SIZE 128
116 int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
117 int (*probe)(const char *type, const char *dir);
118 struct xendev_list_head *bus;
127 extern void xenbus_backend_probe_and_watch(void);
128 int xenbus_probe_node(struct xen_bus_type *bus, const char *type,
129 const char *nodename);
130 int xenbus_probe_devices(struct xen_bus_type *bus);
132 int xenbus_register_driver_common(struct xenbus_driver *drv,
133 struct xen_bus_type *bus);
135 void dev_changed(const char *node, struct xen_bus_type *bus);
138 read_otherend_details(struct xenbus_device *xendev, char *id_node,
141 char *kasprintf(const char *fmt, ...);
146 #endif /* _XENBUS_COMMS_H */
150 * c-file-style: "linux"
151 * indent-tabs-mode: t