From 8b3232121be0909ac885bc4e86ebbebdd0b9f6db Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sun, 24 Oct 2021 19:59:56 +0200 Subject: [PATCH] Kernel: Do not detect mouse or keyboard when handling IRQ for I8042 Instead of detecting which flag was set in the status register, we can use the instrument type passed to us. This works because the mouse and keyboard use different IRQs. --- Kernel/Devices/HID/I8042Controller.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Kernel/Devices/HID/I8042Controller.cpp b/Kernel/Devices/HID/I8042Controller.cpp index 423b0dc71a..c19c58b38a 100644 --- a/Kernel/Devices/HID/I8042Controller.cpp +++ b/Kernel/Devices/HID/I8042Controller.cpp @@ -131,21 +131,20 @@ UNMAP_AFTER_INIT void I8042Controller::detect_devices() m_mouse_device->enable_interrupts(); } -bool I8042Controller::irq_process_input_buffer(HIDDevice::Type) +bool I8042Controller::irq_process_input_buffer(HIDDevice::Type instrument_type) { VERIFY(Processor::current_in_irq()); u8 status = IO::in8(I8042Port::Status); if (!(status & I8042StatusFlag::OutputBuffer)) return false; - HIDDevice::Type data_for_device = ((status & I8042StatusFlag::SecondPS2PortOutputBuffer) == 0) ? HIDDevice::Type::Keyboard : HIDDevice::Type::Mouse; u8 byte = IO::in8(I8042Port::Buffer); - if (data_for_device == HIDDevice::Type::Mouse) { + if (instrument_type == HIDDevice::Type::Mouse) { VERIFY(m_mouse_device); static_cast(*m_mouse_device).irq_handle_byte_read(byte); return true; } - if (data_for_device == HIDDevice::Type::Keyboard) { + if (instrument_type == HIDDevice::Type::Keyboard) { VERIFY(m_keyboard_device); static_cast(*m_keyboard_device).irq_handle_byte_read(byte); return true;