Page 1 of 1
Small nudge in right direction for buggy keyboard handling
Posted: Mon Nov 05, 2018 4:14 pm
by Bowlslaw
What would cause this bug? I can post my code if you need it, but I am interested in trying to figure out what the issue is myself. So far, I have been reading about the 8259 PIC and "Interrupt Problems" on the OSDev wiki, but I haven't not noticed anything.
The correct characters show up on the left side, but then it inserts that strange text afterwards, and goes to a newline.
Have I missed something? Anyone have a nudge in the right direction?
Re: Small nudge in right direction for buggy keyboard handli
Posted: Mon Nov 05, 2018 4:49 pm
by eryjus
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.
Re: Small nudge in right direction for buggy keyboard handli
Posted: Tue Nov 06, 2018 12:16 pm
by Bowlslaw
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 ... terrupts.c
It draws heavily from meaty skeleton and Sortie, Sortix's OS.
Code: Select all
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!