Subversion Repositories SvarDOS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
967 mateusz.vi 1
;
2
; WORK IN PROGRESS TEMPLATE! NOT USED YET
3
;
4
; int 24h handler, part of SvarCOM. MIT license.
5
; Copyright (C) 2022 Mateusz Viste
6
;
7
; this is an executable image that can be set up as the critical error handler
8
; interrupt (int 24h). It displays the usual "Abort, retry, fail" prompt.
9
;
1836 mateusz.vi 10
; documentation:
11
; http://www.techhelpmanual.com/564-int_24h__critical_error_handler.html
12
;
967 mateusz.vi 13
 
14
org 0   ; this code does not have a PSP, it is loaded as-is into a memory
15
        ; segment
16
 
17
; === CRIT HANDLER DETAILS ====================================================
18
;
19
; *** ON ENTRY ***
20
;
21
; upon entry to the INT 24h handler, the registers are as follows:
22
;  BP:SI = addr of a "device header" that identifies the failing device
23
;     DI = error code in lower 8 bits (only for non-disk errors)
24
;     AL = drive number, but only if AH bit 7 is reset
25
;     AH = error flags
26
;        0x80 = reset if device is a disk, set otherwise
27
;           all the following are valid ONLY for disks (0x80 reset):
28
;        0x20 = set if "ignore" action allowed
29
;        0x10 = set if "retry" action allowed
30
;        0x08 = set if "fail" action allowed
31
;        0x06 = disk area, 0=sys files, 1=fat, 10=directory, 11=data
32
;        0x01 = set if failure is a write, reset if read
33
;
34
; within the int 24h handler, only these DOS functions are allowed:
35
;   01H-0CH (DOS character I/O)
36
;   33H (all subfns are OK, including 3306H get DOS version)
37
;   50H (set PSP address)
38
;   51H and 62H (query PSP address)
39
;   59H (get extended error information)
40
;
41
;
42
; *** ON EXIT ***
43
;
44
; After handling the error, AL should be set with an action code and get back
45
; to DOS. Available actions are defined in AH at entry (see above). Possible
46
; values on exit are:
47
;   AL=0  ignore error (pretend nothing happenned)
48
;   AL=1  retry operation
49
;   AL=2  abort (terminates the failed program via int 23h, like ctrl+break)
50
;   AL=3  return to application indicating a failure of the DOS function
51
;
52
; A very basic "always fail" handler would be as simple as this:
53
;   mov al, 3
54
;   iret
1836 mateusz.vi 55
;
56
;
57
; *** DOS CALLS ***
58
;
59
; Warning! Be careful about using DOS fns in your Critical Error handler.
60
;          With DOS 5.0+, ONLY the following fns can be called safely:
61
;
62
;          01H-0CH (DOS character I/O)
63
;          33H (all subfns are OK, including 3306H get DOS version)
64
;          50H (set PSP address)
65
;          51H and 62H (query PSP address)
66
;          59H (get extended error information)
967 mateusz.vi 67
; =============================================================================
68
 
69
 
70
; save registers so I can restore them later
71
push ah
72
push bx
73
push cx
74
push dx
75
pushf
76
 
77
; disk errors product this message:
78
; CRITICAL ERROR - DRIVE A: - READ|WRITE FAILURE
79
; (A)bort, (R)etry, (F)ail
80
;
81
; non-disk errors produce this:
82
; CRITICAL ERROR #errno
83
 
84
 
85
; restore registers and quit the handler
86
popf
87
pop dx
88
pop cx
89
pop bx
90
pop ah
91
 
92
iret
93
 
94
 
95
; write DX string to stderr
96
write_dx_str_to_stderr:
97
push ax
98
push bx
99
push cx
100
 
101
mov ah, 0x40       ; write to file -- am I sure I can use this function safely?
102
mov bx, 2          ; stderr
103
mov cx, 1          ; one byte
104
int 0x21
105
 
106
pop cx
107
pop bx
108
pop ax