tree: 86036c2ae31ab43892802c9cbe7afdb22f3529ee [search]
  1. bin/
  2. drivers/
  3. lib/
  4. testing/
  5. BUILD.gn
  6. METADATA.textproto
  7. OWNERS
  8. README.md
src/devices/pci/README.md

PCI

The PCI bus driver provides management of the PCI bus in applicable systems and allows device drivers to be written for and bind to PCI devices in the system.

Architecture

Source

Location

Organization

Bus level operations are handled in bus.cc. Device-specific operations and the fuchsia.hardware.pci/Device FIDL protocol implementation are in device.cc and device_*.cc. The interface between a Device and the Bus is the BusDeviceInterface specified in bus_device_interface.h. The fuchsia.hardware.pci/Debug protocol (served through fuchsia.hardware.pci/DebugService) used by lspci is implemented in device_service.cc.

Build Targets

FIDL

Dependent Protocols

The PCI bus driver binds to fuchsia.hardware.pci.root/RootService (and uses fuchsia.hardware.pci.root/ConfigService when offered) to receive platform-level information for ACPI or devicetree devices, interrupts, interrupt routing, address space allocation, and bus configuration. On boards whose platform bus driver still serves the legacy banjo fuchsia.hardware.pciroot/Pciroot protocol, pciroot-banjo-adapter bridges it to fuchsia.hardware.pci.root.

Implemented Protocols

Libraries

  • //sdk/lib/driver/pci/cpp:cpp
    • Provides helper methods MapMmio and ConfigureInterruptMode for use with drivers, as well as convenience methods for constructing a client end for fuchsia.hardware.pci/Device calls.
  • //src/devices/pci/lib/pci:pci
    • Provides base implementations for the PciRootHost interface which provides a way for a platform to implement a backing driver that can service multiple fuchsia.hardware.pciroot/Pciroot instances to support multiple PCI buses in the system.
  • //src/devices/pci/testing:pci-protocol-fake
    • Provides a fake fuchsia.hardware.pci/Device implementation for use in unit testing, allowing users to create fake PCI devices that match the configuration of their real hardware.

Testing

See //src/devices/pci/drivers/pci/test/README.md for detailed documentation of the PCI test suite.

Tests

  • //sdk/lib/driver/pci/cpp:tests
    • driver-pci-cpp-test
  • //src/devices/pci/drivers/pci:tests
    • pci-driver-test: Rust integration test suite in drivers/pci/test/driver/driver_tests.rs running against fake-bus-pci (build target pci_fake) inside DriverTestRealm.
    • pci-unit-test: C++ unit test suite in drivers/pci/test/unit/ testing allocation, bus, config, device, and MSI-X against fakes.
  • //src/devices/pci:tests
    • pci-protocol-fake-test
    • pci-roothost-test
    • pciroot-banjo-adapter-test

Fakes

Fakes exist for most major classes in the PCI bus driver and can be found in //src/devices/pci/drivers/pci/test/fakes/

Debugging

Driver nodes

Each PCI function is published as a child node of the bus node, named <bus>_<device>_<function> in hex (for example 00_1f_3). Use ffx driver list-devices -v to see the nodes, their bind properties, and the drivers bound to them.

Tools