xref: /openbmc/qemu/hw/i386/kvm/xen_evtchn.h (revision c85cad81)
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(unsigned int nr_gsis, qemu_irq *system_gsis);
20 int xen_evtchn_soft_reset(void);
21 int xen_evtchn_set_callback_param(uint64_t param);
22 void xen_evtchn_set_callback_level(int level);
23 
24 int xen_evtchn_set_port(uint16_t port);
25 
26 bool xen_evtchn_set_gsi(int gsi, int level);
27 void xen_evtchn_snoop_msi(PCIDevice *dev, bool is_msix, unsigned int vector,
28                           uint64_t addr, uint32_t data, bool is_masked);
29 void xen_evtchn_remove_pci_device(PCIDevice *dev);
30 struct kvm_irq_routing_entry;
31 int xen_evtchn_translate_pirq_msi(struct kvm_irq_routing_entry *route,
32                                   uint64_t address, uint32_t data);
33 bool xen_evtchn_deliver_pirq_msi(uint64_t address, uint32_t data);
34 
35 
36 /*
37  * These functions mirror the libxenevtchn library API, providing the QEMU
38  * backend side of "interdomain" event channels.
39  */
40 struct xenevtchn_handle;
41 struct xenevtchn_handle *xen_be_evtchn_open(void);
42 int xen_be_evtchn_bind_interdomain(struct xenevtchn_handle *xc, uint32_t domid,
43                                    evtchn_port_t guest_port);
44 int xen_be_evtchn_unbind(struct xenevtchn_handle *xc, evtchn_port_t port);
45 int xen_be_evtchn_close(struct xenevtchn_handle *xc);
46 int xen_be_evtchn_fd(struct xenevtchn_handle *xc);
47 int xen_be_evtchn_notify(struct xenevtchn_handle *xc, evtchn_port_t port);
48 int xen_be_evtchn_unmask(struct xenevtchn_handle *xc, evtchn_port_t port);
49 int xen_be_evtchn_pending(struct xenevtchn_handle *xc);
50 /* Apart from this which is a local addition */
51 int xen_be_evtchn_get_guest_port(struct xenevtchn_handle *xc);
52 
53 struct evtchn_status;
54 struct evtchn_close;
55 struct evtchn_unmask;
56 struct evtchn_bind_virq;
57 struct evtchn_bind_pirq;
58 struct evtchn_bind_ipi;
59 struct evtchn_send;
60 struct evtchn_alloc_unbound;
61 struct evtchn_bind_interdomain;
62 struct evtchn_bind_vcpu;
63 struct evtchn_reset;
64 int xen_evtchn_status_op(struct evtchn_status *status);
65 int xen_evtchn_close_op(struct evtchn_close *close);
66 int xen_evtchn_unmask_op(struct evtchn_unmask *unmask);
67 int xen_evtchn_bind_virq_op(struct evtchn_bind_virq *virq);
68 int xen_evtchn_bind_pirq_op(struct evtchn_bind_pirq *pirq);
69 int xen_evtchn_bind_ipi_op(struct evtchn_bind_ipi *ipi);
70 int xen_evtchn_send_op(struct evtchn_send *send);
71 int xen_evtchn_alloc_unbound_op(struct evtchn_alloc_unbound *alloc);
72 int xen_evtchn_bind_interdomain_op(struct evtchn_bind_interdomain *interdomain);
73 int xen_evtchn_bind_vcpu_op(struct evtchn_bind_vcpu *vcpu);
74 int xen_evtchn_reset_op(struct evtchn_reset *reset);
75 
76 struct physdev_map_pirq;
77 struct physdev_unmap_pirq;
78 struct physdev_eoi;
79 struct physdev_irq_status_query;
80 struct physdev_get_free_pirq;
81 int xen_physdev_map_pirq(struct physdev_map_pirq *map);
82 int xen_physdev_unmap_pirq(struct physdev_unmap_pirq *unmap);
83 int xen_physdev_eoi_pirq(struct physdev_eoi *eoi);
84 int xen_physdev_query_pirq(struct physdev_irq_status_query *query);
85 int xen_physdev_get_free_pirq(struct physdev_get_free_pirq *get);
86 
87 #endif /* QEMU_XEN_EVTCHN_H */
88