120599463SMichael S. Tsirkin #ifndef QEMU_PCI_BUS_H 220599463SMichael S. Tsirkin #define QEMU_PCI_BUS_H 3cfb0a50aSIsaku Yamahata 42728a57aSPhilippe Mathieu-Daudé #include "hw/pci/pci.h" 52728a57aSPhilippe Mathieu-Daudé 6cfb0a50aSIsaku Yamahata /* 7791bf3c8SDavid Gibson * PCI Bus datastructures. 868f79994SIsaku Yamahata * 9952deab6SMichael S. Tsirkin * Do not access the following members directly; 10791bf3c8SDavid Gibson * use accessor functions in pci.h 11cfb0a50aSIsaku Yamahata */ 12cfb0a50aSIsaku Yamahata 13616bbde3SEduardo Habkost struct PCIBusClass { 14ce6a28eeSMarcel Apfelbaum /*< private >*/ 15ce6a28eeSMarcel Apfelbaum BusClass parent_class; 16ce6a28eeSMarcel Apfelbaum /*< public >*/ 17ce6a28eeSMarcel Apfelbaum 18602141d9SMarcel Apfelbaum int (*bus_num)(PCIBus *bus); 196a3042b2SMarcel Apfelbaum uint16_t (*numa_node)(PCIBus *bus); 20616bbde3SEduardo Habkost }; 21ce6a28eeSMarcel Apfelbaum 22b0e5196aSDavid Gibson enum PCIBusFlags { 23b0e5196aSDavid Gibson /* This bus is the root of a PCI domain */ 24b0e5196aSDavid Gibson PCI_BUS_IS_ROOT = 0x0001, 252f57db8aSDavid Gibson /* PCIe extended configuration space is accessible on this bus */ 262f57db8aSDavid Gibson PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002, 279dccb121SBen Widawsky /* This is a CXL Type BUS */ 289dccb121SBen Widawsky PCI_BUS_CXL = 0x0004, 29b0e5196aSDavid Gibson }; 30b0e5196aSDavid Gibson 311b2b1237SJason Wang #define PCI_NO_PASID UINT32_MAX 321b2b1237SJason Wang 33cfb0a50aSIsaku Yamahata struct PCIBus { 34cfb0a50aSIsaku Yamahata BusState qbus; 35b0e5196aSDavid Gibson enum PCIBusFlags flags; 36*ba7d12ebSYi Liu const PCIIOMMUOps *iommu_ops; 37e00387d5SAvi Kivity void *iommu_opaque; 386f3279b5SIsaku Yamahata uint8_t devfn_min; 398b884984SMark Cave-Ayland uint32_t slot_reserved_mask; 40cfb0a50aSIsaku Yamahata pci_set_irq_fn set_irq; 41cfb0a50aSIsaku Yamahata pci_map_irq_fn map_irq; 423afa9bb4SMichael S. Tsirkin pci_route_irq_fn route_intx_to_irq; 43cfb0a50aSIsaku Yamahata void *irq_opaque; 4490a20dbbSIsaku Yamahata PCIDevice *devices[PCI_SLOT_MAX * PCI_FUNC_MAX]; 45cfb0a50aSIsaku Yamahata PCIDevice *parent_dev; 465968eca3SAvi Kivity MemoryRegion *address_space_mem; 475968eca3SAvi Kivity MemoryRegion *address_space_io; 48cfb0a50aSIsaku Yamahata 49cfb0a50aSIsaku Yamahata QLIST_HEAD(, PCIBus) child; /* this will be replaced by qdev later */ 50cfb0a50aSIsaku Yamahata QLIST_ENTRY(PCIBus) sibling;/* this will be replaced by qdev later */ 51cfb0a50aSIsaku Yamahata 52cfb0a50aSIsaku Yamahata /* The bus IRQ state is the logical OR of the connected devices. 53cfb0a50aSIsaku Yamahata Keep a count of the number of devices with raised IRQs. */ 54cfb0a50aSIsaku Yamahata int nirq; 55cfb0a50aSIsaku Yamahata int *irq_count; 56b86eacb8SMarcel Apfelbaum 57b86eacb8SMarcel Apfelbaum Notifier machine_done; 58cfb0a50aSIsaku Yamahata }; 59cfb0a50aSIsaku Yamahata pci_bus_is_cxl(PCIBus * bus)609dccb121SBen Widawskystatic inline bool pci_bus_is_cxl(PCIBus *bus) 619dccb121SBen Widawsky { 629dccb121SBen Widawsky return !!(bus->flags & PCI_BUS_CXL); 639dccb121SBen Widawsky } 649dccb121SBen Widawsky pci_bus_is_root(PCIBus * bus)65b0e5196aSDavid Gibsonstatic inline bool pci_bus_is_root(PCIBus *bus) 66b0e5196aSDavid Gibson { 67b0e5196aSDavid Gibson return !!(bus->flags & PCI_BUS_IS_ROOT); 68b0e5196aSDavid Gibson } 69b0e5196aSDavid Gibson pci_bus_allows_extended_config_space(PCIBus * bus)702f57db8aSDavid Gibsonstatic inline bool pci_bus_allows_extended_config_space(PCIBus *bus) 712f57db8aSDavid Gibson { 722f57db8aSDavid Gibson return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE); 732f57db8aSDavid Gibson } 742f57db8aSDavid Gibson 7520599463SMichael S. Tsirkin #endif /* QEMU_PCI_BUS_H */ 76