EDIT: For the source code, you can check my repo on Github: https://github.com/tuhdo/os-study.
I mapped the IRQs on 2 PICs (x86) to entry 32th and onward in IDT. To test out the PIC interrupts, I put the first 31 routines to the same function. The problem is, I cannot get 15th interrupt entry to work, since it is reserved according to Interrupt Vector Table. That is, whenever I get into protected mode, after enable the mode in cr0
and jump to the first instruction in kernel space (the last line in stage2.asm
, that is jmp 08h:0xFF0
), it crashes (in Bochs, it jumps to address f000:fff0
, which happens when things go wrong). Without adding the 15th entry, I can execute all code and terminate properly with hlt
instruction.
Since the entry is reserved, what should I do to skip the 15h entry? Currently, my generic IDT entry looks like this:
;; IRQ0
dw 0
dw 0x30 ; gdt selector 0x30
db 0
db 011001110b ; interrupt gate callable from userspace
dw 0
The relevant code is in gdt.inc and idt.inc. My OS has some basic features:
- Bootloader
- 32 bit protected mode.
- System calls (from userspace to kernel and back)
- Initial interrupt support: So far, I can handle division by 0 or explicit interrupt call (i.e.
int 1
). I already activated PIC (pic.inc) and wanted to try it out since I mapped the PIC interrupts at 0x32. However, after adding 15th IDT entry, I got triple fault, while 14th and downward I did not have such problem.