pci: Refactor bus.rs to better fit a PCI bus's semantics

This commit refactors the PCI bus struct. It has two major focuses.
First, we change the type of `device_ids` in `PciBus` to an array. A
fixed-size array better reflects real PCI bus constraints, especially
its limited number of PCI devices. Moreover, it can't be grown
accidentally.

The second focus is changing the type of the key of `devices` in
`PciBus` to `u8`, since device IDs are not allowed to exceed 31. We
furthermore replace magic numbers with constants and make them publicly
available so we can use them in a follow-up change when parsing user
input.

Signed-off-by: Pascal Scholz <pascal.scholz@cyberus-technology.de>
On-behalf-of: SAP pascal.scholz@sap.com
This commit is contained in:
Pascal Scholz
2026-03-16 15:26:12 +01:00
committed by Rob Bradford
parent 43b5a474f9
commit afd155d578
3 changed files with 22 additions and 16 deletions

View File

@@ -4125,7 +4125,7 @@ impl DeviceManager {
.unwrap();
pci_bus
.add_device(bdf.device() as u32, pci_device)
.add_device(bdf.device(), pci_device)
.map_err(DeviceManagerError::AddPciDevice)?;
self.bus_devices.push(Arc::clone(&bus_device));