Page 1 of 1

[SOLVED] PS/2 Keyboard interrupts not firing on new laptop

Posted: Tue Jan 07, 2025 12:25 am
by pross
Hi. I am testing my operating system on real computers, and found that on a new Lenovo AMD laptop, PS/2 keyboard interrupts are not being fired. My operating system works on other real computers ( https://github.com/rouseabout/os ). I am seeking suggestions beyond those already on the forums for this kind of problem.

So far:

* I have tested other established osdev projects (Sortix, Redox OS) on the laptop and they suffer the same problem: tapping the keyboard produces no interrupts. So I feel this is a new problem, and not something simple like masked interrupts or forgetting to acknowledge EOI.

* If I poll the keyboard, I do so correct scan codes. Resetting the keyboard with 0xFF command doesn't make any difference. Toggling bit 0 (first port interrupt bit) of the PS/2 controller configuration byte doesn't make any difference.

* Other interrupts, such as the PIT timer, fire correctly. Upgrading my operating system to use APIC and X2APIC instead of legacy PIC also made no difference.

* The keyboard works fine on Linux and Windows... So to explore the issue, I have built a custom Linux kernel, stripping out the i8042/libps2/atkbd components, and then wrote my own minimal PS/2 keyboard driver. I found PS/2 keyboard interrupts do work with this custom kernel, so Linux is doing something else to make them work.

Thanks for reading!

Re: PS/2 Keyboard interrupts not firing on new laptop

Posted: Tue Jan 07, 2025 10:46 am
by Klakap
I may have missed something, but I don't see where you initialize the PS/2 controller. Without proper initialization, there are many potential reasons why interrupts might not be fired on real hardware.

That being said, I have debugged my PS/2 driver on about ten real computers and managed to make it work on all of them. I would be really interested to see if it works on your computer as well. Additionally, it logs quite a lot of useful information, which could help us further identify the problem. If you would want to give it a try, you can find the source code here (or you can run image of release): https://github.com/VendelinSlezak/Blesk ... rivers/ps2

Re: PS/2 Keyboard interrupts not firing on new laptop

Posted: Tue Jan 07, 2025 12:09 pm
by Octocontrabass
Does it work if you disable legacy USB support in the BIOS/UEFI setup?

Re: PS/2 Keyboard interrupts not firing on new laptop

Posted: Tue Jan 07, 2025 11:01 pm
by pross
Thanks for the ideas. I managed to fix it: There was an APIC interrupt source override entry for IRQ1 with the active low polarity flag set, but I was neglecting to set the pin polarity on the corresponding APIC redirection entry. Keyboard interrupts now work! This took many rebuilds of the Linux kernel to isolate.

@Klakap: The laptop is EFI only, so I was unable to boot your operating system which relies on BIOS for its boot loader. Booted it on another computer and it runs great!