Subversion Repositories SvarDOS

Rev

Rev 1853 | Rev 1864 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1853 Rev 1863
Line 96... Line 96...
96
; set up myself as break handler (int 0x23)
96
; set up myself as break handler (int 0x23)
97
mov ax, 0x2523  ; set int vector 23h
97
mov ax, 0x2523  ; set int vector 23h
98
mov dx, BREAK_HANDLER
98
mov dx, BREAK_HANDLER
99
int 0x21
99
int 0x21
100
 
100
 
-
 
101
; set up myself as criterr handler (int 0x24)
-
 
102
mov ax, 0x2524
-
 
103
mov dx, HANDLER_24H
-
 
104
int 0x21
-
 
105
 
101
; set up myself as int 0x2E handler ("pass command to shell")
106
; set up myself as int 0x2E handler ("pass command to shell")
102
mov ax, 0x252E
107
mov ax, 0x252E
103
mov dx, INT2E ; TODO do something meaningful instead of a no-op
108
mov dx, INT2E ; TODO do something meaningful instead of a no-op
104
int 0x21
109
int 0x21
105
 
110
 
Line 385... Line 390...
385
; close the original file handle, I no longer need it
390
; close the original file handle, I no longer need it
386
mov ah, 0x3e           ; close a file handle (handle in BX)
391
mov ah, 0x3e           ; close a file handle (handle in BX)
387
int 0x21
392
int 0x21
388
NO_STDIN_REDIR:
393
NO_STDIN_REDIR:
389
ret
394
ret
-
 
395
 
-
 
396
 
-
 
397
; ****************************************************************************
-
 
398
; *                                                                          *
390
; ----------------------------------------------------------------------------
399
; * INT 24H HANDLER                                                          *
-
 
400
; *                                                                          *
-
 
401
; ****************************************************************************
-
 
402
;
-
 
403
; this is an executable image that can be set up as the critical error handler
-
 
404
; interrupt (int 24h). It displays the usual "Abort, retry, fail" prompt.
-
 
405
;
-
 
406
; documentation:
-
 
407
; http://www.techhelpmanual.com/564-int_24h__critical_error_handler.html
-
 
408
;
-
 
409
; === CRIT HANDLER DETAILS ====================================================
-
 
410
;
-
 
411
; *** ON ENTRY ***
-
 
412
;
-
 
413
; upon entry to the INT 24h handler, the registers are as follows:
-
 
414
;  BP:SI = addr of a "device header" that identifies the failing device
-
 
415
;     DI = error code in lower 8 bits (only for non-disk errors)
-
 
416
;     AL = drive number, but only if AH bit 7 is reset
-
 
417
;     AH = error flags
-
 
418
;        0x80 = reset if device is a disk, set otherwise
-
 
419
;           all the following are valid ONLY for disks (0x80 reset):
-
 
420
;        0x20 = set if "ignore" action allowed
-
 
421
;        0x10 = set if "retry" action allowed
-
 
422
;        0x08 = set if "fail" action allowed
-
 
423
;        0x06 = disk area, 0=sys files, 1=fat, 10=directory, 11=data
-
 
424
;        0x01 = set if failure is a write, reset if read
-
 
425
;
-
 
426
; within the int 24h handler, only these DOS functions are allowed:
-
 
427
;   01H-0CH (DOS character I/O)
-
 
428
;   33H (all subfns are OK, including 3306H get DOS version)
-
 
429
;   50H (set PSP address)
-
 
430
;   51H and 62H (query PSP address)
-
 
431
;   59H (get extended error information)
-
 
432
;
-
 
433
; *** ON EXIT ***
-
 
434
;
-
 
435
; After handling the error, AL should be set with an action code and get back
-
 
436
; to DOS. Available actions are defined in AH at entry (see above). Possible
-
 
437
; values on exit are:
-
 
438
;   AL=0  ignore error (pretend nothing happened)
-
 
439
;   AL=1  retry operation
-
 
440
;   AL=2  abort (terminates the failed program via int 23h, like ctrl+break)
-
 
441
;   AL=3  return to application indicating a failure of the DOS function
-
 
442
;
-
 
443
; A very basic "always fail" handler would be as simple as this:
-
 
444
;   mov al, 3
-
 
445
;   iret
-
 
446
;
-
 
447
; *** DOS CALLS ***
-
 
448
;
-
 
449
; Warning! Be careful about using DOS fns in your Critical Error handler.
-
 
450
;          With DOS 5.0+, ONLY the following fns can be called safely:
-
 
451
;
-
 
452
;          01H-0CH (DOS character I/O)
-
 
453
;          33H (all subfns are OK, including 3306H get DOS version)
-
 
454
;          50H (set PSP address)
-
 
455
;          51H and 62H (query PSP address)
-
 
456
;          59H (get extended error information)
-
 
457
;
-
 
458
; =============================================================================
-
 
459
HANDLER_24H:    ; +46Ch
-
 
460
 
-
 
461
; save registers so I can restore them later
-
 
462
push ax
-
 
463
push bx
-
 
464
push cx
-
 
465
push dx
-
 
466
push ds
-
 
467
pushf
-
 
468
 
-
 
469
; set DS to myself
-
 
470
push cs
-
 
471
pop ds
-
 
472
 
-
 
473
; is this a DISK error?
-
 
474
;test ah, 0x80
-
 
475
;jz DISKERROR
-
 
476
; non-disk error: output "CRITICAL ERROR #XXX SYSTEM HALTED" and freeze
-
 
477
; update the crit string so it contains the proper error code
-
 
478
mov bx, CRITERR
-
 
479
mov ax, di
-
 
480
xor ah, ah
-
 
481
mov cl, 100
-
 
482
div cl ; AL = AX / cl     AH = remainder
-
 
483
add al, '0'
-
 
484
mov [bx+16], al
-
 
485
 
-
 
486
mov al, ah
-
 
487
xor ah, ah
-
 
488
mov cl, 10
-
 
489
div cl
-
 
490
add al, '0'
-
 
491
add ah, '0'
-
 
492
mov [bx+17], al
-
 
493
mov [bx+18], ah
-
 
494
 
-
 
495
; display the string
-
 
496
mov ah, 0x09
-
 
497
mov dx, CRITERR
-
 
498
int 0x21
-
 
499
; freeze the system
-
 
500
HALT:
-
 
501
sti
-
 
502
hlt;
-
 
503
jmp HALT
-
 
504
 
-
 
505
DISKERROR:
-
 
506
; disk errors product this message:
-
 
507
; CRITICAL ERROR - DRIVE A: - READ|WRITE FAILURE
-
 
508
; (A)bort, (R)etry, (F)ail
-
 
509
;
-
 
510
; non-disk errors produce this:
-
 
511
; CRITICAL ERROR #errno
-
 
512
 
-
 
513
 
-
 
514
; restore registers and quit the handler
-
 
515
popf
-
 
516
pop ds
-
 
517
pop dx
-
 
518
pop cx
-
 
519
pop bx
-
 
520
pop ax
-
 
521
 
-
 
522
iret
-
 
523
 
-
 
524
CRITERR db "CRITICAL ERROR #XXX SYSTEM HALTED$"