Browse Source

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.
Liav A 4 years ago
parent
commit
441e374396
4 changed files with 10 additions and 5 deletions
  1. 7 2
      Kernel/CommandLine.cpp
  2. 1 1
      Kernel/CommandLine.h
  3. 1 1
      Kernel/PCI/Initializer.cpp
  4. 1 1
      Kernel/PCI/MMIOAccess.cpp

+ 7 - 2
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

+ 1 - 1
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;

+ 1 - 1
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"));

+ 1 - 1
Kernel/PCI/MMIOAccess.cpp

@@ -126,7 +126,7 @@ UNMAP_AFTER_INIT MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
     });
 }
 
-UNMAP_AFTER_INIT Optional<VirtualAddress> MMIOAccess::get_device_configuration_space(Address address)
+Optional<VirtualAddress> 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) {