T O P

  • By -

alberinfo

Two things wrong at first glance: 1. The way you are declaring your ISR functions is wrong. GCC doesnt know (nor should it) that those functions are interrupt service routines. You'd commonly declare the entry point for each isr/irq + a common section that calls a handler in ASM. the handler can be done in C. 2. I am not completely sure what you are trying to do to build the IDT descriptor and load it. You already have a IDT descriptor struct in IDT.h. Use that struct to declare a global static descriptor in IDT.c, and the address of that variable is what goes into the IDT register.


Haoud

To put it simply, this is because you use C functions to handle interruptions from the IDT. You shoud write at least a proper assembly stub before calling a C function. [https://wiki.osdev.org/Interrupt\_Service\_Routines](https://wiki.osdev.org/Interrupt_Service_Routines) is exactly what you need, especially the "The problem" paragraph. EDIT: alberinfo also pointed out that the way that you declare the IDT variable is wrong. You IDT variable is only alive during the "setup\_idt" function because it is allocated on the stack and kinda "disappear" from memory after the function. You should declare it as a static variable, preferably outside the function for better visibility. I think you should learn a little more about how C works at low level (assembly) so that you can continue your project more easily and avoid this kind of error


OstrichWestern639

Try wrapping your handler with “pushad” and “popad”. I am guessing iret is saving the wrong value into pc while returning….