xenbus.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. bool (*otherend_will_handle)(struct xenbus_watch *watch,
  44. const char *path, const char *token);
  45. void (*otherend_changed)(struct xenbus_watch *watch, const char *path,
  46. const char *token);
  47. struct bus_type bus;
  48. };
  49. enum xenstore_init {
  50. XS_UNKNOWN,
  51. XS_PV,
  52. XS_HVM,
  53. XS_LOCAL,
  54. };
  55. struct xs_watch_event {
  56. struct list_head list;
  57. unsigned int len;
  58. struct xenbus_watch *handle;
  59. const char *path;
  60. const char *token;
  61. char body[];
  62. };
  63. enum xb_req_state {
  64. xb_req_state_queued,
  65. xb_req_state_wait_reply,
  66. xb_req_state_got_reply,
  67. xb_req_state_aborted
  68. };
  69. struct xb_req_data {
  70. struct list_head list;
  71. wait_queue_head_t wq;
  72. struct xsd_sockmsg msg;
  73. uint32_t caller_req_id;
  74. enum xsd_sockmsg_type type;
  75. char *body;
  76. const struct kvec *vec;
  77. int num_vecs;
  78. int err;
  79. enum xb_req_state state;
  80. bool user_req;
  81. void (*cb)(struct xb_req_data *);
  82. void *par;
  83. };
  84. extern enum xenstore_init xen_store_domain_type;
  85. extern const struct attribute_group *xenbus_dev_groups[];
  86. extern struct mutex xs_response_mutex;
  87. extern struct list_head xs_reply_list;
  88. extern struct list_head xb_write_list;
  89. extern wait_queue_head_t xb_waitq;
  90. extern struct mutex xb_write_mutex;
  91. int xs_init(void);
  92. int xb_init_comms(void);
  93. void xb_deinit_comms(void);
  94. int xs_watch_msg(struct xs_watch_event *event);
  95. void xs_request_exit(struct xb_req_data *req);
  96. int xenbus_match(struct device *_dev, struct device_driver *_drv);
  97. int xenbus_dev_probe(struct device *_dev);
  98. void xenbus_dev_remove(struct device *_dev);
  99. int xenbus_register_driver_common(struct xenbus_driver *drv,
  100. struct xen_bus_type *bus,
  101. struct module *owner,
  102. const char *mod_name);
  103. int xenbus_probe_node(struct xen_bus_type *bus,
  104. const char *type,
  105. const char *nodename);
  106. int xenbus_probe_devices(struct xen_bus_type *bus);
  107. void xenbus_dev_changed(const char *node, struct xen_bus_type *bus);
  108. int xenbus_dev_suspend(struct device *dev);
  109. int xenbus_dev_resume(struct device *dev);
  110. int xenbus_dev_cancel(struct device *dev);
  111. void xenbus_otherend_changed(struct xenbus_watch *watch,
  112. const char *path, const char *token,
  113. int ignore_on_shutdown);
  114. int xenbus_read_otherend_details(struct xenbus_device *xendev,
  115. char *id_node, char *path_node);
  116. void xenbus_ring_ops_init(void);
  117. int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par);
  118. void xenbus_dev_queue_reply(struct xb_req_data *req);
  119. extern unsigned int xb_dev_generation_id;
  120. #endif