-
Notifications
You must be signed in to change notification settings - Fork 0
PCI Subsystem
NtinosTheGamer2324 edited this page Dec 11, 2025
·
1 revision
The PCI (Peripheral Component Interconnect) subsystem handles device enumeration and configuration.
PCI provides a standardized way to discover and configure hardware devices.
┌────────────────────────────────────┐
│ PCI Device Detection │
└───────────┬────────────────────────┘
│
┌───────────▼────────────────────────┐
│ Scan Bus 0-255 │
│ └─ Device 0-31 │
│ └─ Function 0-7 │
└───────────┬────────────────────────┘
│
┌───────────▼────────────────────────┐
│ Read Device Info │
│ - Vendor ID / Device ID │
│ - Class / Subclass │
│ - BARs (Base Address Registers) │
└───────────┬────────────────────────┘
│
┌───────────▼────────────────────────┐
│ Initialize Driver │
│ (AHCI, USB, Network, etc.) │
└────────────────────────────────────┘
Ports:
#define PCI_CONFIG_ADDRESS 0xCF8
#define PCI_CONFIG_DATA 0xCFCuint32_t pci_config_read_dword(uint8_t bus, uint8_t device,
uint8_t func, uint8_t offset) {
uint32_t address = (1 << 31) // Enable bit
| (bus << 16)
| (device << 11)
| (func << 8)
| (offset & 0xFC);
outl(PCI_CONFIG_ADDRESS, address);
return inl(PCI_CONFIG_DATA);
}| Class | Description |
|---|---|
| 0x00 | Unclassified |
| 0x01 | Mass Storage Controller |
| 0x02 | Network Controller |
| 0x03 | Display Controller |
| 0x06 | Bridge Device |
| 0x0C | Serial Bus Controller (USB) |
void pci_init(void) {
for (int bus = 0; bus < 256; bus++) {
for (int device = 0; device < 32; device++) {
uint16_t vendor = pci_config_read_word(bus, device, 0, 0);
if (vendor != 0xFFFF) {
// Device exists
pci_probe_device(bus, device);
}
}
}
}- Device Drivers - Driver architecture
- Storage Drivers - AHCI detection