Skip to content

PCIe support & virtio PCIe driver#74

Merged
EDGW merged 9 commits intomainfrom
dev/kako/pci
Apr 24, 2026
Merged

PCIe support & virtio PCIe driver#74
EDGW merged 9 commits intomainfrom
dev/kako/pci

Conversation

@EDGW
Copy link
Copy Markdown
Member

@EDGW EDGW commented Apr 23, 2026

This PR includes

  • the enumeration, initialization and probe logic of multi-level buses for PCIe devices,
  • the PCIe driver for virtio devices, and
  • the interrupt mapping mechanism.

AI Usage Status

AI is used for

  • generating simple logic (such as repetitive MMIO interface design),
  • conducting code reviews, and
  • producing documentation.

@EDGW EDGW self-assigned this Apr 23, 2026
Copilot AI review requested due to automatic review settings April 23, 2026 16:47
@EDGW EDGW added the enhancement New feature or request label Apr 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial PCIe support to the kernel, including multi-level PCIe bus enumeration, PCIe virtio transport, BAR pre-initialization/mapping, and DT-based interrupt-map parsing for the root bus (with platform/QEMU config updates for LoongArch64).

Changes:

  • Introduce PCIe bus infrastructure (ECAM access, device/domain modeling, address parsing, BAR sizing/allocation, and ioremap registry).
  • Add a VirtIO PCIe transport driver and update VirtIO HAL/device IRQ wiring for PCIe-backed virtio devices.
  • Implement DT ranges + interrupt-map parsing for the PCIe host bridge and update LoongArch64 QEMU platform/rootfs configs.

Reviewed changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
conf/rootfs/minimal.toml Switches minimal rootfs build arch to loongarch64.
conf/platforms/qemu-virt-la64.toml Enables virtio-blk PCIe devices and sets rootfs settings for LoongArch64 QEMU.
anemone-kernel/src/mm/remap.rs Exposes IoRemap virtual base and size for PCIe/ioremap consumers.
anemone-kernel/src/exception/intr/irq.rs Adds IrqDomain::xlate helper to translate interrupt specifiers.
anemone-kernel/src/driver/virtio/pcie.rs New VirtIO PCIe transport driver (virtio-drivers PciTransport integration).
anemone-kernel/src/driver/virtio/mod.rs Implements mmio_phys_to_virt using the PCIe remap registry.
anemone-kernel/src/driver/pcie_drivers/platform.rs PCIe ECAM platform driver: parses DT bus-range, ranges, and interrupt-map.
anemone-kernel/src/driver/pcie_drivers/bus.rs Bridge driver: multi-level bus enumeration, BAR/bridge window setup, interrupt keying.
anemone-kernel/src/driver/intc/sifive_plic.rs Makes PLIC xlate unconditional on OF-node presence (supports non-OF fw nodes).
anemone-kernel/src/driver/intc/loongson_platic.rs Same xlate behavior adjustment for LA7A1000 PLATIC.
anemone-kernel/src/driver/block/virtio_blk.rs Requests IRQ earlier during virtio-blk probe.
anemone-kernel/src/device/bus/virtio/device.rs Allows virtio transport parent to be either PlatformDevice or PcieDevice.
anemone-kernel/src/device/bus/pcie/remap.rs New global remap registry for mapping phys MMIO ranges to virt addresses.
anemone-kernel/src/device/bus/pcie/mod.rs PCIe module exports, naming docs, and class-code constants.
anemone-kernel/src/device/bus/pcie/fwnode.rs New firmware-node wrapper for PCIe devices to provide interrupt routing info.
anemone-kernel/src/device/bus/pcie/ecam.rs Enhances ECAM config access: writers, BAR/capability handling, multi-function iteration.
anemone-kernel/src/device/bus/pcie/driver.rs Extends PCIe driver trait with vendor/device match table + postinit hook.
anemone-kernel/src/device/bus/pcie/device.rs PCIe device/domain model, BAR resource allocators, and driver preinit/postinit flow.
anemone-kernel/src/device/bus/pcie/bus.rs PCIe BusType: matching logic, BAR preinit/allocation/ioremap integration.
anemone-kernel/src/device/bus/pcie/addr.rs New OpenFirmware PCI address parsing/encoding helpers.
anemone-kernel/crates/range-allocator/src/lib.rs Adds aligned allocation and introduces IncreasingRangeAllocator; updates Rangable bounds.
anemone-kernel/crates/range-allocator/src/increasing.rs New monotonic range allocator implementation + tests.
anemone-kernel/crates/device-tree/src/unflattened.rs Adds raw accessors and optional address/size-cells getters.
anemone-kernel/Cargo.toml Adds wavltree dependency.
Cargo.lock Locks wavltree crate.
.vscode/settings.json Switches rust-analyzer target to loongarch64.
.gitattributes Marks PCI ID database file as binary for git attributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread anemone-kernel/src/device/bus/pcie/fwnode.rs Outdated
Comment thread anemone-kernel/crates/range-allocator/src/increasing.rs Outdated
Comment thread .vscode/settings.json
Comment thread anemone-kernel/src/device/bus/pcie/device.rs
Comment thread conf/rootfs/minimal.toml
Comment thread anemone-kernel/src/device/bus/pcie/bus.rs Outdated
Comment thread anemone-kernel/src/device/bus/pcie/ecam.rs
Comment thread anemone-kernel/src/device/bus/pcie/remap.rs
Comment thread anemone-kernel/src/device/bus/pcie/mod.rs Outdated
Comment thread anemone-kernel/src/device/bus/pcie/mod.rs
@EDGW EDGW changed the title PCIe support PCIe support & virtio PCIe driver Apr 24, 2026
@EDGW EDGW merged commit 450f442 into main Apr 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants