[comp.sys.ibm.pc.programmer] Warm reboot routine

mechling@secola.Columbia.NCR.COM (Randy Mechling) (06/07/90)

I am trying to do a warm reboot (such as CTL-ALT-DEL) from within an assembly
module.  Can anyone suggest a means of doing this.  I would prefer to do this
in assembly as I want to call it as what Novell calls an Event Service Routine.
Please email me any suggestions.  Thanks

bobmon@iuvax.cs.indiana.edu (RAMontante) (06/07/90)

Here are some articles I scarfed a few years ago, on this subject.
Nostalgia alert:  one of the return addresses here is ihnp4...
________________________

{ Three articles about warm-reboot vectors, culminating in debug scripts
  and a MASM assembler listing to do the dirty deed
}

1}
  Article 1899 of comp.sys.ibm.pc:
  Subject: Re: Code to perform warm reboot.
  Date: 22 Feb 87 20:26:01 GMT
  From: jmh@hyper.UUCP (Joel Halpern)
  Organization: Network Systems Corp., Mpls. MN
  Summary: Warm Boot and Extended Memory

  <1442@bnrmtv.UUCP>, zarifes@bnrmtv.UUCP (Kenneth Zarifes) :
  >
  > I almost forgot, the best way to do a warm reboot is to move the value 1234H
  > into the location 0040:0072 and THEN jump to F000:FFF0
  >
  > You'll find that this works on clones, AT's, PC's and about everything else.

  I believe that this machanism is used internally in DOS. Specifically,
  on the AT, there are DOS routines for manipulating extended memory.  These
  routines switch into protected mode to get to the memory they want.  However,
  the only way out of protected mode is a hardware reset.  In order to
  avoid the memory checks and delays on the reset, the magic number is
  stored at 0040:0072 to control the restart process.

  Joel M. Halpern -- Network Systems Corporation
  ihnp4!umn-cs!hyper!jmh

2}
  Date: Mon, 16 Feb 87 15:27:48 EST
  From: John.Brennen@VI.RI.CMU.EDU
  Subject: Reboot

  In order to reboot a PC, PC clone, PC compatible or whatever, you can
  use the following code (to make a .COM file, cut the text between the
  lines into a file, say "foo.bar", and on a PC, run "debug < foo.bar").
   ----------------------------------------
  a100
  xor ax,ax
  mov ds,ax
  mov [472],wo 1234
  jmp ffff:0

  nreboot.com
  rcx
  f
  w
  q
   ----------------------------------------

  The storage of 1234 in absolute memory location 00472 avoids the
  memory check.

  If you have an AT, AT clone, AT compatible or whatever, you can pulse
  the RESET line through software control:
   ----------------------------------------
  a100
  xor ax,ax
  mov ds,ax
  mov [472],wo 1234
  mov al,fe
  out 64,al
  jmp 10e

  nreboot.com
  rcx
  10
  w
  q
          John Brennen            CMU Visual Inspection Lab
          jfb@vi.ri.cmu.edu       Pittsburgh, PA

  ------------------------------

3}
  Date:    02/18/87 17:06:06 GMT+1
  From:    UF02%DDAGSI3.BITNET@wiscvm.wisc.edu
  Subject: REBOOT Program and 640K Limit

  Frank Schwab
  069/798-8238
  Institut fuer theoretische Physik
  Robert-Mayer-Str. 10
  D-6000 Frankfurt/M.
  This letter is to answer a question in Info-IBMPC V6  #9  and  to
  correct a common misunderstanding I want to make clear.

  First I want to answer the question of Scott Hutchinson:  "How do
  I reboot?".  This is not a complicated task.  You  just  have  to
  jump  to  where  the 80x86 jumps after a hardware reset.  This is
  location 'F000:FFF0'.  But if you just use  a  'JMP'  instruction
  you'll  have to go through all the memory testing.  Therefore the
  BIOS designers put a small trap door into the  BIOS.   Place  the
  value  '1234H'  into  the RESET_FLAG location at '40:72' and when
  the BIOS gets control and finds that value it  skips  the  memory
  tests.

  The  whole  program  can be debuged into the PC very easily.  Put
  the following debug commands which are  surrounded  by  the  'Cut
  here'  marks  into a file called 'reset.dbg' and then start DEBUG
  with 'debug < reset.dbg'.  (Please note that the blank line after
  'JMP   F000:FFF0'   is   mandatory!). This  will  create  a  file
  'reset.com' which does the  resetting.   (Check  this  by  typing
  'reset'  at  the  DOS  command  level but save your previous work
  before).

  Those of you which don't want to save the way  they  created  the
  program  can also type the commands directly after calling DEBUG.


  ---- Cut here ---- (begin)
  N RESET.COM
  A
  MOV AX,40
  MOV DS,AX
  MOV WORD PTR [72],1234
  JMP F000:FFF0

  R CX
  10
  W
  Q
  ---- Cut here ---- (end)

  If you want it a bit more complete you can also use the following
  assembly program and build it together with:

      MASM RESET;
      LINK RESET;
      EXE2BIN RESET RESET.COM

  The program is again surrounded by 'Cut here' marks:

  ---- Cut here ---- (begin)

PAGE    65,130
TITLE   RESET --- Requests a System Reset (Ctrl+Alt+Del)

;**********************************************************************
;*                         R E S E T   V3.01                          *
;**********************************************************************
;*                                                                    *
;* RESET jumpes to the 80x86-reset-location (F000:FFF0) to perform    *
;* a system reset. Before there is placed a special value into the    *
;* RESET_FLAG (40:72) to indicate that this is a software reset. This *
;* will cause a shorter reset sequence on all IBM-PCs and will also   *
;* reset all other 80x86-machines. The method of using INT 19H to     *
;* reboot has been discarded because it does not reset the interrupts *
;* which causes failure at restart because DOS-resident programs have *
;* been cleared but the corresponding vectors have not.               *
;*                                                                    *
;* ---- This program is hereby donated to the public domain. ----     *
;* ---- (I know that this is not too much of a donation.)    ----     *
;*                                                                    *
;**********************************************************************
;*                                                                    *
;*      Author            :   Frank Schwab                            *
;*      Start             :   16 May 1986                             *
;*      Last Modification :   11 Jun 1986                             *
;*                                                                    *
;*      Buildup           :  MASM RESET;                              *
;*                           LINK RESET;                              *
;*                           EXE2BIN RESET RESET.COM                  *
;*                                                                    *
;**********************************************************************
;*                                                                    *
;* Syntax:      RESET                                                 *
;*                                                                    *
;**********************************************************************
;*
 
 
BIOS_DATA_SEGMENT SEGMENT AT 0040H

        ORG     0072H
RESET_FLAG      EQU     THIS WORD

BIOS_DATA_SEGMENT ENDS


BIOS_CODE_SEGMENT SEGMENT AT 0F000H

        ORG     0FFF0H
RESET_ADDR      LABEL   FAR                     ;80x86-Reset addr.

BIOS_CODE_SEGMENT ENDS

CSEG    SEGMENT 'CODE'

        ASSUME CS:CSEG,DS:BIOS_DATA_SEGMENT,ES:NOTHING,SS:CSEG

        ORG 0100H

RESET:
        MOV     AX,SEG BIOS_DATA_SEGMENT        ;Signal that this is
        MOV     DS,AX                           ;a keyboard reset.
        MOV     RESET_FLAG,1234H

        JMP     BIOS_CODE_SEGMENT:RESET_ADDR    ;O.k., do it


WHO     DB      'RESET  V3.01  11 Jun 1986  Frank Schwab'

CSEG    ENDS

        END    RESET
---- Cut here ---- (end)