xref: /titanic_41/usr/src/uts/common/xen/public/event_channel.h (revision a576ab5b6e08c47732b3dedca9eaa8a8cbb85720)
1843e1988Sjohnlev /******************************************************************************
2843e1988Sjohnlev  * event_channel.h
3843e1988Sjohnlev  *
4843e1988Sjohnlev  * Event channels between domains.
5843e1988Sjohnlev  *
6843e1988Sjohnlev  * Permission is hereby granted, free of charge, to any person obtaining a copy
7843e1988Sjohnlev  * of this software and associated documentation files (the "Software"), to
8843e1988Sjohnlev  * deal in the Software without restriction, including without limitation the
9843e1988Sjohnlev  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10843e1988Sjohnlev  * sell copies of the Software, and to permit persons to whom the Software is
11843e1988Sjohnlev  * furnished to do so, subject to the following conditions:
12843e1988Sjohnlev  *
13843e1988Sjohnlev  * The above copyright notice and this permission notice shall be included in
14843e1988Sjohnlev  * all copies or substantial portions of the Software.
15843e1988Sjohnlev  *
16843e1988Sjohnlev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17843e1988Sjohnlev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18843e1988Sjohnlev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19843e1988Sjohnlev  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20843e1988Sjohnlev  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21843e1988Sjohnlev  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22843e1988Sjohnlev  * DEALINGS IN THE SOFTWARE.
23843e1988Sjohnlev  *
24843e1988Sjohnlev  * Copyright (c) 2003-2004, K A Fraser.
25843e1988Sjohnlev  */
26843e1988Sjohnlev 
27843e1988Sjohnlev #ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
28843e1988Sjohnlev #define __XEN_PUBLIC_EVENT_CHANNEL_H__
29843e1988Sjohnlev 
30843e1988Sjohnlev /*
31843e1988Sjohnlev  * Prototype for this hypercall is:
32843e1988Sjohnlev  *  int event_channel_op(int cmd, void *args)
33843e1988Sjohnlev  * @cmd  == EVTCHNOP_??? (event-channel operation).
34843e1988Sjohnlev  * @args == Operation-specific extra arguments (NULL if none).
35843e1988Sjohnlev  */
36843e1988Sjohnlev 
37843e1988Sjohnlev typedef uint32_t evtchn_port_t;
38843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
39843e1988Sjohnlev 
40843e1988Sjohnlev /*
41843e1988Sjohnlev  * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
42843e1988Sjohnlev  * accepting interdomain bindings from domain <remote_dom>. A fresh port
43843e1988Sjohnlev  * is allocated in <dom> and returned as <port>.
44843e1988Sjohnlev  * NOTES:
45843e1988Sjohnlev  *  1. If the caller is unprivileged then <dom> must be DOMID_SELF.
46843e1988Sjohnlev  *  2. <rdom> may be DOMID_SELF, allowing loopback connections.
47843e1988Sjohnlev  */
48843e1988Sjohnlev #define EVTCHNOP_alloc_unbound    6
49843e1988Sjohnlev struct evtchn_alloc_unbound {
50843e1988Sjohnlev     /* IN parameters */
51843e1988Sjohnlev     domid_t dom, remote_dom;
52843e1988Sjohnlev     /* OUT parameters */
53843e1988Sjohnlev     evtchn_port_t port;
54843e1988Sjohnlev };
55843e1988Sjohnlev typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
56843e1988Sjohnlev 
57843e1988Sjohnlev /*
58843e1988Sjohnlev  * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
59843e1988Sjohnlev  * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
60843e1988Sjohnlev  * a port that is unbound and marked as accepting bindings from the calling
61843e1988Sjohnlev  * domain. A fresh port is allocated in the calling domain and returned as
62843e1988Sjohnlev  * <local_port>.
63843e1988Sjohnlev  * NOTES:
64843e1988Sjohnlev  *  2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
65843e1988Sjohnlev  */
66843e1988Sjohnlev #define EVTCHNOP_bind_interdomain 0
67843e1988Sjohnlev struct evtchn_bind_interdomain {
68843e1988Sjohnlev     /* IN parameters. */
69843e1988Sjohnlev     domid_t remote_dom;
70843e1988Sjohnlev     evtchn_port_t remote_port;
71843e1988Sjohnlev     /* OUT parameters. */
72843e1988Sjohnlev     evtchn_port_t local_port;
73843e1988Sjohnlev };
74843e1988Sjohnlev typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t;
75843e1988Sjohnlev 
76843e1988Sjohnlev /*
77843e1988Sjohnlev  * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
78843e1988Sjohnlev  * vcpu.
79843e1988Sjohnlev  * NOTES:
80843e1988Sjohnlev  *  1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list
81843e1988Sjohnlev  *     in xen.h for the classification of each VIRQ.
82843e1988Sjohnlev  *  2. Global VIRQs must be allocated on VCPU0 but can subsequently be
83843e1988Sjohnlev  *     re-bound via EVTCHNOP_bind_vcpu.
84843e1988Sjohnlev  *  3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu.
85843e1988Sjohnlev  *     The allocated event channel is bound to the specified vcpu and the
86843e1988Sjohnlev  *     binding cannot be changed.
87843e1988Sjohnlev  */
88843e1988Sjohnlev #define EVTCHNOP_bind_virq        1
89843e1988Sjohnlev struct evtchn_bind_virq {
90843e1988Sjohnlev     /* IN parameters. */
91843e1988Sjohnlev     uint32_t virq;
92843e1988Sjohnlev     uint32_t vcpu;
93843e1988Sjohnlev     /* OUT parameters. */
94843e1988Sjohnlev     evtchn_port_t port;
95843e1988Sjohnlev };
96843e1988Sjohnlev typedef struct evtchn_bind_virq evtchn_bind_virq_t;
97843e1988Sjohnlev 
98843e1988Sjohnlev /*
99843e1988Sjohnlev  * EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.
100843e1988Sjohnlev  * NOTES:
101843e1988Sjohnlev  *  1. A physical IRQ may be bound to at most one event channel per domain.
102843e1988Sjohnlev  *  2. Only a sufficiently-privileged domain may bind to a physical IRQ.
103843e1988Sjohnlev  */
104843e1988Sjohnlev #define EVTCHNOP_bind_pirq        2
105843e1988Sjohnlev struct evtchn_bind_pirq {
106843e1988Sjohnlev     /* IN parameters. */
107843e1988Sjohnlev     uint32_t pirq;
108843e1988Sjohnlev #define BIND_PIRQ__WILL_SHARE 1
109843e1988Sjohnlev     uint32_t flags; /* BIND_PIRQ__* */
110843e1988Sjohnlev     /* OUT parameters. */
111843e1988Sjohnlev     evtchn_port_t port;
112843e1988Sjohnlev };
113843e1988Sjohnlev typedef struct evtchn_bind_pirq evtchn_bind_pirq_t;
114843e1988Sjohnlev 
115843e1988Sjohnlev /*
116843e1988Sjohnlev  * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
117843e1988Sjohnlev  * NOTES:
118843e1988Sjohnlev  *  1. The allocated event channel is bound to the specified vcpu. The binding
119843e1988Sjohnlev  *     may not be changed.
120843e1988Sjohnlev  */
121843e1988Sjohnlev #define EVTCHNOP_bind_ipi         7
122843e1988Sjohnlev struct evtchn_bind_ipi {
123843e1988Sjohnlev     uint32_t vcpu;
124843e1988Sjohnlev     /* OUT parameters. */
125843e1988Sjohnlev     evtchn_port_t port;
126843e1988Sjohnlev };
127843e1988Sjohnlev typedef struct evtchn_bind_ipi evtchn_bind_ipi_t;
128843e1988Sjohnlev 
129843e1988Sjohnlev /*
130843e1988Sjohnlev  * EVTCHNOP_close: Close a local event channel <port>. If the channel is
131843e1988Sjohnlev  * interdomain then the remote end is placed in the unbound state
132843e1988Sjohnlev  * (EVTCHNSTAT_unbound), awaiting a new connection.
133843e1988Sjohnlev  */
134843e1988Sjohnlev #define EVTCHNOP_close            3
135843e1988Sjohnlev struct evtchn_close {
136843e1988Sjohnlev     /* IN parameters. */
137843e1988Sjohnlev     evtchn_port_t port;
138843e1988Sjohnlev };
139843e1988Sjohnlev typedef struct evtchn_close evtchn_close_t;
140843e1988Sjohnlev 
141843e1988Sjohnlev /*
142843e1988Sjohnlev  * EVTCHNOP_send: Send an event to the remote end of the channel whose local
143843e1988Sjohnlev  * endpoint is <port>.
144843e1988Sjohnlev  */
145843e1988Sjohnlev #define EVTCHNOP_send             4
146843e1988Sjohnlev struct evtchn_send {
147843e1988Sjohnlev     /* IN parameters. */
148843e1988Sjohnlev     evtchn_port_t port;
149843e1988Sjohnlev };
150843e1988Sjohnlev typedef struct evtchn_send evtchn_send_t;
151843e1988Sjohnlev 
152843e1988Sjohnlev /*
153843e1988Sjohnlev  * EVTCHNOP_status: Get the current status of the communication channel which
154843e1988Sjohnlev  * has an endpoint at <dom, port>.
155843e1988Sjohnlev  * NOTES:
156843e1988Sjohnlev  *  1. <dom> may be specified as DOMID_SELF.
157843e1988Sjohnlev  *  2. Only a sufficiently-privileged domain may obtain the status of an event
158843e1988Sjohnlev  *     channel for which <dom> is not DOMID_SELF.
159843e1988Sjohnlev  */
160843e1988Sjohnlev #define EVTCHNOP_status           5
161843e1988Sjohnlev struct evtchn_status {
162843e1988Sjohnlev     /* IN parameters */
163843e1988Sjohnlev     domid_t  dom;
164843e1988Sjohnlev     evtchn_port_t port;
165843e1988Sjohnlev     /* OUT parameters */
166843e1988Sjohnlev #define EVTCHNSTAT_closed       0  /* Channel is not in use.                 */
167843e1988Sjohnlev #define EVTCHNSTAT_unbound      1  /* Channel is waiting interdom connection.*/
168843e1988Sjohnlev #define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
169843e1988Sjohnlev #define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
170843e1988Sjohnlev #define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
171843e1988Sjohnlev #define EVTCHNSTAT_ipi          5  /* Channel is bound to a virtual IPI line */
172843e1988Sjohnlev     uint32_t status;
173843e1988Sjohnlev     uint32_t vcpu;                 /* VCPU to which this channel is bound.   */
174843e1988Sjohnlev     union {
175843e1988Sjohnlev         struct {
176843e1988Sjohnlev             domid_t dom;
177843e1988Sjohnlev         } unbound; /* EVTCHNSTAT_unbound */
178843e1988Sjohnlev         struct {
179843e1988Sjohnlev             domid_t dom;
180843e1988Sjohnlev             evtchn_port_t port;
181843e1988Sjohnlev         } interdomain; /* EVTCHNSTAT_interdomain */
182843e1988Sjohnlev         uint32_t pirq;      /* EVTCHNSTAT_pirq        */
183843e1988Sjohnlev         uint32_t virq;      /* EVTCHNSTAT_virq        */
184843e1988Sjohnlev     } u;
185843e1988Sjohnlev };
186843e1988Sjohnlev typedef struct evtchn_status evtchn_status_t;
187843e1988Sjohnlev 
188843e1988Sjohnlev /*
189843e1988Sjohnlev  * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
190843e1988Sjohnlev  * event is pending.
191843e1988Sjohnlev  * NOTES:
192843e1988Sjohnlev  *  1. IPI-bound channels always notify the vcpu specified at bind time.
193843e1988Sjohnlev  *     This binding cannot be changed.
194843e1988Sjohnlev  *  2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time.
195843e1988Sjohnlev  *     This binding cannot be changed.
196843e1988Sjohnlev  *  3. All other channels notify vcpu0 by default. This default is set when
197843e1988Sjohnlev  *     the channel is allocated (a port that is freed and subsequently reused
198843e1988Sjohnlev  *     has its binding reset to vcpu0).
199843e1988Sjohnlev  */
200843e1988Sjohnlev #define EVTCHNOP_bind_vcpu        8
201843e1988Sjohnlev struct evtchn_bind_vcpu {
202843e1988Sjohnlev     /* IN parameters. */
203843e1988Sjohnlev     evtchn_port_t port;
204843e1988Sjohnlev     uint32_t vcpu;
205843e1988Sjohnlev };
206843e1988Sjohnlev typedef struct evtchn_bind_vcpu evtchn_bind_vcpu_t;
207843e1988Sjohnlev 
208843e1988Sjohnlev /*
209843e1988Sjohnlev  * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
210843e1988Sjohnlev  * a notification to the appropriate VCPU if an event is pending.
211843e1988Sjohnlev  */
212843e1988Sjohnlev #define EVTCHNOP_unmask           9
213843e1988Sjohnlev struct evtchn_unmask {
214843e1988Sjohnlev     /* IN parameters. */
215843e1988Sjohnlev     evtchn_port_t port;
216843e1988Sjohnlev };
217843e1988Sjohnlev typedef struct evtchn_unmask evtchn_unmask_t;
218843e1988Sjohnlev 
219843e1988Sjohnlev /*
220*a576ab5bSrab  * EVTCHNOP_reset: Close all event channels associated with specified domain.
221*a576ab5bSrab  * NOTES:
222*a576ab5bSrab  *  1. <dom> may be specified as DOMID_SELF.
223*a576ab5bSrab  *  2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
224*a576ab5bSrab  */
225*a576ab5bSrab #define EVTCHNOP_reset           10
226*a576ab5bSrab struct evtchn_reset {
227*a576ab5bSrab     /* IN parameters. */
228*a576ab5bSrab     domid_t dom;
229*a576ab5bSrab };
230*a576ab5bSrab typedef struct evtchn_reset evtchn_reset_t;
231*a576ab5bSrab 
232*a576ab5bSrab /*
233843e1988Sjohnlev  * Argument to event_channel_op_compat() hypercall. Superceded by new
234843e1988Sjohnlev  * event_channel_op() hypercall since 0x00030202.
235843e1988Sjohnlev  */
236843e1988Sjohnlev struct evtchn_op {
237843e1988Sjohnlev     uint32_t cmd; /* EVTCHNOP_* */
238843e1988Sjohnlev     union {
239843e1988Sjohnlev         struct evtchn_alloc_unbound    alloc_unbound;
240843e1988Sjohnlev         struct evtchn_bind_interdomain bind_interdomain;
241843e1988Sjohnlev         struct evtchn_bind_virq        bind_virq;
242843e1988Sjohnlev         struct evtchn_bind_pirq        bind_pirq;
243843e1988Sjohnlev         struct evtchn_bind_ipi         bind_ipi;
244843e1988Sjohnlev         struct evtchn_close            close;
245843e1988Sjohnlev         struct evtchn_send             send;
246843e1988Sjohnlev         struct evtchn_status           status;
247843e1988Sjohnlev         struct evtchn_bind_vcpu        bind_vcpu;
248843e1988Sjohnlev         struct evtchn_unmask           unmask;
249843e1988Sjohnlev     } u;
250843e1988Sjohnlev };
251843e1988Sjohnlev typedef struct evtchn_op evtchn_op_t;
252843e1988Sjohnlev DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
253843e1988Sjohnlev 
254843e1988Sjohnlev #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
255843e1988Sjohnlev 
256843e1988Sjohnlev /*
257843e1988Sjohnlev  * Local variables:
258843e1988Sjohnlev  * mode: C
259843e1988Sjohnlev  * c-set-style: "BSD"
260843e1988Sjohnlev  * c-basic-offset: 4
261843e1988Sjohnlev  * tab-width: 4
262843e1988Sjohnlev  * indent-tabs-mode: nil
263843e1988Sjohnlev  * End:
264843e1988Sjohnlev  */
265