![]() |
RT-Thread RTOS
An open source embedded real-time operating system
|
PCI/PCIe support in RT-Thread covers config-space access, bus enumeration, BAR assignment, INTx/MSI/MSI-X, and function drivers. Implementation layout matches **components/drivers/pci/**.
| Source / topic | Documentation |
|---|---|
**probe.c** — scan, setup, drivers | PCI enumeration and drivers |
**access.c** — config accessors | PCI config space access |
**ecam.c**, **host/** — root complex | PCI host controllers |
**irq.c** — INTx assign/mask | PCI INTx interrupts |
**pme.c** — power management | PCI power management |
**ofw.c** — DT ranges/IRQ | PCI and device tree |
**msi/** | PCI MSI and MSI-X |
**host-bridge.c** — bridge function driver | PCI bridge function driver |
**endpoint/** — EP mode | PCI endpoint (EP) mode |
Header: **drivers/pci.h**. Requires **RT_USING_DM** and **RT_USING_PIC**.
| Option | Role |
|---|---|
**RT_USING_PCI** | Core PCI stack |
**RT_PCI_MSI** | MSI / MSI-X (default y) |
**RT_PCI_ENDPOINT** | Endpoint framework |
**RT_PCI_ECAM** | ECAM config access |
**RT_PCI_SYS_64BIT** | 64-bit resource alloc |
**RT_PCI_CACHE_LINE_SIZE** | Cache line bytes written to config |
**RT_PCI_LOCKLESS** | Skip global config spinlock |
Host-specific options: **pci/host/Kconfig**, **pci/host/dw/Kconfig**.
| Object | Role |
|---|---|
**struct rt_pci_host_bridge** | Domain, **bus_regions**, **rt_pci_ops**, optional OFW node |
**struct rt_pci_bus** | Bus number, device list, **ops** chain |
**struct rt_pci_device** | BDF, BARs **resource[]**, caps, **irq**, bound driver |
**struct rt_pci_driver** | **ids[]**, **probe/remove** |
BDF macros: **RT_PCI_DEVFN**, **RT_PCI_DEVID**, **RT_PCI_SLOT**, **RT_PCI_FUNC**.
Full call chain (host → scan → BAR → function driver): PCI enumeration and drivers §「Full initialization flow」.
rt_pci_host_bridge_init** — **ranges**, **bus-range** — PCI and device tree rt_pci_host_bridge_probe** — DFS enumeration, **rt_pci_setup_device**, **rt_pci_device_register** pci_probe** → **rt_pci_assign_irq** → function **pdrv->probe** — IRQ: PCI INTx interrupts, MSI: PCI MSI and MSI-Xrt_pci_setup_device** completed (BARs in **pdev->resource**).void *base = rt_pci_iomap(pdev, bar)** before MMIO.rt_pci_set_master** only when DMA is ready.rt_pci_alloc_vector** or **rt_pci_msi_enable** — not raw INTx unless legacy.remove**: **rt_pci_free_vector**, **rt_pci_clear_master**, disable INTx.| PCI | Platform / AMBA |
|---|---|
| Device behind root complex with config space | Fixed SoC block with only **reg/interrupts** |
components/drivers/include/drivers/pci.h