xref: /openbmc/qemu/include/hw/remote/iohub.h (revision 93e0932b)
1 /*
2  * IO Hub for remote device
3  *
4  * Copyright © 2018, 2021 Oracle and/or its affiliates.
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  *
9  */
10 
11 #ifndef REMOTE_IOHUB_H
12 #define REMOTE_IOHUB_H
13 
14 #include "hw/pci/pci_device.h"
15 #include "qemu/event_notifier.h"
16 #include "qemu/thread-posix.h"
17 #include "hw/remote/mpqemu-link.h"
18 
19 #define REMOTE_IOHUB_NB_PIRQS    PCI_DEVFN_MAX
20 
21 typedef struct ResampleToken {
22     void *iohub;
23     int pirq;
24 } ResampleToken;
25 
26 typedef struct RemoteIOHubState {
27     PCIDevice d;
28     EventNotifier irqfds[REMOTE_IOHUB_NB_PIRQS];
29     EventNotifier resamplefds[REMOTE_IOHUB_NB_PIRQS];
30     unsigned int irq_level[REMOTE_IOHUB_NB_PIRQS];
31     ResampleToken token[REMOTE_IOHUB_NB_PIRQS];
32     QemuMutex irq_level_lock[REMOTE_IOHUB_NB_PIRQS];
33 } RemoteIOHubState;
34 
35 int remote_iohub_map_irq(PCIDevice *pci_dev, int intx);
36 void remote_iohub_set_irq(void *opaque, int pirq, int level);
37 void process_set_irqfd_msg(PCIDevice *pci_dev, MPQemuMsg *msg);
38 
39 void remote_iohub_init(RemoteIOHubState *iohub);
40 void remote_iohub_finalize(RemoteIOHubState *iohub);
41 
42 #endif
43