Below is the setup code that gets called, fills the idt table with not-present interrupt gates, configures int 0 only to a handler (div by 0).. nothing goes wrong here.. second we're back in the main code and we do an STI or force an IDIV by zero we triple fault.
Anyone see anything wrong that I'm missing?
PS NMI and IRQS are still disabled at this point (until this table is working and I've fully populated all the handlers with a base generic handler chainable etc etc).
Code: Select all
struct interrupt_gate
rsrvd dd ?
ofs63_32 dd ?
ofs31_16 dw ?
flags dw ?
selector dw ?
ofs15_0 dw ?
ends
idt_init64:
mov rsi,offset kernel_idt
mov ecx,256
fillidt:
mov ax,0e00h
mov [rsi+interrupt_gate.flags],ax
add rsi,16
dec ecx
jnz short fillidt
mov rsi,offset kernel_idt
mov ax,8e00h
mov [rsi+interrupt_gate.flags],ax
mov rax,offset exception0_handler
mov rbx,rax
shr rbx,32
mov [rsi+interrupt_gate.ofs15_0],ax
shr rax,16
mov [rsi+interrupt_gate.ofs31_16],ax
mov [rsi+interrupt_gate.ofs63_32],ebx
mov ax,08h
mov [rsi+interrupt_gate.selector],ax
mov rax,offset kernel_idt
mov rsi,offset IDTReg
mov [rsi+2],rax
lidt [rsi]
ret
align 16
kernel_idt:
repeat 256
dq 0,0
end repeat
idt_size equ ($-kernel_idt)-1
align 16
IDTReg:
dw idt_size
dq 0
align 16
exception0_handler:
jmp short $
iretq