Fixed interrupt handler bug

Table was wrong. Oops. Pointer math got me.
This commit is contained in:
lordtet 2025-06-28 01:35:35 -04:00
parent 561c7f9fa7
commit 4c76d5647a
4 changed files with 13 additions and 6 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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);
}

View file

@ -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,7 +35,6 @@ isr_%1:
%assign j 0
%rep 255
isr_ %+ j:
ISR_ENTRY j
%assign j j+1
%endrep