From 0a220a413f15bc79c5b4ea58df3c018c7395f6c6 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 2 Sep 2022 10:02:16 +0300 Subject: Kernel/PCI: Don't use x86 initialization methods in non-x86 builds Using the IO address space is only relevant for x86 machines, so let's not compile instructions to access the PCI configuration space when we don't target x86 platforms. --- Kernel/Bus/PCI/Initializer.cpp | 6 ++++++ Kernel/CommandLine.cpp | 2 ++ Kernel/CommandLine.h | 2 ++ 3 files changed, 10 insertions(+) (limited to 'Kernel') diff --git a/Kernel/Bus/PCI/Initializer.cpp b/Kernel/Bus/PCI/Initializer.cpp index a6a9162368..2ca868014c 100644 --- a/Kernel/Bus/PCI/Initializer.cpp +++ b/Kernel/Bus/PCI/Initializer.cpp @@ -23,6 +23,7 @@ static bool test_pci_io(); UNMAP_AFTER_INIT static PCIAccessLevel detect_optimal_access_type() { +#if ARCH(I386) || ARCH(X86_64) auto boot_determined = kernel_command_line().pci_access_level(); if (!ACPI::is_enabled() || !ACPI::Parser::the()->find_table("MCFG"sv).has_value()) return PCIAccessLevel::IOAddressing; @@ -32,6 +33,7 @@ UNMAP_AFTER_INIT static PCIAccessLevel detect_optimal_access_type() if (!g_pci_access_io_probe_failed) return PCIAccessLevel::IOAddressing; +#endif PANIC("No PCI bus access method detected!"); } @@ -44,17 +46,21 @@ UNMAP_AFTER_INIT void initialize() return; switch (detect_optimal_access_type()) { case PCIAccessLevel::MemoryAddressing: { + // FIXME: There are other arch-specific methods to find the memory range + // for accessing the PCI configuration space. auto mcfg = ACPI::Parser::the()->find_table("MCFG"sv); VERIFY(mcfg.has_value()); auto success = Access::initialize_for_multiple_pci_domains(mcfg.value()); VERIFY(success); break; } +#if ARCH(I386) || ARCH(X86_64) case PCIAccessLevel::IOAddressing: { auto success = Access::initialize_for_one_pci_domain(); VERIFY(success); break; } +#endif default: VERIFY_NOT_REACHED(); } diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index b50f776a7e..ad9349f68d 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -149,8 +149,10 @@ UNMAP_AFTER_INIT PCIAccessLevel CommandLine::pci_access_level() const auto value = lookup("pci"sv).value_or("ecam"sv); if (value == "ecam"sv) return PCIAccessLevel::MemoryAddressing; +#if ARCH(I386) || ARCH(X86_64) if (value == "io"sv) return PCIAccessLevel::IOAddressing; +#endif if (value == "none"sv) return PCIAccessLevel::None; PANIC("Unknown PCI ECAM setting: {}", value); diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h index 618f031088..28a48ac6e0 100644 --- a/Kernel/CommandLine.h +++ b/Kernel/CommandLine.h @@ -32,7 +32,9 @@ enum class AcpiFeatureLevel { enum class PCIAccessLevel { None, +#if ARCH(I386) || ARCH(X86_64) IOAddressing, +#endif MemoryAddressing, }; -- cgit v1.2.3