GDT entry?!

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
terrabyte
Posts: 2
Joined: Sat Sep 14, 2013 4:15 pm

GDT entry?!

Post by terrabyte »

Hello community!

Well, I've a problem understanding the structure of the a GDT-entry. I have the article about GDT and the GDT tutorial, and also the wikipedia article, but it's like already said
The actual structure of descriptors is a little messy for backwards compatibility with the 286's GDT.
:D
My problem is mainly: why are there two times limit-bits and three times base-bits?? What values do I have to put in the different bytes? Setting the flags and other bits shouldn't be difficult.
For example, i want a segment starting at 1GB end ending by 4GB. 1024 Bytes = 1 KB, 1024 KB = 1MB, 1024 MB = 1 GB, hence 1024³ Bytes = 1GB = 1073741824 Bytes = 0x40000000 Bytes.
3 GB would be 3221225472 Bytes, butif the granularity bit is set, limit is counted in 4 KB-steps, so 3221225472 divided by 4096 is 786432 or 0xC0000 in hex.^^
Now, ignoring the flag and attribute bits, what would the entry look like? I'm sorry, but I'm really confused :P
The other problem is, that I don't understand the codeexample enough to deduce the structure :oops:

Thank you!
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: GDT entry?!

Post by sortie »

I would recommend that you read the Intel/AMD CPU manuals, they describe the data structure in great detail.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: GDT entry?!

Post by dozniak »

terrabyte wrote: why are there two times limit-bits and three times base-bits??
for backwards compatibility with the 286's GDT.
Learn to read.
terrabyte
Posts: 2
Joined: Sat Sep 14, 2013 4:15 pm

Re: GDT entry?!

Post by terrabyte »

Well, "why" is probably not the corrct word...

But ok, thank you, I'll "rtfm" ;)
Post Reply