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 11*ce6a28eeSMarcel Apfelbaum typedef struct PCIBusClass { 12*ce6a28eeSMarcel Apfelbaum /*< private >*/ 13*ce6a28eeSMarcel Apfelbaum BusClass parent_class; 14*ce6a28eeSMarcel Apfelbaum /*< public >*/ 15*ce6a28eeSMarcel Apfelbaum 16*ce6a28eeSMarcel Apfelbaum bool (*is_root)(PCIBus *bus); 17*ce6a28eeSMarcel Apfelbaum } PCIBusClass; 18*ce6a28eeSMarcel Apfelbaum 19cfb0a50aSIsaku Yamahata struct PCIBus { 20cfb0a50aSIsaku Yamahata BusState qbus; 21e00387d5SAvi Kivity PCIIOMMUFunc iommu_fn; 22e00387d5SAvi Kivity void *iommu_opaque; 236f3279b5SIsaku Yamahata uint8_t devfn_min; 24cfb0a50aSIsaku Yamahata pci_set_irq_fn set_irq; 25cfb0a50aSIsaku Yamahata pci_map_irq_fn map_irq; 263afa9bb4SMichael S. Tsirkin pci_route_irq_fn route_intx_to_irq; 27cfb0a50aSIsaku Yamahata void *irq_opaque; 2890a20dbbSIsaku Yamahata PCIDevice *devices[PCI_SLOT_MAX * PCI_FUNC_MAX]; 29cfb0a50aSIsaku Yamahata PCIDevice *parent_dev; 305968eca3SAvi Kivity MemoryRegion *address_space_mem; 315968eca3SAvi Kivity MemoryRegion *address_space_io; 32cfb0a50aSIsaku Yamahata 33cfb0a50aSIsaku Yamahata QLIST_HEAD(, PCIBus) child; /* this will be replaced by qdev later */ 34cfb0a50aSIsaku Yamahata QLIST_ENTRY(PCIBus) sibling;/* this will be replaced by qdev later */ 35cfb0a50aSIsaku Yamahata 36cfb0a50aSIsaku Yamahata /* The bus IRQ state is the logical OR of the connected devices. 37cfb0a50aSIsaku Yamahata Keep a count of the number of devices with raised IRQs. */ 38cfb0a50aSIsaku Yamahata int nirq; 39cfb0a50aSIsaku Yamahata int *irq_count; 40cfb0a50aSIsaku Yamahata }; 41cfb0a50aSIsaku Yamahata 42b308c82cSAvi Kivity typedef struct PCIBridgeWindows PCIBridgeWindows; 43b308c82cSAvi Kivity 44b308c82cSAvi Kivity /* 45b308c82cSAvi Kivity * Aliases for each of the address space windows that the bridge 46b308c82cSAvi Kivity * can forward. Mapped into the bridge's parent's address space, 47b308c82cSAvi Kivity * as subregions. 48b308c82cSAvi Kivity */ 49b308c82cSAvi Kivity struct PCIBridgeWindows { 50b308c82cSAvi Kivity MemoryRegion alias_pref_mem; 51b308c82cSAvi Kivity MemoryRegion alias_mem; 52b308c82cSAvi Kivity MemoryRegion alias_io; 53ba7d8515SAlex Williamson /* 54ba7d8515SAlex Williamson * When bridge control VGA forwarding is enabled, bridges will 55ba7d8515SAlex Williamson * provide positive decode on the PCI VGA defined I/O port and 56ba7d8515SAlex Williamson * MMIO ranges. When enabled forwarding is only qualified on the 57ba7d8515SAlex Williamson * I/O and memory enable bits in the bridge command register. 58ba7d8515SAlex Williamson */ 59ba7d8515SAlex Williamson MemoryRegion alias_vga[QEMU_PCI_VGA_NUM_REGIONS]; 60b308c82cSAvi Kivity }; 61b308c82cSAvi Kivity 62f055e96bSAndreas Färber #define TYPE_PCI_BRIDGE "base-pci-bridge" 63f055e96bSAndreas Färber #define PCI_BRIDGE(obj) OBJECT_CHECK(PCIBridge, (obj), TYPE_PCI_BRIDGE) 64f055e96bSAndreas Färber 6568f79994SIsaku Yamahata struct PCIBridge { 66f055e96bSAndreas Färber /*< private >*/ 67f055e96bSAndreas Färber PCIDevice parent_obj; 68f055e96bSAndreas Färber /*< public >*/ 6968f79994SIsaku Yamahata 7068f79994SIsaku Yamahata /* private member */ 717e98e3afSIsaku Yamahata PCIBus sec_bus; 72336411caSMichael S. Tsirkin /* 73336411caSMichael S. Tsirkin * Memory regions for the bridge's address spaces. These regions are not 74336411caSMichael S. Tsirkin * directly added to system_memory/system_io or its descendants. 75336411caSMichael S. Tsirkin * Bridge's secondary bus points to these, so that devices 76336411caSMichael S. Tsirkin * under the bridge see these regions as its address spaces. 77336411caSMichael S. Tsirkin * The regions are as large as the entire address space - 78336411caSMichael S. Tsirkin * they don't take into account any windows. 79336411caSMichael S. Tsirkin */ 80336411caSMichael S. Tsirkin MemoryRegion address_space_mem; 81336411caSMichael S. Tsirkin MemoryRegion address_space_io; 82b308c82cSAvi Kivity 83b308c82cSAvi Kivity PCIBridgeWindows *windows; 84b308c82cSAvi Kivity 8568f79994SIsaku Yamahata pci_map_irq_fn map_irq; 8668f79994SIsaku Yamahata const char *bus_name; 8768f79994SIsaku Yamahata }; 88cfb0a50aSIsaku Yamahata 8920599463SMichael S. Tsirkin #endif /* QEMU_PCI_BUS_H */ 90