Page 1 of 1

lgdt problem

Posted: Sun Dec 07, 2003 12:00 am
by Gandalf
hi all,

   I have an elf kernel which i load using GRUB. The entry point into the kernel is through an assembly stub that after setting up the gdt and doing other initializations jumps to the "c" code.

   But when I try to change my gdt using lgdt inside my "C" code my kernel does a triple fault(Atleast thats what it looks like - coz bochs tries to reboot and says floppy error at the second attempt)

   To check for the memory addresses I dumped the gdt using sgdt(both before and after loading the gdt)

    //gdt is a pointer to the GDT structure {DD base, DW limit}

    My sgdt is __asm__ ("sgdt %0"::"m"(gdt));
    My lgdt is __asm__ ("lgdt (%0)"::"p"(gdt));

   The first gdt points to a memory location well above the 1Mb mark(there's where GRUB loads my kernel). But the second sgdt(the one after i try my lgdt from C code) gives me an address of 0xFF90 (a mem value less than 1Mb - I cann't figure out why).

   If you are interested to look at the code I will post that too. Please tell me what's wrong - its driving me crazy.


Gandalf

RE:lgdt problem

Posted: Tue Dec 09, 2003 12:00 am
by Ramanan
gdt is a double word.
I think u must have loaded partial gdt thru C code

: Ramanan.T