Hi. I'm new to OS programming. I wrote a multiboot compliant kernel and wrote a couple of funtions to write stuff to the screen and got it to load with GRUB (I use bochs, though on occasion I boot it up properly to make sure it looks normal). Now I want to set up some proper things (like a keyboard driver). I've been reading into it, and I can't figure out exactly what a GDT is. Does GRUB set one up? What does it do? What entries should I put in it? What is a selector? I've tried reading a few tutorials on the subject and I can't say I understood them. Thank you,
Shalom.
GDT
Re:GDT
Yes, but you should set up a whole new GDT if you want to reload any segment registers.Shalom wrote:Does GRUB set one up?
It defines the segments used by the whole system. Each segment has a base address, which gets added to all addresses referenced through the segment, and a limit, which places an upper limit on the addresses you can use through the segment. Each segment also has several flags, which define the type of segment (code, data or system) and access permissions.What does it do?
At a minimum: null, code and data.What entries should I put in it?
It's a number which references a segment. A selector contains a table indicator bit, which says whether it references the GDT or the LDT; a two-bit requested privilege level field, which allows you to 'ask' for a certain privilege level; and thirteen index bits, which point to the segment within the GDT or LDT.What is a selector?
You should read the Intel manuals if you haven't already done do; they should be considered the ultimate reference for things relating to the processor. Other than that, just keep reading and re-reading -- and browse through other peoples' source code for practical examples of usage.I've tried reading a few tutorials on the subject and I can't say I understood them.