From 467f6c74a4d2bfd46fdd04c7ef3ff35ab88e1384 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 14 Nov 2020 17:18:58 +0100 Subject: [PATCH] Kernel: Keep reading from i8042 until the buffer is empty Otherwise we might not drain the mouse buffer until the next IRQ. --- Kernel/Devices/I8042Controller.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Kernel/Devices/I8042Controller.cpp b/Kernel/Devices/I8042Controller.cpp index ed65c1ef9bb..dc723b8291a 100644 --- a/Kernel/Devices/I8042Controller.cpp +++ b/Kernel/Devices/I8042Controller.cpp @@ -149,13 +149,15 @@ void I8042Controller::irq_process_input_buffer(Device) { ASSERT(Processor::current().in_irq()); - u8 status = IO::in8(I8042_STATUS); - if (!(status & I8042_BUFFER_FULL)) - return; - Device data_for_device = ((status & I8042_WHICH_BUFFER) == I8042_MOUSE_BUFFER) ? Device::Mouse : Device::Keyboard; - u8 byte = IO::in8(I8042_BUFFER); - if (auto* device = m_devices[data_for_device == Device::Keyboard ? 0 : 1].device) - device->irq_handle_byte_read(byte); + for (;;) { + u8 status = IO::in8(I8042_STATUS); + if (!(status & I8042_BUFFER_FULL)) + return; + Device data_for_device = ((status & I8042_WHICH_BUFFER) == I8042_MOUSE_BUFFER) ? Device::Mouse : Device::Keyboard; + u8 byte = IO::in8(I8042_BUFFER); + if (auto* device = m_devices[data_for_device == Device::Keyboard ? 0 : 1].device) + device->irq_handle_byte_read(byte); + } } void I8042Controller::do_drain()