iPXE
include
xen
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
67
typedef
uint32_t
evtchn_port_t
;
68
DEFINE_XEN_GUEST_HANDLE
(
evtchn_port_t
);
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
*/
78
struct
evtchn_alloc_unbound
{
79
/* IN parameters */
80
domid_t
dom
,
remote_dom
;
81
/* OUT parameters */
82
evtchn_port_t
port
;
83
};
84
typedef
struct
evtchn_alloc_unbound
evtchn_alloc_unbound_t
;
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
*/
106
struct
evtchn_bind_interdomain
{
107
/* IN parameters. */
108
domid_t
remote_dom
;
109
evtchn_port_t
remote_port
;
110
/* OUT parameters. */
111
evtchn_port_t
local_port
;
112
};
113
typedef
struct
evtchn_bind_interdomain
evtchn_bind_interdomain_t
;
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
*/
127
struct
evtchn_bind_virq
{
128
/* IN parameters. */
129
uint32_t
virq
;
/* enum virq */
130
uint32_t
vcpu
;
131
/* OUT parameters. */
132
evtchn_port_t
port
;
133
};
134
typedef
struct
evtchn_bind_virq
evtchn_bind_virq_t
;
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
*/
142
struct
evtchn_bind_pirq
{
143
/* IN parameters. */
144
uint32_t
pirq
;
145
#define BIND_PIRQ__WILL_SHARE 1
146
uint32_t
flags
;
/* BIND_PIRQ__* */
147
/* OUT parameters. */
148
evtchn_port_t
port
;
149
};
150
typedef
struct
evtchn_bind_pirq
evtchn_bind_pirq_t
;
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
*/
158
struct
evtchn_bind_ipi
{
159
uint32_t
vcpu
;
160
/* OUT parameters. */
161
evtchn_port_t
port
;
162
};
163
typedef
struct
evtchn_bind_ipi
evtchn_bind_ipi_t
;
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. */
172
evtchn_port_t
port
;
173
};
174
typedef
struct
evtchn_close
evtchn_close_t
;
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. */
182
evtchn_port_t
port
;
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
*/
194
struct
evtchn_status
{
195
/* IN parameters */
196
domid_t
dom
;
197
evtchn_port_t
port
;
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 */
205
uint32_t
status
;
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
;
213
evtchn_port_t
port
;
214
}
interdomain
;
/* EVTCHNSTAT_interdomain */
215
uint32_t
pirq
;
/* EVTCHNSTAT_pirq */
216
uint32_t
virq
;
/* EVTCHNSTAT_virq */
217
}
u
;
218
};
219
typedef
struct
evtchn_status
evtchn_status_t
;
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
*/
233
struct
evtchn_bind_vcpu
{
234
/* IN parameters. */
235
evtchn_port_t
port
;
236
uint32_t
vcpu
;
237
};
238
typedef
struct
evtchn_bind_vcpu
evtchn_bind_vcpu_t
;
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
*/
244
struct
evtchn_unmask
{
245
/* IN parameters. */
246
evtchn_port_t
port
;
247
};
248
typedef
struct
evtchn_unmask
evtchn_unmask_t
;
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. */
262
domid_t
dom
;
263
};
264
typedef
struct
evtchn_reset
evtchn_reset_t
;
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
*/
273
struct
evtchn_init_control
{
274
/* IN parameters. */
275
uint64_t
control_gfn
;
276
uint32_t
offset
;
277
uint32_t
vcpu
;
278
/* OUT parameters. */
279
uint8_t
link_bits
;
280
uint8_t
_pad
[7];
281
};
282
typedef
struct
evtchn_init_control
evtchn_init_control_t
;
283
284
/*
285
* EVTCHNOP_expand_array: add an additional page to the event array.
286
*/
287
struct
evtchn_expand_array
{
288
/* IN parameters. */
289
uint64_t
array_gfn
;
290
};
291
typedef
struct
evtchn_expand_array
evtchn_expand_array_t
;
292
293
/*
294
* EVTCHNOP_set_priority: set the priority for an event channel.
295
*/
296
struct
evtchn_set_priority
{
297
/* IN parameters. */
298
evtchn_port_t
port
;
299
uint32_t
priority
;
300
};
301
typedef
struct
evtchn_set_priority
evtchn_set_priority_t
;
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
{
312
evtchn_alloc_unbound_t
alloc_unbound
;
313
evtchn_bind_interdomain_t
bind_interdomain
;
314
evtchn_bind_virq_t
bind_virq
;
315
evtchn_bind_pirq_t
bind_pirq
;
316
evtchn_bind_ipi_t
bind_ipi
;
317
evtchn_close_t
close
;
318
evtchn_send_t
send
;
319
evtchn_status_t
status
;
320
evtchn_bind_vcpu_t
bind_vcpu
;
321
evtchn_unmask_t
unmask
;
322
}
u
;
323
};
324
typedef
struct
evtchn_op
evtchn_op_t
;
325
DEFINE_XEN_GUEST_HANDLE
(
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
344
typedef
uint32_t
event_word_t
;
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
356
struct
evtchn_fifo_control_block
{
357
uint32_t
ready
;
358
uint32_t
_rsvd
;
359
uint32_t
head
[
EVTCHN_FIFO_MAX_QUEUES
];
360
};
361
typedef
struct
evtchn_fifo_control_block
evtchn_fifo_control_block_t
;
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_bind_interdomain::remote_dom
domid_t remote_dom
Definition:
event_channel.h:108
evtchn_unmask
Definition:
event_channel.h:244
evtchn_send::port
evtchn_port_t port
Definition:
event_channel.h:182
evtchn_init_control::link_bits
uint8_t link_bits
Definition:
event_channel.h:279
DEFINE_XEN_GUEST_HANDLE
DEFINE_XEN_GUEST_HANDLE(evtchn_port_t)
domid_t
uint16_t domid_t
Definition:
xen.h:608
evtchn_expand_array
Definition:
event_channel.h:287
evtchn_alloc_unbound
Definition:
event_channel.h:78
evtchn_bind_pirq::flags
uint32_t flags
Definition:
event_channel.h:146
evtchn_op::send
evtchn_send_t send
Definition:
event_channel.h:318
evtchn_bind_interdomain
Definition:
event_channel.h:106
evtchn_expand_array::array_gfn
uint64_t array_gfn
Definition:
event_channel.h:289
evtchn_status::port
evtchn_port_t port
Definition:
event_channel.h:197
xen.h
evtchn_op::u
union evtchn_op::@660 u
evtchn_bind_interdomain::remote_port
evtchn_port_t remote_port
Definition:
event_channel.h:109
evtchn_op::status
evtchn_status_t status
Definition:
event_channel.h:319
evtchn_init_control::vcpu
uint32_t vcpu
Definition:
event_channel.h:277
evtchn_status::pirq
uint32_t pirq
Definition:
event_channel.h:215
evtchn_bind_ipi::vcpu
uint32_t vcpu
Definition:
event_channel.h:159
evtchn_fifo_control_block
Definition:
event_channel.h:356
uint64_t
unsigned long long uint64_t
Definition:
stdint.h:13
evtchn_port_t
uint32_t evtchn_port_t
Definition:
event_channel.h:67
evtchn_reset::dom
domid_t dom
Definition:
event_channel.h:262
evtchn_bind_virq::virq
uint32_t virq
Definition:
event_channel.h:129
evtchn_bind_ipi
Definition:
event_channel.h:158
evtchn_bind_virq
Definition:
event_channel.h:127
evtchn_op
Definition:
event_channel.h:309
evtchn_bind_ipi::port
evtchn_port_t port
Definition:
event_channel.h:161
evtchn_bind_pirq::pirq
uint32_t pirq
Definition:
event_channel.h:144
EVTCHN_FIFO_MAX_QUEUES
#define EVTCHN_FIFO_MAX_QUEUES
Definition:
event_channel.h:342
evtchn_status::status
uint32_t status
Definition:
event_channel.h:205
evtchn_bind_pirq
Definition:
event_channel.h:142
evtchn_bind_vcpu::vcpu
uint32_t vcpu
Definition:
event_channel.h:236
evtchn_op::cmd
uint32_t cmd
Definition:
event_channel.h:310
event_word_t
uint32_t event_word_t
Definition:
event_channel.h:344
evtchn_close
Definition:
event_channel.h:170
evtchn_bind_pirq::port
evtchn_port_t port
Definition:
event_channel.h:148
evtchn_fifo_control_block::ready
uint32_t ready
Definition:
event_channel.h:357
evtchn_op::close
evtchn_close_t close
Definition:
event_channel.h:317
evtchn_fifo_control_block::_rsvd
uint32_t _rsvd
Definition:
event_channel.h:358
evtchn_op::bind_pirq
evtchn_bind_pirq_t bind_pirq
Definition:
event_channel.h:315
evtchn_bind_virq::port
evtchn_port_t port
Definition:
event_channel.h:132
evtchn_init_control::offset
uint32_t offset
Definition:
event_channel.h:276
evtchn_op::bind_ipi
evtchn_bind_ipi_t bind_ipi
Definition:
event_channel.h:316
evtchn_alloc_unbound::dom
domid_t dom
Definition:
event_channel.h:80
evtchn_init_control::control_gfn
uint64_t control_gfn
Definition:
event_channel.h:275
evtchn_alloc_unbound::remote_dom
domid_t remote_dom
Definition:
event_channel.h:80
evtchn_set_priority::priority
uint32_t priority
Definition:
event_channel.h:299
evtchn_send
Definition:
event_channel.h:180
evtchn_bind_interdomain::local_port
evtchn_port_t local_port
Definition:
event_channel.h:111
evtchn_op::alloc_unbound
evtchn_alloc_unbound_t alloc_unbound
Definition:
event_channel.h:312
evtchn_op::bind_interdomain
evtchn_bind_interdomain_t bind_interdomain
Definition:
event_channel.h:313
evtchn_status::vcpu
uint32_t vcpu
Definition:
event_channel.h:206
evtchn_status::u
union evtchn_status::@657 u
evtchn_init_control::_pad
uint8_t _pad[7]
Definition:
event_channel.h:280
evtchn_bind_virq::vcpu
uint32_t vcpu
Definition:
event_channel.h:130
uint8_t
unsigned char uint8_t
Definition:
stdint.h:10
evtchn_set_priority::port
evtchn_port_t port
Definition:
event_channel.h:298
evtchn_bind_vcpu::port
evtchn_port_t port
Definition:
event_channel.h:235
uint32_t
unsigned int uint32_t
Definition:
stdint.h:12
evtchn_status::interdomain
struct evtchn_status::@657::@659 interdomain
evtchn_unmask::port
evtchn_port_t port
Definition:
event_channel.h:246
evtchn_set_priority
Definition:
event_channel.h:296
evtchn_op::bind_vcpu
evtchn_bind_vcpu_t bind_vcpu
Definition:
event_channel.h:320
evtchn_alloc_unbound::port
evtchn_port_t port
Definition:
event_channel.h:82
evtchn_init_control
Definition:
event_channel.h:273
evtchn_status::unbound
struct evtchn_status::@657::@658 unbound
evtchn_status::virq
uint32_t virq
Definition:
event_channel.h:216
evtchn_fifo_control_block::head
uint32_t head[EVTCHN_FIFO_MAX_QUEUES]
Definition:
event_channel.h:359
evtchn_reset
Definition:
event_channel.h:260
evtchn_bind_vcpu
Definition:
event_channel.h:233
evtchn_status::dom
domid_t dom
Definition:
event_channel.h:196
evtchn_close::port
evtchn_port_t port
Definition:
event_channel.h:172
evtchn_op::bind_virq
evtchn_bind_virq_t bind_virq
Definition:
event_channel.h:314
FILE_LICENCE
FILE_LICENCE(MIT)
evtchn_status
Definition:
event_channel.h:194
evtchn_op::unmask
evtchn_unmask_t unmask
Definition:
event_channel.h:321
Generated by
1.8.15