event_channel.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /******************************************************************************
  2. * event_channel.h
  3. *
  4. * Event channels between domains.
  5. *
  6. * Copyright (c) 2003-2004, K A Fraser.
  7. */
  8. #ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
  9. #define __XEN_PUBLIC_EVENT_CHANNEL_H__
  10. #include <xen/interface/xen.h>
  11. typedef uint32_t evtchn_port_t;
  12. DEFINE_GUEST_HANDLE(evtchn_port_t);
  13. /*
  14. * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
  15. * accepting interdomain bindings from domain <remote_dom>. A fresh port
  16. * is allocated in <dom> and returned as <port>.
  17. * NOTES:
  18. * 1. If the caller is unprivileged then <dom> must be DOMID_SELF.
  19. * 2. <rdom> may be DOMID_SELF, allowing loopback connections.
  20. */
  21. #define EVTCHNOP_alloc_unbound 6
  22. struct evtchn_alloc_unbound {
  23. /* IN parameters */
  24. domid_t dom, remote_dom;
  25. /* OUT parameters */
  26. evtchn_port_t port;
  27. };
  28. /*
  29. * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
  30. * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
  31. * a port that is unbound and marked as accepting bindings from the calling
  32. * domain. A fresh port is allocated in the calling domain and returned as
  33. * <local_port>.
  34. * NOTES:
  35. * 2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
  36. */
  37. #define EVTCHNOP_bind_interdomain 0
  38. struct evtchn_bind_interdomain {
  39. /* IN parameters. */
  40. domid_t remote_dom;
  41. evtchn_port_t remote_port;
  42. /* OUT parameters. */
  43. evtchn_port_t local_port;
  44. };
  45. /*
  46. * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
  47. * vcpu.
  48. * NOTES:
  49. * 1. A virtual IRQ may be bound to at most one event channel per vcpu.
  50. * 2. The allocated event channel is bound to the specified vcpu. The binding
  51. * may not be changed.
  52. */
  53. #define EVTCHNOP_bind_virq 1
  54. struct evtchn_bind_virq {
  55. /* IN parameters. */
  56. uint32_t virq;
  57. uint32_t vcpu;
  58. /* OUT parameters. */
  59. evtchn_port_t port;
  60. };
  61. /*
  62. * EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.
  63. * NOTES:
  64. * 1. A physical IRQ may be bound to at most one event channel per domain.
  65. * 2. Only a sufficiently-privileged domain may bind to a physical IRQ.
  66. */
  67. #define EVTCHNOP_bind_pirq 2
  68. struct evtchn_bind_pirq {
  69. /* IN parameters. */
  70. uint32_t pirq;
  71. #define BIND_PIRQ__WILL_SHARE 1
  72. uint32_t flags; /* BIND_PIRQ__* */
  73. /* OUT parameters. */
  74. evtchn_port_t port;
  75. };
  76. /*
  77. * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
  78. * NOTES:
  79. * 1. The allocated event channel is bound to the specified vcpu. The binding
  80. * may not be changed.
  81. */
  82. #define EVTCHNOP_bind_ipi 7
  83. struct evtchn_bind_ipi {
  84. uint32_t vcpu;
  85. /* OUT parameters. */
  86. evtchn_port_t port;
  87. };
  88. /*
  89. * EVTCHNOP_close: Close a local event channel <port>. If the channel is
  90. * interdomain then the remote end is placed in the unbound state
  91. * (EVTCHNSTAT_unbound), awaiting a new connection.
  92. */
  93. #define EVTCHNOP_close 3
  94. struct evtchn_close {
  95. /* IN parameters. */
  96. evtchn_port_t port;
  97. };
  98. /*
  99. * EVTCHNOP_send: Send an event to the remote end of the channel whose local
  100. * endpoint is <port>.
  101. */
  102. #define EVTCHNOP_send 4
  103. struct evtchn_send {
  104. /* IN parameters. */
  105. evtchn_port_t port;
  106. };
  107. /*
  108. * EVTCHNOP_status: Get the current status of the communication channel which
  109. * has an endpoint at <dom, port>.
  110. * NOTES:
  111. * 1. <dom> may be specified as DOMID_SELF.
  112. * 2. Only a sufficiently-privileged domain may obtain the status of an event
  113. * channel for which <dom> is not DOMID_SELF.
  114. */
  115. #define EVTCHNOP_status 5
  116. struct evtchn_status {
  117. /* IN parameters */
  118. domid_t dom;
  119. evtchn_port_t port;
  120. /* OUT parameters */
  121. #define EVTCHNSTAT_closed 0 /* Channel is not in use. */
  122. #define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/
  123. #define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
  124. #define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
  125. #define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
  126. #define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */
  127. uint32_t status;
  128. uint32_t vcpu; /* VCPU to which this channel is bound. */
  129. union {
  130. struct {
  131. domid_t dom;
  132. } unbound; /* EVTCHNSTAT_unbound */
  133. struct {
  134. domid_t dom;
  135. evtchn_port_t port;
  136. } interdomain; /* EVTCHNSTAT_interdomain */
  137. uint32_t pirq; /* EVTCHNSTAT_pirq */
  138. uint32_t virq; /* EVTCHNSTAT_virq */
  139. } u;
  140. };
  141. /*
  142. * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
  143. * event is pending.
  144. * NOTES:
  145. * 1. IPI- and VIRQ-bound channels always notify the vcpu that initialised
  146. * the binding. This binding cannot be changed.
  147. * 2. All other channels notify vcpu0 by default. This default is set when
  148. * the channel is allocated (a port that is freed and subsequently reused
  149. * has its binding reset to vcpu0).
  150. */
  151. #define EVTCHNOP_bind_vcpu 8
  152. struct evtchn_bind_vcpu {
  153. /* IN parameters. */
  154. evtchn_port_t port;
  155. uint32_t vcpu;
  156. };
  157. /*
  158. * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
  159. * a notification to the appropriate VCPU if an event is pending.
  160. */
  161. #define EVTCHNOP_unmask 9
  162. struct evtchn_unmask {
  163. /* IN parameters. */
  164. evtchn_port_t port;
  165. };
  166. /*
  167. * EVTCHNOP_reset: Close all event channels associated with specified domain.
  168. * NOTES:
  169. * 1. <dom> may be specified as DOMID_SELF.
  170. * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
  171. */
  172. #define EVTCHNOP_reset 10
  173. struct evtchn_reset {
  174. /* IN parameters. */
  175. domid_t dom;
  176. };
  177. typedef struct evtchn_reset evtchn_reset_t;
  178. /*
  179. * EVTCHNOP_init_control: initialize the control block for the FIFO ABI.
  180. */
  181. #define EVTCHNOP_init_control 11
  182. struct evtchn_init_control {
  183. /* IN parameters. */
  184. uint64_t control_gfn;
  185. uint32_t offset;
  186. uint32_t vcpu;
  187. /* OUT parameters. */
  188. uint8_t link_bits;
  189. uint8_t _pad[7];
  190. };
  191. /*
  192. * EVTCHNOP_expand_array: add an additional page to the event array.
  193. */
  194. #define EVTCHNOP_expand_array 12
  195. struct evtchn_expand_array {
  196. /* IN parameters. */
  197. uint64_t array_gfn;
  198. };
  199. /*
  200. * EVTCHNOP_set_priority: set the priority for an event channel.
  201. */
  202. #define EVTCHNOP_set_priority 13
  203. struct evtchn_set_priority {
  204. /* IN parameters. */
  205. uint32_t port;
  206. uint32_t priority;
  207. };
  208. struct evtchn_op {
  209. uint32_t cmd; /* EVTCHNOP_* */
  210. union {
  211. struct evtchn_alloc_unbound alloc_unbound;
  212. struct evtchn_bind_interdomain bind_interdomain;
  213. struct evtchn_bind_virq bind_virq;
  214. struct evtchn_bind_pirq bind_pirq;
  215. struct evtchn_bind_ipi bind_ipi;
  216. struct evtchn_close close;
  217. struct evtchn_send send;
  218. struct evtchn_status status;
  219. struct evtchn_bind_vcpu bind_vcpu;
  220. struct evtchn_unmask unmask;
  221. } u;
  222. };
  223. DEFINE_GUEST_HANDLE_STRUCT(evtchn_op);
  224. /*
  225. * 2-level ABI
  226. */
  227. #define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)
  228. /*
  229. * FIFO ABI
  230. */
  231. /* Events may have priorities from 0 (highest) to 15 (lowest). */
  232. #define EVTCHN_FIFO_PRIORITY_MAX 0
  233. #define EVTCHN_FIFO_PRIORITY_DEFAULT 7
  234. #define EVTCHN_FIFO_PRIORITY_MIN 15
  235. #define EVTCHN_FIFO_MAX_QUEUES (EVTCHN_FIFO_PRIORITY_MIN + 1)
  236. typedef uint32_t event_word_t;
  237. #define EVTCHN_FIFO_PENDING 31
  238. #define EVTCHN_FIFO_MASKED 30
  239. #define EVTCHN_FIFO_LINKED 29
  240. #define EVTCHN_FIFO_BUSY 28
  241. #define EVTCHN_FIFO_LINK_BITS 17
  242. #define EVTCHN_FIFO_LINK_MASK ((1 << EVTCHN_FIFO_LINK_BITS) - 1)
  243. #define EVTCHN_FIFO_NR_CHANNELS (1 << EVTCHN_FIFO_LINK_BITS)
  244. struct evtchn_fifo_control_block {
  245. uint32_t ready;
  246. uint32_t _rsvd;
  247. event_word_t head[EVTCHN_FIFO_MAX_QUEUES];
  248. };
  249. #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */