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 #include "xen.h"
31 
32 /*
33  * `incontents 150 evtchn Event Channels
34  *
35  * Event channels are the basic primitive provided by Xen for event
36  * notifications. An event is the Xen equivalent of a hardware
37  * interrupt. They essentially store one bit of information, the event
38  * of interest is signalled by transitioning this bit from 0 to 1.
39  *
40  * Notifications are received by a guest via an upcall from Xen,
41  * indicating when an event arrives (setting the bit). Further
42  * notifications are masked until the bit is cleared again (therefore,
43  * guests must check the value of the bit after re-enabling event
44  * delivery to ensure no missed notifications).
45  *
46  * Event notifications can be masked by setting a flag; this is
47  * equivalent to disabling interrupts and can be used to ensure
48  * atomicity of certain operations in the guest kernel.
49  *
50  * Event channels are represented by the evtchn_* fields in
51  * struct shared_info and struct vcpu_info.
52  */
53 
54 /*
55  * ` enum neg_errnoval
56  * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, VOID *args)
57  * `
58  * @cmd  == EVTCHNOP_* (event-channel operation).
59  * @args == struct evtchn_* Operation-specific extra arguments (NULL if none).
60  */
61 
62 /* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */
63 #define EVTCHNOP_close            3
64 #define EVTCHNOP_send             4
65 #define EVTCHNOP_alloc_unbound    6
66 /* ` } */
67 
68 typedef UINT32 evtchn_port_t;
69 DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
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. <rdom> may be DOMID_SELF, allowing loopback connections.
78  */
79 struct evtchn_alloc_unbound {
80     /* IN parameters */
81     domid_t dom, remote_dom;
82     /* OUT parameters */
83     evtchn_port_t port;
84 };
85 typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
86 
87 /*
88  * EVTCHNOP_close: Close a local event channel <port>. If the channel is
89  * interdomain then the remote end is placed in the unbound state
90  * (EVTCHNSTAT_unbound), awaiting a new connection.
91  */
92 struct evtchn_close {
93     /* IN parameters. */
94     evtchn_port_t port;
95 };
96 typedef struct evtchn_close evtchn_close_t;
97 
98 /*
99  * EVTCHNOP_send: Send an event to the remote end of the channel whose local
100  * endpoint is <port>.
101  */
102 struct evtchn_send {
103     /* IN parameters. */
104     evtchn_port_t port;
105 };
106 typedef struct evtchn_send evtchn_send_t;
107 
108 #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
109 
110 /*
111  * Local variables:
112  * mode: C
113  * c-file-style: "BSD"
114  * c-basic-offset: 4
115  * tab-width: 4
116  * indent-tabs-mode: nil
117  * End:
118  */
119