Switching from protected mode to real mode and back

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
bluman
Posts: 3
Joined: Sat Sep 25, 2010 7:57 am

Switching from protected mode to real mode and back

Post by bluman »

Hello,
Sorry for the stupid question, but I can't figure it out how to switch from protected mode to real mode and then get back to protected mode and continue running. Is there any easy way to do it? I need to do this in order to be able to switch to VGA 0x13 mode.

Thanks,
Paul Herman
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Switching from protected mode to real mode and back

Post by bluemoon »

While getting the processor from pmode to real mode and back to pmode is as easy as flipping a bit in CR0. However before doing so you need to clean up and setup all the surrounding environments like paging, IRQs, etc. As Brendan said on this thread, you need to "stop the world" to call real mode BIOS, which usually end up a mess.

It's probably easier to deal with the VGA directly.
Check this out VGA_Hardware.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Switching from protected mode to real mode and back

Post by gerryg400 »

This wiki page tells you how to do it.

http://wiki.osdev.org/Real_mode
If a trainstation is where trains stop, what is a workstation ?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Switching from protected mode to real mode and back

Post by Combuster »

Bluemoon +1, mostly because of the following:
I need to do this in order to be able to switch to VGA 0x13 mode.
You definitely don't. I recommend that you check out the link posted as well as the FAQ entry on changing video modes and then decide if you really need it or if you are just misinformed.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply