Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Private include for xenbus communications.
0003  *
0004  * Copyright (C) 2005 Rusty Russell, IBM Corporation
0005  * Copyright (C) 2005 XenSource Ltd.
0006  *
0007  * This program is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU General Public License version 2
0009  * as published by the Free Software Foundation; or, when distributed
0010  * separately from the Linux kernel or incorporated into other
0011  * software packages, subject to the following license:
0012  *
0013  * Permission is hereby granted, free of charge, to any person obtaining a copy
0014  * of this source file (the "Software"), to deal in the Software without
0015  * restriction, including without limitation the rights to use, copy, modify,
0016  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
0017  * and to permit persons to whom the Software is furnished to do so, subject to
0018  * the following conditions:
0019  *
0020  * The above copyright notice and this permission notice shall be included in
0021  * all copies or substantial portions of the Software.
0022  *
0023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0024  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0025  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0026  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0027  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0028  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
0029  * IN THE SOFTWARE.
0030  */
0031 
0032 #ifndef _XENBUS_XENBUS_H
0033 #define _XENBUS_XENBUS_H
0034 
0035 #include <linux/mutex.h>
0036 #include <linux/uio.h>
0037 #include <xen/xenbus.h>
0038 
0039 #define XEN_BUS_ID_SIZE         20
0040 
0041 struct xen_bus_type {
0042     char *root;
0043     unsigned int levels;
0044     int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename);
0045     int (*probe)(struct xen_bus_type *bus, const char *type,
0046              const char *dir);
0047     bool (*otherend_will_handle)(struct xenbus_watch *watch,
0048                      const char *path, const char *token);
0049     void (*otherend_changed)(struct xenbus_watch *watch, const char *path,
0050                  const char *token);
0051     struct bus_type bus;
0052 };
0053 
0054 enum xenstore_init {
0055     XS_UNKNOWN,
0056     XS_PV,
0057     XS_HVM,
0058     XS_LOCAL,
0059 };
0060 
0061 struct xs_watch_event {
0062     struct list_head list;
0063     unsigned int len;
0064     struct xenbus_watch *handle;
0065     const char *path;
0066     const char *token;
0067     char body[];
0068 };
0069 
0070 enum xb_req_state {
0071     xb_req_state_queued,
0072     xb_req_state_wait_reply,
0073     xb_req_state_got_reply,
0074     xb_req_state_aborted
0075 };
0076 
0077 struct xb_req_data {
0078     struct list_head list;
0079     wait_queue_head_t wq;
0080     struct xsd_sockmsg msg;
0081     uint32_t caller_req_id;
0082     enum xsd_sockmsg_type type;
0083     char *body;
0084     const struct kvec *vec;
0085     int num_vecs;
0086     int err;
0087     enum xb_req_state state;
0088     bool user_req;
0089     void (*cb)(struct xb_req_data *);
0090     void *par;
0091 };
0092 
0093 extern enum xenstore_init xen_store_domain_type;
0094 extern const struct attribute_group *xenbus_dev_groups[];
0095 extern struct mutex xs_response_mutex;
0096 extern struct list_head xs_reply_list;
0097 extern struct list_head xb_write_list;
0098 extern wait_queue_head_t xb_waitq;
0099 extern struct mutex xb_write_mutex;
0100 
0101 int xs_init(void);
0102 int xb_init_comms(void);
0103 void xb_deinit_comms(void);
0104 int xs_watch_msg(struct xs_watch_event *event);
0105 void xs_request_exit(struct xb_req_data *req);
0106 
0107 int xenbus_match(struct device *_dev, struct device_driver *_drv);
0108 int xenbus_dev_probe(struct device *_dev);
0109 void xenbus_dev_remove(struct device *_dev);
0110 int xenbus_register_driver_common(struct xenbus_driver *drv,
0111                   struct xen_bus_type *bus,
0112                   struct module *owner,
0113                   const char *mod_name);
0114 int xenbus_probe_node(struct xen_bus_type *bus,
0115               const char *type,
0116               const char *nodename);
0117 int xenbus_probe_devices(struct xen_bus_type *bus);
0118 
0119 void xenbus_dev_changed(const char *node, struct xen_bus_type *bus);
0120 
0121 int xenbus_dev_suspend(struct device *dev);
0122 int xenbus_dev_resume(struct device *dev);
0123 int xenbus_dev_cancel(struct device *dev);
0124 
0125 void xenbus_otherend_changed(struct xenbus_watch *watch,
0126                  const char *path, const char *token,
0127                  int ignore_on_shutdown);
0128 
0129 int xenbus_read_otherend_details(struct xenbus_device *xendev,
0130                  char *id_node, char *path_node);
0131 
0132 void xenbus_ring_ops_init(void);
0133 
0134 int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par);
0135 void xenbus_dev_queue_reply(struct xb_req_data *req);
0136 
0137 extern unsigned int xb_dev_generation_id;
0138 
0139 #endif