> On Thu, Dec 17, 1998 at 03:10:44PM -0500, Richard B. Johnson wrote:
> > On Thu, 17 Dec 1998, Kenny Thomas wrote:
> >
> > > I am working on a project where I would like to be able to load up a
> > > minimum linux kernel with a small ramdisk similer to what is used for
> > > install puposes. But I need to be able to shutdown linux and return
> > > back to dos without rebooting. Is this possible, practical or remotely
> > > doable?
> > > Kenny Thomas
> > > ADMINKT@flint.umich.edu
>
> > That said, it IS possible to get back from protected mode to real-mode.
> > You can even restore the whole 16-bit environment (IDTs, GDTs, etc),
> > if you saved them somewhere. The problem is that Linux may have used
> > your secret memory location(s) for something else, and the state of
> > the hardware in undefined. To reinitialize the hardware, you've got
> > to either let the BIOS do it (cold boot), or do it all yourself from
> > some launch/restore program.
>
> This is the really bad part of the story. In principal, yes, you setup up
> everything like before and clear some bit of the CR0 register to get back to
> real mode. (The 286 funnily didn't allow that; you needed to play tricks with
> soft processor resetes to get back ... Seems the intel engineers just could
> not imagine one would really want to go back to this inferior Real Mode.
> They didn't expect the power with which M$ could keep people using their
> Real Mode OSes,. which really only used a small part of the processors
> power. The 386 was first sold in 1985, IIRC!)
>
> I think the restoring of the descriptors (GDT, ...) and the memory,
> processor state would be some work to be done but not that hard. The really
> bad thing is hardware! There are devices with write only registers ...
> (OK, it should be forbidden by law to built such hardware, but reality
> differs from what I think it should be.)
>
> Maybe you can use some of the BIOS' routines to set them to the intial
> state, before DOS was loaded. On a clean DOS installation, i.e. without
> CONFIG.SYS and AUTOEXEC.BAT, there are almost no device drivers which could
> change the state of the hardware from the inital state ...
> On a DOS with plenty of drivers in C.SYS/A.BAT, it's hopeless.
I would not bother to do it that way. I would put a "launch program"
as the last entry in my autoexec.bat file. If, upon startup, it did
not see a file, say RESTART.SYS, it would do nothing. Note, the hardware
has been initialized at that point.
The 'linux loader' program loadlin or whatever, before it did anything
to load linux, would copy all of user RAM into the file, RESTART.SYS.
This represents the state of DOS before loadlin started to load/start
linux. Note that if, at this time, loadlin were to execute MS-DOS
interrupt 0x21 with ax = 0x4c00, it would (properly) return to DOS.
This is important.
Now, the launch program, seeing the file RESTART.SYS, would relocate
itself into the last page of screen memory (yes, it's RAM and there
is always 16k of it with color boards). It would then take the memory
image from the file, one 64k block at a time, and load it via BIOS
INT 0x15 into memory above 1 megabyte. Once everything was loaded into
high RAM, I would delete RESTART.SYS. Then I would clear the interrupts
and grab the timer-tick value at 0x40:[0x6c]. Then copy high RAM, one 64k
block at a time into its original place, overlaying everything except my
code on the last page of screen memory. Then I would put back the saved
time at 0x40:[0x6c].
Then, the magic. Enable interrupts and execute MS-DOS interrupt 0x21
with ax = 0x4c00. You are home as if you had ^C exited from loadlin.
Linux just does it's normal `shutdown -r now`.
Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.1.131 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/