Kernel: Fix PS/2 device detection

If we cannot find PS/2 devices in the acpi namespace check 8042 bit in
FADT. Also if user explicitly specified PS/2 scancode set, assume that
we do have a PS/2 controller even when other detection mechanisms fail
This commit is contained in:
2026-08-22 11:57:19 +03:00
parent 82fd57af9e
commit 892829adeb
+12 -14
View File
@@ -388,14 +388,11 @@ namespace Kernel::Input
} }
dprintln("Found {} PS/2 devices from ACPI namespace", acpi_devices.size()); dprintln("Found {} PS/2 devices from ACPI namespace", acpi_devices.size());
if (acpi_devices.empty())
return {};
if (acpi_devices.size() > 2) if (acpi_devices.size() > 2)
{ {
dwarnln("TODO: over 2 PS/2 devices"); dwarnln("TODO: over 2 PS/2 devices");
while (acpi_devices.size() > 2) MUST(acpi_devices.resize(2));
acpi_devices.pop_back();
} }
if (acpi_devices.size() == 2) if (acpi_devices.size() == 2)
@@ -421,6 +418,8 @@ namespace Kernel::Input
} }
} }
if (!acpi_devices.empty())
{
BAN::Optional<uint16_t> command_port; BAN::Optional<uint16_t> command_port;
command_port = acpi_devices[0].command_port; command_port = acpi_devices[0].command_port;
if (!command_port.has_value() && acpi_devices.size() >= 2) if (!command_port.has_value() && acpi_devices.size() >= 2)
@@ -434,21 +433,20 @@ namespace Kernel::Input
data_port = acpi_devices[1].data_port; data_port = acpi_devices[1].data_port;
if (data_port.has_value()) if (data_port.has_value())
m_data_port = data_port.value(); m_data_port = data_port.value();
}
devices[0] = { for (size_t i = 0; i < acpi_devices.size(); i++)
.type = acpi_devices[0].type,
.interrupt = acpi_devices[0].irq.value_or(PS2::IRQ::DEVICE0)
};
if (acpi_devices.size() > 1)
{ {
devices[1] = { devices[i] = {
.type = acpi_devices[1].type, .type = acpi_devices[i].type,
.interrupt = acpi_devices[1].irq.value_or(PS2::IRQ::DEVICE1) .interrupt = acpi_devices[i].irq.value_or(i == 0 ? PS2::IRQ::DEVICE0 : PS2::IRQ::DEVICE1),
}; };
} }
} }
else if (has_legacy_8042())
if (devices[0].type != DeviceType::None)
;
else if (scancode_set || has_legacy_8042())
{ {
devices[0] = { devices[0] = {
.type = DeviceType::Unknown, .type = DeviceType::Unknown,