diff options
author | Liav A <liavalb@gmail.com> | 2021-04-08 21:18:48 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-08 22:17:13 +0200 |
commit | a0be30f655a26e3e597292aab406231358a38202 (patch) | |
tree | db0f97c8281dcd9f8b481cd499b8ac125afe1674 | |
parent | 649564585ef42527b35d261363885af99cfb0a1a (diff) | |
download | serenity-a0be30f655a26e3e597292aab406231358a38202.zip |
Kernel: Introduce two new boot arguments to assist with bare metal debug
The first one is for disabling the PS2 controller, the other one is for
disabling physical storage enumeration.
We can't be sure any machine will work with our implementation,
therefore this will help us to test more machines.
-rw-r--r-- | Kernel/CommandLine.cpp | 10 | ||||
-rw-r--r-- | Kernel/CommandLine.h | 2 | ||||
-rw-r--r-- | Kernel/Devices/HID/HIDManagement.cpp | 3 | ||||
-rw-r--r-- | Kernel/Storage/StorageManagement.cpp | 18 |
4 files changed, 24 insertions, 9 deletions
diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index 4f8c254a7f..443fb0e20b 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -155,6 +155,16 @@ UNMAP_AFTER_INIT HPETMode CommandLine::hpet_mode() const PANIC("Unknown HPETMode: {}", hpet_mode); } +UNMAP_AFTER_INIT bool CommandLine::disable_ps2_controller() const +{ + return contains("disable_ps2_controller"); +} + +UNMAP_AFTER_INIT bool CommandLine::disable_physical_storage() const +{ + return contains("disable_physical_storage"); +} + UNMAP_AFTER_INIT AHCIResetMode CommandLine::ahci_reset_mode() const { const auto ahci_reset_mode = lookup("ahci_reset_mode").value_or("controller"); diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h index 12c0078bce..7ec1c484e3 100644 --- a/Kernel/CommandLine.h +++ b/Kernel/CommandLine.h @@ -84,6 +84,8 @@ public: [[nodiscard]] AcpiFeatureLevel acpi_feature_level() const; [[nodiscard]] BootMode boot_mode() const; [[nodiscard]] HPETMode hpet_mode() const; + [[nodiscard]] bool disable_physical_storage() const; + [[nodiscard]] bool disable_ps2_controller() const; [[nodiscard]] AHCIResetMode ahci_reset_mode() const; [[nodiscard]] String userspace_init() const; [[nodiscard]] Vector<String> userspace_init_args() const; diff --git a/Kernel/Devices/HID/HIDManagement.cpp b/Kernel/Devices/HID/HIDManagement.cpp index c16dabce12..1e589471a2 100644 --- a/Kernel/Devices/HID/HIDManagement.cpp +++ b/Kernel/Devices/HID/HIDManagement.cpp @@ -26,6 +26,7 @@ #include <AK/Singleton.h> #include <Kernel/ACPI/Parser.h> +#include <Kernel/CommandLine.h> #include <Kernel/Devices/HID/HIDManagement.h> #include <Kernel/Devices/HID/I8042Controller.h> @@ -125,7 +126,7 @@ UNMAP_AFTER_INIT void HIDManagement::enumerate() // emulation of the PS/2 controller if it was set by the BIOS. // If ACPI indicates we have an i8042 controller and the USB controller was // set to emulate PS/2, we should not initialize the PS/2 controller. - if (!ACPI::Parser::the()->have_8042()) + if (!ACPI::Parser::the()->have_8042() || kernel_command_line().disable_ps2_controller()) return; m_i8042_controller = I8042Controller::initialize(); m_i8042_controller->detect_devices(); diff --git a/Kernel/Storage/StorageManagement.cpp b/Kernel/Storage/StorageManagement.cpp index a9ca89e858..e91620e2c6 100644 --- a/Kernel/Storage/StorageManagement.cpp +++ b/Kernel/Storage/StorageManagement.cpp @@ -65,18 +65,20 @@ bool StorageManagement::boot_argument_contains_partition_uuid() UNMAP_AFTER_INIT NonnullRefPtrVector<StorageController> StorageManagement::enumerate_controllers(bool force_pio) const { NonnullRefPtrVector<StorageController> controllers; - if (kernel_command_line().is_ide_enabled()) { + if (!kernel_command_line().disable_physical_storage()) { + if (kernel_command_line().is_ide_enabled()) { + PCI::enumerate([&](const PCI::Address& address, PCI::ID) { + if (PCI::get_class(address) == 0x1 && PCI::get_subclass(address) == 0x1) { + controllers.append(IDEController::initialize(address, force_pio)); + } + }); + } PCI::enumerate([&](const PCI::Address& address, PCI::ID) { - if (PCI::get_class(address) == 0x1 && PCI::get_subclass(address) == 0x1) { - controllers.append(IDEController::initialize(address, force_pio)); + if (PCI::get_class(address) == 0x1 && PCI::get_subclass(address) == 0x6 && PCI::get_programming_interface(address) == 0x1) { + controllers.append(AHCIController::initialize(address)); } }); } - PCI::enumerate([&](const PCI::Address& address, PCI::ID) { - if (PCI::get_class(address) == 0x1 && PCI::get_subclass(address) == 0x6 && PCI::get_programming_interface(address) == 0x1) { - controllers.append(AHCIController::initialize(address)); - } - }); controllers.append(RamdiskController::initialize()); return controllers; } |