xref: /onnv-gate/usr/src/uts/common/xen/public/event_channel.h (revision 6144:5a5f883be4e5)
15084Sjohnlev /******************************************************************************
25084Sjohnlev  * event_channel.h
35084Sjohnlev  *
45084Sjohnlev  * Event channels between domains.
55084Sjohnlev  *
65084Sjohnlev  * Permission is hereby granted, free of charge, to any person obtaining a copy
75084Sjohnlev  * of this software and associated documentation files (the "Software"), to
85084Sjohnlev  * deal in the Software without restriction, including without limitation the
95084Sjohnlev  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
105084Sjohnlev  * sell copies of the Software, and to permit persons to whom the Software is
115084Sjohnlev  * furnished to do so, subject to the following conditions:
125084Sjohnlev  *
135084Sjohnlev  * The above copyright notice and this permission notice shall be included in
145084Sjohnlev  * all copies or substantial portions of the Software.
155084Sjohnlev  *
165084Sjohnlev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
175084Sjohnlev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
185084Sjohnlev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
195084Sjohnlev  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
205084Sjohnlev  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
215084Sjohnlev  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
225084Sjohnlev  * DEALINGS IN THE SOFTWARE.
235084Sjohnlev  *
245084Sjohnlev  * Copyright (c) 2003-2004, K A Fraser.
255084Sjohnlev  */
265084Sjohnlev 
275084Sjohnlev #ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
285084Sjohnlev #define __XEN_PUBLIC_EVENT_CHANNEL_H__
295084Sjohnlev 
305084Sjohnlev /*
315084Sjohnlev  * Prototype for this hypercall is:
325084Sjohnlev  *  int event_channel_op(int cmd, void *args)
335084Sjohnlev  * @cmd  == EVTCHNOP_??? (event-channel operation).
345084Sjohnlev  * @args == Operation-specific extra arguments (NULL if none).
355084Sjohnlev  */
365084Sjohnlev 
375084Sjohnlev typedef uint32_t evtchn_port_t;
385084Sjohnlev DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
395084Sjohnlev 
405084Sjohnlev /*
415084Sjohnlev  * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
425084Sjohnlev  * accepting interdomain bindings from domain <remote_dom>. A fresh port
435084Sjohnlev  * is allocated in <dom> and returned as <port>.
445084Sjohnlev  * NOTES:
455084Sjohnlev  *  1. If the caller is unprivileged then <dom> must be DOMID_SELF.
465084Sjohnlev  *  2. <rdom> may be DOMID_SELF, allowing loopback connections.
475084Sjohnlev  */
485084Sjohnlev #define EVTCHNOP_alloc_unbound    6
495084Sjohnlev struct evtchn_alloc_unbound {
505084Sjohnlev     /* IN parameters */
515084Sjohnlev     domid_t dom, remote_dom;
525084Sjohnlev     /* OUT parameters */
535084Sjohnlev     evtchn_port_t port;
545084Sjohnlev };
555084Sjohnlev typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
565084Sjohnlev 
575084Sjohnlev /*
585084Sjohnlev  * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
595084Sjohnlev  * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
605084Sjohnlev  * a port that is unbound and marked as accepting bindings from the calling
615084Sjohnlev  * domain. A fresh port is allocated in the calling domain and returned as
625084Sjohnlev  * <local_port>.
635084Sjohnlev  * NOTES:
645084Sjohnlev  *  2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
655084Sjohnlev  */
665084Sjohnlev #define EVTCHNOP_bind_interdomain 0
675084Sjohnlev struct evtchn_bind_interdomain {
685084Sjohnlev     /* IN parameters. */
695084Sjohnlev     domid_t remote_dom;
705084Sjohnlev     evtchn_port_t remote_port;
715084Sjohnlev     /* OUT parameters. */
725084Sjohnlev     evtchn_port_t local_port;
735084Sjohnlev };
745084Sjohnlev typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t;
755084Sjohnlev 
765084Sjohnlev /*
775084Sjohnlev  * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
785084Sjohnlev  * vcpu.
795084Sjohnlev  * NOTES:
805084Sjohnlev  *  1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list
815084Sjohnlev  *     in xen.h for the classification of each VIRQ.
825084Sjohnlev  *  2. Global VIRQs must be allocated on VCPU0 but can subsequently be
835084Sjohnlev  *     re-bound via EVTCHNOP_bind_vcpu.
845084Sjohnlev  *  3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu.
855084Sjohnlev  *     The allocated event channel is bound to the specified vcpu and the
865084Sjohnlev  *     binding cannot be changed.
875084Sjohnlev  */
885084Sjohnlev #define EVTCHNOP_bind_virq        1
895084Sjohnlev struct evtchn_bind_virq {
905084Sjohnlev     /* IN parameters. */
915084Sjohnlev     uint32_t virq;
925084Sjohnlev     uint32_t vcpu;
935084Sjohnlev     /* OUT parameters. */
945084Sjohnlev     evtchn_port_t port;
955084Sjohnlev };
965084Sjohnlev typedef struct evtchn_bind_virq evtchn_bind_virq_t;
975084Sjohnlev 
985084Sjohnlev /*
995084Sjohnlev  * EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.
1005084Sjohnlev  * NOTES:
1015084Sjohnlev  *  1. A physical IRQ may be bound to at most one event channel per domain.
1025084Sjohnlev  *  2. Only a sufficiently-privileged domain may bind to a physical IRQ.
1035084Sjohnlev  */
1045084Sjohnlev #define EVTCHNOP_bind_pirq        2
1055084Sjohnlev struct evtchn_bind_pirq {
1065084Sjohnlev     /* IN parameters. */
1075084Sjohnlev     uint32_t pirq;
1085084Sjohnlev #define BIND_PIRQ__WILL_SHARE 1
1095084Sjohnlev     uint32_t flags; /* BIND_PIRQ__* */
1105084Sjohnlev     /* OUT parameters. */
1115084Sjohnlev     evtchn_port_t port;
1125084Sjohnlev };
1135084Sjohnlev typedef struct evtchn_bind_pirq evtchn_bind_pirq_t;
1145084Sjohnlev 
1155084Sjohnlev /*
1165084Sjohnlev  * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
1175084Sjohnlev  * NOTES:
1185084Sjohnlev  *  1. The allocated event channel is bound to the specified vcpu. The binding
1195084Sjohnlev  *     may not be changed.
1205084Sjohnlev  */
1215084Sjohnlev #define EVTCHNOP_bind_ipi         7
1225084Sjohnlev struct evtchn_bind_ipi {
1235084Sjohnlev     uint32_t vcpu;
1245084Sjohnlev     /* OUT parameters. */
1255084Sjohnlev     evtchn_port_t port;
1265084Sjohnlev };
1275084Sjohnlev typedef struct evtchn_bind_ipi evtchn_bind_ipi_t;
1285084Sjohnlev 
1295084Sjohnlev /*
1305084Sjohnlev  * EVTCHNOP_close: Close a local event channel <port>. If the channel is
1315084Sjohnlev  * interdomain then the remote end is placed in the unbound state
1325084Sjohnlev  * (EVTCHNSTAT_unbound), awaiting a new connection.
1335084Sjohnlev  */
1345084Sjohnlev #define EVTCHNOP_close            3
1355084Sjohnlev struct evtchn_close {
1365084Sjohnlev     /* IN parameters. */
1375084Sjohnlev     evtchn_port_t port;
1385084Sjohnlev };
1395084Sjohnlev typedef struct evtchn_close evtchn_close_t;
1405084Sjohnlev 
1415084Sjohnlev /*
1425084Sjohnlev  * EVTCHNOP_send: Send an event to the remote end of the channel whose local
1435084Sjohnlev  * endpoint is <port>.
1445084Sjohnlev  */
1455084Sjohnlev #define EVTCHNOP_send             4
1465084Sjohnlev struct evtchn_send {
1475084Sjohnlev     /* IN parameters. */
1485084Sjohnlev     evtchn_port_t port;
1495084Sjohnlev };
1505084Sjohnlev typedef struct evtchn_send evtchn_send_t;
1515084Sjohnlev 
1525084Sjohnlev /*
1535084Sjohnlev  * EVTCHNOP_status: Get the current status of the communication channel which
1545084Sjohnlev  * has an endpoint at <dom, port>.
1555084Sjohnlev  * NOTES:
1565084Sjohnlev  *  1. <dom> may be specified as DOMID_SELF.
1575084Sjohnlev  *  2. Only a sufficiently-privileged domain may obtain the status of an event
1585084Sjohnlev  *     channel for which <dom> is not DOMID_SELF.
1595084Sjohnlev  */
1605084Sjohnlev #define EVTCHNOP_status           5
1615084Sjohnlev struct evtchn_status {
1625084Sjohnlev     /* IN parameters */
1635084Sjohnlev     domid_t  dom;
1645084Sjohnlev     evtchn_port_t port;
1655084Sjohnlev     /* OUT parameters */
1665084Sjohnlev #define EVTCHNSTAT_closed       0  /* Channel is not in use.                 */
1675084Sjohnlev #define EVTCHNSTAT_unbound      1  /* Channel is waiting interdom connection.*/
1685084Sjohnlev #define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
1695084Sjohnlev #define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
1705084Sjohnlev #define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
1715084Sjohnlev #define EVTCHNSTAT_ipi          5  /* Channel is bound to a virtual IPI line */
1725084Sjohnlev     uint32_t status;
1735084Sjohnlev     uint32_t vcpu;                 /* VCPU to which this channel is bound.   */
1745084Sjohnlev     union {
1755084Sjohnlev         struct {
1765084Sjohnlev             domid_t dom;
1775084Sjohnlev         } unbound; /* EVTCHNSTAT_unbound */
1785084Sjohnlev         struct {
1795084Sjohnlev             domid_t dom;
1805084Sjohnlev             evtchn_port_t port;
1815084Sjohnlev         } interdomain; /* EVTCHNSTAT_interdomain */
1825084Sjohnlev         uint32_t pirq;      /* EVTCHNSTAT_pirq        */
1835084Sjohnlev         uint32_t virq;      /* EVTCHNSTAT_virq        */
1845084Sjohnlev     } u;
1855084Sjohnlev };
1865084Sjohnlev typedef struct evtchn_status evtchn_status_t;
1875084Sjohnlev 
1885084Sjohnlev /*
1895084Sjohnlev  * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
1905084Sjohnlev  * event is pending.
1915084Sjohnlev  * NOTES:
1925084Sjohnlev  *  1. IPI-bound channels always notify the vcpu specified at bind time.
1935084Sjohnlev  *     This binding cannot be changed.
1945084Sjohnlev  *  2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time.
1955084Sjohnlev  *     This binding cannot be changed.
1965084Sjohnlev  *  3. All other channels notify vcpu0 by default. This default is set when
1975084Sjohnlev  *     the channel is allocated (a port that is freed and subsequently reused
1985084Sjohnlev  *     has its binding reset to vcpu0).
1995084Sjohnlev  */
2005084Sjohnlev #define EVTCHNOP_bind_vcpu        8
2015084Sjohnlev struct evtchn_bind_vcpu {
2025084Sjohnlev     /* IN parameters. */
2035084Sjohnlev     evtchn_port_t port;
2045084Sjohnlev     uint32_t vcpu;
2055084Sjohnlev };
2065084Sjohnlev typedef struct evtchn_bind_vcpu evtchn_bind_vcpu_t;
2075084Sjohnlev 
2085084Sjohnlev /*
2095084Sjohnlev  * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
2105084Sjohnlev  * a notification to the appropriate VCPU if an event is pending.
2115084Sjohnlev  */
2125084Sjohnlev #define EVTCHNOP_unmask           9
2135084Sjohnlev struct evtchn_unmask {
2145084Sjohnlev     /* IN parameters. */
2155084Sjohnlev     evtchn_port_t port;
2165084Sjohnlev };
2175084Sjohnlev typedef struct evtchn_unmask evtchn_unmask_t;
2185084Sjohnlev 
2195084Sjohnlev /*
220*6144Srab  * EVTCHNOP_reset: Close all event channels associated with specified domain.
221*6144Srab  * NOTES:
222*6144Srab  *  1. <dom> may be specified as DOMID_SELF.
223*6144Srab  *  2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
224*6144Srab  */
225*6144Srab #define EVTCHNOP_reset           10
226*6144Srab struct evtchn_reset {
227*6144Srab     /* IN parameters. */
228*6144Srab     domid_t dom;
229*6144Srab };
230*6144Srab typedef struct evtchn_reset evtchn_reset_t;
231*6144Srab 
232*6144Srab /*
2335084Sjohnlev  * Argument to event_channel_op_compat() hypercall. Superceded by new
2345084Sjohnlev  * event_channel_op() hypercall since 0x00030202.
2355084Sjohnlev  */
2365084Sjohnlev struct evtchn_op {
2375084Sjohnlev     uint32_t cmd; /* EVTCHNOP_* */
2385084Sjohnlev     union {
2395084Sjohnlev         struct evtchn_alloc_unbound    alloc_unbound;
2405084Sjohnlev         struct evtchn_bind_interdomain bind_interdomain;
2415084Sjohnlev         struct evtchn_bind_virq        bind_virq;
2425084Sjohnlev         struct evtchn_bind_pirq        bind_pirq;
2435084Sjohnlev         struct evtchn_bind_ipi         bind_ipi;
2445084Sjohnlev         struct evtchn_close            close;
2455084Sjohnlev         struct evtchn_send             send;
2465084Sjohnlev         struct evtchn_status           status;
2475084Sjohnlev         struct evtchn_bind_vcpu        bind_vcpu;
2485084Sjohnlev         struct evtchn_unmask           unmask;
2495084Sjohnlev     } u;
2505084Sjohnlev };
2515084Sjohnlev typedef struct evtchn_op evtchn_op_t;
2525084Sjohnlev DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
2535084Sjohnlev 
2545084Sjohnlev #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
2555084Sjohnlev 
2565084Sjohnlev /*
2575084Sjohnlev  * Local variables:
2585084Sjohnlev  * mode: C
2595084Sjohnlev  * c-set-style: "BSD"
2605084Sjohnlev  * c-basic-offset: 4
2615084Sjohnlev  * tab-width: 4
2625084Sjohnlev  * indent-tabs-mode: nil
2635084Sjohnlev  * End:
2645084Sjohnlev  */
265