xref: /openbmc/qemu/hw/i386/kvm/xen_evtchn.h (revision 4f81baa3)
1 /*
2  * QEMU Xen emulation: Event channel support
3  *
4  * Copyright © 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5  *
6  * Authors: David Woodhouse <dwmw2@infradead.org>
7  *
8  * This work is licensed under the terms of the GNU GPL, version 2 or later.
9  * See the COPYING file in the top-level directory.
10  */
11 
12 #ifndef QEMU_XEN_EVTCHN_H
13 #define QEMU_XEN_EVTCHN_H
14 
15 #include "hw/sysbus.h"
16 
17 typedef uint32_t evtchn_port_t;
18 
19 void xen_evtchn_create(void);
20 int xen_evtchn_soft_reset(void);
21 int xen_evtchn_set_callback_param(uint64_t param);
22 void xen_evtchn_connect_gsis(qemu_irq *system_gsis);
23 void xen_evtchn_set_callback_level(int level);
24 
25 int xen_evtchn_set_port(uint16_t port);
26 
27 bool xen_evtchn_set_gsi(int gsi, int level);
28 
29 /*
30  * These functions mirror the libxenevtchn library API, providing the QEMU
31  * backend side of "interdomain" event channels.
32  */
33 struct xenevtchn_handle;
34 struct xenevtchn_handle *xen_be_evtchn_open(void);
35 int xen_be_evtchn_bind_interdomain(struct xenevtchn_handle *xc, uint32_t domid,
36                                    evtchn_port_t guest_port);
37 int xen_be_evtchn_unbind(struct xenevtchn_handle *xc, evtchn_port_t port);
38 int xen_be_evtchn_close(struct xenevtchn_handle *xc);
39 int xen_be_evtchn_fd(struct xenevtchn_handle *xc);
40 int xen_be_evtchn_notify(struct xenevtchn_handle *xc, evtchn_port_t port);
41 int xen_be_evtchn_unmask(struct xenevtchn_handle *xc, evtchn_port_t port);
42 int xen_be_evtchn_pending(struct xenevtchn_handle *xc);
43 /* Apart from this which is a local addition */
44 int xen_be_evtchn_get_guest_port(struct xenevtchn_handle *xc);
45 
46 struct evtchn_status;
47 struct evtchn_close;
48 struct evtchn_unmask;
49 struct evtchn_bind_virq;
50 struct evtchn_bind_pirq;
51 struct evtchn_bind_ipi;
52 struct evtchn_send;
53 struct evtchn_alloc_unbound;
54 struct evtchn_bind_interdomain;
55 struct evtchn_bind_vcpu;
56 struct evtchn_reset;
57 int xen_evtchn_status_op(struct evtchn_status *status);
58 int xen_evtchn_close_op(struct evtchn_close *close);
59 int xen_evtchn_unmask_op(struct evtchn_unmask *unmask);
60 int xen_evtchn_bind_virq_op(struct evtchn_bind_virq *virq);
61 int xen_evtchn_bind_pirq_op(struct evtchn_bind_pirq *pirq);
62 int xen_evtchn_bind_ipi_op(struct evtchn_bind_ipi *ipi);
63 int xen_evtchn_send_op(struct evtchn_send *send);
64 int xen_evtchn_alloc_unbound_op(struct evtchn_alloc_unbound *alloc);
65 int xen_evtchn_bind_interdomain_op(struct evtchn_bind_interdomain *interdomain);
66 int xen_evtchn_bind_vcpu_op(struct evtchn_bind_vcpu *vcpu);
67 int xen_evtchn_reset_op(struct evtchn_reset *reset);
68 
69 struct physdev_map_pirq;
70 struct physdev_unmap_pirq;
71 struct physdev_eoi;
72 struct physdev_irq_status_query;
73 struct physdev_get_free_pirq;
74 int xen_physdev_map_pirq(struct physdev_map_pirq *map);
75 int xen_physdev_unmap_pirq(struct physdev_unmap_pirq *unmap);
76 int xen_physdev_eoi_pirq(struct physdev_eoi *eoi);
77 int xen_physdev_query_pirq(struct physdev_irq_status_query *query);
78 int xen_physdev_get_free_pirq(struct physdev_get_free_pirq *get);
79 
80 #endif /* QEMU_XEN_EVTCHN_H */
81