From 3d87445c823e5b49ace4cb2a51b53353fc6e766d Mon Sep 17 00:00:00 2001 From: Liav A Date: Thu, 22 Dec 2022 04:18:50 +0200 Subject: [PATCH] Kernel: Restore setting i8042 scan code set to scan code set 2 sequence This seems to work perfectly OK on my ICH7 test machine and also it works on QEMU, so it is probably OK to restore this. This will ensure we always get scan code set 1 input, because we enable scan code set 2 and PS/2 translation on the first (keyboard) port. --- Kernel/Arch/x86_64/ISABus/I8042Controller.cpp | 5 +++++ Kernel/Arch/x86_64/ISABus/I8042Controller.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp b/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp index f4ceeea04e3..3b80df2cb1d 100644 --- a/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp +++ b/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp @@ -176,6 +176,11 @@ UNMAP_AFTER_INIT ErrorOr I8042Controller::detect_devices() configuration |= I8042ConfigurationFlag::FirstPS2PortClock; m_keyboard_device = nullptr; SpinlockLocker lock(m_lock); + // NOTE: Before setting the actual scan code set, stop packet streaming entirely. + TRY(send_command(HIDDevice::Type::Keyboard, I8042Command::DisablePacketStreaming)); + TRY(do_wait_then_write(I8042Port::Buffer, I8042Command::SetScanCodeSet)); + TRY(do_wait_then_write(I8042Port::Buffer, 0x2)); + TRY(do_wait_then_write(I8042Port::Command, I8042Command::WriteConfiguration)); TRY(do_wait_then_write(I8042Port::Buffer, configuration)); } else { diff --git a/Kernel/Arch/x86_64/ISABus/I8042Controller.h b/Kernel/Arch/x86_64/ISABus/I8042Controller.h index e62b5517a30..c73997150b1 100644 --- a/Kernel/Arch/x86_64/ISABus/I8042Controller.h +++ b/Kernel/Arch/x86_64/ISABus/I8042Controller.h @@ -34,6 +34,7 @@ enum I8042Command : u8 { GetDeviceID = 0xF2, SetSampleRate = 0xF3, EnablePacketStreaming = 0xF4, + DisablePacketStreaming = 0xF5, SetDefaults = 0xF6, Reset = 0xFF, };