📚 AOS Docs

PCI Bus Driver

Peripheral Component Interconnect Device Enumeration

Overview

The PCI driver enumerates and configures devices on the PCI bus. Modern hardware connects via PCI, including network cards, AHCI storage controllers, and graphics cards.

PCI Configuration Space

Each PCI device has 256 bytes of configuration space accessible via I/O ports or memory-mapped I/O. AOS uses the port-based method:

Port Purpose
0xCF8 Address register (write device address)
0xCFC Data register (read/write 32-bit data)

Device Enumeration

The kernel scans all PCI buses and devices:

  1. For each bus (0-255)
  2. For each device on bus (0-31)
  3. For each function (0-7)
  4. Read vendor/device ID
  5. If valid, record device info
  6. Initialize appropriate driver

Key Takeaways

  • ✓ PCI uses configuration space ports
  • ✓ Device enumeration finds all hardware
  • ✓ Vendor/Device IDs identify devices
  • ✓ Class codes determine driver type
  • ✓ Interrupt distribution via MSI