xref: /qemu/include/hw/pci/pci_bus.h (revision 6a3042b23bbb1fa92c00ea9267c830e7f2e99313)
120599463SMichael S. Tsirkin #ifndef QEMU_PCI_BUS_H
220599463SMichael S. Tsirkin #define QEMU_PCI_BUS_H
3cfb0a50aSIsaku Yamahata 
4cfb0a50aSIsaku Yamahata /*
5952deab6SMichael S. Tsirkin  * PCI Bus and Bridge datastructures.
668f79994SIsaku Yamahata  *
7952deab6SMichael S. Tsirkin  * Do not access the following members directly;
8952deab6SMichael S. Tsirkin  * use accessor functions in pci.h, pci_bridge.h
9cfb0a50aSIsaku Yamahata  */
10cfb0a50aSIsaku Yamahata 
11ce6a28eeSMarcel Apfelbaum typedef struct PCIBusClass {
12ce6a28eeSMarcel Apfelbaum     /*< private >*/
13ce6a28eeSMarcel Apfelbaum     BusClass parent_class;
14ce6a28eeSMarcel Apfelbaum     /*< public >*/
15ce6a28eeSMarcel Apfelbaum 
16ce6a28eeSMarcel Apfelbaum     bool (*is_root)(PCIBus *bus);
17602141d9SMarcel Apfelbaum     int (*bus_num)(PCIBus *bus);
18*6a3042b2SMarcel Apfelbaum     uint16_t (*numa_node)(PCIBus *bus);
19ce6a28eeSMarcel Apfelbaum } PCIBusClass;
20ce6a28eeSMarcel Apfelbaum 
21cfb0a50aSIsaku Yamahata struct PCIBus {
22cfb0a50aSIsaku Yamahata     BusState qbus;
23e00387d5SAvi Kivity     PCIIOMMUFunc iommu_fn;
24e00387d5SAvi Kivity     void *iommu_opaque;
256f3279b5SIsaku Yamahata     uint8_t devfn_min;
26cfb0a50aSIsaku Yamahata     pci_set_irq_fn set_irq;
27cfb0a50aSIsaku Yamahata     pci_map_irq_fn map_irq;
283afa9bb4SMichael S. Tsirkin     pci_route_irq_fn route_intx_to_irq;
29cfb0a50aSIsaku Yamahata     void *irq_opaque;
3090a20dbbSIsaku Yamahata     PCIDevice *devices[PCI_SLOT_MAX * PCI_FUNC_MAX];
31cfb0a50aSIsaku Yamahata     PCIDevice *parent_dev;
325968eca3SAvi Kivity     MemoryRegion *address_space_mem;
335968eca3SAvi Kivity     MemoryRegion *address_space_io;
34cfb0a50aSIsaku Yamahata 
35cfb0a50aSIsaku Yamahata     QLIST_HEAD(, PCIBus) child; /* this will be replaced by qdev later */
36cfb0a50aSIsaku Yamahata     QLIST_ENTRY(PCIBus) sibling;/* this will be replaced by qdev later */
37cfb0a50aSIsaku Yamahata 
38cfb0a50aSIsaku Yamahata     /* The bus IRQ state is the logical OR of the connected devices.
39cfb0a50aSIsaku Yamahata        Keep a count of the number of devices with raised IRQs.  */
40cfb0a50aSIsaku Yamahata     int nirq;
41cfb0a50aSIsaku Yamahata     int *irq_count;
42cfb0a50aSIsaku Yamahata };
43cfb0a50aSIsaku Yamahata 
44b308c82cSAvi Kivity typedef struct PCIBridgeWindows PCIBridgeWindows;
45b308c82cSAvi Kivity 
46b308c82cSAvi Kivity /*
47b308c82cSAvi Kivity  * Aliases for each of the address space windows that the bridge
48b308c82cSAvi Kivity  * can forward. Mapped into the bridge's parent's address space,
49b308c82cSAvi Kivity  * as subregions.
50b308c82cSAvi Kivity  */
51b308c82cSAvi Kivity struct PCIBridgeWindows {
52b308c82cSAvi Kivity     MemoryRegion alias_pref_mem;
53b308c82cSAvi Kivity     MemoryRegion alias_mem;
54b308c82cSAvi Kivity     MemoryRegion alias_io;
55ba7d8515SAlex Williamson     /*
56ba7d8515SAlex Williamson      * When bridge control VGA forwarding is enabled, bridges will
57ba7d8515SAlex Williamson      * provide positive decode on the PCI VGA defined I/O port and
58ba7d8515SAlex Williamson      * MMIO ranges.  When enabled forwarding is only qualified on the
59ba7d8515SAlex Williamson      * I/O and memory enable bits in the bridge command register.
60ba7d8515SAlex Williamson      */
61ba7d8515SAlex Williamson     MemoryRegion alias_vga[QEMU_PCI_VGA_NUM_REGIONS];
62b308c82cSAvi Kivity };
63b308c82cSAvi Kivity 
64f055e96bSAndreas Färber #define TYPE_PCI_BRIDGE "base-pci-bridge"
65f055e96bSAndreas Färber #define PCI_BRIDGE(obj) OBJECT_CHECK(PCIBridge, (obj), TYPE_PCI_BRIDGE)
66f055e96bSAndreas Färber 
6768f79994SIsaku Yamahata struct PCIBridge {
68f055e96bSAndreas Färber     /*< private >*/
69f055e96bSAndreas Färber     PCIDevice parent_obj;
70f055e96bSAndreas Färber     /*< public >*/
7168f79994SIsaku Yamahata 
7268f79994SIsaku Yamahata     /* private member */
737e98e3afSIsaku Yamahata     PCIBus sec_bus;
74336411caSMichael S. Tsirkin     /*
75336411caSMichael S. Tsirkin      * Memory regions for the bridge's address spaces.  These regions are not
76336411caSMichael S. Tsirkin      * directly added to system_memory/system_io or its descendants.
77336411caSMichael S. Tsirkin      * Bridge's secondary bus points to these, so that devices
78336411caSMichael S. Tsirkin      * under the bridge see these regions as its address spaces.
79336411caSMichael S. Tsirkin      * The regions are as large as the entire address space -
80336411caSMichael S. Tsirkin      * they don't take into account any windows.
81336411caSMichael S. Tsirkin      */
82336411caSMichael S. Tsirkin     MemoryRegion address_space_mem;
83336411caSMichael S. Tsirkin     MemoryRegion address_space_io;
84b308c82cSAvi Kivity 
85b308c82cSAvi Kivity     PCIBridgeWindows *windows;
86b308c82cSAvi Kivity 
8768f79994SIsaku Yamahata     pci_map_irq_fn map_irq;
8868f79994SIsaku Yamahata     const char *bus_name;
8968f79994SIsaku Yamahata };
90cfb0a50aSIsaku Yamahata 
9120599463SMichael S. Tsirkin #endif /* QEMU_PCI_BUS_H */
92