xref: /qemu/hw/i386/kvm/xen_evtchn.h (revision 6096cf7877bc6ee84e6b3b44dfe144bc8b549724)
191cce756SDavid Woodhouse /*
291cce756SDavid Woodhouse  * QEMU Xen emulation: Event channel support
391cce756SDavid Woodhouse  *
491cce756SDavid Woodhouse  * Copyright © 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
591cce756SDavid Woodhouse  *
691cce756SDavid Woodhouse  * Authors: David Woodhouse <dwmw2@infradead.org>
791cce756SDavid Woodhouse  *
891cce756SDavid Woodhouse  * This work is licensed under the terms of the GNU GPL, version 2 or later.
991cce756SDavid Woodhouse  * See the COPYING file in the top-level directory.
1091cce756SDavid Woodhouse  */
1191cce756SDavid Woodhouse 
1291cce756SDavid Woodhouse #ifndef QEMU_XEN_EVTCHN_H
1391cce756SDavid Woodhouse #define QEMU_XEN_EVTCHN_H
1491cce756SDavid Woodhouse 
15ddf0fd9aSDavid Woodhouse #include "hw/sysbus.h"
16ddf0fd9aSDavid Woodhouse 
17794fba23SDavid Woodhouse typedef uint32_t evtchn_port_t;
18794fba23SDavid Woodhouse 
1991cce756SDavid Woodhouse void xen_evtchn_create(void);
20a15b1097SDavid Woodhouse int xen_evtchn_soft_reset(void);
2191cce756SDavid Woodhouse int xen_evtchn_set_callback_param(uint64_t param);
22ddf0fd9aSDavid Woodhouse void xen_evtchn_connect_gsis(qemu_irq *system_gsis);
23ddf0fd9aSDavid Woodhouse void xen_evtchn_set_callback_level(int level);
2491cce756SDavid Woodhouse 
25b746a779SJoao Martins int xen_evtchn_set_port(uint16_t port);
26b746a779SJoao Martins 
274f81baa3SDavid Woodhouse bool xen_evtchn_set_gsi(int gsi, int level);
28*6096cf78SDavid Woodhouse void xen_evtchn_snoop_msi(PCIDevice *dev, bool is_msix, unsigned int vector,
29*6096cf78SDavid Woodhouse                           uint64_t addr, uint32_t data, bool is_masked);
30*6096cf78SDavid Woodhouse void xen_evtchn_remove_pci_device(PCIDevice *dev);
31*6096cf78SDavid Woodhouse struct kvm_irq_routing_entry;
32*6096cf78SDavid Woodhouse int xen_evtchn_translate_pirq_msi(struct kvm_irq_routing_entry *route,
33*6096cf78SDavid Woodhouse                                   uint64_t address, uint32_t data);
34*6096cf78SDavid Woodhouse bool xen_evtchn_deliver_pirq_msi(uint64_t address, uint32_t data);
35*6096cf78SDavid Woodhouse 
364f81baa3SDavid Woodhouse 
37794fba23SDavid Woodhouse /*
38794fba23SDavid Woodhouse  * These functions mirror the libxenevtchn library API, providing the QEMU
39794fba23SDavid Woodhouse  * backend side of "interdomain" event channels.
40794fba23SDavid Woodhouse  */
41794fba23SDavid Woodhouse struct xenevtchn_handle;
42794fba23SDavid Woodhouse struct xenevtchn_handle *xen_be_evtchn_open(void);
43794fba23SDavid Woodhouse int xen_be_evtchn_bind_interdomain(struct xenevtchn_handle *xc, uint32_t domid,
44794fba23SDavid Woodhouse                                    evtchn_port_t guest_port);
45794fba23SDavid Woodhouse int xen_be_evtchn_unbind(struct xenevtchn_handle *xc, evtchn_port_t port);
46794fba23SDavid Woodhouse int xen_be_evtchn_close(struct xenevtchn_handle *xc);
47794fba23SDavid Woodhouse int xen_be_evtchn_fd(struct xenevtchn_handle *xc);
48794fba23SDavid Woodhouse int xen_be_evtchn_notify(struct xenevtchn_handle *xc, evtchn_port_t port);
49794fba23SDavid Woodhouse int xen_be_evtchn_unmask(struct xenevtchn_handle *xc, evtchn_port_t port);
50794fba23SDavid Woodhouse int xen_be_evtchn_pending(struct xenevtchn_handle *xc);
51794fba23SDavid Woodhouse /* Apart from this which is a local addition */
52794fba23SDavid Woodhouse int xen_be_evtchn_get_guest_port(struct xenevtchn_handle *xc);
53794fba23SDavid Woodhouse 
544858ba20SDavid Woodhouse struct evtchn_status;
5583eb5811SDavid Woodhouse struct evtchn_close;
56190cc3c0SDavid Woodhouse struct evtchn_unmask;
57c723d4c1SDavid Woodhouse struct evtchn_bind_virq;
58aa98ee38SDavid Woodhouse struct evtchn_bind_pirq;
59f5417856SDavid Woodhouse struct evtchn_bind_ipi;
60cf7679abSDavid Woodhouse struct evtchn_send;
61e1db61b8SDavid Woodhouse struct evtchn_alloc_unbound;
6284327881SDavid Woodhouse struct evtchn_bind_interdomain;
6330667046SDavid Woodhouse struct evtchn_bind_vcpu;
64a15b1097SDavid Woodhouse struct evtchn_reset;
654858ba20SDavid Woodhouse int xen_evtchn_status_op(struct evtchn_status *status);
6683eb5811SDavid Woodhouse int xen_evtchn_close_op(struct evtchn_close *close);
67190cc3c0SDavid Woodhouse int xen_evtchn_unmask_op(struct evtchn_unmask *unmask);
68c723d4c1SDavid Woodhouse int xen_evtchn_bind_virq_op(struct evtchn_bind_virq *virq);
69aa98ee38SDavid Woodhouse int xen_evtchn_bind_pirq_op(struct evtchn_bind_pirq *pirq);
70f5417856SDavid Woodhouse int xen_evtchn_bind_ipi_op(struct evtchn_bind_ipi *ipi);
71cf7679abSDavid Woodhouse int xen_evtchn_send_op(struct evtchn_send *send);
72e1db61b8SDavid Woodhouse int xen_evtchn_alloc_unbound_op(struct evtchn_alloc_unbound *alloc);
7384327881SDavid Woodhouse int xen_evtchn_bind_interdomain_op(struct evtchn_bind_interdomain *interdomain);
7430667046SDavid Woodhouse int xen_evtchn_bind_vcpu_op(struct evtchn_bind_vcpu *vcpu);
75a15b1097SDavid Woodhouse int xen_evtchn_reset_op(struct evtchn_reset *reset);
764858ba20SDavid Woodhouse 
77799c2354SDavid Woodhouse struct physdev_map_pirq;
78799c2354SDavid Woodhouse struct physdev_unmap_pirq;
79799c2354SDavid Woodhouse struct physdev_eoi;
80799c2354SDavid Woodhouse struct physdev_irq_status_query;
81799c2354SDavid Woodhouse struct physdev_get_free_pirq;
82799c2354SDavid Woodhouse int xen_physdev_map_pirq(struct physdev_map_pirq *map);
83799c2354SDavid Woodhouse int xen_physdev_unmap_pirq(struct physdev_unmap_pirq *unmap);
84799c2354SDavid Woodhouse int xen_physdev_eoi_pirq(struct physdev_eoi *eoi);
85799c2354SDavid Woodhouse int xen_physdev_query_pirq(struct physdev_irq_status_query *query);
86799c2354SDavid Woodhouse int xen_physdev_get_free_pirq(struct physdev_get_free_pirq *get);
87799c2354SDavid Woodhouse 
8891cce756SDavid Woodhouse #endif /* QEMU_XEN_EVTCHN_H */
89