Page 1 of 1

Help Understanding GDT

Posted: Wed Nov 10, 2004 12:42 pm
by saderax
Before I write code to branch to protected mode, I would like to understand more about it. I have been reading information about the GDT, and have been unable to find a clear definition.

What i have learned so far is:
In real mode you have segmented memory with different segments in cs, ds, ss, es, fs, gs. It is my understanding that in protected mode, you create a table (GDT) which contains among other things a pointer to a memory location. So i can set the first entry to be the address of my kernel, and second to be video memory. Then the address 0x1:0x0000 will reference my code, and 0x2:0x0000 will reference video memory.

Is this correct? Does anyone have a good descriptive overview of protected mode and the GDT/IDT?

(P.s. What is the purpose of the LDT?)

Re:Help Understanding GDT

Posted: Wed Nov 10, 2004 1:41 pm
by Candy
saderax wrote: Before I write code to branch to protected mode, I would like to understand more about it. I have been reading information about the GDT, and have been unable to find a clear definition.

What i have learned so far is:
In real mode you have segmented memory with different segments in cs, ds, ss, es, fs, gs. It is my understanding that in protected mode, you create a table (GDT) which contains among other things a pointer to a memory location. So i can set the first entry to be the address of my kernel, and second to be video memory. Then the address 0x1:0x0000 will reference my code, and 0x2:0x0000 will reference video memory.

Is this correct? Does anyone have a good descriptive overview of protected mode and the GDT/IDT?

(P.s. What is the purpose of the LDT?)
No.

You multiply each entry by 8 for the offset. That means you use 8:0000 and 0x10:0000 etc. The lowest 2 bits are the PL (0-3) and the 3rd bit from the lower and up is the bit toggling between the LDT and the GDT.

For the rest, yes that's true.

Re:Help Understanding GDT

Posted: Wed Nov 10, 2004 5:12 pm
by Dreamsmith
saderax wrote:(P.s. What is the purpose of the LDT?)
For creating descriptors that are only used by one process.