What is the best place to enter protected mode?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

What is the best place to enter protected mode?

Post by Roman »

What is the best place to enter protected mode? (bootloader stage 1, stage 2 or kernel or something else?)
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: What is the best place to enter protected mode?

Post by DavidCooper »

Roman wrote:What is the best place to enter protected mode? (bootloader stage 1, stage 2 or kernel or something else?)
What is protected mode for? Do your loader stages need protection from apps? Do they need to access memory above the 1MB point? If not, stay in real mode while you're still working with the BIOS to load your code, to set up a better screen mode and to get a map of usable memory. If you need to load in lots of code above the 1MB point, write code to go in and out of protected mode so that you can use the BIOS to load it to a buffer in low memory and then switch in and out of protected mode to shift it up memory. Once you've finished using the BIOS you can stay in protected mode, though you will need to limit how far you change the set-up of the machine if you want to change back into real mode to use the BIOS again to save or load more data later on, because every time you switch to real mode you'll need to undo all those changes.

Whatever you do, don't return to your original plan of writing a real-mode OS: protected mode will enable you to access a linear frame buffer for high-resolution graphics modes and make your OS a lot more capable than a real-mode OS as a result, as well as giving you gigabytes of memory to play with.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
User avatar
hometue
Member
Member
Posts: 100
Joined: Thu Dec 19, 2013 1:40 am
Location: Asia, Singapore

Re: What is the best place to enter protected mode?

Post by hometue »

My view on this is you load protected mode once you are done with things you want to do in real mode (things that can only be done in real mode, if there is, or things you prefer done in real mode due to the BIOS functions available to you etc.) I don't suggest switching between Real mode and Protected mode unless there is a must.
CookieOS. Want a cookie? Its only black and white for now though, probably as bad as my baking skills.
Post Reply