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.