]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MEMM/MEMM/ERRHNDLR.ASM
4 ;******************************************************************************
5 TITLE ErrHndlr
- Error Handler
6 ;******************************************************************************
7 ; (C) Copyright MICROSOFT Corp. 1986
9 ; Title: MEMM.EXE - MICROSOFT Expanded Memory Manager 386 Driver
11 ; Module: ErrHndlr - Recover from exception and priveledged operation errors
19 ;******************************************************************************
23 ; DATE REVISION DESCRIPTION
24 ; -------- -------- ------------------------------------------------------
26 ; 06/28/86 0.02 Name changed from MEMM386 to MEMM
27 ; 06/28/86 0.02 Removed STI at end of ErrHndlr
28 ; 06/28/86 0.02 Changed error # display to leading zeroes
29 ; 07/06/86 0.04 Changed assume to DGROUP
31 ;******************************************************************************
33 ;******************************************************************************
35 ; Functional description:
37 ; This module contains the code that displays an error message and
38 ; asks the user to continue or reboot.
40 ;******************************************************************************
48 ;******************************************************************************
50 ;******************************************************************************
52 public ErrHndlr
; Display message and continue or reboot
54 ;******************************************************************************
56 ;******************************************************************************
58 extrn RetReal
:near ; return to real mode
59 extrn egetc
:near ; get keyboard character
60 extrn WaitKBD
:near ; wait for keyboard ready
64 extrn powr10
:word ; power of 10's table
65 extrn POE_Mess
:byte ; privileged operation error
66 extrn POE_Num
:byte ; where to put error code
67 extrn POE_Len
:abs
; length of message
68 extrn EXCPE_Mess
:byte ; exception error message
69 extrn EXCPE_Num
:byte ; where to put error code
70 extrn EXCPE_CS
:byte ; where to put CS
71 extrn EXCPE_EIP
:byte ; where to put EIP
72 extrn EXCPE_ERR
:byte ; where to put ERR
73 extrn EXCPE_Len
:abs
; length of message
76 romdata
segment use16 at 40h
82 ;******************************************************************************
84 ;******************************************************************************
86 MASTER
= 0A1H ; Master interrupt i/o port
87 SLAVE
= 021H ; Slave interrupt i/o port
88 NMI
= 070H ; Non-Maskable interrupt i/o port
89 DIS_MSTSLV
= 00H ; Value to write to disable master/slave
90 DIS_NMI
= 080H ; Value to write to disable NMI
91 ENA_NMI
= 008H ; Value to write to enable NMI
92 B
= 48 ; make code for B
93 C
= 46 ; make code for C
94 ENTER = 28 ; make code for enter key
95 ATTR
= 07 ; attribute for write string
96 WRSTR
= 1301h
; write string function code (format 1)
97 CPOSN
= 5*256+0 ; cursor position to write
100 ;******************************************************************************
102 ;******************************************************************************
104 Error_Flag dw 0 ; flags for Instruction Prefixes
105 masterp db 0 ; save master port value
106 slavep db 0 ; save slave port value
107 mode db 0 ; save mode
108 boot db 0 ; value to reboot
109 continue db 0 ; value to continue
111 GPsavERR dw 0 ; GP fault Error Code save
112 GPsavEIP dd 0 ; GP fault EIP save
113 GPsavCS dw 0 ; GP fault CS save
117 ;******************************************************************************
119 ; ErrHndlr - displays the appropriate error message and prompts the
120 ; user for a character to continue or reboot. The screen
121 ; is cleared by this routine. If the user chooses to
122 ; continue, the system is in real mode.
124 ; entry: ax = 0 => Privileged operation error
125 ; ax = 1 => Exception error
126 ; bx = error number to display
128 ; exit: either reboot, or exit in "real" mode with CLI
134 ;******************************************************************************
136 ASSUME
CS:_TEXT
, DS:DGROUP
, ES:DGROUP
145 mov eax, dword ptr [bp.VTFO
] ; error code
147 mov eax, dword ptr [bp.VTFOE
+VMTF_EIP
] ; EIP
149 mov ax, word ptr [bp.VTFOE
+VMTF_CS
] ; CS
154 call RetReal
; return to real mode
163 push ax ; save input to this routine
164 in al,MASTER
; get value of master interrupt port
165 mov [masterp
],al ; save it
166 in al,SLAVE
; get value of slave interrupt port
167 mov [slavep
],al ; save it
168 mov al,DIS_MSTSLV
; value to disable master/slave int
169 out MASTER
,al ; disable master
170 out SLAVE
,al ; disable slave
171 mov al,DIS_NMI
; value to disable NMI
174 call egetc
; q: is there stuff in keyboard buffer?
175 jnz kbdbusy
; y: get it and pitch it
177 pop ax ; get entry condition
178 or ax,ax ; q: privileged error?
179 jnz excep
; n: exception error
180 mov bp,offset DGROUP
:POE_Mess
; y: privileged error
182 mov di,offset DGROUP
:POE_Num
; error number location
183 mov ax,bx ; error number in ax
184 call b2asc10
; convert to ascii
185 mov [boot
],B
; key to boot
186 mov [continue
],C
; key to continue
187 jmp skip_exc
; skip exception stuff
189 mov bp,offset DGROUP
:EXCPE_Mess
; n: load up exception error
190 mov cx,EXCPE_Len
; length of msg
191 mov di,offset DGROUP
:EXCPE_Num
; error number location
192 mov ax,bx ; error number in ax
193 call b2asc10
; convert to ascii
194 mov di,offset DGROUP
:EXCPE_CS
197 mov di,offset DGROUP
:EXCPE_EIP
203 mov di,offset DGROUP
:EXCPE_ERR
206 mov [boot
],ENTER ; key to reboot
207 mov [continue
],0ffh ; can't continue
209 mov ah,0fh ; read video state
211 mov [mode
],al ; save mode
212 ; mov ax,3 ; set to mode 3
213 ; int 10h ; standard 80 x 25 color
214 mov dx,CPOSN
; cursor position
215 mov bl,ATTR
; attribute
216 mov ax,WRSTR
; write string function code
218 cli ; make sure int 10 didn't enable
220 call egetc
; get a character
221 jz key_loop
; nothing there yet
222 cmp al,[continue
] ; q: continue?
224 cmp al,[boot
] ; q: boot?
225 jne key_loop
; n: try again
226 ;******************************************************************************
230 ;******************************************************************************
233 mov ds,ax ; ds = romdata segment
234 mov [freset
],0 ; cold restart
235 mov al,0fh or 80h
; shutdown byte address/disable NMI
236 out 70h
,al ; write CMOS address
237 jmp short $+2 ; delay
238 mov al,0h
; shutdown code 0 = processor reset
239 out 71h
,al ; write shutdown code to shutdown byte
240 call WaitKBD
; wait for 8042 to accept command
241 mov al,0feh ; feh = pulse output bit 0 (reset)
242 out KbStatus
,al ; reset processor
247 xor ah,ah ; ah = 0 to set video mode
248 mov al,[mode
] ; restore their mode
250 cli ; turn them off...
252 ; restore master, slave, and NMI
254 mov al,[masterp
] ; get value of master interrupt port
255 out MASTER
,al ; restore it
256 mov al,[slavep
] ; get value of slave interrupt port
257 out SLAVE
,al ; restore it
258 mov al,ENA_NMI
; value to enable NMI
271 ;******************************************************************************
273 ; b2asc10 - converts binary to ascii decimal and store at _TEXT:DI
274 ; stores 2 ascii chars (decimal # is right justified and
275 ; filled on left with 0s)
277 ; entry: ax = binary number
279 ; ds:di = place to store ascii chars.
281 ; exit: ASCII decimal representation of number stored at _TEXT:DI
287 ;******************************************************************************
298 mov si,2 ; pointer to base 10 table
299 mov bl,1 ; leading zeroes on
301 ; convert binary number to decimal ascii
304 xor dx,dx ; clear word extension
306 div cx ; divide by power of 10
310 or ax,ax ; q: zero result?
311 jnz b2_ascii
; n: go convert to ascii
313 mov al,' ' ; y: go blank fill
317 add al,'0' ; put into ascii format
318 mov bl,1 ; leading zeroes on
321 mov ds:[di],al ; put ascii number into string
323 inc di ; increment buffer string pointer
324 dec si ; decrement power of 10 pointer
326 jge b2_loop
; Q: Last digit? N: Jump if not
338 ;******************************************************************************
340 ; b2asc16 - converts binary to hexidecimal and store at _TEXT:DI
341 ; stores 4 ascii chars (# is right justified and
342 ; filled on left with 0s)
344 ; entry: ax = binary number
346 ; ds:di = place to store ascii chars.
348 ; exit: ASCII hexidecimal representation of number stored at _TEXT:DI
354 ;******************************************************************************