xref: /openbmc/qemu/include/hw/pci-host/gpex.h (revision d0bf492f)
1 /*
2  * QEMU Generic PCI Express Bridge Emulation
3  *
4  * Copyright (C) 2015 Alexander Graf <agraf@suse.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <http://www.gnu.org/licenses/>
18  */
19 
20 #ifndef HW_GPEX_H
21 #define HW_GPEX_H
22 
23 #include "exec/hwaddr.h"
24 #include "hw/sysbus.h"
25 #include "hw/pci/pci_device.h"
26 #include "hw/pci/pcie_host.h"
27 #include "qom/object.h"
28 
29 #define TYPE_GPEX_HOST "gpex-pcihost"
30 OBJECT_DECLARE_SIMPLE_TYPE(GPEXHost, GPEX_HOST)
31 
32 #define TYPE_GPEX_ROOT_DEVICE "gpex-root"
33 OBJECT_DECLARE_SIMPLE_TYPE(GPEXRootState, GPEX_ROOT_DEVICE)
34 
35 #define GPEX_NUM_IRQS 4
36 
37 struct GPEXRootState {
38     /*< private >*/
39     PCIDevice parent_obj;
40     /*< public >*/
41 };
42 
43 struct GPEXHost {
44     /*< private >*/
45     PCIExpressHost parent_obj;
46     /*< public >*/
47 
48     GPEXRootState gpex_root;
49 
50     MemoryRegion io_ioport;
51     MemoryRegion io_mmio;
52     MemoryRegion io_ioport_window;
53     MemoryRegion io_mmio_window;
54     qemu_irq irq[GPEX_NUM_IRQS];
55     int irq_num[GPEX_NUM_IRQS];
56 
57     bool allow_unmapped_accesses;
58 };
59 
60 struct GPEXConfig {
61     MemMapEntry ecam;
62     MemMapEntry mmio32;
63     MemMapEntry mmio64;
64     MemMapEntry pio;
65     int         irq;
66     PCIBus      *bus;
67 };
68 
69 int gpex_set_irq_num(GPEXHost *s, int index, int gsi);
70 
71 void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg);
72 
73 #endif /* HW_GPEX_H */
74