This commit was generated by cvs2svn to compensate for changes in r925,
[linux-2.6.git] / include / asm-xen / xen-public / event_channel.h
1 /******************************************************************************
2  * event_channel.h
3  * 
4  * Event channels between domains.
5  * 
6  * Copyright (c) 2003-2004, K A Fraser.
7  */
8
9 #ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
10 #define __XEN_PUBLIC_EVENT_CHANNEL_H__
11
12 /*
13  * EVTCHNOP_alloc_unbound: Allocate a fresh local port and prepare
14  * it for binding to <dom>.
15  */
16 #define EVTCHNOP_alloc_unbound    6
17 typedef struct {
18     /* IN parameters */
19     domid_t dom;                      /*  0 */
20     u16     __pad;
21     /* OUT parameters */
22     u32     port;                     /*  4 */
23 } PACKED evtchn_alloc_unbound_t; /* 8 bytes */
24
25 /*
26  * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
27  * <dom1> and <dom2>. Either <port1> or <port2> may be wildcarded by setting to
28  * zero. On successful return both <port1> and <port2> are filled in and
29  * <dom1,port1> is fully bound to <dom2,port2>.
30  * 
31  * NOTES:
32  *  1. A wildcarded port is allocated from the relevant domain's free list
33  *     (i.e., some port that was previously EVTCHNSTAT_closed). However, if the
34  *     remote port pair is already fully bound then a port is not allocated,
35  *     and instead the existing local port is returned to the caller.
36  *  2. If the caller is unprivileged then <dom1> must be DOMID_SELF.
37  *  3. If the caller is unprivileged and <dom2,port2> is EVTCHNSTAT_closed
38  *     then <dom2> must be DOMID_SELF.
39  *  4. If either port is already bound then it must be bound to the other
40  *     specified domain and port (if not wildcarded).
41  *  5. If either port is awaiting binding (EVTCHNSTAT_unbound) then it must
42  *     be awaiting binding to the other domain, and the other port pair must
43  *     be closed or unbound.
44  */
45 #define EVTCHNOP_bind_interdomain 0
46 typedef struct {
47     /* IN parameters. */
48     domid_t dom1, dom2;               /*  0,  2 */
49     /* IN/OUT parameters. */
50     u32     port1, port2;             /*  4,  8 */
51 } PACKED evtchn_bind_interdomain_t; /* 12 bytes */
52
53 /*
54  * EVTCHNOP_bind_virq: Bind a local event channel to IRQ <irq>.
55  * NOTES:
56  *  1. A virtual IRQ may be bound to at most one event channel per domain.
57  */
58 #define EVTCHNOP_bind_virq        1
59 typedef struct {
60     /* IN parameters. */
61     u32 virq;                         /*  0 */
62     /* OUT parameters. */
63     u32 port;                         /*  4 */
64 } PACKED evtchn_bind_virq_t; /* 8 bytes */
65
66 /*
67  * EVTCHNOP_bind_pirq: Bind a local event channel to IRQ <irq>.
68  * NOTES:
69  *  1. A physical IRQ may be bound to at most one event channel per domain.
70  *  2. Only a sufficiently-privileged domain may bind to a physical IRQ.
71  */
72 #define EVTCHNOP_bind_pirq        2
73 typedef struct {
74     /* IN parameters. */
75     u32 pirq;                         /*  0 */
76 #define BIND_PIRQ__WILL_SHARE 1
77     u32 flags; /* BIND_PIRQ__* */     /*  4 */
78     /* OUT parameters. */
79     u32 port;                         /*  8 */
80 } PACKED evtchn_bind_pirq_t; /* 12 bytes */
81
82 /*
83  * EVTCHNOP_close: Close the communication channel which has an endpoint at
84  * <dom, port>. If the channel is interdomain then the remote end is placed in
85  * the unbound state (EVTCHNSTAT_unbound), awaiting a new connection.
86  * NOTES:
87  *  1. <dom> may be specified as DOMID_SELF.
88  *  2. Only a sufficiently-privileged domain may close an event channel
89  *     for which <dom> is not DOMID_SELF.
90  */
91 #define EVTCHNOP_close            3
92 typedef struct {
93     /* IN parameters. */
94     domid_t dom;                      /*  0 */
95     u16     __pad;
96     u32     port;                     /*  4 */
97     /* No OUT parameters. */
98 } PACKED evtchn_close_t; /* 8 bytes */
99
100 /*
101  * EVTCHNOP_send: Send an event to the remote end of the channel whose local
102  * endpoint is <DOMID_SELF, local_port>.
103  */
104 #define EVTCHNOP_send             4
105 typedef struct {
106     /* IN parameters. */
107     u32     local_port;               /*  0 */
108     /* No OUT parameters. */
109 } PACKED evtchn_send_t; /* 4 bytes */
110
111 /*
112  * EVTCHNOP_status: Get the current status of the communication channel which
113  * has an endpoint at <dom, port>.
114  * NOTES:
115  *  1. <dom> may be specified as DOMID_SELF.
116  *  2. Only a sufficiently-privileged domain may obtain the status of an event
117  *     channel for which <dom> is not DOMID_SELF.
118  */
119 #define EVTCHNOP_status           5
120 typedef struct {
121     /* IN parameters */
122     domid_t dom;                      /*  0 */
123     u16     __pad;
124     u32     port;                     /*  4 */
125     /* OUT parameters */
126 #define EVTCHNSTAT_closed       0  /* Channel is not in use.                 */
127 #define EVTCHNSTAT_unbound      1  /* Channel is waiting interdom connection.*/
128 #define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
129 #define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
130 #define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
131 #define EVTCHNSTAT_ipi          5  /* Channel is bound to a virtual IPI line */
132     u32     status;                   /*  8 */
133     union {                           /* 12 */
134         struct {
135             domid_t dom;                              /* 12 */
136         } PACKED unbound; /* EVTCHNSTAT_unbound */
137         struct {
138             domid_t dom;                              /* 12 */
139             u16     __pad;
140             u32     port;                             /* 16 */
141         } PACKED interdomain; /* EVTCHNSTAT_interdomain */
142         u32 pirq;      /* EVTCHNSTAT_pirq        */   /* 12 */
143         u32 virq;      /* EVTCHNSTAT_virq        */   /* 12 */
144         u32 ipi_edom;  /* EVTCHNSTAT_ipi         */   /* 12 */
145     } PACKED u;
146 } PACKED evtchn_status_t; /* 20 bytes */
147
148 /*
149  * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
150  */
151 #define EVTCHNOP_bind_ipi         7
152 typedef struct {
153     /* IN parameters. */
154     u32 ipi_edom;                     /*  0 */
155     /* OUT parameters. */
156     u32 port;                         /*  4 */
157 } PACKED evtchn_bind_ipi_t; /* 8 bytes */
158
159
160 typedef struct {
161     u32 cmd; /* EVTCHNOP_* */         /*  0 */
162     u32 __reserved;                   /*  4 */
163     union {                           /*  8 */
164         evtchn_alloc_unbound_t    alloc_unbound;
165         evtchn_bind_interdomain_t bind_interdomain;
166         evtchn_bind_virq_t        bind_virq;
167         evtchn_bind_pirq_t        bind_pirq;
168         evtchn_close_t            close;
169         evtchn_send_t             send;
170         evtchn_status_t           status;
171         evtchn_bind_ipi_t         bind_ipi;
172         u8                        __dummy[24];
173     } PACKED u;
174 } PACKED evtchn_op_t; /* 32 bytes */
175
176 #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */