Basically, I'm trying to set up my IDT so I can get keyboard input. I've tried numerous methods, but can't seem to get it working. Whenever I run my OS in qemu it just restarts. From what I've gathered online it's probably a triple fault because my IDT isn't set up right. This only occurs if I've used the STI directive so that's led me to believe my IRQs are incorrect.
This is the code I've been using to initialize the IDT.
My OS is already in long mode. I've set up paging and the GDT at this point in the code. Also, the PICs are remapped.
Code: Select all
long_mode_start:
; load null into all data segment registers
mov ax, 0x0000
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
lidt [idt.pointer]
sti
call kernel_main
hlt
idt:
.irq0:
dq isr_wrapper.handler
dw 0x0008
db 0x00
db 10101110b
dw 0x0000
.irq1:
dq isr_wrapper.handler
dw 0x0008
db 0x00
db 10101110b
dw 0x0000
; ---------------------------
; irq2-29
; ---------------------------
.irq30:
dq isr_wrapper.error_code
dw 0x0008
db 0x00
db 0x00
db 10101110b
dw 0x0000
.irq31:
dq isr_wrapper.handler
dw 0x0008
db 0x00
db 10101110b
dw 0x0000
.pointer:
dw $ - idt - 1
dq idt
isr_wrapper:
.error_code:
add rsp, 8
.handler:
cld
call interrupt_handler
iretq