Software Interrupts
Posted: Tue Oct 11, 2005 7:25 pm
Today I tried added software interrupts to my kernel for system calls. I already have IRQs, ISRs, and an IDT working perfectly fine. Like most other kernels, I decided to use int 30h for my interrupt. 30h is 48 in decimal.
What I did was added a isr48 entry to my kernel's IDT:
idt_set_gate(48, (unsigned)isr48, 0x08, 0x8E);
I also added an ISR to my ASM file.
Now, I get a general protection fault when I do an int 30h. Calling other interrupts with the int instruction works fine. The commented out lines do not affect the general protection fault at all. I've been debugging this for 2 days, and I'm not one to seek help unless I absolutely cannot figure it out. This is one of those times.
The Bochs debugger wasn't very helpful for me. I couldn't get it to step through the ISR.
Why is it GPFing? I am not doing any weird memory accesses and I have no memory protection schemes besides a simple GDT that maps the entire RAM as being one whole segment both code and data. My paging code maps the entire RAM under supervisor mode. Something must be awry with the interrupt but I've checked the way I'm setting up my IDT at least 20 times. I must be missing something, but what!
What I did was added a isr48 entry to my kernel's IDT:
idt_set_gate(48, (unsigned)isr48, 0x08, 0x8E);
I also added an ISR to my ASM file.
Code: Select all
; 48 : 30h System Call
isr48:
cli
push byte 0
push byte 48
jmp irq_common_stub
; We call a C function in here. We need to let the assembler know
; that '_fault_handler' exists in another file
extern fault_handler
; This is our common ISR stub. It saves the processor state, sets
; up for kernel mode segments, calls the C-level fault handler,
; and finally restores the stack frame.
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
The Bochs debugger wasn't very helpful for me. I couldn't get it to step through the ISR.
Why is it GPFing? I am not doing any weird memory accesses and I have no memory protection schemes besides a simple GDT that maps the entire RAM as being one whole segment both code and data. My paging code maps the entire RAM under supervisor mode. Something must be awry with the interrupt but I've checked the way I'm setting up my IDT at least 20 times. I must be missing something, but what!