Re: A92: Crash Errors
[Prev][Next][Index][Thread]
Re: A92: Crash Errors
>
> Hello !
> I want to suggested something for the Fargo Kernel. I don't know if It might
work or not, but here it is :
>
> Could the Fargo exec function take the error interrupts (address error,
illegal instruction...) and exit the program, delete the screen buffer &
restore the old stack when such an error is made ?
> So we would just have to modify the vector table, and to skip the old
routine.
>
> What do you think about ?
>
And thank you for the introduction! Version 0.5 of System Stabilizer is now
available! (See attached files)
Simply run the installation program, then delete it. Any errors encountered
during execution cause the program to exit back to the Fargo shell! This is
still alpha, so let me know who's system it doesn't stabilize...
--Bryan
bcturner@eos.ncsu.edu
binary file
;
; System Stabilizer for Fargo II v0.5
;
; By Bryan Turner
;
;
; Fargo II calls ER_catch and saves the state of the machine before calling a program
; this is very usefull since at any time we can exit from the program by calling ER_throw
; all we have to do is execute one simple instruction: $A001
;
; There are some situations where exiting from the programs could be bad, but we'll ignore
; those for this version.
;
; Does not: Turn off grayscale - Corrected v0.5
; Re-adjust the LCD base addr - Corrected v0.5
; Turn off Hardware Grayscale - Corrected v0.5
; Unload used memory
; Adjust interrupts back to normal
; Set memory protection - Corrected v0.5
;
include "flib.h"
include "tios.h"
xdef _main
xdef _comment
NUMTRAPS equ 17
_comment:
dc.b "System Stabilizer Installer",0
ds.w 0
_main:
jsr flib::clr_scr
move.w #1,-(a7)
jsr tios::FontSetSys ; 8pt font
addq #2,a7
move.w #$700,d0 ; disable interrupts, and put
trap #1 ; the old int mask in D0
move.w d0,d7 ; save old mask
move.w ($8),d0 ; Check that Raven or another debugger is not installed..
cmp.w #$0040,d0
bne debug_there ; Something's already there!
bclr.b #2,($600001) ; Memory protect OFF
lea (auto_one+2)(pc),a0
move.l ($64),(a0) ; Store original auto int 1 proc (for use in exception handler)
lea (LCD_addr+2)(pc),a0
move.l #tios::main_lcd,d0 ; Load basic LCD address for this calc
lsr.l #3,d0
move.w d0,(a0)
move.l ($5d36),a1
move.l #the_end-except,d0 ; Load size of program
sub.l d0,a1 ; Subtract size
move.l a1,($5d36) ; Store new top of heap --- NOT ROM 2.1 Compatable
move.l a1,d1 ; Keep a copy in D1
lea except(pc),a0 ; Load address to start of handler
lsr.l #2,d0 ; Divide size by 4 (number of longwords)
subq #1,d0 ; Adjust to 0..numlongs-1
copy_loop:
move.l (a0)+,(a1)+ ; Copy exception processor to high memory
dbra d0,copy_loop ; *** May not copy last 2 bytes!!
;
; Install exception proc to catch lots of errors
;
lea TRAPNUMS(pc),a0 ; Load trap numbers to catch
moveq #NUMTRAPS-1,d2 ; Load number of traps to edit
clr.l d0
;
; First two exceptions are special, they have a different address...
;
move.b (a0)+,d0 ; Get a trap number
move.l d0,a1 ; Make it an address
move.l d1,(a1) ; Install our exception routine
move.b (a0)+,d0 ; Get a trap number
move.l d0,a1 ; Make it an address
move.l d1,(a1) ; Install our exception routine
subq #2,d2
addq #2,d1 ; Only the first two exceptions have the special
; Stack frame (Address error and Bus error)
inlup:
move.b (a0)+,d0 ; Get a trap number
move.l d0,a1 ; Make it an address
move.l d1,(a1) ; Install our exception routine
dbra d2,inlup ; Loop back..
bset.b #2,($600001) ; Memory protect ON
done:
move.w d7,d0
trap #1 ; Re-enable interrupts
move.w #4,-(a7)
pea good_str(pc) ; Draw good_str
move.l #$00100010,-(a7)
jsr tios::DrawStrXY
lea 10(a7),a7
move.w #4,-(a7)
pea good_str2(pc) ; Draw good_str2
move.l #$0010001A,-(a7)
jsr tios::DrawStrXY
lea 10(a7),a7
; --- Delete the program! It is no longer needed, and only taking up space!
bra pause
debug_there:
move.w #4,-(a7)
pea debugger(pc) ; Draw Debuuger str
clr.l -(a7)
jsr tios::DrawStrXY
lea 10(a7),a7
bra bad_install
bad_install:
move.w d7,d0
trap #1 ; Re-enable interrupts
move.w #4,-(a7)
pea bad_str(pc)
move.w #10,-(a7)
clr.w -(a7)
jsr tios::DrawStrXY ; Draw bad_str
lea 10(a7),a7
pause:
jsr flib::idle_loop ; Wait for a keypress
rts
;
; The trap numbers we replace
;
TRAPNUMS:
dc.b $08,$0c,$10,$14,$18,$1c,$20,$24,$2c,$3c
dc.b $60,$6c,$7c,$ac,$b0,$b4,$b8,0
debugger:
dc.b "Debugger already present.",0
ds.w 0
bad_str:
dc.b "Not Installed!",0
ds.w 0
good_str:
dc.b "Instalation Complete, you may",0
ds.w 0
good_str2:
dc.b "now delete this program!",0,0
ds.w 0
;
; This is the exception processor, simply stabilize the system, and call ER_Throw
;
except:
addq #8,a7 ; Pop junk off Address & Bus Error frames
move.w #$2700,sr ; Disable interrupts
bclr.b #2,($600001) ; Memory protect OFF
auto_one:
move.l #$10000001,($64) ; Restore correct autoint 1 (Turns off GRAY screens)
LCD_addr:
move.w #$1001,($600010) ; Switch to basic LCD buffer
move.b #$31,($600012) ; Restore LCD bytes/line and turn off HW grayscale
move.b #$DE,($600003) ; Turn off HW Grayscale settings
bset.b #2,($600001) ; Memory protect ON
lea throw(pc),a0
move.l a0,2(a7) ; When we return from the exception, go to 'throw'
rte
throw:
tios::ER_throw 1 ; Error #1
padding:
dc.w 0
the_end:
dc.w 0
end
References: