Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
BusErrTestInit.a
*********************************************************************** |
*** |
*** BusErrTest |
*** |
*** Build commands: |
*** |
*** asm BusErrTest.a |
*** link BusErrTest.a.o -o BusErrTest |
*** |
*********************************************************************** |
STRING ASIS |
PRINT OFF |
INCLUDE 'Traps.a' |
INCLUDE 'QuickEqu.a' |
INCLUDE 'SysEqu.a' |
PRINT ON |
machine mc68030 |
*********************************************************************** |
UnImpTrap EQU $A89F |
HWPriv EQU $A198 |
*********************************************************************** |
InitEntry PROC;MAIN |
IMPORT OldGuy |
IMPORT BusErrProc |
IMPORT theEnd |
IMPORT InstallVector |
IMPORT ReplaceVector |
lea theEnd,a0 |
lea BusErrProc,a1 |
suba.l a1,a0 |
move.l a0,d0 |
move.l d0,d2 |
_NewPtr ,SYS,CLEAR |
move.l a0,d1 |
beq.s abort |
lea BusErrProc,a0 |
move.l d1,a1 |
move.l d2,d0 |
_blockMove |
bsr InstallVector |
abort rts |
ENDP |
*********************************************************************** |
InstallVector PROC EXPORT |
IMPORT OldGuy |
IMPORT BusErrProc |
move.l d1,a0 ;OldGuy is a place to keep the original bus error vector |
move.l 8,OldGuy-BusErrProc(a0) ;so fill it up with the vector, victor |
move.l a0,8 ;and install it |
outtahere |
rts |
ENDP |
*********************************************************************** |
CauseBusErr PROC EXPORT |
movem.l a0/d0,-(sp) ;preserve the register we use |
move.l #$FFFFFFFF,a0 ;this address looks pretty dangerous... |
move.b (a0),d0 |
movem.l (sp)+,a0/d0 ;restore the registers we use |
rts ;it's Miller time |
ENDP |
*********************************************************************** |
ReplaceVector PROC EXPORT |
IMPORT OldGuy |
IMPORT BusErrProc |
movem.l a0-a1,-(sp) ;preserve reg |
lea 8,a0 ;point to the 680x0 bus error vector |
move.l 8,a1 |
move.l OldGuy-BusErrProc(a1),(a0) ;and fill it full of the original |
move.l a1,a0 |
_disposPtr |
movem.l (sp)+,a0-a1 ;restore reg |
rts ;system handler vector |
ENDP |
*********************************************************************** |
BusErrProc PROC EXPORT ;THIS CODE ASSUMES THE BUS ERROR |
;EXCEPTION STACK FRAME FOR THE |
;68030!!! (REF MOTOROLA 68030 USER'S |
;MANUAL PAGE 8-25) |
IMPORT OldGuy |
RegOffset EQU 4*2 |
movem.l a1/d0,-(sp) ;take only pictures, leave only footprints |
move.b 6+RegOffset(sp),d0 ;get the id nibble for the stack frame |
andi.b #$F0,d0 ;don't care 'bout the lower nibble... |
cmpi.b #$B0,d0 ;make sure it's the one we like |
bne.s NotOurs ;if not, pass it on to system handler |
bclr.b #0,$A+RegOffset(sp) ;clear DF bit of Special Status Reg |
;so that the instruction will not be re-tried |
move.l scrnbase,a1 ;let the user know we arrived by inverting |
move.w #$2ff,d0 ;a hunk o' screen |
Loop |
eori.l #$ffffffff,(a1)+ ;we do a long word at a time |
dbra d0,Loop ;till d0 goes negative |
movem.l (sp)+,a1/d0 ;clean up after ourselves |
ret rte ;and return from the exception |
NotOurs |
movem.l (sp)+,a1/d0 ;restore battered registers |
move.l OldGuy,-(sp) ;and pass control onto the system |
rts ;bus error handler |
ENDP |
*********************************************************************** |
OldGuy PROC EXPORT |
DC.L 0 ;a long word for storage |
ENDP |
theEnd PROC EXPORT |
ENDP |
END |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14