1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

Kernel: Make i8042 controller initialization sequence more robust

The setting of scan code set sequence is removed, as it's buggy and
could lead the controller to fail immediately when doing self-test
afterwards. We will restore it when we understand how to do so safely.

Allow the user to determine a preferred detection path with a new kernel
command line argument. The defualt option is to check i8042 presence
with an ACPI check and if necessary - an "aggressive" test to determine
i8042 existence in the system.
Also, keep the i8042 controller pointer on the stack, so don't assign
m_i8042_controller member pointer if it does not exist.
This commit is contained in:
Liav A 2022-12-22 03:46:22 +02:00 committed by Jelle Raaijmakers
parent fc5bcd8476
commit 0f7cc468b2
6 changed files with 62 additions and 34 deletions

View file

@ -120,24 +120,39 @@ UNMAP_AFTER_INIT ErrorOr<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 (kernel_command_line().disable_ps2_controller())
return {};
#if ARCH(X86_64)
m_i8042_controller = I8042Controller::initialize();
// Note: If ACPI is disabled or doesn't indicate that we have an i8042, we
// still perform a manual existence check via probing, which is relevant on
// QEMU, for example. This probing check is known to not work on bare metal
// in all cases, so if we can get a 'yes' from ACPI, we skip it.
auto has_i8042_controller = false;
if (ACPI::Parser::the() && ACPI::Parser::the()->have_8042())
has_i8042_controller = true;
else if (m_i8042_controller->check_existence_via_probing({}))
auto i8042_controller = I8042Controller::initialize();
switch (kernel_command_line().i8042_presence_mode()) {
case I8042PresenceMode::Automatic: {
// Note: If ACPI is disabled or doesn't indicate that we have an i8042, we
// still perform a manual existence check via probing, which is relevant on
// QEMU, for example. This probing check is known to not work on bare metal
// in all cases, so if we can get a 'yes' from ACPI, we skip it.
if (ACPI::Parser::the() && ACPI::Parser::the()->have_8042())
has_i8042_controller = true;
else if (i8042_controller->check_existence_via_probing({}))
has_i8042_controller = true;
break;
}
case I8042PresenceMode::Force: {
has_i8042_controller = true;
break;
}
case I8042PresenceMode::None: {
break;
}
case I8042PresenceMode::AggressiveTest: {
if (i8042_controller->check_existence_via_probing({}))
has_i8042_controller = true;
break;
}
}
// Note: If we happen to not have i8042 just return "gracefully" for now.
if (!has_i8042_controller)
return {};
m_i8042_controller = i8042_controller;
TRY(m_i8042_controller->detect_devices());
if (m_i8042_controller->mouse())
m_hid_devices.append(m_i8042_controller->mouse().release_nonnull());