Page 1 of 2

Switching over to real mode from protected mode.......

Posted: Wed Apr 02, 2008 5:59 am
by East
Hi all
I am using Linux OS and i want switch over from protected mode to real mode. I have searched some documents from google, but nothing made me clear. http://www.sudleyplace.com/pmtorm.html
can anyone elaborate the mode switching process, where it be done...

Thanks in advance.
:cry:

Posted: Wed Apr 02, 2008 6:05 am
by einsteinjunior
You will find info in the topic in the Intel Manual ,more specifically the systems programming reference volume 3A.
Its quite somehow complicated as far as i remeber.Something about page alignment and some weird stuff i don't want to remeber,or else i will have some headache.
Jut check...........

Posted: Wed Apr 02, 2008 6:06 am
by AJ
Hi,

Try this tutorial.

Cheers,
Adam

Posted: Wed Apr 02, 2008 6:32 am
by East
Thanks for the responses.
AJ wrote: Try this tutorial.

The above documents explains about entering into protected mode and my previous post has the url for enter into real mode which is not clear for me. my one more doubt is entering into real mode and entering into protected mode ...all these things where should i do.....For me now i want to enter into real mode. I am in Linux (protected mode) , so where execute the code... I am new to this...
Thanks in advance.

Posted: Wed Apr 02, 2008 6:52 am
by AJ
Oh - sorry. I didn't realise you were in Linux - I'll read the question next time! :oops:

What is it you're trying to achieve at a higher level? I would be surprised if Linux let a user application switch to real mode. Perhaps you could do it from a driver module, although the system won't be too stable afterwards.

If you just want to run 16 bit code, you can try running it in v86 mode instead.

Cheers,
Adam

Posted: Wed Apr 02, 2008 7:32 am
by t6q4
Well, you could always try injecting the realmode code in the bootloader of your os before it goes to PMode, and (as AJ said) V86 mode is good because you are in Pmode, but can access the IVT.

Posted: Wed Apr 02, 2008 8:12 am
by inflater
Well, you could always try injecting the realmode code in the bootloader of your os before it goes to PMode
He is using Linux...

You can't switch Linux to real mode, neither MS-DOS to protected mode. In Linux, it's impossible by its architecture and security - direct access to register CR0 is prohibited.
In MS-DOS case you can freely fiddle with registers and stuff, but before leaving your application you must restore real mode, plus all segment/stack registers! (Or else a unpredictable result would happen, triple fault or some sort.)

Regards
inflater

Posted: Wed Apr 02, 2008 8:16 am
by East
So is it not at all possible?

Posted: Wed Apr 02, 2008 8:20 am
by Brynet-Inc
East wrote:So is it not at all possible?
It has already been explained to you several times on this forum, in fact, you created another topic asking the same question and received the same response! :roll:

http://www.osdev.org/phpBB2/viewtopic.php?t=16651

Write a bootloader, or GRUB, just stop asking the same questions.. :lol:

Posted: Wed Apr 02, 2008 8:24 am
by East
Actually what i want to do is, from user application using the int 19h, it should boot the my HDD second partition (HDD-which is currently running from first partition). Previously i restarted the system and selected the boot option in BIOS. Now i am trying to boot the system with int 19h. if no other way to go, then i have to startup with writing the OS...from OS scratch can i access the BIOS interrupts? Can anyone help me

Posted: Wed Apr 02, 2008 8:26 am
by East
i apologize for against the forum rule.

Posted: Wed Apr 02, 2008 8:33 am
by AJ
East wrote:if no other way to go, then i have to startup with writing the OS...from OS scratch can i access the BIOS interrupts? Can anyone help me
Yes - if you write an OS from scratch, you definitely can use the BIOS interrupts because you can choose to remain in (un)real mode. You can probably even do this from earlier DOS versions (someone correct me, please!) because that is real mode too (after all, DPMI switches to and from PMode).

If all you are trying to do is restart the computer, there are other ways. You can restart a Windows box using either the WinAPI or .NET framework and Linux must have its equivalents.

Can I ask you to do one of two things:
1) Do more background reading yourself, AND/OR
2) Give us a succinct overview of your project at the top level so that we can suggest something that does work.

Cheers,
Adam

Posted: Wed Apr 02, 2008 8:47 am
by inflater
East wrote:from user application using the int 19h, it should boot the my HDD second partition
...okay, take it easy Myself........ yeah, it'll be hunky-dory... .... yes indeed...... .... so....



FOR THE LAST TIME: YOU -CAN'T- USE ANY INTERRUPTS, ANY, AND I REPEAT: -ANY- INTERRUPTS IN LINUX !!!!!!!! DO YOU ARE A COMPLETE MORON ??!!

Posted: Wed Apr 02, 2008 10:51 am
by Pitchu
Hi
Access to cr0 is a previldged instruction and can be executed by kernel only (i dont think any kernel would do it), user programs cant access cr0.
If your motive is to restart, as told find some equivalent API.
If you are confused with DOS DPMI for pmode, take it as converse of NTVDM for V86.

Posted: Wed Apr 02, 2008 10:53 am
by Pitchu
Hi
Access to cr0 is a previldged instruction and can be executed by kernel only (i dont think any kernel would do it), user programs cant access cr0.
If your motive is to restart, as told find some equivalent API.
If you are confused with DOS DPMI for pmode, take it as converse of NTVDM for V86.