iPXE
event_channel.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
2 /******************************************************************************
3  * event_channel.h
4  *
5  * Event channels between domains.
6  *
7  * Copyright (c) 2003-2004, K A Fraser.
8  */
9 
10 #ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
11 #define __XEN_PUBLIC_EVENT_CHANNEL_H__
12 
13 FILE_LICENCE ( MIT );
14 
15 #include "xen.h"
16 
17 /*
18  * `incontents 150 evtchn Event Channels
19  *
20  * Event channels are the basic primitive provided by Xen for event
21  * notifications. An event is the Xen equivalent of a hardware
22  * interrupt. They essentially store one bit of information, the event
23  * of interest is signalled by transitioning this bit from 0 to 1.
24  *
25  * Notifications are received by a guest via an upcall from Xen,
26  * indicating when an event arrives (setting the bit). Further
27  * notifications are masked until the bit is cleared again (therefore,
28  * guests must check the value of the bit after re-enabling event
29  * delivery to ensure no missed notifications).
30  *
31  * Event notifications can be masked by setting a flag; this is
32  * equivalent to disabling interrupts and can be used to ensure
33  * atomicity of certain operations in the guest kernel.
34  *
35  * Event channels are represented by the evtchn_* fields in
36  * struct shared_info and struct vcpu_info.
37  */
38 
39 /*
40  * ` enum neg_errnoval
41  * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, void *args)
42  * `
43  * @cmd == EVTCHNOP_* (event-channel operation).
44  * @args == struct evtchn_* Operation-specific extra arguments (NULL if none).
45  */
46 
47 /* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */
48 #define EVTCHNOP_bind_interdomain 0
49 #define EVTCHNOP_bind_virq 1
50 #define EVTCHNOP_bind_pirq 2
51 #define EVTCHNOP_close 3
52 #define EVTCHNOP_send 4
53 #define EVTCHNOP_status 5
54 #define EVTCHNOP_alloc_unbound 6
55 #define EVTCHNOP_bind_ipi 7
56 #define EVTCHNOP_bind_vcpu 8
57 #define EVTCHNOP_unmask 9
58 #define EVTCHNOP_reset 10
59 #define EVTCHNOP_init_control 11
60 #define EVTCHNOP_expand_array 12
61 #define EVTCHNOP_set_priority 13
62 #ifdef __XEN__
63 #define EVTCHNOP_reset_cont 14
64 #endif
65 /* ` } */
66 
69 
70 /*
71  * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
72  * accepting interdomain bindings from domain <remote_dom>. A fresh port
73  * is allocated in <dom> and returned as <port>.
74  * NOTES:
75  * 1. If the caller is unprivileged then <dom> must be DOMID_SELF.
76  * 2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
77  */
79  /* IN parameters */
81  /* OUT parameters */
83 };
85 
86 /*
87  * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
88  * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
89  * a port that is unbound and marked as accepting bindings from the calling
90  * domain. A fresh port is allocated in the calling domain and returned as
91  * <local_port>.
92  *
93  * In case the peer domain has already tried to set our event channel
94  * pending, before it was bound, EVTCHNOP_bind_interdomain always sets
95  * the local event channel pending.
96  *
97  * The usual pattern of use, in the guest's upcall (or subsequent
98  * handler) is as follows: (Re-enable the event channel for subsequent
99  * signalling and then) check for the existence of whatever condition
100  * is being waited for by other means, and take whatever action is
101  * needed (if any).
102  *
103  * NOTES:
104  * 1. <remote_dom> may be DOMID_SELF, allowing loopback connections.
105  */
107  /* IN parameters. */
110  /* OUT parameters. */
112 };
114 
115 /*
116  * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
117  * vcpu.
118  * NOTES:
119  * 1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list
120  * in xen.h for the classification of each VIRQ.
121  * 2. Global VIRQs must be allocated on VCPU0 but can subsequently be
122  * re-bound via EVTCHNOP_bind_vcpu.
123  * 3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu.
124  * The allocated event channel is bound to the specified vcpu and the
125  * binding cannot be changed.
126  */
128  /* IN parameters. */
129  uint32_t virq; /* enum virq */
131  /* OUT parameters. */
133 };
135 
136 /*
137  * EVTCHNOP_bind_pirq: Bind a local event channel to a real IRQ (PIRQ <irq>).
138  * NOTES:
139  * 1. A physical IRQ may be bound to at most one event channel per domain.
140  * 2. Only a sufficiently-privileged domain may bind to a physical IRQ.
141  */
143  /* IN parameters. */
145 #define BIND_PIRQ__WILL_SHARE 1
146  uint32_t flags; /* BIND_PIRQ__* */
147  /* OUT parameters. */
149 };
151 
152 /*
153  * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
154  * NOTES:
155  * 1. The allocated event channel is bound to the specified vcpu. The binding
156  * may not be changed.
157  */
160  /* OUT parameters. */
162 };
164 
165 /*
166  * EVTCHNOP_close: Close a local event channel <port>. If the channel is
167  * interdomain then the remote end is placed in the unbound state
168  * (EVTCHNSTAT_unbound), awaiting a new connection.
169  */
170 struct evtchn_close {
171  /* IN parameters. */
173 };
175 
176 /*
177  * EVTCHNOP_send: Send an event to the remote end of the channel whose local
178  * endpoint is <port>.
179  */
180 struct evtchn_send {
181  /* IN parameters. */
183 };
184 typedef struct evtchn_send evtchn_send_t;
185 
186 /*
187  * EVTCHNOP_status: Get the current status of the communication channel which
188  * has an endpoint at <dom, port>.
189  * NOTES:
190  * 1. <dom> may be specified as DOMID_SELF.
191  * 2. Only a sufficiently-privileged domain may obtain the status of an event
192  * channel for which <dom> is not DOMID_SELF.
193  */
195  /* IN parameters */
198  /* OUT parameters */
199 #define EVTCHNSTAT_closed 0 /* Channel is not in use. */
200 #define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/
201 #define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
202 #define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
203 #define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
204 #define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */
206  uint32_t vcpu; /* VCPU to which this channel is bound. */
207  union {
208  struct {
209  domid_t dom;
210  } unbound; /* EVTCHNSTAT_unbound */
211  struct {
212  domid_t dom;
214  } interdomain; /* EVTCHNSTAT_interdomain */
215  uint32_t pirq; /* EVTCHNSTAT_pirq */
216  uint32_t virq; /* EVTCHNSTAT_virq */
217  } u;
218 };
220 
221 /*
222  * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
223  * event is pending.
224  * NOTES:
225  * 1. IPI-bound channels always notify the vcpu specified at bind time.
226  * This binding cannot be changed.
227  * 2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time.
228  * This binding cannot be changed.
229  * 3. All other channels notify vcpu0 by default. This default is set when
230  * the channel is allocated (a port that is freed and subsequently reused
231  * has its binding reset to vcpu0).
232  */
234  /* IN parameters. */
237 };
239 
240 /*
241  * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
242  * a notification to the appropriate VCPU if an event is pending.
243  */
245  /* IN parameters. */
247 };
249 
250 /*
251  * EVTCHNOP_reset: Close all event channels associated with specified domain.
252  * NOTES:
253  * 1. <dom> may be specified as DOMID_SELF.
254  * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
255  * 3. Destroys all control blocks and event array, resets event channel
256  * operations to 2-level ABI if called with <dom> == DOMID_SELF and FIFO
257  * ABI was used. Guests should not bind events during EVTCHNOP_reset call
258  * as these events are likely to be lost.
259  */
260 struct evtchn_reset {
261  /* IN parameters. */
263 };
265 
266 /*
267  * EVTCHNOP_init_control: initialize the control block for the FIFO ABI.
268  *
269  * Note: any events that are currently pending will not be resent and
270  * will be lost. Guests should call this before binding any event to
271  * avoid losing any events.
272  */
274  /* IN parameters. */
278  /* OUT parameters. */
281 };
283 
284 /*
285  * EVTCHNOP_expand_array: add an additional page to the event array.
286  */
288  /* IN parameters. */
290 };
292 
293 /*
294  * EVTCHNOP_set_priority: set the priority for an event channel.
295  */
297  /* IN parameters. */
300 };
302 
303 /*
304  * ` enum neg_errnoval
305  * ` HYPERVISOR_event_channel_op_compat(struct evtchn_op *op)
306  * `
307  * Superceded by new event_channel_op() hypercall since 0x00030202.
308  */
309 struct evtchn_op {
310  uint32_t cmd; /* enum event_channel_op */
311  union {
322  } u;
323 };
324 typedef struct evtchn_op evtchn_op_t;
326 
327 /*
328  * 2-level ABI
329  */
330 
331 #define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)
332 
333 /*
334  * FIFO ABI
335  */
336 
337 /* Events may have priorities from 0 (highest) to 15 (lowest). */
338 #define EVTCHN_FIFO_PRIORITY_MAX 0
339 #define EVTCHN_FIFO_PRIORITY_DEFAULT 7
340 #define EVTCHN_FIFO_PRIORITY_MIN 15
341 
342 #define EVTCHN_FIFO_MAX_QUEUES (EVTCHN_FIFO_PRIORITY_MIN + 1)
343 
345 
346 #define EVTCHN_FIFO_PENDING 31
347 #define EVTCHN_FIFO_MASKED 30
348 #define EVTCHN_FIFO_LINKED 29
349 #define EVTCHN_FIFO_BUSY 28
350 
351 #define EVTCHN_FIFO_LINK_BITS 17
352 #define EVTCHN_FIFO_LINK_MASK ((1 << EVTCHN_FIFO_LINK_BITS) - 1)
353 
354 #define EVTCHN_FIFO_NR_CHANNELS (1 << EVTCHN_FIFO_LINK_BITS)
355 
360 };
362 
363 #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
364 
365 /*
366  * Local variables:
367  * mode: C
368  * c-file-style: "BSD"
369  * c-basic-offset: 4
370  * tab-width: 4
371  * indent-tabs-mode: nil
372  * End:
373  */
evtchn_port_t port
DEFINE_XEN_GUEST_HANDLE(evtchn_port_t)
uint16_t domid_t
Definition: xen.h:608
union evtchn_status::@603 u
evtchn_send_t send
evtchn_port_t port
evtchn_port_t remote_port
evtchn_status_t status
struct evtchn_status::@603::@604 unbound
unsigned long long uint64_t
Definition: stdint.h:13
uint32_t evtchn_port_t
Definition: event_channel.h:67
evtchn_port_t port
#define EVTCHN_FIFO_MAX_QUEUES
uint32_t status
uint32_t cmd
uint32_t event_word_t
evtchn_port_t port
evtchn_close_t close
evtchn_bind_pirq_t bind_pirq
evtchn_port_t port
evtchn_bind_ipi_t bind_ipi
union evtchn_op::@606 u
evtchn_port_t local_port
evtchn_alloc_unbound_t alloc_unbound
evtchn_bind_interdomain_t bind_interdomain
unsigned char uint8_t
Definition: stdint.h:10
evtchn_port_t port
evtchn_port_t port
unsigned int uint32_t
Definition: stdint.h:12
evtchn_port_t port
evtchn_bind_vcpu_t bind_vcpu
evtchn_port_t port
Definition: event_channel.h:82
uint32_t head[EVTCHN_FIFO_MAX_QUEUES]
evtchn_port_t port
evtchn_bind_virq_t bind_virq
FILE_LICENCE(MIT)
struct evtchn_status::@603::@605 interdomain
evtchn_unmask_t unmask