xenbus.h 4.1 KB

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