confusion on multiple initialization of GDT

If you are new to development, plan on spending some time here before visiting the other forums.

Moderator: Moderators

confusion on multiple initialization of GDT

Postby bluemimmosa » Fri Feb 18, 2011 5:15 am

Hello there, I have been following the tutorial on os development from this website and i have reached the descriptor tables and to my extent i have tried to understand it. My question is since we already have set up the GDT (5) entries on the assembly fime called gdt.inc, why are we again initializing the gdt on the kernel as well, is this the requirement?
Are we going to use the kernel defined gdt to enable access upto 4gb of memeory that the stage2 loader has restricted us?
and from this i have got that we can set up new gdt and invalidate the old whenever required?
is that holds true since we are invalidating the gdt entry from kernel loader and implementing a new gdt in kernel code.

Please make me clear on this as i am scratching my heads a lot.

Thanks in advance..
bluemimmosa
 
Posts: 3
Joined: Fri Feb 18, 2011 5:10 am

Re: confusion on multiple initialization of GDT

Postby halofreak1990 » Fri Feb 18, 2011 1:52 pm

The GDT in the bootloader was a generic one to make sure we could properly go to protected mode, but it lacked specifics, I.E. privileges and protection, which is fixed by the one created in the kernel.

bluemimmosa wrote:and from this i have got that we can set up new gdt and invalidate the old whenever required?
is that holds true since we are invalidating the gdt entry from kernel loader and implementing a new gdt in kernel code.

That is correct. You can replace the GDT at any time with a new one.
halofreak1990
 
Posts: 92
Joined: Thu May 27, 2010 8:54 pm
Location: Netherlands

Re: confusion on multiple initialization of GDT

Postby Andyhhp » Fri Feb 18, 2011 8:27 pm

You also have to consider this:

What if you use GRUB instead of your own bootloader? How are you certain that it has been set up as you want it?

The answer is that you are not, so the solution is to set one up yourself. In the grand scheme of booting, it is a trivial overhead, and offers the flexibility of multiple bootloaders.

~Andrew
Image
Andyhhp
Moderator
 
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1

Re: confusion on multiple initialization of GDT

Postby bluemimmosa » Sun Feb 20, 2011 7:27 am

so its like the GDT entries depends on our os design, if we want our os to have different levels of protection.,, like if we are giving ring3 to user ring2 to shared libs and ring1 to drivers and ring 0 to kernel then we can have entries like;
0x0
null entry;
0x08
ring0 kernel code entry
0x10
ring0 kernel data entry
0x18
ring1 device driver code entry
0x20
ring1 device driver data entry
0x28
ring2 shared lib code entry
0x30
ring2 shared lib data entry
0x38
ring3 user mode code entry
0x40
ring3 user mode data entry


ok then i am all set to go on reading about paging and virtual memory..
lesse, whats next on line....
:P
bluemimmosa
 
Posts: 3
Joined: Fri Feb 18, 2011 5:10 am


Return to Beginners

Who is online

Users browsing this forum: No registered users and 3 guests

cron