From 83835c72564538e317a8e53b71fad47dbcee505d Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 5 Mar 2022 13:58:10 +0200 Subject: [PATCH] Kernel/HID: Add boot option to disable PS2 Mouse --- Base/usr/share/man/man7/boot_parameters.md | 2 ++ Kernel/Arch/x86_64/ISABus/I8042Controller.cpp | 3 ++- Kernel/Boot/CommandLine.cpp | 5 +++++ Kernel/Boot/CommandLine.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Base/usr/share/man/man7/boot_parameters.md b/Base/usr/share/man/man7/boot_parameters.md index b04099bedd..6ecda181fa 100644 --- a/Base/usr/share/man/man7/boot_parameters.md +++ b/Base/usr/share/man/man7/boot_parameters.md @@ -28,6 +28,8 @@ List of options: during the boot sequence. Leaving only the AHCI and Ram Disk controllers. * **`disable_physical_storage`** - If present on the command line, neither AHCI, or IDE controllers will be initialized on boot. + +* **`disable_ps2_mouse`** - If present on the command line, no PS2 mouse will be attached. * **`disable_uhci_controller`** - If present on the command line, the UHCI controller will not be initialized on boot. diff --git a/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp b/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp index a675e33f06..0fd6cce927 100644 --- a/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp +++ b/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -216,7 +217,7 @@ UNMAP_AFTER_INIT ErrorOr I8042Controller::detect_devices() m_first_ps2_port.device = error_or_device.release_value(); } } - if (m_second_port_available) { + if (m_second_port_available && !kernel_command_line().disable_ps2_mouse()) { // FIXME: Actually figure out the connected PS2 device type m_second_ps2_port.device_type = PS2DeviceType::StandardMouse; auto mouse_device = TRY(MouseDevice::try_to_initialize()); diff --git a/Kernel/Boot/CommandLine.cpp b/Kernel/Boot/CommandLine.cpp index 1db86eb84c..0dad946fe3 100644 --- a/Kernel/Boot/CommandLine.cpp +++ b/Kernel/Boot/CommandLine.cpp @@ -226,6 +226,11 @@ UNMAP_AFTER_INIT bool CommandLine::is_physical_networking_disabled() const return contains("disable_physical_networking"sv); } +UNMAP_AFTER_INIT bool CommandLine::disable_ps2_mouse() const +{ + return contains("disable_ps2_mouse"sv); +} + UNMAP_AFTER_INIT bool CommandLine::disable_physical_storage() const { return contains("disable_physical_storage"sv); diff --git a/Kernel/Boot/CommandLine.h b/Kernel/Boot/CommandLine.h index 98395eab2e..180ddda392 100644 --- a/Kernel/Boot/CommandLine.h +++ b/Kernel/Boot/CommandLine.h @@ -90,6 +90,7 @@ public: [[nodiscard]] PanicMode panic_mode(Validate should_validate = Validate::No) const; [[nodiscard]] HPETMode hpet_mode() const; [[nodiscard]] bool disable_physical_storage() const; + [[nodiscard]] bool disable_ps2_mouse() const; [[nodiscard]] bool disable_uhci_controller() const; [[nodiscard]] bool disable_usb() const; [[nodiscard]] bool disable_virtio() const;