1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Private include for xenbus communications. 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Copyright (C) 2005 Rusty Russell, IBM Corporation 5*4882a593Smuzhiyun * Copyright (C) 2005 XenSource Ltd. 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or 8*4882a593Smuzhiyun * modify it under the terms of the GNU General Public License version 2 9*4882a593Smuzhiyun * as published by the Free Software Foundation; or, when distributed 10*4882a593Smuzhiyun * separately from the Linux kernel or incorporated into other 11*4882a593Smuzhiyun * software packages, subject to the following license: 12*4882a593Smuzhiyun * 13*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a copy 14*4882a593Smuzhiyun * of this source file (the "Software"), to deal in the Software without 15*4882a593Smuzhiyun * restriction, including without limitation the rights to use, copy, modify, 16*4882a593Smuzhiyun * merge, publish, distribute, sublicense, and/or sell copies of the Software, 17*4882a593Smuzhiyun * and to permit persons to whom the Software is furnished to do so, subject to 18*4882a593Smuzhiyun * the following conditions: 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * The above copyright notice and this permission notice shall be included in 21*4882a593Smuzhiyun * all copies or substantial portions of the Software. 22*4882a593Smuzhiyun * 23*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26*4882a593Smuzhiyun * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27*4882a593Smuzhiyun * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28*4882a593Smuzhiyun * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29*4882a593Smuzhiyun * IN THE SOFTWARE. 30*4882a593Smuzhiyun */ 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun #ifndef _XENBUS_XENBUS_H 33*4882a593Smuzhiyun #define _XENBUS_XENBUS_H 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun #include <linux/mutex.h> 36*4882a593Smuzhiyun #include <linux/uio.h> 37*4882a593Smuzhiyun #include <xen/xenbus.h> 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun #define XEN_BUS_ID_SIZE 20 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun struct xen_bus_type { 42*4882a593Smuzhiyun char *root; 43*4882a593Smuzhiyun unsigned int levels; 44*4882a593Smuzhiyun int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename); 45*4882a593Smuzhiyun int (*probe)(struct xen_bus_type *bus, const char *type, 46*4882a593Smuzhiyun const char *dir); 47*4882a593Smuzhiyun bool (*otherend_will_handle)(struct xenbus_watch *watch, 48*4882a593Smuzhiyun const char *path, const char *token); 49*4882a593Smuzhiyun void (*otherend_changed)(struct xenbus_watch *watch, const char *path, 50*4882a593Smuzhiyun const char *token); 51*4882a593Smuzhiyun struct bus_type bus; 52*4882a593Smuzhiyun }; 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun enum xenstore_init { 55*4882a593Smuzhiyun XS_UNKNOWN, 56*4882a593Smuzhiyun XS_PV, 57*4882a593Smuzhiyun XS_HVM, 58*4882a593Smuzhiyun XS_LOCAL, 59*4882a593Smuzhiyun }; 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun struct xs_watch_event { 62*4882a593Smuzhiyun struct list_head list; 63*4882a593Smuzhiyun unsigned int len; 64*4882a593Smuzhiyun struct xenbus_watch *handle; 65*4882a593Smuzhiyun const char *path; 66*4882a593Smuzhiyun const char *token; 67*4882a593Smuzhiyun char body[]; 68*4882a593Smuzhiyun }; 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun enum xb_req_state { 71*4882a593Smuzhiyun xb_req_state_queued, 72*4882a593Smuzhiyun xb_req_state_wait_reply, 73*4882a593Smuzhiyun xb_req_state_got_reply, 74*4882a593Smuzhiyun xb_req_state_aborted 75*4882a593Smuzhiyun }; 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun struct xb_req_data { 78*4882a593Smuzhiyun struct list_head list; 79*4882a593Smuzhiyun wait_queue_head_t wq; 80*4882a593Smuzhiyun struct xsd_sockmsg msg; 81*4882a593Smuzhiyun uint32_t caller_req_id; 82*4882a593Smuzhiyun enum xsd_sockmsg_type type; 83*4882a593Smuzhiyun char *body; 84*4882a593Smuzhiyun const struct kvec *vec; 85*4882a593Smuzhiyun int num_vecs; 86*4882a593Smuzhiyun int err; 87*4882a593Smuzhiyun enum xb_req_state state; 88*4882a593Smuzhiyun bool user_req; 89*4882a593Smuzhiyun void (*cb)(struct xb_req_data *); 90*4882a593Smuzhiyun void *par; 91*4882a593Smuzhiyun }; 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun extern enum xenstore_init xen_store_domain_type; 94*4882a593Smuzhiyun extern const struct attribute_group *xenbus_dev_groups[]; 95*4882a593Smuzhiyun extern struct mutex xs_response_mutex; 96*4882a593Smuzhiyun extern struct list_head xs_reply_list; 97*4882a593Smuzhiyun extern struct list_head xb_write_list; 98*4882a593Smuzhiyun extern wait_queue_head_t xb_waitq; 99*4882a593Smuzhiyun extern struct mutex xb_write_mutex; 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun int xs_init(void); 102*4882a593Smuzhiyun int xb_init_comms(void); 103*4882a593Smuzhiyun void xb_deinit_comms(void); 104*4882a593Smuzhiyun int xs_watch_msg(struct xs_watch_event *event); 105*4882a593Smuzhiyun void xs_request_exit(struct xb_req_data *req); 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun int xenbus_match(struct device *_dev, struct device_driver *_drv); 108*4882a593Smuzhiyun int xenbus_dev_probe(struct device *_dev); 109*4882a593Smuzhiyun int xenbus_dev_remove(struct device *_dev); 110*4882a593Smuzhiyun int xenbus_register_driver_common(struct xenbus_driver *drv, 111*4882a593Smuzhiyun struct xen_bus_type *bus, 112*4882a593Smuzhiyun struct module *owner, 113*4882a593Smuzhiyun const char *mod_name); 114*4882a593Smuzhiyun int xenbus_probe_node(struct xen_bus_type *bus, 115*4882a593Smuzhiyun const char *type, 116*4882a593Smuzhiyun const char *nodename); 117*4882a593Smuzhiyun int xenbus_probe_devices(struct xen_bus_type *bus); 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun void xenbus_dev_changed(const char *node, struct xen_bus_type *bus); 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun int xenbus_dev_suspend(struct device *dev); 122*4882a593Smuzhiyun int xenbus_dev_resume(struct device *dev); 123*4882a593Smuzhiyun int xenbus_dev_cancel(struct device *dev); 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun void xenbus_otherend_changed(struct xenbus_watch *watch, 126*4882a593Smuzhiyun const char *path, const char *token, 127*4882a593Smuzhiyun int ignore_on_shutdown); 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun int xenbus_read_otherend_details(struct xenbus_device *xendev, 130*4882a593Smuzhiyun char *id_node, char *path_node); 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun void xenbus_ring_ops_init(void); 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par); 135*4882a593Smuzhiyun void xenbus_dev_queue_reply(struct xb_req_data *req); 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun extern unsigned int xb_dev_generation_id; 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun #endif 140