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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pross
Posts: 2
Joined: Mon Jan 06, 2025 11:39 pm
Libera.chat IRC: pross

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

Post 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!
Last edited by pross on Tue Jan 07, 2025 11:02 pm, edited 1 time in total.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

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

Post 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
Octocontrabass
Member
Member
Posts: 5623
Joined: Mon Mar 25, 2013 7:01 pm

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

Post by Octocontrabass »

Does it work if you disable legacy USB support in the BIOS/UEFI setup?
pross
Posts: 2
Joined: Mon Jan 06, 2025 11:39 pm
Libera.chat IRC: pross

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

Post 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!
Post Reply