xref: /openbmc/qemu/hw/i386/kvm/xen_evtchn.h (revision eeedfe6c)
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 
19*eeedfe6cSDavid Woodhouse void xen_evtchn_create(unsigned int nr_gsis, qemu_irq *system_gsis);
20a15b1097SDavid Woodhouse int xen_evtchn_soft_reset(void);
2191cce756SDavid Woodhouse int xen_evtchn_set_callback_param(uint64_t param);
22ddf0fd9aSDavid Woodhouse void xen_evtchn_set_callback_level(int level);
2391cce756SDavid Woodhouse 
24b746a779SJoao Martins int xen_evtchn_set_port(uint16_t port);
25b746a779SJoao Martins 
264f81baa3SDavid Woodhouse bool xen_evtchn_set_gsi(int gsi, int level);
276096cf78SDavid Woodhouse void xen_evtchn_snoop_msi(PCIDevice *dev, bool is_msix, unsigned int vector,
286096cf78SDavid Woodhouse                           uint64_t addr, uint32_t data, bool is_masked);
296096cf78SDavid Woodhouse void xen_evtchn_remove_pci_device(PCIDevice *dev);
306096cf78SDavid Woodhouse struct kvm_irq_routing_entry;
316096cf78SDavid Woodhouse int xen_evtchn_translate_pirq_msi(struct kvm_irq_routing_entry *route,
326096cf78SDavid Woodhouse                                   uint64_t address, uint32_t data);
336096cf78SDavid Woodhouse bool xen_evtchn_deliver_pirq_msi(uint64_t address, uint32_t data);
346096cf78SDavid Woodhouse 
354f81baa3SDavid Woodhouse 
36794fba23SDavid Woodhouse /*
37794fba23SDavid Woodhouse  * These functions mirror the libxenevtchn library API, providing the QEMU
38794fba23SDavid Woodhouse  * backend side of "interdomain" event channels.
39794fba23SDavid Woodhouse  */
40794fba23SDavid Woodhouse struct xenevtchn_handle;
41794fba23SDavid Woodhouse struct xenevtchn_handle *xen_be_evtchn_open(void);
42794fba23SDavid Woodhouse int xen_be_evtchn_bind_interdomain(struct xenevtchn_handle *xc, uint32_t domid,
43794fba23SDavid Woodhouse                                    evtchn_port_t guest_port);
44794fba23SDavid Woodhouse int xen_be_evtchn_unbind(struct xenevtchn_handle *xc, evtchn_port_t port);
45794fba23SDavid Woodhouse int xen_be_evtchn_close(struct xenevtchn_handle *xc);
46794fba23SDavid Woodhouse int xen_be_evtchn_fd(struct xenevtchn_handle *xc);
47794fba23SDavid Woodhouse int xen_be_evtchn_notify(struct xenevtchn_handle *xc, evtchn_port_t port);
48794fba23SDavid Woodhouse int xen_be_evtchn_unmask(struct xenevtchn_handle *xc, evtchn_port_t port);
49794fba23SDavid Woodhouse int xen_be_evtchn_pending(struct xenevtchn_handle *xc);
50794fba23SDavid Woodhouse /* Apart from this which is a local addition */
51794fba23SDavid Woodhouse int xen_be_evtchn_get_guest_port(struct xenevtchn_handle *xc);
52794fba23SDavid Woodhouse 
534858ba20SDavid Woodhouse struct evtchn_status;
5483eb5811SDavid Woodhouse struct evtchn_close;
55190cc3c0SDavid Woodhouse struct evtchn_unmask;
56c723d4c1SDavid Woodhouse struct evtchn_bind_virq;
57aa98ee38SDavid Woodhouse struct evtchn_bind_pirq;
58f5417856SDavid Woodhouse struct evtchn_bind_ipi;
59cf7679abSDavid Woodhouse struct evtchn_send;
60e1db61b8SDavid Woodhouse struct evtchn_alloc_unbound;
6184327881SDavid Woodhouse struct evtchn_bind_interdomain;
6230667046SDavid Woodhouse struct evtchn_bind_vcpu;
63a15b1097SDavid Woodhouse struct evtchn_reset;
644858ba20SDavid Woodhouse int xen_evtchn_status_op(struct evtchn_status *status);
6583eb5811SDavid Woodhouse int xen_evtchn_close_op(struct evtchn_close *close);
66190cc3c0SDavid Woodhouse int xen_evtchn_unmask_op(struct evtchn_unmask *unmask);
67c723d4c1SDavid Woodhouse int xen_evtchn_bind_virq_op(struct evtchn_bind_virq *virq);
68aa98ee38SDavid Woodhouse int xen_evtchn_bind_pirq_op(struct evtchn_bind_pirq *pirq);
69f5417856SDavid Woodhouse int xen_evtchn_bind_ipi_op(struct evtchn_bind_ipi *ipi);
70cf7679abSDavid Woodhouse int xen_evtchn_send_op(struct evtchn_send *send);
71e1db61b8SDavid Woodhouse int xen_evtchn_alloc_unbound_op(struct evtchn_alloc_unbound *alloc);
7284327881SDavid Woodhouse int xen_evtchn_bind_interdomain_op(struct evtchn_bind_interdomain *interdomain);
7330667046SDavid Woodhouse int xen_evtchn_bind_vcpu_op(struct evtchn_bind_vcpu *vcpu);
74a15b1097SDavid Woodhouse int xen_evtchn_reset_op(struct evtchn_reset *reset);
754858ba20SDavid Woodhouse 
76799c2354SDavid Woodhouse struct physdev_map_pirq;
77799c2354SDavid Woodhouse struct physdev_unmap_pirq;
78799c2354SDavid Woodhouse struct physdev_eoi;
79799c2354SDavid Woodhouse struct physdev_irq_status_query;
80799c2354SDavid Woodhouse struct physdev_get_free_pirq;
81799c2354SDavid Woodhouse int xen_physdev_map_pirq(struct physdev_map_pirq *map);
82799c2354SDavid Woodhouse int xen_physdev_unmap_pirq(struct physdev_unmap_pirq *unmap);
83799c2354SDavid Woodhouse int xen_physdev_eoi_pirq(struct physdev_eoi *eoi);
84799c2354SDavid Woodhouse int xen_physdev_query_pirq(struct physdev_irq_status_query *query);
85799c2354SDavid Woodhouse int xen_physdev_get_free_pirq(struct physdev_get_free_pirq *get);
86799c2354SDavid Woodhouse 
8791cce756SDavid Woodhouse #endif /* QEMU_XEN_EVTCHN_H */
88