diff --git a/include/interrupt_handlers.h b/include/interrupt_handlers.h index 1e03db7..d298ca6 100644 --- a/include/interrupt_handlers.h +++ b/include/interrupt_handlers.h @@ -6,7 +6,7 @@ extern void (*isr_ptrs[])(void); //Struct is built "backwards" since it is pushed in this order. typedef struct StateSnapshot_s { - uint32_t edi, esi, esp, ebx, edx, ecx, eax; + uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; uint32_t interrupt_id, error_code; uint32_t eip, cs, eflags; } StateSnapshot_t; diff --git a/src/idt.c b/src/idt.c index 239d72e..d060fe2 100644 --- a/src/idt.c +++ b/src/idt.c @@ -12,7 +12,7 @@ void write_descriptors() { for(int i = 0; i <= num_interrupts; i++) { uint32_t current_isr = (uint32_t)isr_ptrs[i]; - InterruptDescriptor_t* current_idt_entry = idtr.IDT + (i*8); + InterruptDescriptor_t* current_idt_entry = idtr.IDT + i; // Offset bits 0-15 current_idt_entry->offset_lo = current_isr & 0xFFFF; diff --git a/src/interrupt_handlers.c b/src/interrupt_handlers.c index 4005b7b..362f5a5 100644 --- a/src/interrupt_handlers.c +++ b/src/interrupt_handlers.c @@ -7,7 +7,15 @@ void generic_isr_handler(StateSnapshot_t* cpu_state) { vga_printf("INTERRUPT TRIGGERED! Info below.\n"); vga_printf("Int_ID|ERR: %X|%X\n", cpu_state->interrupt_id, cpu_state->error_code); vga_printf("EFLAGS|CS|EIP: %X|%X|%X\n", cpu_state->eflags, cpu_state->cs,cpu_state->eip); - vga_printf("GP Registers:\neax:%X\nebx:%X\necx:%X\nedx:%X\nesp:%X\nesi:%X\nedi:%X\n"); + vga_printf("GP Registers:\neax:%X\nebx:%X\necx:%X\nedx:%X\nesp:%X\nebp:%X\nesi:%X\nedi:%X\n", + cpu_state->eax, + cpu_state->ebx, + cpu_state->ecx, + cpu_state->edx, + cpu_state->esp, + cpu_state->ebp, + cpu_state->esi, + cpu_state->edi); vga_printf("HALT!"); while(1); } diff --git a/src/interrupts.s b/src/interrupts.s index 2e1db19..e75a253 100644 --- a/src/interrupts.s +++ b/src/interrupts.s @@ -18,7 +18,7 @@ isr_common: call generic_isr_handler add esp,4 ;Remove that esp ref from the stack popad ;restore our gp registers - add esp,4 ;deallocate the error code from the stack before heading out + add esp,8 ;deallocate the error code from the stack before heading out iret %macro ISR_ENTRY 1 @@ -35,8 +35,7 @@ isr_%1: %assign j 0 %rep 255 - isr_ %+ j: - ISR_ENTRY j + ISR_ENTRY j %assign j j+1 %endrep ; Generate a table of pointers that point to each of our ISRs. This will be accessed from C to setup our IDT.