The problem is I only get one keypress and thats it. I have tried the two tests in this previous post to check my PIC, IDT, CLI/STI functions and I had no problems getting them to work. I also have added the the EOI, but I only get one keypress.
keyboard handler
I believe this is my problem, as if I look in the bochs error log, it gives me a "internal keyboard buffer full, ignoring scancode" and then the scancode.
How do I add this extra dummy "importb(0x60)" to my codeIf the OS (or boot code) masks IRQs, then the keyboard sends a byte, and then the OS's keyboard driver takes over (unmasks the IRQ in the PIC, etc) then you can have a byte "jammed" in the keyboard controller chip's buffer. In this case any further bytes sent by the keyboard will result in a "buffer overflow" condition, and will not generate an IRQ.
The easiest way to resolve this situation is to do a dummy "inportb(0x60)" as seen here. If the OS has a very small delay between masking the IRQs and installing a keyboard IRQ handler it will be very unlikely (but still possible) for the keyboard controller chip to become "jammed".
Code: Select all
void init_keyboard(void)
{
???install_handlers(0x21, keyboard_handler, 0);
???outportb(0x21, (inportb(0x21) & 0xFD));
}
void keyboard_handler(void)
{
???unsigned scancode;
???scancode = inportb(0x60);
???printk("Testing\n");
}
; IRQ01 (Keyboard Interrupt)
[GLOBAL irq01]
[EXTERN _keyboard_handler]
irq01:
???pusha
???push ds
???push es
???push fs
???push gs
???call _keyboard_handler
???mov al, 0x20
???out 0x20, al
???pop gs
???pop fs
???pop es
???pop ds
???popa
???iret