Hi!
As I continue to struggle with OS dev, I have been reading about paging and segmentation. In the tutorial I'm using, the author creates a GDT with 3 entries, a null descriptor, one for data and one for code. The last two both start at 0 and are 4Gb in size (all of the memory). I am planning to use a memory manager using paging, is it necessary to use a more advanced segmentation system if I'm using paging anyway? I don't understand half of all this segmentation-paging stuff, but according to the intel manual there's no way to get around segmentation, so I wondered if you could get away with such a basic table.
Paging and segmentation
Re:Paging and segmentation
Segments are on top of paging, flat segmentation makes it seem as though segmentation is disabled, however you will need more segments unless you intend to run all programs in the kernel.
Re:Paging and segmentation
Well erm no I'm hoping of creating a more or less posix compliant system, with a shell and user applications and modular drivers, both seperate from the kernel. Isn't there a tutorial that discusses how to use segmentation and paging together, as all I'm reading discusses paging and assumes I have experience with all of the other aspects of OS dev, which I don't. It would also be useful to talk to an experienced OS dever, and bug him with questions on an IM medium, as they pop up, because I don't understand all of this segmentation and paging stuff.
Re:Paging and segmentation
When you need usermode code support, you'll need usermode segments too. So, the minimal GDT would consist of kernel mode (ring0) code & data, as well as usermode (ring3) code & data, all spanning from 0 - 4GB. For task switching with usermode support, you'll need one TSS descriptor as well, but I'm sure you'll find tons of helpful info about this topic (why you need the TSS) in the FAQ, as well as in the forum here.
You can't turn off segmentation, but with this style of GDT you can almost ignore it, since it allows you to access the whole address space without translating the addresses (any translation is then performed by the paging hardware). All you need to take care of then, is that you use the appropriate pair of segments (code/data) for the requested privilege level.
I hope this could help you getting started, feel free to ask further (specific) questions!
cheers
Joe
You can't turn off segmentation, but with this style of GDT you can almost ignore it, since it allows you to access the whole address space without translating the addresses (any translation is then performed by the paging hardware). All you need to take care of then, is that you use the appropriate pair of segments (code/data) for the requested privilege level.
I hope this could help you getting started, feel free to ask further (specific) questions!
cheers
Joe