No interrupts being received from PIC
Posted: Tue Nov 19, 2019 12:46 pm
I have been trying to get the PS/2 keyboard interrupt and/or the PIT interrupt to fire, but I cannot get either to work. My other interrupts work properly (I have tested GP fault, page fault, breakpoint, and divide-by-zero and all work as expected). I can also get to ring 3 and perform a system call using int $0x80.
I am following the PIC guide on the wiki, but instead of restoring whatever masks were being used originally, I set PIC1's mask to 0xF8 and PIC2's mask to 0xFF. Here's the code for that:
where inb and outb are implemented exactly as they are in the wiki, and waitb is just io_wait with a different name.
init_idt is where my IDT gets configured:
https://gitlab.com/ryukoposting/rios/bl ... i686/idt.c
My kernel_main is at the bottom of this file, it's a bit ugly at the moment but should be fairly easy to follow. This is where the PIT setup happens:
https://gitlab.com/ryukoposting/rios/bl ... 6/kernel.c
This is the PIC stuff:
https://gitlab.com/ryukoposting/rios/bl ... i686/pic.c
I expect exception_0x21_handler to get called when a key is pressed, and I expect exception_0x20_handler to get called when the PIT counter rolls over.
Like I said, I know the EXCEPTION_ENTRY macro is working as expected, seeing as other interrupts using it are working fine.
I am using qemu-system-i386. My understanding is that it automatically maps they keyboard and mouse to the PS/2 inputs in the emulator.
I am following the PIC guide on the wiki, but instead of restoring whatever masks were being used originally, I set PIC1's mask to 0xF8 and PIC2's mask to 0xFF. Here's the code for that:
Code: Select all
void pic_remap(int offset1, int offset2)
{
outb(PIC1_COMMAND, ICW1_INIT | ICW1_ICW4); // starts the initialization sequence (in cascade mode)
waitb();
outb(PIC2_COMMAND, ICW1_INIT | ICW1_ICW4);
waitb();
outb(PIC1_DATA, offset1); // ICW2: Master PIC vector offset
waitb();
outb(PIC2_DATA, offset2); // ICW2: Slave PIC vector offset
waitb();
outb(PIC1_DATA, 4); // ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100)
waitb();
outb(PIC2_DATA, 2); // ICW3: tell Slave PIC its cascade identity (0000 0010)
waitb();
outb(PIC1_DATA, ICW4_8086);
waitb();
outb(PIC2_DATA, ICW4_8086);
waitb();
// enable PIT, keyboard, and PIC2 connection. all others disabled.
outb(PIC1_DATA, 0xF8);
outb(PIC2_DATA, 0xFF);
}
init_idt is where my IDT gets configured:
https://gitlab.com/ryukoposting/rios/bl ... i686/idt.c
My kernel_main is at the bottom of this file, it's a bit ugly at the moment but should be fairly easy to follow. This is where the PIT setup happens:
https://gitlab.com/ryukoposting/rios/bl ... 6/kernel.c
This is the PIC stuff:
https://gitlab.com/ryukoposting/rios/bl ... i686/pic.c
I expect exception_0x21_handler to get called when a key is pressed, and I expect exception_0x20_handler to get called when the PIT counter rolls over.
Like I said, I know the EXCEPTION_ENTRY macro is working as expected, seeing as other interrupts using it are working fine.
I am using qemu-system-i386. My understanding is that it automatically maps they keyboard and mouse to the PS/2 inputs in the emulator.