Fixed interrupt handler bug
Table was wrong. Oops. Pointer math got me.
This commit is contained in:
parent
561c7f9fa7
commit
4c76d5647a
4 changed files with 13 additions and 6 deletions
|
|
@ -6,7 +6,7 @@ extern void (*isr_ptrs[])(void);
|
||||||
|
|
||||||
//Struct is built "backwards" since it is pushed in this order.
|
//Struct is built "backwards" since it is pushed in this order.
|
||||||
typedef struct StateSnapshot_s {
|
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 interrupt_id, error_code;
|
||||||
uint32_t eip, cs, eflags;
|
uint32_t eip, cs, eflags;
|
||||||
} StateSnapshot_t;
|
} StateSnapshot_t;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ void write_descriptors() {
|
||||||
|
|
||||||
for(int i = 0; i <= num_interrupts; i++) {
|
for(int i = 0; i <= num_interrupts; i++) {
|
||||||
uint32_t current_isr = (uint32_t)isr_ptrs[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
|
// Offset bits 0-15
|
||||||
current_idt_entry->offset_lo = current_isr & 0xFFFF;
|
current_idt_entry->offset_lo = current_isr & 0xFFFF;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,15 @@ void generic_isr_handler(StateSnapshot_t* cpu_state) {
|
||||||
vga_printf("INTERRUPT TRIGGERED! Info below.\n");
|
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("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("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!");
|
vga_printf("HALT!");
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ isr_common:
|
||||||
call generic_isr_handler
|
call generic_isr_handler
|
||||||
add esp,4 ;Remove that esp ref from the stack
|
add esp,4 ;Remove that esp ref from the stack
|
||||||
popad ;restore our gp registers
|
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
|
iret
|
||||||
|
|
||||||
%macro ISR_ENTRY 1
|
%macro ISR_ENTRY 1
|
||||||
|
|
@ -35,8 +35,7 @@ isr_%1:
|
||||||
|
|
||||||
%assign j 0
|
%assign j 0
|
||||||
%rep 255
|
%rep 255
|
||||||
isr_ %+ j:
|
ISR_ENTRY j
|
||||||
ISR_ENTRY j
|
|
||||||
%assign j j+1
|
%assign j j+1
|
||||||
%endrep
|
%endrep
|
||||||
; Generate a table of pointers that point to each of our ISRs. This will be accessed from C to setup our IDT.
|
; Generate a table of pointers that point to each of our ISRs. This will be accessed from C to setup our IDT.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue