ISR handler not being called
Posted: Thu Sep 29, 2022 6:47 pm
Hi, I'm getting started in OS Dev and I just got to implementing ISR's. My problem is that the code in my ISR handler function seemingly isn't called. Here is my assembly file (boot header omitted):
And here is my ISR code
I assume that the ISR handling works to some capacity because if I omit the isrs_install function then the kernel crashes if it encounters an interrupt like this
or when I divide an int by zero.
I have read the wiki page on this issue but I'm not sure if any of the listed potential problems apply to me. Can anyone point me in the right direction? Thanks.
[/size]
Code: Select all
.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 KiB
stack_top:
.section .text
.global _start
.type _start, @function
_start:
mov $stack_top, %esp
call kernel_main
.global _gdt_flush
.extern _gp
.type _gdt_flush, @function
_gdt_flush:
lgdt (_gp)
mov %ax, 0x10
mov %ds, %ax
mov %es, %ax
mov %fs, %ax
mov %gs, %ax
mov %ss, %ax
jmp $0x08, $flush2
flush2:
ret
.global _idt_load
.extern _idtp
.type _idt_load, @function
_idt_load:
lidt (_idtp)
ret
.global _isr0
/* _isr1, isr2 etc... */
.type _isr0, @function
_isr0:
cli
push 0
push 0
jmp isr_common_stub
.type _isr1, @function
_isr1:
cli
push 0
push 1
jmp isr_common_stub
/* _isr2, isr3 etc... */
.global isr_common_stub
.extern _fault_handler
.type isr_common_stub, @function
isr_common_stub:
pusha
push %ds
push %es
push %fs
push %gs
mov %ax, 0x10
mov %ds, %ax
mov %es, %ax
mov %fs, %ax
mov %gs, %ax
mov %eax, %esp
push %eax
mov %eax, _fault_handler
call *%eax
pop %eax
pop %gs
pop %fs
pop %es
pop %ds
popa
add %esp, 8
iret
.size _start, . - _start
Code: Select all
struct regs{
unsigned int gs, fs, es, ds;
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;
unsigned int int_no, err_code;
unsigned int eip, cs, eflags, useresp, ss;
};
extern void _isr0();
/* _isr1, isr2 etc... */
void isrs_install(){
idt_set_gate(0, (unsigned)_isr0, 0x08, 0x8E);
/* _isr1, isr2 etc... */
}
void _fault_handler(struct regs *r){
printf("Exception!\n");
}
Code: Select all
asm("int $0x10");
I have read the wiki page on this issue but I'm not sure if any of the listed potential problems apply to me. Can anyone point me in the right direction? Thanks.
[/size]