From 441e3743964d6f5b12d402c7001b78e656676bd9 Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 3 Apr 2021 13:29:07 +0300 Subject: [PATCH] Kernel: Enable PCI ECAM method again if available Apparently we don't enable PCI ECAM (MMIO access to the PCI configuration space) even if we can. This is a regression, as it was enabled in the past and in unknown time it was regressed. The CommandLine::is_mmio_enabled method was renamed to CommandLine::is_pci_ecam_enabled to better represent the meaning of this method and what it determines. Also, an UNMAP_AFTER_INIT macro was removed from a method in the MMIOAccess class as it halted the system when the kernel tried to access devices after the boot process. --- Kernel/CommandLine.cpp | 9 +++++++-- Kernel/CommandLine.h | 2 +- Kernel/PCI/Initializer.cpp | 2 +- Kernel/PCI/MMIOAccess.cpp | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index 4294b97c9c..007af0e706 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -108,9 +108,14 @@ UNMAP_AFTER_INIT bool CommandLine::is_vmmouse_enabled() const return lookup("vmmouse").value_or("on") == "on"; } -UNMAP_AFTER_INIT bool CommandLine::is_mmio_enabled() const +UNMAP_AFTER_INIT bool CommandLine::is_pci_ecam_enabled() const { - return lookup("pci_mmio").value_or("off") == "on"; + auto value = lookup("pci_ecam").value_or("on"); + if (value == "on") + return true; + if (value == "off") + return false; + PANIC("Unknown PCI ECAM setting: {}", value); } UNMAP_AFTER_INIT bool CommandLine::is_legacy_time_enabled() const diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h index 91e553026e..ed5d632b3e 100644 --- a/Kernel/CommandLine.h +++ b/Kernel/CommandLine.h @@ -71,7 +71,7 @@ public: [[nodiscard]] bool is_ide_enabled() const; [[nodiscard]] bool is_smp_enabled() const; [[nodiscard]] bool is_vmmouse_enabled() const; - [[nodiscard]] bool is_mmio_enabled() const; + [[nodiscard]] bool is_pci_ecam_enabled() const; [[nodiscard]] bool is_legacy_time_enabled() const; [[nodiscard]] bool is_text_mode() const; [[nodiscard]] bool is_force_pio() const; diff --git a/Kernel/PCI/Initializer.cpp b/Kernel/PCI/Initializer.cpp index d010c5fd09..98a660c59f 100644 --- a/Kernel/PCI/Initializer.cpp +++ b/Kernel/PCI/Initializer.cpp @@ -50,7 +50,7 @@ UNMAP_AFTER_INIT static Access::Type detect_optimal_access_type(bool mmio_allowe UNMAP_AFTER_INIT void initialize() { - bool mmio_allowed = kernel_command_line().is_mmio_enabled(); + bool mmio_allowed = kernel_command_line().is_pci_ecam_enabled(); if (detect_optimal_access_type(mmio_allowed) == Access::Type::MMIO) MMIOAccess::initialize(ACPI::Parser::the()->find_table("MCFG")); diff --git a/Kernel/PCI/MMIOAccess.cpp b/Kernel/PCI/MMIOAccess.cpp index 702f85aa87..1aabc5f1c1 100644 --- a/Kernel/PCI/MMIOAccess.cpp +++ b/Kernel/PCI/MMIOAccess.cpp @@ -126,7 +126,7 @@ UNMAP_AFTER_INIT MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg) }); } -UNMAP_AFTER_INIT Optional MMIOAccess::get_device_configuration_space(Address address) +Optional MMIOAccess::get_device_configuration_space(Address address) { dbgln_if(PCI_DEBUG, "PCI: Getting device configuration space for {}", address); for (auto& mapping : m_mapped_device_regions) {