Page 1 of 1

IDT only printing interrupt 16, no matter what interrupt is supposed to be recieved

Posted: Tue Apr 14, 2026 7:53 pm
by aether123
Hey guys,
I've recently been trying to setup my idt for keyboard interrupts, and its really confusing me, all it seems to be doing is printing interrupt 16, no matter what interrupt is supposed to print and i dont know why. I've re-wired the pic so that the keyboard interrupts would work but i really cant seem to figure it out, and it doesnt look to me like theres an actual math fault in my code, please help!


(idt code is in the beta branch)
https://www.github.com/x-aether-x/solsticeOS/tree/beta

Re: IDT only printing interrupt 16, no matter what interrupt is supposed to be recieved

Posted: Tue Apr 14, 2026 9:29 pm
by Octocontrabass
Take a look at your interrupt_handler() function. What arguments does it expect? Where does it expect to find those arguments?

Re: IDT only printing interrupt 16, no matter what interrupt is supposed to be recieved

Posted: Tue Apr 14, 2026 9:38 pm
by aether123
Oh, right. So it was trying to acces data from the entire CPU, and not just the registers with the interrupt number and error code!

I've just updated it with this block of code, which seems to be working

Code: Select all

struct registers {
    uint32_t ds;                                     // pushed manually
    uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; // pushed by pusha
    uint32_t int_no, err_code;                       // int number and err code
    uint32_t eip, cs, eflags, useresp, ss;           // pushed by cpu
};


extern "C" void interrupt_handler(struct registers* regs) {
    printf("Received Interrupt: %d\n", regs->int_no);
    if (regs->int_no >= 0x20) {
        // If it's from the pic, send eoi 
        if (regs->int_no >= 0x28) {
            outb(0xA0, 0x20);
        }
        outb(0x20, 0x20); // send eoi to master
    }
}
Thanks so much for your help, I was really struggling with this :)