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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
aether123
Posts: 21
Joined: Fri Jun 20, 2025 5:23 pm
Libera.chat IRC: aether123
Location: Australia
GitHub: https://www.github.com/x-aether-x

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

Post 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
Octocontrabass
Member
Member
Posts: 6249
Joined: Mon Mar 25, 2013 7:01 pm

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

Post by Octocontrabass »

Take a look at your interrupt_handler() function. What arguments does it expect? Where does it expect to find those arguments?
aether123
Posts: 21
Joined: Fri Jun 20, 2025 5:23 pm
Libera.chat IRC: aether123
Location: Australia
GitHub: https://www.github.com/x-aether-x

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

Post 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 :)
Capybara Gymastics is one of the most prestigious Olympic sports
Post Reply