Emulated 8042 PS/2 controller sends IRQs only when polled
Posted: Wed Nov 14, 2018 6:13 pm
Some time ago I have written a very basic driver for the firmware-emulated PS/2 controller, to receive key presses from a connected USB keyboard. I try to avoid having to write an entire USB implementation, since the focus of this project is more on research, and only very basic I/O is necessary.
The driver just enables IRQ1 and, on interrupt, reads port 0x60 to retrieve the scan code. This works pretty well for 6th and 7th gen Intel processors, but on 4th and 5th gen systems it has a slightly weird behavior: First of all, the configuration register of the emulated controller has value 0x70, so both PS/2 ports are disabled. I then set this register to 0x65 (as for the other computers). Unfortunately I still do not get any interrupt - until I start polling port 0x60, which after a key press raises IRQ1 and triggers my interrupt handler.
So right now for each single keyboard interrupt, I have to read port 0x60 beforehand - which renders that interrupt rather useless, since I have to poll anyway.
Has anyone of you ever encountered such a behavior, or do you have an idea on how to fix this without needing to implement an entire USB stack?
The driver just enables IRQ1 and, on interrupt, reads port 0x60 to retrieve the scan code. This works pretty well for 6th and 7th gen Intel processors, but on 4th and 5th gen systems it has a slightly weird behavior: First of all, the configuration register of the emulated controller has value 0x70, so both PS/2 ports are disabled. I then set this register to 0x65 (as for the other computers). Unfortunately I still do not get any interrupt - until I start polling port 0x60, which after a key press raises IRQ1 and triggers my interrupt handler.
So right now for each single keyboard interrupt, I have to read port 0x60 beforehand - which renders that interrupt rather useless, since I have to poll anyway.
Has anyone of you ever encountered such a behavior, or do you have an idea on how to fix this without needing to implement an entire USB stack?