Article View: comp.os.msdos.programmer
Article #655Re: Warm boot? (All suggestions so far have been dangerous!)
From: Bill Mitchell
Date: Fri, 10 Apr 1992 15:56
Date: Fri, 10 Apr 1992 15:56
91 lines
3508 bytes
3508 bytes
>>>
>>>Many people (including me, even) suggest the standard "jmp FFFF:0000"
>>>method.
>>>
>>>But this is extremely dangerous if the user is running disk cacheing
>>>software, since it bypasses *everything*! Caches don't get flushed,
>>>and you run the risk of trashing your hard drive!
>
Well, what I've been telling people is:
------------------------------------------------------------------
The reboot program is reboot.com. This program is created
from a debug script named reboot.dbg by typing "debug <reboot.dbg".
Reboot.dbg looks like this:
a 100
;cs:100
MOV SI,0080 ;point at command tail
MOV CX,[SI] ;get the length
XOR CH,CH ;check if it was zero
JCXZ 0115 ;if so, jmp
INC SI ;else get first char of arg 1
INC SI
MOV AL,[SI] ;into al
CMP AL,43 ;was is 'C'?
JZ 011A ;if so, jmp
CMP AL,63 ;was it 'c'?
JZ 011A ;if so, jmp
MOV BX,1234 ;set bx to magic number 1234 hex
JMP 011D ;and jmp
;cs:11a
MOV BX,7F7F ;else set bx to non-magic number
;cs:11d
MOV AX,0040
MOV DS,AX
MOV [0072],BX ;store bx in 0040:0072
JMP FFFF:0000 ;and reboot
n reboot.com
r bx
0
r cx
2b
w cs:100
q
------------------------------------------------------------------
A microsoft-c program to create reboot.exe which would do the same
thing is:
----------------------------------------------------------------
/* this program reboots the pc */
/* cold boot if an argument beginning with 'C' or 'c' is supplied */
/* warm boot otherwise */
#include <dos.h>
#include <ctype.h>
main(int argc, char **argv) {
void (far *reboot)(void);
int far *magic;
FP_SEG(reboot) = 0xffff;
FP_OFF(reboot) = 0;
FP_SEG(magic) = 0x40;
FP_OFF(magic) = 0x72;
if (argc > 1 && tolower(*argv[1]) == 'c') {
*magic = 0xffff;
else
*magic = 0x1234;
}
(*reboot)(); /* this should never return */
}
----------------------------------------------------------------
If there is any system-specific shutdown processing which needs to
be done (flushing the disk cache, idling the metal-stamping machine the
PC controls, whatever) it can/should be added.
Presumably, special measures will also be taken to assure that the
special shutdown processing gets done in case of ctl-alt-del reboot,
power fail/restore handling, trapping execution of illegal instructions,
vectoring thru unsupported interrupts, etc.
--
mitchell@mdd.comm.mot.com (Bill Mitchell)
Technical Details
Message-ID:
<1992Apr10.155609.28817@mdd.comm.mot.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!mdisea!mitchellReferences:
<1992Mar27.181824.20534@Princeton.EDU> <1992Mar30.171014.3133@exu.ericsson.se> <roelof.8@parst1.UUCP>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!mdisea!mitchell From: mitchell@mdd.comm.mot.com (Bill Mitchell) Subject: Re: Warm boot? (All suggestions so far have been dangerous!) Message-ID: <1992Apr10.155609.28817@mdd.comm.mot.com> Sender: news@mdd.comm.mot.com Bcc: mitchell Reply-To: mitchell@mdd.comm.mot.com (Bill Mitchell) Organization: Motorola, Mobile Data Division - Seattle, WA References: <1992Mar27.181824.20534@Princeton.EDU> <1992Mar30.171014.3133@exu.ericsson.se> <roelof.8@parst1.UUCP> Date: Fri, 10 Apr 1992 15:56:09 GMT Lines: 92