Octo beat me to it, and you can find a discussion/solution about the issue here:
viewtopic.php?f=1&t=33636&p=289580&hilit=+registers_t#p289580Upon further review of your code there is a mixture of a fix already in place. The parameters to irs_handler is passed properly, just your delcaration and prototype in the C code are wrong. In kernel/include/kernel/isrs.h it should be:
Code:
void isr_handler(registers_t *regs);
and in kernel/arch/i386/isrs.c your isr_handler function should be:
Code:
void isr_handler(registers_t *regs) {
terminal_writestring("Received interrupt: ");
terminal_writestring(interrupts_messages[(uint8_t)regs->int_no]); // Print message associated to num
// terminal_writestring(regs->int_no);
terminal_writestring("\n");
}
As Octo points out to use terminal_writestring to print an integer you'd have to write a function to do that (ie: itoa).
There is one other significant issue even if you fix the code above will still prevent the right interrupt number from being accessed properly. In kernel/include/kernel/isrs.h you have:
Code:
// This struct will be used to store all registers we've pushed
typedef struct registers {
uint32_t ds; // Data segment selector
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; // Pushed by pusha
uint32_t int_no, err_code; // Interrupt number and error code
uint32_t eip, cs, eflags, useresp, ss; // Pushed by the CPU itself
} registers_t;
The problem is that in kernel/arch/i386/boot.asm you do:
Code:
pusha ; Pushes EDI, ESI, EBP, ESP, EBX, EDX, ECX and EAX registers
push ds
push es
push fs
push gs
What you push has to exactly match the registers_t structure (in reverse order). You push DS, ES, FS, and GS and not just DS. Because these two things don't match you will be accessing data in registers_t at incorrect offsets. registers_t should look like:
Code:
typedef struct registers {
uint32_t gs, fs, es, ds; // Segment selectors
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; // Pushed by pusha
uint32_t int_no, err_code; // Interrupt number and error code
uint32_t eip, cs, eflags, useresp, ss; // Pushed by the CPU itself
} registers_t;