iPXE
event_channel.h
Go to the documentation of this file.
1 /******************************************************************************
2  * event_channel.h
3  *
4  * Event channels between domains.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  *
24  * Copyright (c) 2003-2004, K A Fraser.
25  */
26 
27 #ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
28 #define __XEN_PUBLIC_EVENT_CHANNEL_H__
29 
30 FILE_LICENCE ( MIT );
31 
32 #include "xen.h"
33 
34 /*
35  * `incontents 150 evtchn Event Channels
36  *
37  * Event channels are the basic primitive provided by Xen for event
38  * notifications. An event is the Xen equivalent of a hardware
39  * interrupt. They essentially store one bit of information, the event
40  * of interest is signalled by transitioning this bit from 0 to 1.
41  *
42  * Notifications are received by a guest via an upcall from Xen,
43  * indicating when an event arrives (setting the bit). Further
44  * notifications are masked until the bit is cleared again (therefore,
45  * guests must check the value of the bit after re-enabling event
46  * delivery to ensure no missed notifications).
47  *
48  * Event notifications can be masked by setting a flag; this is
49  * equivalent to disabling interrupts and can be used to ensure
50  * atomicity of certain operations in the guest kernel.
51  *
52  * Event channels are represented by the evtchn_* fields in
53  * struct shared_info and struct vcpu_info.
54  */
55 
56 /*
57  * ` enum neg_errnoval
58  * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, void *args)
59  * `
60  * @cmd == EVTCHNOP_* (event-channel operation).
61  * @args == struct evtchn_* Operation-specific extra arguments (NULL if none).
62  */
63 
64 /* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */
65 #define EVTCHNOP_bind_interdomain 0
66 #define EVTCHNOP_bind_virq 1
67 #define EVTCHNOP_bind_pirq 2
68 #define EVTCHNOP_close 3
69 #define EVTCHNOP_send 4
70 #define EVTCHNOP_status 5
71 #define EVTCHNOP_alloc_unbound 6
72 #define EVTCHNOP_bind_ipi 7
73 #define EVTCHNOP_bind_vcpu 8
74 #define EVTCHNOP_unmask 9
75 #define EVTCHNOP_reset 10
76 #define EVTCHNOP_init_control 11
77 #define EVTCHNOP_expand_array 12
78 #define EVTCHNOP_set_priority 13
79 /* ` } */
80 
83 
84 /*
85  * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
86  * accepting interdomain bindings from domain <remote_dom>. A fresh port
87  * is allocated in <dom> and returned as <port>.
88  * NOTES:
89  * 1. If the caller is unprivileged then <dom> must be DOMID_SELF.
90  * 2. <rdom> may be DOMID_SELF, allowing loopback connections.
91  */
93  /* IN parameters */
95  /* OUT parameters */
97 };
99 
100 /*
101  * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
102  * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
103  * a port that is unbound and marked as accepting bindings from the calling
104  * domain. A fresh port is allocated in the calling domain and returned as
105  * <local_port>.
106  *
107  * In case the peer domain has already tried to set our event channel
108  * pending, before it was bound, EVTCHNOP_bind_interdomain always sets
109  * the local event channel pending.
110  *
111  * The usual pattern of use, in the guest's upcall (or subsequent
112  * handler) is as follows: (Re-enable the event channel for subsequent
113  * signalling and then) check for the existence of whatever condition
114  * is being waited for by other means, and take whatever action is
115  * needed (if any).
116  *
117  * NOTES:
118  * 1. <remote_dom> may be DOMID_SELF, allowing loopback connections.
119  */
121  /* IN parameters. */
124  /* OUT parameters. */
126 };
128 
129 /*
130  * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
131  * vcpu.
132  * NOTES:
133  * 1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list
134  * in xen.h for the classification of each VIRQ.
135  * 2. Global VIRQs must be allocated on VCPU0 but can subsequently be
136  * re-bound via EVTCHNOP_bind_vcpu.
137  * 3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu.
138  * The allocated event channel is bound to the specified vcpu and the
139  * binding cannot be changed.
140  */
142  /* IN parameters. */
143  uint32_t virq; /* enum virq */
145  /* OUT parameters. */
147 };
149 
150 /*
151  * EVTCHNOP_bind_pirq: Bind a local event channel to a real IRQ (PIRQ <irq>).
152  * NOTES:
153  * 1. A physical IRQ may be bound to at most one event channel per domain.
154  * 2. Only a sufficiently-privileged domain may bind to a physical IRQ.
155  */
157  /* IN parameters. */
159 #define BIND_PIRQ__WILL_SHARE 1
160  uint32_t flags; /* BIND_PIRQ__* */
161  /* OUT parameters. */
163 };
165 
166 /*
167  * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
168  * NOTES:
169  * 1. The allocated event channel is bound to the specified vcpu. The binding
170  * may not be changed.
171  */
174  /* OUT parameters. */
176 };
178 
179 /*
180  * EVTCHNOP_close: Close a local event channel <port>. If the channel is
181  * interdomain then the remote end is placed in the unbound state
182  * (EVTCHNSTAT_unbound), awaiting a new connection.
183  */
184 struct evtchn_close {
185  /* IN parameters. */
187 };
189 
190 /*
191  * EVTCHNOP_send: Send an event to the remote end of the channel whose local
192  * endpoint is <port>.
193  */
194 struct evtchn_send {
195  /* IN parameters. */
197 };
198 typedef struct evtchn_send evtchn_send_t;
199 
200 /*
201  * EVTCHNOP_status: Get the current status of the communication channel which
202  * has an endpoint at <dom, port>.
203  * NOTES:
204  * 1. <dom> may be specified as DOMID_SELF.
205  * 2. Only a sufficiently-privileged domain may obtain the status of an event
206  * channel for which <dom> is not DOMID_SELF.
207  */
209  /* IN parameters */
212  /* OUT parameters */
213 #define EVTCHNSTAT_closed 0 /* Channel is not in use. */
214 #define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/
215 #define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
216 #define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
217 #define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
218 #define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */
220  uint32_t vcpu; /* VCPU to which this channel is bound. */
221  union {
222  struct {
223  domid_t dom;
224  } unbound; /* EVTCHNSTAT_unbound */
225  struct {
226  domid_t dom;
228  } interdomain; /* EVTCHNSTAT_interdomain */
229  uint32_t pirq; /* EVTCHNSTAT_pirq */
230  uint32_t virq; /* EVTCHNSTAT_virq */
231  } u;
232 };
234 
235 /*
236  * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
237  * event is pending.
238  * NOTES:
239  * 1. IPI-bound channels always notify the vcpu specified at bind time.
240  * This binding cannot be changed.
241  * 2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time.
242  * This binding cannot be changed.
243  * 3. All other channels notify vcpu0 by default. This default is set when
244  * the channel is allocated (a port that is freed and subsequently reused
245  * has its binding reset to vcpu0).
246  */
248  /* IN parameters. */
251 };
253 
254 /*
255  * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
256  * a notification to the appropriate VCPU if an event is pending.
257  */
259  /* IN parameters. */
261 };
263 
264 /*
265  * EVTCHNOP_reset: Close all event channels associated with specified domain.
266  * NOTES:
267  * 1. <dom> may be specified as DOMID_SELF.
268  * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
269  */
270 struct evtchn_reset {
271  /* IN parameters. */
273 };
275 
276 /*
277  * EVTCHNOP_init_control: initialize the control block for the FIFO ABI.
278  *
279  * Note: any events that are currently pending will not be resent and
280  * will be lost. Guests should call this before binding any event to
281  * avoid losing any events.
282  */
284  /* IN parameters. */
288  /* OUT parameters. */
291 };
293 
294 /*
295  * EVTCHNOP_expand_array: add an additional page to the event array.
296  */
298  /* IN parameters. */
300 };
302 
303 /*
304  * EVTCHNOP_set_priority: set the priority for an event channel.
305  */
307  /* IN parameters. */
310 };
312 
313 /*
314  * ` enum neg_errnoval
315  * ` HYPERVISOR_event_channel_op_compat(struct evtchn_op *op)
316  * `
317  * Superceded by new event_channel_op() hypercall since 0x00030202.
318  */
319 struct evtchn_op {
320  uint32_t cmd; /* enum event_channel_op */
321  union {
332  } u;
333 };
334 typedef struct evtchn_op evtchn_op_t;
336 
337 /*
338  * 2-level ABI
339  */
340 
341 #define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)
342 
343 /*
344  * FIFO ABI
345  */
346 
347 /* Events may have priorities from 0 (highest) to 15 (lowest). */
348 #define EVTCHN_FIFO_PRIORITY_MAX 0
349 #define EVTCHN_FIFO_PRIORITY_DEFAULT 7
350 #define EVTCHN_FIFO_PRIORITY_MIN 15
351 
352 #define EVTCHN_FIFO_MAX_QUEUES (EVTCHN_FIFO_PRIORITY_MIN + 1)
353 
355 
356 #define EVTCHN_FIFO_PENDING 31
357 #define EVTCHN_FIFO_MASKED 30
358 #define EVTCHN_FIFO_LINKED 29
359 #define EVTCHN_FIFO_BUSY 28
360 
361 #define EVTCHN_FIFO_LINK_BITS 17
362 #define EVTCHN_FIFO_LINK_MASK ((1 << EVTCHN_FIFO_LINK_BITS) - 1)
363 
364 #define EVTCHN_FIFO_NR_CHANNELS (1 << EVTCHN_FIFO_LINK_BITS)
365 
370 };
372 
373 #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
374 
375 /*
376  * Local variables:
377  * mode: C
378  * c-file-style: "BSD"
379  * c-basic-offset: 4
380  * tab-width: 4
381  * indent-tabs-mode: nil
382  * End:
383  */
struct evtchn_bind_virq bind_virq
evtchn_port_t port
DEFINE_XEN_GUEST_HANDLE(evtchn_port_t)
uint16_t domid_t
Definition: xen.h:495
evtchn_port_t port
evtchn_port_t remote_port
unsigned long long uint64_t
Definition: stdint.h:13
uint32_t evtchn_port_t
Definition: event_channel.h:81
evtchn_port_t port
#define EVTCHN_FIFO_MAX_QUEUES
uint32_t status
uint32_t cmd
uint32_t event_word_t
struct evtchn_status::@573::@574 unbound
evtchn_port_t port
struct evtchn_bind_vcpu bind_vcpu
struct evtchn_close close
struct evtchn_bind_ipi bind_ipi
struct evtchn_bind_interdomain bind_interdomain
evtchn_port_t port
union evtchn_op::@576 u
union evtchn_status::@573 u
struct evtchn_alloc_unbound alloc_unbound
struct evtchn_status status
evtchn_port_t local_port
unsigned char uint8_t
Definition: stdint.h:10
evtchn_port_t port
unsigned int uint32_t
Definition: stdint.h:12
struct evtchn_unmask unmask
evtchn_port_t port
struct evtchn_bind_pirq bind_pirq
evtchn_port_t port
Definition: event_channel.h:96
struct evtchn_send send
uint32_t head[EVTCHN_FIFO_MAX_QUEUES]
evtchn_port_t port
struct evtchn_status::@573::@575 interdomain
FILE_LICENCE(MIT)