xref: /qemu/include/hw/pci/pci_bus.h (revision a53ae8e934cd54686875b5bcfc2f434244ee55d6)
1 #ifndef QEMU_PCI_BUS_H
2 #define QEMU_PCI_BUS_H
3 
4 /*
5  * PCI Bus and Bridge datastructures.
6  *
7  * Do not access the following members directly;
8  * use accessor functions in pci.h, pci_bridge.h
9  */
10 
11 struct PCIBus {
12     BusState qbus;
13     PCIIOMMUFunc iommu_fn;
14     void *iommu_opaque;
15     uint8_t devfn_min;
16     pci_set_irq_fn set_irq;
17     pci_map_irq_fn map_irq;
18     pci_route_irq_fn route_intx_to_irq;
19     pci_hotplug_fn hotplug;
20     DeviceState *hotplug_qdev;
21     void *irq_opaque;
22     PCIDevice *devices[PCI_SLOT_MAX * PCI_FUNC_MAX];
23     PCIDevice *parent_dev;
24     MemoryRegion *address_space_mem;
25     MemoryRegion *address_space_io;
26     MemoryRegion master_abort_mem;
27 
28     QLIST_HEAD(, PCIBus) child; /* this will be replaced by qdev later */
29     QLIST_ENTRY(PCIBus) sibling;/* this will be replaced by qdev later */
30 
31     /* The bus IRQ state is the logical OR of the connected devices.
32        Keep a count of the number of devices with raised IRQs.  */
33     int nirq;
34     int *irq_count;
35 };
36 
37 typedef struct PCIBridgeWindows PCIBridgeWindows;
38 
39 /*
40  * Aliases for each of the address space windows that the bridge
41  * can forward. Mapped into the bridge's parent's address space,
42  * as subregions.
43  */
44 struct PCIBridgeWindows {
45     MemoryRegion alias_pref_mem;
46     MemoryRegion alias_mem;
47     MemoryRegion alias_io;
48     /*
49      * When bridge control VGA forwarding is enabled, bridges will
50      * provide positive decode on the PCI VGA defined I/O port and
51      * MMIO ranges.  When enabled forwarding is only qualified on the
52      * I/O and memory enable bits in the bridge command register.
53      */
54     MemoryRegion alias_vga[QEMU_PCI_VGA_NUM_REGIONS];
55 };
56 
57 #define TYPE_PCI_BRIDGE "base-pci-bridge"
58 #define PCI_BRIDGE(obj) OBJECT_CHECK(PCIBridge, (obj), TYPE_PCI_BRIDGE)
59 
60 struct PCIBridge {
61     /*< private >*/
62     PCIDevice parent_obj;
63     /*< public >*/
64 
65     /* private member */
66     PCIBus sec_bus;
67     /*
68      * Memory regions for the bridge's address spaces.  These regions are not
69      * directly added to system_memory/system_io or its descendants.
70      * Bridge's secondary bus points to these, so that devices
71      * under the bridge see these regions as its address spaces.
72      * The regions are as large as the entire address space -
73      * they don't take into account any windows.
74      */
75     MemoryRegion address_space_mem;
76     MemoryRegion address_space_io;
77 
78     PCIBridgeWindows *windows;
79 
80     pci_map_irq_fn map_irq;
81     const char *bus_name;
82 };
83 
84 #endif /* QEMU_PCI_BUS_H */
85