event_channel.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. struct evtchn_op {
  167. uint32_t cmd; /* EVTCHNOP_* */
  168. union {
  169. struct evtchn_alloc_unbound alloc_unbound;
  170. struct evtchn_bind_interdomain bind_interdomain;
  171. struct evtchn_bind_virq bind_virq;
  172. struct evtchn_bind_pirq bind_pirq;
  173. struct evtchn_bind_ipi bind_ipi;
  174. struct evtchn_close close;
  175. struct evtchn_send send;
  176. struct evtchn_status status;
  177. struct evtchn_bind_vcpu bind_vcpu;
  178. struct evtchn_unmask unmask;
  179. } u;
  180. };
  181. DEFINE_GUEST_HANDLE_STRUCT(evtchn_op);
  182. #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */