Help Understanding GDT

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
saderax

Help Understanding GDT

Post 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?)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Help Understanding GDT

Post 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.
Dreamsmith

Re:Help Understanding GDT

Post by Dreamsmith »

saderax wrote:(P.s. What is the purpose of the LDT?)
For creating descriptors that are only used by one process.
Post Reply