Skip to content

Commit

Permalink
x86_64: debug print discovered PCI(e) devices from MCFG
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Feb 19, 2025
1 parent 43810bd commit 2cb5cf5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions oro-arch-x86_64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ oro-dbgutil.workspace = true
oro-acpi.workspace = true
oro-sync.workspace = true
oro.workspace = true
oro-pci.workspace = true

# Work around non-composability of `test` profile and global allocator conflicts in unit test runner.
[dev-dependencies]
Expand Down
29 changes: 29 additions & 0 deletions oro-arch-x86_64/src/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,35 @@ pub unsafe fn boot_primary() -> ! {
.sdt()
.expect("ACPI tables are missing either the RSDT or XSDT table");

{
let mcfg = sdt
.find::<oro_acpi::Mcfg>()
.expect("MCFG table not found in ACPI tables");

for entry in mcfg.entries() {
dbg!("MCFG entry: {entry:?}", entry = entry);

let base =
unsafe { Phys::from_address_unchecked(entry.Address.read()).as_ptr_unchecked() };

for dev in oro_pci::MmioIterator::new(
base,
entry.StartBusNumber.read(),
entry.EndBusNumber.read(),
)
.expect("mis-aligned MCFG PCI(e) base pointer")
{
#[allow(unreachable_patterns)]
match dev.config {
oro_pci::PciConfig::Type0(config) => {
dbg!("{dev:?} -> {:#?}", unsafe { config.read_volatile() });
}
_ => dbg!("{dev:?} -> ???"),
}
}
}
}

let fadt = sdt
.find::<oro_acpi::Fadt>()
.expect("FADT table not found in ACPI tables");
Expand Down

0 comments on commit 2cb5cf5

Please sign in to comment.