Could I change GDT in protected mode?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
eyee

Could I change GDT in protected mode?

Post 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!
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Could I change GDT in protected mode?

Post 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 ...)
eyee

Re:Could I change GDT in protected mode?

Post by eyee »

I mean, if I can do this in protected-mode
or If I must return to real mode?
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Could I change GDT in protected mode?

Post 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 :-)
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
Post Reply