Hi everyone,
I want to use BIOS interrupts in protected mode but setting up user mode, multitasking and vm86 for this purpose only is useless for my small OS.
So that i want to back to real mode and call the BIOS interrupt then back again to protected mode.
My question is : Can i do that ?
If yes: how can i do that ?
If no : why?
My OS is in C++ language and i am using MSVS 2005.
----------------------------------------------------
Thanks in advance
[Solved]Switch From Protected Mode to Real Mode and reverse
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
[Solved]Switch From Protected Mode to Real Mode and reverse
Last edited by melgmry0101b on Wed Jul 13, 2011 1:03 pm, edited 1 time in total.
Re: Switch From Protected Mode to Real Mode and reverse
You can do that though it is not always the clean way. And regarding your HOW question, there are plenty of posts on this subject lying here. I too, did post a fully working code somewhere over here, though I don't exactly remember the thread title. Search Task left as assignment.
Cheers#
Cheers#
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: Switch From Protected Mode to Real Mode and reverse
Start off by writing code to take the processor into protected mode and back to real mode - if you've changed nothing else, the BIOS should function fine after this. Then add more changes, one at a time and see if you can undo them and get the BIOS to work again each time before you take things further. You can leave the A20 enabled, and you'll probably get away with not restoring any GDT that the BIOS might have set up for itself. If you change the pic masks, store the original ones so that you can restore them when returning to real mode - on real hardware I found things worked fine without restoring them, but Bochs didn't like that at all. I also leave the RTC clock and periodic interrupts active on return to real mode on the assumption that the BIOS won't be thrown by them if it hasn't masked them out - it hasn't caused any problem so far. At some point you might find something that you can't undo, but I'm not aware of anything of that kind - no one supplied any details of such a thing the last time I asked, so I'm guessing that everything can be restored.
You certainly won't want to use the BIOS to print to the screen or collect input from keyboard and mouse, but it isn't too damaging for a hobby OS to use it for loading and saving files or to change screen mode.
You certainly won't want to use the BIOS to print to the screen or collect input from keyboard and mouse, but it isn't too damaging for a hobby OS to use it for loading and saving files or to change screen mode.
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
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
-
- Member
- Posts: 109
- Joined: Wed Nov 10, 2010 10:49 am
Re: Switch From Protected Mode to Real Mode and reverse
Thank you DavidCooper.
Re: [Solved]Switch From Protected Mode to Real Mode and reve
Just remember that you have to keep the original IVT intact so that yo can use 16bit interrupts, and that paging won't work in real mode.