Interrupt 24h   Critical Error Handler                    

     When a critical  error  occurs within DOS, control is transferred
     to an error handler with an int 24h. This may be the standard DOS
     error handler (ABORT, RETRY, IGNORE) or a user-written routine.

     On entry to the error handler, AH will  have  its  bit  7=0 (high
     order bit)  if  the  error  was  a  disk error (probably the most
     common error), bit 7=1 if not.

     BP:SI contains the address of  a Device Header Control Block from
     which additional information can be retrieved (see below).

     The register is set up for a retry operation and an error code is
     in  the  lower  half of the  DI  register  with  the  upper  half
     undefined. See the seperate section for error codes

     The user stack is  in  effect and contains the following from top
     to bottom:

             IP      DOS registers from issuing int 24h
             CS      int 24h
             flags
             AX      user registers at time of signal
             BX      int 21h request
             CX   
             DX   
             SI   
             DI   
             BP   
             DS   
             ES   
             IP      from original int 21h
             CS   
             flags

     To reroute the  critical  error handler to a user-writen critical
     error handler, the following should be done:

     Before an INT 24h occurs:

     1)   The user application initialization code should save the int
          24h vector and replace the vector with one  pointing  to the
          user error routine.

     When the int 24h occurs:

     2)   When the  user error routine received control it should push
          the flag registers onto the stack and execute a far  call to
          the original int 24h vector saved in step 1.

     3)   DOS gives the  appropriate  prompt, and waits for user input
          (Abort, Retry, Ignore,  Fail).  After  the  user  input, DOS
          returns  control  to  the  user  error  routine  instruction
          following the far call.

     4)   The user error routine can now do any  tasks  nescessary. To
          return to the original  application  at  the point the error
          occurred,  the  error  routine  needs  to  execute  an  IRET
          instruction. Otherwise, the user error routine should remove
          the IP, CS, and flag registers from the  stack.  Control can
          then be passed to the desired point.

     INT  24h  provides  the following values in registers on entry to
     interrupt handler:

Input

DOS1 Y DOS2 Y

DOS3

Y DOS5 Y

Output

AX

Status Byte Drive Number   Operation AX

BX

        BX

CX

        CX

DI

 Error Code     DX

BP:SI

 Addr of a Device Header Ctrl Blck   CF

 

Status Byte
Bit Dec Hex  Description
0 1 01h  Operation:     0 = Read
                     1 = Write
1 2 02h  Area of Disk: 00 = DOS Area
                     01 = FAT
                     10 = Root Directory
                     11 = Data Area
2 4 04h
3 8 08h  FAIL allowed
4 16 10h  RETRY allowed
5 32 20h  IGNORE allowed
6 64 40h  Not Used
7 128 80h  Disk I/O Error if zero
Drive Number:   0=A:, 1=B:, etc.

Error Codes: (Note: high byte is undefined)

        Error Code    Description
           00h        Attempt to write on write-protected diskette
           01h        Unknown unit
           02h        Drive not ready
           03h        Unknown command
           04h        Data error (bad CRC)
           05h        Bad request structure length
           06h        Seek error
           07h        Unknown media type
           08h        Sector not found
           09h        Printer out of paper
           0Ah        Write fault
           0Bh        Read fault
           0Ch        General failure
           0Fh        Invalid disk change (DOS 3.x)

Returned Operation:

        00h  Ignore the error
        01h  Retry the operation
        02h  Terminate via int 22h
        03h  Fail the system call that is in progress (DOS 3.2+)

Notes:

     1)   Be careful when  choosing  to ignore a response because this
          causes  DOS  to  beleive  that  an  operation  has completed
          successfully when it may not have.

     2)   If the error was a character device, the contents of  AL are
          invalid.

Other Errors

     If AH bit 7=1, the error  occurred  on a character device, or was
     the  result  of  a bad memory image of the FAT. The device header
     passed in BP:SI can be examined to determine  which  case exists.
     If the attribute byte  high-order  bit  indicates a block device,
     then the error was a  bad  FAT.  Otherwise,  the  error  is  on a
     character device.

     If  a  character  device is involved,  the  contents  of  AL  are
     unpredictable, the error code is in DI as above.

Notes:

     1.   Before giving this  routine  control  for  disk  errors, DOS
          performs several  retries.  The  number  of  retries  varies
          according to the DOS version.

     2.   For  disk  errors,  this  exit  is  taken  only  for  errors
          occurring  during  an  int 21h function call. It is not used
          for errors during an int 25h or 26h.

     3.   This routine is entered in a disabled state.

     4.   All registers must be preserved.

     5.   This  interrupt  handler   should  refrain  from  using  DOS
          function calls. If  necessary,  it may use calls 01h through
          12h. Use of any other call destroys the DOS stack and leaves
          DOS in an unpredictable state.

     6.   The interrupt handler must  not  change  the contents of the
          device header.

     7.   If the interrupt handler handles errors  itself  rather than
          returning   to  DOS,  it  should  restore  the   application
          program's registers  from the stack, remove all but the last
          three  words on the stack, then issue  an  IRET.  This  will
          return to the program immediately  after  the  int  21h that
          experienced the error. Note that if this is done DOS will be
          in an unstable state until a function call  higher  than 12h
          is issued, therefore not recommended.

     8.   For DOS 3.x, IGNORE  requests  (AL=0)  are converted to FAIL
          for critical errors that occur on FAT or DIR sectors.

     9.   For DOS 3.10 up, IGNORE  requests  (AL=0)  are  converted to
          FAIL requests for network critical errors (50-79).

     The device header pointed to by BP:SI is as follows:

        DWORD Pointer to next device (0FFFFh if last device)

        WORD Attributes:
Attributes
Bit Dec Hex  Description
0 1 0001h  Standard Input  (Char only)
1 2 0002h  Standard Output (Char only)
2 4 0004h  NULL            (Char only)
3 8 0008h  Clock           (Char only)
4 16 0010h  Not Used
5 32 0020h
6 64 0040h
7 128 0080h
8 256 0100h
9 512 0200h
10 1024 0400h
11 2048 0800h
12 4096 1000h
13 8192 2000h
14 16384 4000h  IOCTL
15 32768 8000h  Character Device
        WORD pointer to device driver strategy entry point
        WORD pointer to device driver interrupt entry point

        8-BYTE  character device named field for block devices. The first
                byte is the  number  of  units.  To  tell  if  the  error
                occurred on a block or character device, look at  bit  15
                in the attribute field (WORD at BP:SI+4).  If the name of
                the character device is desired, look at the eight bytes
                starting at BP:SI+10.

Handling of Invalid Responses (DOS 3.x)

        A)     If IGNORE (AL=0)  is  specified  by  the  user and
               IGNORE is not allowed (bit 5=0), make the response
               FAIL (AL=3).
        B)     If RETRY (AL=1) is specified by the user and RETRY
               is not allowed (bit 4=0), make  the  response FAIL
               (AL=3).
        C)     If FAIL (AL=3)  is  specified by the user and FAIL
               is not allowed (bit 3=0), make the response ABORT.
               (AL=2)
 
See Also Func/59h


Copyright © 1985 to 2022 Beta Systems                            Last modified: Wednesday, January 05, 2022 .