Path: blob/master/include/xen/interface/event_channel.h
26282 views
/* SPDX-License-Identifier: MIT */1/******************************************************************************2* event_channel.h3*4* Event channels between domains.5*6* Copyright (c) 2003-2004, K A Fraser.7*/89#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__10#define __XEN_PUBLIC_EVENT_CHANNEL_H__1112#include <xen/interface/xen.h>1314typedef uint32_t evtchn_port_t;15DEFINE_GUEST_HANDLE(evtchn_port_t);1617/*18* EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as19* accepting interdomain bindings from domain <remote_dom>. A fresh port20* is allocated in <dom> and returned as <port>.21* NOTES:22* 1. If the caller is unprivileged then <dom> must be DOMID_SELF.23* 2. <rdom> may be DOMID_SELF, allowing loopback connections.24*/25#define EVTCHNOP_alloc_unbound 626struct evtchn_alloc_unbound {27/* IN parameters */28domid_t dom, remote_dom;29/* OUT parameters */30evtchn_port_t port;31};3233/*34* EVTCHNOP_bind_interdomain: Construct an interdomain event channel between35* the calling domain and <remote_dom>. <remote_dom,remote_port> must identify36* a port that is unbound and marked as accepting bindings from the calling37* domain. A fresh port is allocated in the calling domain and returned as38* <local_port>.39* NOTES:40* 2. <remote_dom> may be DOMID_SELF, allowing loopback connections.41*/42#define EVTCHNOP_bind_interdomain 043struct evtchn_bind_interdomain {44/* IN parameters. */45domid_t remote_dom;46evtchn_port_t remote_port;47/* OUT parameters. */48evtchn_port_t local_port;49};5051/*52* EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified53* vcpu.54* NOTES:55* 1. A virtual IRQ may be bound to at most one event channel per vcpu.56* 2. The allocated event channel is bound to the specified vcpu. The binding57* may not be changed.58*/59#define EVTCHNOP_bind_virq 160struct evtchn_bind_virq {61/* IN parameters. */62uint32_t virq;63uint32_t vcpu;64/* OUT parameters. */65evtchn_port_t port;66};6768/*69* EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.70* NOTES:71* 1. A physical IRQ may be bound to at most one event channel per domain.72* 2. Only a sufficiently-privileged domain may bind to a physical IRQ.73*/74#define EVTCHNOP_bind_pirq 275struct evtchn_bind_pirq {76/* IN parameters. */77uint32_t pirq;78#define BIND_PIRQ__WILL_SHARE 179uint32_t flags; /* BIND_PIRQ__* */80/* OUT parameters. */81evtchn_port_t port;82};8384/*85* EVTCHNOP_bind_ipi: Bind a local event channel to receive events.86* NOTES:87* 1. The allocated event channel is bound to the specified vcpu. The binding88* may not be changed.89*/90#define EVTCHNOP_bind_ipi 791struct evtchn_bind_ipi {92uint32_t vcpu;93/* OUT parameters. */94evtchn_port_t port;95};9697/*98* EVTCHNOP_close: Close a local event channel <port>. If the channel is99* interdomain then the remote end is placed in the unbound state100* (EVTCHNSTAT_unbound), awaiting a new connection.101*/102#define EVTCHNOP_close 3103struct evtchn_close {104/* IN parameters. */105evtchn_port_t port;106};107108/*109* EVTCHNOP_send: Send an event to the remote end of the channel whose local110* endpoint is <port>.111*/112#define EVTCHNOP_send 4113struct evtchn_send {114/* IN parameters. */115evtchn_port_t port;116};117118/*119* EVTCHNOP_status: Get the current status of the communication channel which120* has an endpoint at <dom, port>.121* NOTES:122* 1. <dom> may be specified as DOMID_SELF.123* 2. Only a sufficiently-privileged domain may obtain the status of an event124* channel for which <dom> is not DOMID_SELF.125*/126#define EVTCHNOP_status 5127struct evtchn_status {128/* IN parameters */129domid_t dom;130evtchn_port_t port;131/* OUT parameters */132#define EVTCHNSTAT_closed 0 /* Channel is not in use. */133#define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/134#define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */135#define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */136#define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */137#define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */138uint32_t status;139uint32_t vcpu; /* VCPU to which this channel is bound. */140union {141struct {142domid_t dom;143} unbound; /* EVTCHNSTAT_unbound */144struct {145domid_t dom;146evtchn_port_t port;147} interdomain; /* EVTCHNSTAT_interdomain */148uint32_t pirq; /* EVTCHNSTAT_pirq */149uint32_t virq; /* EVTCHNSTAT_virq */150} u;151};152153/*154* EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an155* event is pending.156* NOTES:157* 1. IPI- and VIRQ-bound channels always notify the vcpu that initialised158* the binding. This binding cannot be changed.159* 2. All other channels notify vcpu0 by default. This default is set when160* the channel is allocated (a port that is freed and subsequently reused161* has its binding reset to vcpu0).162*/163#define EVTCHNOP_bind_vcpu 8164struct evtchn_bind_vcpu {165/* IN parameters. */166evtchn_port_t port;167uint32_t vcpu;168};169170/*171* EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver172* a notification to the appropriate VCPU if an event is pending.173*/174#define EVTCHNOP_unmask 9175struct evtchn_unmask {176/* IN parameters. */177evtchn_port_t port;178};179180/*181* EVTCHNOP_reset: Close all event channels associated with specified domain.182* NOTES:183* 1. <dom> may be specified as DOMID_SELF.184* 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.185*/186#define EVTCHNOP_reset 10187struct evtchn_reset {188/* IN parameters. */189domid_t dom;190};191typedef struct evtchn_reset evtchn_reset_t;192193/*194* EVTCHNOP_init_control: initialize the control block for the FIFO ABI.195*/196#define EVTCHNOP_init_control 11197struct evtchn_init_control {198/* IN parameters. */199uint64_t control_gfn;200uint32_t offset;201uint32_t vcpu;202/* OUT parameters. */203uint8_t link_bits;204uint8_t _pad[7];205};206207/*208* EVTCHNOP_expand_array: add an additional page to the event array.209*/210#define EVTCHNOP_expand_array 12211struct evtchn_expand_array {212/* IN parameters. */213uint64_t array_gfn;214};215216/*217* EVTCHNOP_set_priority: set the priority for an event channel.218*/219#define EVTCHNOP_set_priority 13220struct evtchn_set_priority {221/* IN parameters. */222evtchn_port_t port;223uint32_t priority;224};225226struct evtchn_op {227uint32_t cmd; /* EVTCHNOP_* */228union {229struct evtchn_alloc_unbound alloc_unbound;230struct evtchn_bind_interdomain bind_interdomain;231struct evtchn_bind_virq bind_virq;232struct evtchn_bind_pirq bind_pirq;233struct evtchn_bind_ipi bind_ipi;234struct evtchn_close close;235struct evtchn_send send;236struct evtchn_status status;237struct evtchn_bind_vcpu bind_vcpu;238struct evtchn_unmask unmask;239} u;240};241DEFINE_GUEST_HANDLE_STRUCT(evtchn_op);242243/*244* 2-level ABI245*/246247#define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)248249/*250* FIFO ABI251*/252253/* Events may have priorities from 0 (highest) to 15 (lowest). */254#define EVTCHN_FIFO_PRIORITY_MAX 0255#define EVTCHN_FIFO_PRIORITY_DEFAULT 7256#define EVTCHN_FIFO_PRIORITY_MIN 15257258#define EVTCHN_FIFO_MAX_QUEUES (EVTCHN_FIFO_PRIORITY_MIN + 1)259260typedef uint32_t event_word_t;261262#define EVTCHN_FIFO_PENDING 31263#define EVTCHN_FIFO_MASKED 30264#define EVTCHN_FIFO_LINKED 29265#define EVTCHN_FIFO_BUSY 28266267#define EVTCHN_FIFO_LINK_BITS 17268#define EVTCHN_FIFO_LINK_MASK ((1 << EVTCHN_FIFO_LINK_BITS) - 1)269270#define EVTCHN_FIFO_NR_CHANNELS (1 << EVTCHN_FIFO_LINK_BITS)271272struct evtchn_fifo_control_block {273uint32_t ready;274uint32_t _rsvd;275event_word_t head[EVTCHN_FIFO_MAX_QUEUES];276};277278#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */279280281