eryjus wrote:
https://wiki.osdev.org/PS/2_Keyboard#Scan_Code_Sets
Are you properly handling the release codes?
As for the extra text, my first thought is an extra format specifier in kprintf() without a matching parameter.
Hm, maybe I forgot to add support for the release codes. This is my code:
https://github.com/Bowlslaw/slawOS/blob/master/kernel/arch/i386/interrupts.cIt draws heavily from meaty skeleton and Sortie, Sortix's OS.
Code:
void pic_init() {
/* ICW1 - begin initialization */
port_byte_out(PIC1_CMD, 0x11);
port_byte_out(PIC2_CMD, 0x11);
/* ICW2 - remap offset address of IDT
* In x86 protected mode, we have to remap the PICs after 0x20 because
* Intel has designated the first 32 interrupts as "reserved" for CPU exceptions
*/
port_byte_out(PIC1_DATA, 0x20);
port_byte_out(PIC2_DATA, 0x28);
/* OCW3 - set up cascading */
port_byte_out(PIC1_DATA, 0x04);
port_byte_out(PIC2_DATA, 0x02);
/*
* port_byte_out(PIC1_DATA, 0x0);
* port_byte_out(PIC2_DATA, 0x0);
*/
/* ICW4 - environment info */
port_byte_out(PIC1_DATA, 0x01);
port_byte_out(PIC2_DATA, 0x01);
/* mask interrupts */
port_byte_out(PIC1_DATA, 0xFF);
port_byte_out(PIC2_DATA, 0xFF);
}
void isr_handler(struct regs *r) {
int irqn = (int)r->irqn;
printf("INT%d\n", irqn);
/* write EOI */
port_byte_out(PIC1_CMD, 0x20);
switch(irqn) {
case 0x21:
kbd_isr_main();
break;
default:
printf("Unknown interrupt %d\n", irqn);
break;
}
}
EDIT: Funnily enough...about 2 minutes after I posted this, I found my bug: I was the "printf(INT%d\n", irqn);" statement in the wrong spot, so it would print out the interrupt every single time. I moved it to the default case of the switch/case statement, and it works just fine now!