IDT & #GP
Posted: Tue Jun 15, 2004 1:01 am
OK... this is my first post ... so hi everyone ! I've read in my spare time for almost three years now about Operating Systems and tried many times to actually implement one... and now it's going well... started a month ago and i've done much (gdt,idt,mm, malloc, multithreading, pic,etc) but now i see the need for some debugging that I was NOT doing at all so its more like restarting for scratch than debugging .
This week I finally got my IDT to work without crashing bochs. I print each vectors when I set them (I print the vector in a function call set_exception which set the entry in the IDT - easier to debug) and then I enable interrupts and I get a General Protection Exception (#GP). If i comment the print instruction... everything goes right... no errors and CPU halts as supposed to be (i halt it because i have nothing to do now). And I was wondering what can cause this.... dump_cpu in bochs give me (eip is somewhere around or is the offset of the halt instruction in my exception handler but should be it since it halts) :
All entries in IDT are OK I double checked that, and they are all DPL0, 32bit trap gates.... selector = 0x08
others are NULL.
kprintf only modifies the video memory... there is only video routines... gdt... idt... string.h... remapping the PIC... all the other functions are commented right now... I'm trying to learn so I'd prefer be pointed to things to look for than giving out my code and someone replies with the correction.
JFF
P.S : I hope my english is still understandable it's like 3 AM
This week I finally got my IDT to work without crashing bochs. I print each vectors when I set them (I print the vector in a function call set_exception which set the entry in the IDT - easier to debug) and then I enable interrupts and I get a General Protection Exception (#GP). If i comment the print instruction... everything goes right... no errors and CPU halts as supposed to be (i halt it because i have nothing to do now). And I was wondering what can cause this.... dump_cpu in bochs give me (eip is somewhere around or is the offset of the halt instruction in my exception handler but should be it since it halts) :
Code: Select all
eax:0x67db4 ebx:0x67d81 ecx:0xb8000 edx:0x0
ebp:0x67e5c esi:0x0 edi:0x5b4c0 esp:0x67d70
eflags:0x6 eip:0x100139
cs:s=0x8, dl=0xffff, dh=0xcf9a00, valid=1
ss:s=0x10, dl=0xffff, dh=0xcf9200, valid=7
ds:s=0x23, dl=0xffff, dh=0xcff200, valid=7
es:s=0x23, dl=0xffff, dh=0xcff300, valid=1
fs:s=0x23, dl=0xffff, dh=0xcff300, valid=1
gs:s=0x23, dl=0xffff, dh=0xcff300, valid=1
ldtr:s=0x0, dl=0x0, dh=0x0, valid=0
tr:s=0x0, dl=0x0, dh=0x0, valid=0
gdtr:base=0x1000, limit=0xffff
idtr:base=0x12000, limit=0x7ff
dr0:0x0 dr1:0x0 dr2:0x0 dr3:0x0
dr6:0xffff0ff0 dr7:0x400
cr0:0x60000011 cr1:0x0 cr2:0x0 cr3:0x0 cr4:0x0
inhibit_mask:0
Code: Select all
GDT :
GDT[0x01]=Code segment, linearaddr=00000000, len=fffff * 4Kbytes, Execute/Read, 32-bit addrs
GDT[0x02]=Data segment, linearaddr=00000000, len=fffff * 4Kbytes, Read/Write, Accessed
GDT[0x03]=Code segment, linearaddr=00000000, len=fffff * 4Kbytes, Execute/Read, 32-bit addrs
GDT[0x04]=Data segment, linearaddr=00000000, len=fffff * 4Kbytes, Read/Write, Accessed
kprintf only modifies the video memory... there is only video routines... gdt... idt... string.h... remapping the PIC... all the other functions are commented right now... I'm trying to learn so I'd prefer be pointed to things to look for than giving out my code and someone replies with the correction.
JFF
P.S : I hope my english is still understandable it's like 3 AM