Hello, I'm really new to this forum and OSDev all around. In fact, my in-progress OS was just started two days ago. I have a good handle on C and at least understand Assembly, but the idea of the Global Descriptor Table really confuses me. I'm generally quick to understand things. I've a basic knowledge of the whole interrupt thing and have read a lot of OS theory. I've also read all the way through the GDT Tutorial. It's just a slightly vague explanation. So, I'm not asking for code, I'm just looking for a basic explanation of the GDT, and possibly some hints.
Thanks, Sydney!
Having trouble understanding the theory behind the GDT.
- BASICFreak
- Member
- Posts: 284
- Joined: Fri Jan 16, 2009 8:34 pm
- Location: Louisiana, USA
Re: Having trouble understanding the theory behind the GDT.
Well, go through all of these and reply back a specific area you need help in (if you still didn't find the answer)
Global_Descriptor_Table
Protected Mode Tutorial
Protected Mode Segmentation <- Please don't use segmentation, use virtual memory.
Best regards,
B!
Global_Descriptor_Table
Protected Mode Tutorial
Protected Mode Segmentation <- Please don't use segmentation, use virtual memory.
Best regards,
B!
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
BOS Expanded Commentary
Both under active development!
Sortie wrote:
- Don't play the role of an operating systems developer, be one.
- Be truly afraid of undefined [behavior].
- Your operating system should be itself, not fight what it is.
Re: Having trouble understanding the theory behind the GDT.
The GDT is the table that the CPU uses to keep track of what memory is read-only, what memory is writable, and what memory is executable.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Re: Having trouble understanding the theory behind the GDT.
Thanks to both of you. I do understand it a bit better now, but now I've got a bit of a problem. I'm pretty sure that GRUB leaves me in protected mode and that it generates its own GDT. I know that it's recommended to overwrite that one. This is a somewhat stupid question compared to my first one, but how would I go about overwriting that. I can figure out the code on my own, with help from the GDT Tutorial, but where (as in what file) would I put this code. I've had problems figuring out where things go this whole time. Thanks, again.
- BASICFreak
- Member
- Posts: 284
- Joined: Fri Jan 16, 2009 8:34 pm
- Location: Louisiana, USA
Re: Having trouble understanding the theory behind the GDT.
Anywhere before you need it, it requires a linear address though so after Virtual Memory / Paging if you are using it.
What file is not relevant, it could be in you main file, a file named gdt, or anywhere - as long as you link in the file.
Creating_an_Operating_System gives a very basic order of when to implement what.
What file is not relevant, it could be in you main file, a file named gdt, or anywhere - as long as you link in the file.
Creating_an_Operating_System gives a very basic order of when to implement what.
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
BOS Expanded Commentary
Both under active development!
Sortie wrote:
- Don't play the role of an operating systems developer, be one.
- Be truly afraid of undefined [behavior].
- Your operating system should be itself, not fight what it is.
Re: Having trouble understanding the theory behind the GDT.
Nevermind about the file. New question: is there a limit or specified required number of GDT entries? Is there a minimum?
Re: Having trouble understanding the theory behind the GDT.
Thanks. That's kind of what I assumed.BASICFreak wrote:Anywhere before you need it, it requires a linear address though so after Virtual Memory / Paging if you are using it.
What file is not relevant, it could be in you main file, a file named gdt, or anywhere - as long as you link in the file.
Creating_an_Operating_System gives a very basic order of when to implement what.
- BASICFreak
- Member
- Posts: 284
- Joined: Fri Jan 16, 2009 8:34 pm
- Location: Louisiana, USA
Re: Having trouble understanding the theory behind the GDT.
Nucleria wrote:Nevermind about the file. New question: is there a limit or specified required number of GDT entries? Is there a minimum?
So a max of 8192.The offset is the linear address of the table itself, which means that paging applies. The size is the size of the table subtracted by 1. This is because the maximum value of size is 65535, while the GDT can be up to 65536 bytes (a maximum of 8192 entries). Further no GDT can have a size of 0.
The minimum is probably 3:
null
code
data
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
BOS Expanded Commentary
Both under active development!
Sortie wrote:
- Don't play the role of an operating systems developer, be one.
- Be truly afraid of undefined [behavior].
- Your operating system should be itself, not fight what it is.
Re: Having trouble understanding the theory behind the GDT.
Thanks. I (somehow) completely missed that. For now, I don't have any more questions, but I'm sure I'll have more soon.BASICFreak wrote:Nucleria wrote:Nevermind about the file. New question: is there a limit or specified required number of GDT entries? Is there a minimum?So a max of 8192.The offset is the linear address of the table itself, which means that paging applies. The size is the size of the table subtracted by 1. This is because the maximum value of size is 65535, while the GDT can be up to 65536 bytes (a maximum of 8192 entries). Further no GDT can have a size of 0.
The minimum is probably 3:
null
code
data
Thanks for all the help!