Page 1 of 1

Could I change GDT in protected mode?

Posted: Wed Feb 26, 2003 4:24 am
by eyee
???Hey, all,
I am writing a tiny kernel,
and I set GDT in bootloader and switch to
prot mode.
Can I change GDT base address
at runtime?

thanks a lot!

Re:Could I change GDT in protected mode?

Posted: Wed Feb 26, 2003 5:26 am
by Pype.Clicker
yep. just prepare another one and lgdt just as you would do before entering pmode.

Just make sure you also refresh segment registers if the new GDT has been modified for those descriptorz. (mov ax,ds ; mov ds,ax ...)

Re:Could I change GDT in protected mode?

Posted: Wed Feb 26, 2003 5:40 am
by eyee
I mean, if I can do this in protected-mode
or If I must return to real mode?

Re:Could I change GDT in protected mode?

Posted: Wed Feb 26, 2003 6:21 am
by distantvoices
You can change GDT in protected mode.

You do not need to switch back to real mode.

You just need to build your new gdt, a proper GDTR-structure and a pointer to this structore.

You pass the pointer to GDTR to your sub routine which executes the lgdt [gdtrptr] - command.

stay safe :-)