event_channel.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. typedef uint32_t evtchn_port_t;
  11. DEFINE_GUEST_HANDLE(evtchn_port_t);
  12. /*
  13. * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
  14. * accepting interdomain bindings from domain <remote_dom>. A fresh port
  15. * is allocated in <dom> and returned as <port>.
  16. * NOTES:
  17. * 1. If the caller is unprivileged then <dom> must be DOMID_SELF.
  18. * 2. <rdom> may be DOMID_SELF, allowing loopback connections.
  19. */
  20. #define EVTCHNOP_alloc_unbound 6
  21. struct evtchn_alloc_unbound {
  22. /* IN parameters */
  23. domid_t dom, remote_dom;
  24. /* OUT parameters */
  25. evtchn_port_t port;
  26. };
  27. /*
  28. * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
  29. * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
  30. * a port that is unbound and marked as accepting bindings from the calling
  31. * domain. A fresh port is allocated in the calling domain and returned as
  32. * <local_port>.
  33. * NOTES:
  34. * 2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
  35. */
  36. #define EVTCHNOP_bind_interdomain 0
  37. struct evtchn_bind_interdomain {
  38. /* IN parameters. */
  39. domid_t remote_dom;
  40. evtchn_port_t remote_port;
  41. /* OUT parameters. */
  42. evtchn_port_t local_port;
  43. };
  44. /*
  45. * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
  46. * vcpu.
  47. * NOTES:
  48. * 1. A virtual IRQ may be bound to at most one event channel per vcpu.
  49. * 2. The allocated event channel is bound to the specified vcpu. The binding
  50. * may not be changed.
  51. */
  52. #define EVTCHNOP_bind_virq 1
  53. struct evtchn_bind_virq {
  54. /* IN parameters. */
  55. uint32_t virq;
  56. uint32_t vcpu;
  57. /* OUT parameters. */
  58. evtchn_port_t port;
  59. };
  60. /*
  61. * EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.
  62. * NOTES:
  63. * 1. A physical IRQ may be bound to at most one event channel per domain.
  64. * 2. Only a sufficiently-privileged domain may bind to a physical IRQ.
  65. */
  66. #define EVTCHNOP_bind_pirq 2
  67. struct evtchn_bind_pirq {
  68. /* IN parameters. */
  69. uint32_t pirq;
  70. #define BIND_PIRQ__WILL_SHARE 1
  71. uint32_t flags; /* BIND_PIRQ__* */
  72. /* OUT parameters. */
  73. evtchn_port_t port;
  74. };
  75. /*
  76. * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
  77. * NOTES:
  78. * 1. The allocated event channel is bound to the specified vcpu. The binding
  79. * may not be changed.
  80. */
  81. #define EVTCHNOP_bind_ipi 7
  82. struct evtchn_bind_ipi {
  83. uint32_t vcpu;
  84. /* OUT parameters. */
  85. evtchn_port_t port;
  86. };
  87. /*
  88. * EVTCHNOP_close: Close a local event channel <port>. If the channel is
  89. * interdomain then the remote end is placed in the unbound state
  90. * (EVTCHNSTAT_unbound), awaiting a new connection.
  91. */
  92. #define EVTCHNOP_close 3
  93. struct evtchn_close {
  94. /* IN parameters. */
  95. evtchn_port_t port;
  96. };
  97. /*
  98. * EVTCHNOP_send: Send an event to the remote end of the channel whose local
  99. * endpoint is <port>.
  100. */
  101. #define EVTCHNOP_send 4
  102. struct evtchn_send {
  103. /* IN parameters. */
  104. evtchn_port_t port;
  105. };
  106. /*
  107. * EVTCHNOP_status: Get the current status of the communication channel which
  108. * has an endpoint at <dom, port>.
  109. * NOTES:
  110. * 1. <dom> may be specified as DOMID_SELF.
  111. * 2. Only a sufficiently-privileged domain may obtain the status of an event
  112. * channel for which <dom> is not DOMID_SELF.
  113. */
  114. #define EVTCHNOP_status 5
  115. struct evtchn_status {
  116. /* IN parameters */
  117. domid_t dom;
  118. evtchn_port_t port;
  119. /* OUT parameters */
  120. #define EVTCHNSTAT_closed 0 /* Channel is not in use. */
  121. #define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/
  122. #define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
  123. #define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
  124. #define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
  125. #define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */
  126. uint32_t status;
  127. uint32_t vcpu; /* VCPU to which this channel is bound. */
  128. union {
  129. struct {
  130. domid_t dom;
  131. } unbound; /* EVTCHNSTAT_unbound */
  132. struct {
  133. domid_t dom;
  134. evtchn_port_t port;
  135. } interdomain; /* EVTCHNSTAT_interdomain */
  136. uint32_t pirq; /* EVTCHNSTAT_pirq */
  137. uint32_t virq; /* EVTCHNSTAT_virq */
  138. } u;
  139. };
  140. /*
  141. * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
  142. * event is pending.
  143. * NOTES:
  144. * 1. IPI- and VIRQ-bound channels always notify the vcpu that initialised
  145. * the binding. This binding cannot be changed.
  146. * 2. All other channels notify vcpu0 by default. This default is set when
  147. * the channel is allocated (a port that is freed and subsequently reused
  148. * has its binding reset to vcpu0).
  149. */
  150. #define EVTCHNOP_bind_vcpu 8
  151. struct evtchn_bind_vcpu {
  152. /* IN parameters. */
  153. evtchn_port_t port;
  154. uint32_t vcpu;
  155. };
  156. /*
  157. * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
  158. * a notification to the appropriate VCPU if an event is pending.
  159. */
  160. #define EVTCHNOP_unmask 9
  161. struct evtchn_unmask {
  162. /* IN parameters. */
  163. evtchn_port_t port;
  164. };
  165. struct evtchn_op {
  166. uint32_t cmd; /* EVTCHNOP_* */
  167. union {
  168. struct evtchn_alloc_unbound alloc_unbound;
  169. struct evtchn_bind_interdomain bind_interdomain;
  170. struct evtchn_bind_virq bind_virq;
  171. struct evtchn_bind_pirq bind_pirq;
  172. struct evtchn_bind_ipi bind_ipi;
  173. struct evtchn_close close;
  174. struct evtchn_send send;
  175. struct evtchn_status status;
  176. struct evtchn_bind_vcpu bind_vcpu;
  177. struct evtchn_unmask unmask;
  178. } u;
  179. };
  180. DEFINE_GUEST_HANDLE_STRUCT(evtchn_op);
  181. #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */