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
14FILE_SECBOOT ( PERMITTED );
15
16#include "xen.h"
17
18/*
19 * `incontents 150 evtchn Event Channels
20 *
21 * Event channels are the basic primitive provided by Xen for event
22 * notifications. An event is the Xen equivalent of a hardware
23 * interrupt. They essentially store one bit of information, the event
24 * of interest is signalled by transitioning this bit from 0 to 1.
25 *
26 * Notifications are received by a guest via an upcall from Xen,
27 * indicating when an event arrives (setting the bit). Further
28 * notifications are masked until the bit is cleared again (therefore,
29 * guests must check the value of the bit after re-enabling event
30 * delivery to ensure no missed notifications).
31 *
32 * Event notifications can be masked by setting a flag; this is
33 * equivalent to disabling interrupts and can be used to ensure
34 * atomicity of certain operations in the guest kernel.
35 *
36 * Event channels are represented by the evtchn_* fields in
37 * struct shared_info and struct vcpu_info.
38 */
39
40/*
41 * ` enum neg_errnoval
42 * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, void *args)
43 * `
44 * @cmd == EVTCHNOP_* (event-channel operation).
45 * @args == struct evtchn_* Operation-specific extra arguments (NULL if none).
46 */
47
48/* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */
49#define EVTCHNOP_bind_interdomain 0
50#define EVTCHNOP_bind_virq 1
51#define EVTCHNOP_bind_pirq 2
52#define EVTCHNOP_close 3
53#define EVTCHNOP_send 4
54#define EVTCHNOP_status 5
55#define EVTCHNOP_alloc_unbound 6
56#define EVTCHNOP_bind_ipi 7
57#define EVTCHNOP_bind_vcpu 8
58#define EVTCHNOP_unmask 9
59#define EVTCHNOP_reset 10
60#define EVTCHNOP_init_control 11
61#define EVTCHNOP_expand_array 12
62#define EVTCHNOP_set_priority 13
63#ifdef __XEN__
64#define EVTCHNOP_reset_cont 14
65#endif
66/* ` } */
67
70
71/*
72 * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
73 * accepting interdomain bindings from domain <remote_dom>. A fresh port
74 * is allocated in <dom> and returned as <port>.
75 * NOTES:
76 * 1. If the caller is unprivileged then <dom> must be DOMID_SELF.
77 * 2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
78 */
80 /* IN parameters */
82 /* OUT parameters */
84};
86
87/*
88 * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
89 * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
90 * a port that is unbound and marked as accepting bindings from the calling
91 * domain. A fresh port is allocated in the calling domain and returned as
92 * <local_port>.
93 *
94 * In case the peer domain has already tried to set our event channel
95 * pending, before it was bound, EVTCHNOP_bind_interdomain always sets
96 * the local event channel pending.
97 *
98 * The usual pattern of use, in the guest's upcall (or subsequent
99 * handler) is as follows: (Re-enable the event channel for subsequent
100 * signalling and then) check for the existence of whatever condition
101 * is being waited for by other means, and take whatever action is
102 * needed (if any).
103 *
104 * NOTES:
105 * 1. <remote_dom> may be DOMID_SELF, allowing loopback connections.
106 */
108 /* IN parameters. */
111 /* OUT parameters. */
113};
115
116/*
117 * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
118 * vcpu.
119 * NOTES:
120 * 1. Virtual IRQs are classified as per-vcpu, per-domain or global. See the
121 * VIRQ list in xen.h for the classification of each VIRQ.
122 * 2. Per-domain and global VIRQs must be allocated on vCPU0 but can
123 * subsequently be re-bound via EVTCHNOP_bind_vcpu.
124 * 3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu.
125 * The allocated event channel is bound to the specified vcpu and the
126 * binding cannot be changed.
127 */
129 /* IN parameters. */
130 uint32_t virq; /* enum virq */
132 /* OUT parameters. */
134};
136
137/*
138 * EVTCHNOP_bind_pirq: Bind a local event channel to a real IRQ (PIRQ <irq>).
139 * NOTES:
140 * 1. A physical IRQ may be bound to at most one event channel per domain.
141 * 2. Only a sufficiently-privileged domain may bind to a physical IRQ.
142 */
144 /* IN parameters. */
146#define BIND_PIRQ__WILL_SHARE 1
147 uint32_t flags; /* BIND_PIRQ__* */
148 /* OUT parameters. */
150};
152
153/*
154 * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
155 * NOTES:
156 * 1. The allocated event channel is bound to the specified vcpu. The binding
157 * may not be changed.
158 */
161 /* OUT parameters. */
163};
165
166/*
167 * EVTCHNOP_close: Close a local event channel <port>. If the channel is
168 * interdomain then the remote end is placed in the unbound state
169 * (EVTCHNSTAT_unbound), awaiting a new connection.
170 */
172 /* IN parameters. */
174};
176
177/*
178 * EVTCHNOP_send: Send an event to the remote end of the channel whose local
179 * endpoint is <port>.
180 */
182 /* IN parameters. */
184};
186
187/*
188 * EVTCHNOP_status: Get the current status of the communication channel which
189 * has an endpoint at <dom, port>.
190 * NOTES:
191 * 1. <dom> may be specified as DOMID_SELF.
192 * 2. Only a sufficiently-privileged domain may obtain the status of an event
193 * channel for which <dom> is not DOMID_SELF.
194 */
196 /* IN parameters */
199 /* OUT parameters */
200#define EVTCHNSTAT_closed 0 /* Channel is not in use. */
201#define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/
202#define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
203#define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
204#define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
205#define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */
207 uint32_t vcpu; /* VCPU to which this channel is bound. */
208 union {
209 struct {
210 domid_t dom;
211 } unbound; /* EVTCHNSTAT_unbound */
212 struct {
213 domid_t dom;
215 } interdomain; /* EVTCHNSTAT_interdomain */
216 uint32_t pirq; /* EVTCHNSTAT_pirq */
217 uint32_t virq; /* EVTCHNSTAT_virq */
218 } u;
219};
221
222/*
223 * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
224 * event is pending.
225 * NOTES:
226 * 1. IPI-bound channels always notify the vcpu specified at bind time.
227 * This binding cannot be changed.
228 * 2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time.
229 * This binding cannot be changed.
230 * 3. All other channels notify vcpu0 by default. This default is set when
231 * the channel is allocated (a port that is freed and subsequently reused
232 * has its binding reset to vcpu0).
233 */
235 /* IN parameters. */
238};
240
241/*
242 * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
243 * a notification to the appropriate VCPU if an event is pending.
244 */
246 /* IN parameters. */
248};
250
251/*
252 * EVTCHNOP_reset: Close all event channels associated with specified domain.
253 * NOTES:
254 * 1. <dom> may be specified as DOMID_SELF.
255 * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
256 * 3. Destroys all control blocks and event array, resets event channel
257 * operations to 2-level ABI if called with <dom> == DOMID_SELF and FIFO
258 * ABI was used. Guests should not bind events during EVTCHNOP_reset call
259 * as these events are likely to be lost.
260 */
262 /* IN parameters. */
264};
266
267/*
268 * EVTCHNOP_init_control: initialize the control block for the FIFO ABI.
269 *
270 * Note: any events that are currently pending will not be resent and
271 * will be lost. Guests should call this before binding any event to
272 * avoid losing any events.
273 */
275 /* IN parameters. */
279 /* OUT parameters. */
282};
284
285/*
286 * EVTCHNOP_expand_array: add an additional page to the event array.
287 */
289 /* IN parameters. */
291};
293
294/*
295 * EVTCHNOP_set_priority: set the priority for an event channel.
296 */
298 /* IN parameters. */
301};
303
304/*
305 * ` enum neg_errnoval
306 * ` HYPERVISOR_event_channel_op_compat(struct evtchn_op *op)
307 * `
308 * Superceded by new event_channel_op() hypercall since 0x00030202.
309 */
325typedef struct evtchn_op evtchn_op_t;
327
328/*
329 * 2-level ABI
330 */
331
332#define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)
333
334/*
335 * FIFO ABI
336 */
337
338/* Events may have priorities from 0 (highest) to 15 (lowest). */
339#define EVTCHN_FIFO_PRIORITY_MAX 0
340#define EVTCHN_FIFO_PRIORITY_DEFAULT 7
341#define EVTCHN_FIFO_PRIORITY_MIN 15
342
343#define EVTCHN_FIFO_MAX_QUEUES (EVTCHN_FIFO_PRIORITY_MIN + 1)
344
346
347#define EVTCHN_FIFO_PENDING 31
348#define EVTCHN_FIFO_MASKED 30
349#define EVTCHN_FIFO_LINKED 29
350#define EVTCHN_FIFO_BUSY 28
351
352#define EVTCHN_FIFO_LINK_BITS 17
353#define EVTCHN_FIFO_LINK_MASK ((1 << EVTCHN_FIFO_LINK_BITS) - 1)
354
355#define EVTCHN_FIFO_NR_CHANNELS (1 << EVTCHN_FIFO_LINK_BITS)
356
363
364#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
365
366/*
367 * Local variables:
368 * mode: C
369 * c-file-style: "BSD"
370 * c-basic-offset: 4
371 * tab-width: 4
372 * indent-tabs-mode: nil
373 * End:
374 */
u8 port
Port number.
Definition CIB_PRM.h:3
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
union @104331263140136355135267063077374276003064103115 u
struct evtchn_bind_pirq evtchn_bind_pirq_t
struct evtchn_bind_vcpu evtchn_bind_vcpu_t
struct evtchn_alloc_unbound evtchn_alloc_unbound_t
#define EVTCHN_FIFO_MAX_QUEUES
struct evtchn_set_priority evtchn_set_priority_t
struct evtchn_reset evtchn_reset_t
struct evtchn_send evtchn_send_t
struct evtchn_status evtchn_status_t
struct evtchn_expand_array evtchn_expand_array_t
uint32_t evtchn_port_t
struct evtchn_init_control evtchn_init_control_t
struct evtchn_bind_virq evtchn_bind_virq_t
struct evtchn_op evtchn_op_t
struct evtchn_bind_interdomain evtchn_bind_interdomain_t
uint32_t event_word_t
struct evtchn_close evtchn_close_t
struct evtchn_bind_ipi evtchn_bind_ipi_t
struct evtchn_unmask evtchn_unmask_t
struct evtchn_fifo_control_block evtchn_fifo_control_block_t
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
uint16_t domid_t
Definition xen.h:622
#define DEFINE_XEN_GUEST_HANDLE(name)
Definition nonxen.h:26
evtchn_port_t port
evtchn_port_t port
evtchn_port_t port
evtchn_port_t port
evtchn_port_t port
uint32_t head[EVTCHN_FIFO_MAX_QUEUES]
evtchn_status_t status
evtchn_bind_ipi_t bind_ipi
evtchn_unmask_t unmask
evtchn_send_t send
evtchn_bind_vcpu_t bind_vcpu
evtchn_alloc_unbound_t alloc_unbound
evtchn_bind_virq_t bind_virq
uint32_t cmd
evtchn_close_t close
evtchn_bind_interdomain_t bind_interdomain
evtchn_bind_pirq_t bind_pirq
evtchn_port_t port
evtchn_port_t port
struct evtchn_status::@027006106007247116320204352235013111340207200003::@130351126327007361257102366344215222316101113155 interdomain
struct evtchn_status::@027006106007247116320204352235013111340207200003::@117273224371246266050040362265102250111143062260 unbound
evtchn_port_t port