Kernel: Bypass PS2 detection if scancode set is forced

This commit is contained in:
Bananymous 2025-04-01 22:57:54 +03:00
parent 27613da5ea
commit aebacb6b6a
2 changed files with 22 additions and 8 deletions

View File

@ -239,14 +239,23 @@ namespace Kernel::Input
} }
BAN::ErrorOr<void> PS2Controller::initialize_impl(uint8_t scancode_set) BAN::ErrorOr<void> PS2Controller::initialize_impl(uint8_t scancode_set)
{
constexpr size_t iapc_flag_off = offsetof(ACPI::FADT, iapc_boot_arch);
constexpr size_t iapc_flag_end = iapc_flag_off + sizeof(ACPI::FADT::iapc_boot_arch);
// If user provided scan code set, skip FADT detection
if (scancode_set == 0xFF)
scancode_set = 0;
else if (scancode_set == 0)
{ {
// Determine if the PS/2 Controller Exists // Determine if the PS/2 Controller Exists
auto* fadt = static_cast<const ACPI::FADT*>(ACPI::ACPI::get().get_header("FACP"_sv, 0)); auto* fadt = static_cast<const ACPI::FADT*>(ACPI::ACPI::get().get_header("FACP"_sv, 0));
if (fadt && fadt->revision > 1 && !(fadt->iapc_boot_arch & (1 << 1))) if (fadt && fadt->revision >= 3 && fadt->length >= iapc_flag_end && !(fadt->iapc_boot_arch & (1 << 1)))
{ {
dwarnln_if(DEBUG_PS2, "No PS/2 available"); dwarnln_if(DEBUG_PS2, "No PS/2 available");
return BAN::Error::from_errno(ENODEV); return BAN::Error::from_errno(ENODEV);
} }
}
// Disable Devices // Disable Devices
TRY(send_command(PS2::Command::DISABLE_FIRST_PORT)); TRY(send_command(PS2::Command::DISABLE_FIRST_PORT));

View File

@ -90,11 +90,16 @@ static void parse_command_line()
else if (argument == "nodebug") else if (argument == "nodebug")
g_disable_debug = true; g_disable_debug = true;
else if (argument.starts_with("ps2=")) else if (argument.starts_with("ps2="))
{
if (argument == "ps2=auto"_sv)
cmdline.ps2_override = 0xFF;
else
{ {
if (argument.size() != 5 || !isdigit(argument[4])) if (argument.size() != 5 || !isdigit(argument[4]))
dprintln("Invalid ps2= command line argument format '{}'", argument); dprintln("Invalid ps2= command line argument format '{}'", argument);
cmdline.ps2_override = argument[4] - '0'; cmdline.ps2_override = argument[4] - '0';
} }
}
else if (argument.size() > 5 && argument.substring(0, 5) == "root=") else if (argument.size() > 5 && argument.substring(0, 5) == "root=")
cmdline.root = argument.substring(5); cmdline.root = argument.substring(5);
else if (argument.size() > 8 && argument.substring(0, 8) == "console=") else if (argument.size() > 8 && argument.substring(0, 8) == "console=")