[SOLVED] Flood of PS2 keyboard IRQs (PS2 driver error)
Posted: Sat Apr 06, 2024 5:12 pm
My operating system has a functioning scheduler, and (I confidently presume) I've solidly configured my interrupt handling and the IOAPIC/LAPIC/PIC/IDT shenanigans. For context, my LAPIC timer interrupt handling works fine, and delivers interrupts at the expected frequency, so I have no reason to believe that my IOAPIC, LAPIC, or IDT configuration is bugged. I am not attempting to make a kernel shell with kernel keyboard handling. Instead, I have a "pid 0" process named 'frame' which contains a rudimentary startup shell and terminal, all isolated from the kernel and running happily in a contained userspace process. My LAPIC timer is used to coordinate context switches, albeit at a relatively low frequency (and also there is no real "switch" because there is only one process).
I have properly implemented the SYSCALL instruction, and I am confident that they work properly because my lone user process is able to properly acquire framebuffer access from the kernel, as is evidenced by the functional userspace terminal.
Basically, I've all but completely isolated the issue to the actual keyboard handling code on the kernel side. I've debugged the userspace keyboard handler ad nauseam, and found that what mainly happens is the first keyboard interrupt is handled correctly, and I do hit the breakpoints in the user code that handles the interrupts. However, after that interrupt returns, I am able to see the EOI being sent to the LAPIC, but after the interrupt ends I receive a spam of interrupts 0x22 (the keyboard IRQ vector). This spam is not triggered until a key is pressed. The flood is large enough that it probably prevents the process from having enough CPU time to execute properly. However, further debugging demonstrated that the interrupts do not trample each other, and each and every IRQ I successfully handles and proceeds to send an EOI.
Yet, it's not throwing any exceptions. I'm kind of at a loss. I'll keep debugging.
I have properly implemented the SYSCALL instruction, and I am confident that they work properly because my lone user process is able to properly acquire framebuffer access from the kernel, as is evidenced by the functional userspace terminal.
Basically, I've all but completely isolated the issue to the actual keyboard handling code on the kernel side. I've debugged the userspace keyboard handler ad nauseam, and found that what mainly happens is the first keyboard interrupt is handled correctly, and I do hit the breakpoints in the user code that handles the interrupts. However, after that interrupt returns, I am able to see the EOI being sent to the LAPIC, but after the interrupt ends I receive a spam of interrupts 0x22 (the keyboard IRQ vector). This spam is not triggered until a key is pressed. The flood is large enough that it probably prevents the process from having enough CPU time to execute properly. However, further debugging demonstrated that the interrupts do not trample each other, and each and every IRQ I successfully handles and proceeds to send an EOI.
Yet, it's not throwing any exceptions. I'm kind of at a loss. I'll keep debugging.