supermario/base/SuperMarioProj.1994-02-09/OS/SCSIMgr4pt3/XPTSCSIXlate.a
2019-06-29 23:17:50 +08:00

537 lines
14 KiB
Plaintext

;——————————————————————————————————————————————————————————————————————————
;
; File: XPTSCSIXlate.a
;
; Function: Intercepts old SCSI Manager calls and sends them to the XPT.
;
; Written by: Paul Wolf
;
; Copyright: © 1992-1993 by Apple Computer, Inc., All rights reserved.
;
; This file is used in these builds:
;
; Change History (most recent first):
;
; <SM12> 10/29/93 DCB Getting rid of warnings.
; <SM11> 10/14/93 pdw <MC2>
; <MC2> 10/12/93 pdw Added support for Synchronous data transfers, rewrote State
; Machine, message handling etc.
; <SM10> 9/9/93 pdw Lots of little changes. Name changes, temporary cache_bug
; stuff.
; <SM9> 7/8/93 pdw Added call to RecordError if error is being returned.
; <SM8> 6/29/93 pdw Massive checkins: Change asynchronicity mechanism to CallMachine
; stack switching mechanism. Adding support for Cold Fusion.
; Rearranging HW/SW Init code. Some code optimizations.
; <SM7> 5/29/93 PW Resolving with my Ludwig sources.
; <SM6> 5/25/93 DCB Changing DebugStr to IFDebugStr/SysErr
; <SM5> 5/5/93 PW Converted names to meanies-friendly names. Updated with latest
; from Ludwig stuff.
; <LW7> 5/1/93 PW Got rid of RECORD_ON and RECORD_rCMD definitions (should only be
; in Debug.a now.
; <LW6> 4/30/93 DCB Changing default RECORD_ON to 0 for final Candidate
; <LW4> 2/9/93 PW Removed some Terror comment tags.
; <SM4> 1/31/93 PW Update from the latest of Ludwig. Also some changes required
; for PDM (will update Ludwig with these changes myself).
; <LW3> 1/13/93 PW Fixed everyone's RECORD_ON build problem.
; <LW2> 1/12/93 DCB Changed CALL_RECORD_ON use to pay attention to -d defines in asm
; command line.
; <SM3> 11/20/92 DCB Support for SCSI Msg In/Out
; <SM2> 10/30/92 DCB New name for SCSI.a
;
;==========================================================================
BLANKS ON ; assembler accepts spaces & tabs in operand field
PRINT OFF ; do not send subsequent lines to the listing file
; don't print includes
CASE OBJECT ; preserve case in object file
LOAD 'StandardEqu.d' ; from StandardEqu.a and for building ROMs
INCLUDE 'Debug.a'
INCLUDE 'SCSI.a' ; <SM2>
INCLUDE 'ACAM.a'
INCLUDE 'XPTEqu.a'
INCLUDE 'HALc96equ.a'
PRINT ON ; do send subsequent lines to the listing files
SCSIXLATE PROC EXPORT
EXPORT Init_SCSIXlate
IMPORT OldSCSICall
IMPORT RecordEvent, RecordError
;--------------------------------------------------------------------------
; EXIT POINT
StdExit2 ; Bad Select and SCSIComplete exit point
StdExit
movem.l (sp)+, a2-a5/d2-d7 ; restore these guys
unlk a6
move.l (sp)+, a0 ; get return address
add.w d0, sp ; fixup the stack
IF RECORD_ON THEN
tst.w (sp)
beq.s @1
bsr RecordError ; use value at (sp)
@1
ENDIF
jmp (a0)
RTSNAME 'StdExit'
;--------------------------------------------------------------------------
;
; FUNCTION SCSIReset: INTEGER;
; (8)
;
; Uses: a0, a3, d0, d2, d3
;
; Return Codes:
; noErr
CI_SCSIReset
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'Rst-'
clr.l -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
clr.l -(sp) ; missing parm 3 padding
clr.l -(sp) ; missing parm 2 padding
clr.l -(sp) ; missing parm 1 padding
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
IF CALL_RECORD_ON and RECORD_ON THEN
pea '-Rst'
move.l D0, -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
move.w d0, 8+0(a6) ; return code
bra.s NoByteExit
RTSNAME 'CI_SCSIReset'
;--------------------------------------------------------------------------
;
; FUNCTION SCSIGet: INTEGER;
; (8)
;
; Uses: d0, d1, d2, d3
;
; Return Codes:
; noErr
CI_SCSIGet
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'Get-'
clr.l -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
clr.l -(sp) ; missing parm 3 padding
clr.l -(sp) ; missing parm 2 padding
clr.l -(sp) ; missing parm 1 padding
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
IF CALL_RECORD_ON and RECORD_ON THEN
pea '-Get' ; EVENT =
move.l D0, -(sp) ; result
bsr RecordEvent
addq.l #8, sp
ENDIF
move.w d0, 8+0(a6) ; return code
NoByteExit
moveq.l #0, d0 ; no arguments to clean up
bra.w StdExit
RTSNAME 'CI_SCSIGet'
;--------------------------------------------------------------------------
;
; FUNCTION SCSISelect(TargID:INTEGER): INTEGER;
; FUNCTION SCSISelAtn(TargID:INTEGER): INTEGER;
; (8) (10)
;
CI_SCSISelect
CI_SCSISelAtn
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'Sel-' ; EVENT =
move.w 8(a6), -(sp) ; get the target's ID - parm 1
clr.w -(sp) ; ID padding
bsr RecordEvent
addq.l #8, sp
ENDIF
clr.l -(sp) ; missing parm 3 padding
clr.l -(sp) ; missing parm 2 padding
move.w 8(a6), -(sp) ; get the target's ID - parm 1
clr.w -(sp) ; ID padding
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
IF CALL_RECORD_ON and RECORD_ON THEN
pea '-Sel' ; EVENT =
move.l D0, -(sp) ; result
bsr RecordEvent
addq.l #8, sp
ENDIF
move.w d0, 8+2(a6) ; return the result
moveq.l #2, d0 ; stack cleanup
bra.w StdExit ;
RTSNAME 'CI_SCSISelect_Atn'
;--------------------------------------------------------------------------
;
; FUNCTION SCSICmd(Buffer:Ptr, Count:INTEGER): INTEGER;
; (10) (8) (14)
;
; Send the target the given command.
;
; Return Codes:
; noErr, scPhaseErr, scCommErr
CI_SCSICmd
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'Cmd-' ; EVENT =
move.w ([10,a6]),-(sp) ; 1st 2 CDB bytes
move.w 8(a6), -(sp) ; get the length - parm 2
bsr RecordEvent
addq.l #8, sp
move.l ([10,a6],2),-(sp) ; CDB bytes 2-5
move.l ([10,a6],6),-(sp) ; CDB bytes 6-9
bsr RecordEvent
addq.l #8, sp
ENDIF
clr.l -(sp) ; missing parm 3 padding
move.w 8(a6), -(sp) ; get the length - parm 2
clr.w -(sp) ; length padding
move.l 10(a6), -(sp) ; get command buffer address - parm 1
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
IF CALL_RECORD_ON and RECORD_ON THEN
pea '-Cmd' ; EVENT =
move.l D0, -(sp) ; result
bsr RecordEvent
addq.l #8, sp
ENDIF
move.w d0, 8+6(a6) ; return the result
moveq.l #6, d0 ; cleanup stack value
bra.w StdExit
RTSNAME 'CI_SCSICmd'
;--------------------------------------------------------------------------
;
; FUNCTION SCSIMsgIn( char * msgPtr): INTEGER;
; (8) (12)
; <SM3>
CI_SCSIMsgIn
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'MgI-' ; EVENT =
move.l 8(a6), -(sp) ; get the msg ptr - parm 1
bsr RecordEvent
addq.l #8, sp
ENDIF
clr.l -(sp) ; missing parm 3 padding
clr.l -(sp) ; missing parm 2 padding
move.l 8(a6), -(sp) ; get the target's ID - parm 1
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
IF CALL_RECORD_ON and RECORD_ON THEN
pea '-MgI' ; EVENT =
move.l D0, -(sp) ; result
bsr RecordEvent
addq.l #8, sp
ENDIF
move.w d0, 8+4(a6) ; return the result
moveq.l #4, d0 ; stack cleanup
bra.w StdExit ;
RTSNAME 'CI_SCSIMsgIn'
;--------------------------------------------------------------------------
;
; FUNCTION SCSIMsgOut( msg): INTEGER;
; (8) (10)
; <SM3>
CI_SCSIMsgOut
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'MgO-' ; EVENT =
move.w 8(a6), -(sp) ; get the msg - parm 1
clr.w -(sp) ; ID padding
bsr RecordEvent
addq.l #8, sp
ENDIF
clr.l -(sp) ; missing parm 3 padding
clr.l -(sp) ; missing parm 2 padding
move.w 8(a6), -(sp) ; get the msg - parm 1
clr.w -(sp) ; ID padding
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
IF CALL_RECORD_ON and RECORD_ON THEN
pea '-MgO' ; EVENT =
move.l D0, -(sp) ; result
bsr RecordEvent
addq.l #8, sp
ENDIF
move.w d0, 8+2(a6) ; return the result
moveq.l #2, d0 ; stack cleanup
bra.w StdExit ;
RTSNAME 'CI_SCSIMsgOut'
;--------------------------------------------------------------------------
;
; SCSIRead, SCSIRBlind, SCSIWrite, SCSIWBlind
;
; FUNCTION SCSI_R/W(TIB:TIBPtr): INTEGER;
; (8) (12)
;
; Called by: Toolbox Trap Dispatcher
;
; Calls: Transfer, primitive data transfer routines
;
; On entry: a3 - SCSI read base address
; a4 - pointer to SCSI Manager globals
;
; Internal: a1 - TIB scan pointer
;
; Function: Performs TIB interpretation, and data transfers.
CI_SCSIWBlind
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'WBL-' ; EVENT =
move.l 8(a6), -(sp) ; get the TIB pointer - parm 1
bsr RecordEvent
addq.l #8, sp
bra.s CI_data
ENDIF
CI_SCSIWrite
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'Wrt-' ; EVENT =
move.l 8(a6), -(sp) ; get the TIB pointer - parm 1
bsr RecordEvent
addq.l #8, sp
bra.s CI_data
ENDIF
CI_SCSIRBlind
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'RBL-' ; EVENT =
move.l 8(a6), -(sp) ; get the TIB pointer - parm 1
bsr RecordEvent
addq.l #8, sp
bra.s CI_data
ENDIF
CI_SCSIRead
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'Rd- ' ; EVENT =
move.l 8(a6), -(sp) ; get the TIB pointer - parm 1
bsr RecordEvent
addq.l #8, sp
ENDIF
CI_data
clr.l -(sp) ; missing parm 3 padding
clr.l -(sp) ; missing parm 2 padding
move.l 8(a6), -(sp) ; get the TIB pointer - parm 1
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
IF CALL_RECORD_ON and RECORD_ON THEN
pea '-Dat' ; EVENT =
move.l D0, -(sp) ; result
bsr RecordEvent
addq.l #8, sp
ENDIF
move.w d0, 8+4(a6) ; return the result
moveq.l #4, d0 ; stack cleanup
bra.w StdExit
RTSNAME 'CI_SCSI_data'
;--------------------------------------------------------------------------
;
; FUNCTION SCSIComplete(VAR Stat, Message: INTEGER; wait:LongInt): INTEGER;
; (16) (12) (8) (20)
;
;
; Return Codes:
; noErr, scCommErr, scPhaseErr, scComplPhaseErr
CI_SCSIComplete
IF CALL_RECORD_ON and RECORD_ON THEN
pea 'Cpt-' ; EVENT =
move.l 16(a6), -(sp) ; get the client's status ptr - parm 1
bsr RecordEvent
addq.l #8, sp
ENDIF
move.l 8(a6), -(sp) ; get tick count timeout - parm 3
move.l 12(a6), -(sp) ; get the client's msg ptr - parm 2
move.l 16(a6), -(sp) ; get the client's status ptr - parm 1
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
IF CALL_RECORD_ON and RECORD_ON THEN
pea '-Cpt' ; EVENT =
move.l D0, -(sp) ; result
bsr RecordEvent
addq.l #8, sp
ENDIF
move.w D0, 8+12(a6) ; return error
moveq.l #12, d0 ; stack cleanup
bra.w StdExit2 ;
RTSNAME 'CI_SCSIComplete'
;--------------------------------------------------------------------------
;
; FUNCTION SCSIStat: INTEGER;
; (8)
;
;
; Uses: d0, d1, d2
;
; Return Codes:
; noErr
CI_SCSIStat
clr.l -(sp) ; missing parm 3 padding
clr.l -(sp) ; missing parm 2 padding
clr.l -(sp) ; missing parm 1 padding
move.l D1, -(sp) ; scsiSelector
bsr OldSCSICall
add.l #$10, sp
move.w D0, 8(a6) ; 8(a6) <- Bus and Status
bra.w NoByteExit ; 9(a6) <- Current SCSI Bus Status
RTSNAME 'CI_SCSIStat'
;--------------------------------------------------------------------------
;
; FUNCTION Unimplemented: INTEGER;
; (8)
CI_Unimplemented
IfDebugStr 'unimplemented SCSIDispatch selector'
moveq #dsIOCoreErr, D0
_SysError
rts
;--------------------------------------------------------------------------
;
; Initialization code for the SCSI Manager
Init_SCSIXlate
movem.l scsiRegs, -(sp) ; save all registers, for convenience
movea.l SCSIGlobals, a4 ; get ptr to structure
; Set up the jump table
moveq.l #numSelectors-1, d1 ; loop count
lea.l OffsetTbl, a1 ; get start of dispatch table
IF forC96Init OR forROM THEN ; if not a linked patch, treat addrs relative
move.l a1, d0 ; remember base address
ELSE
moveq.l #0, D0 ; if linked patch, treat addrs absolute
ENDIF
movea.l a4, a0 ; point to base of old SCSI Mgr jump table
@MakeJmpTbl
move.l (a1)+, d2 ; get the next offset
beq.s @skipEntry ; if zero, skip this entry
add.l d0, d2 ; compute the address
move.l d2, (a0) ; install it in the jump table
@skipEntry
adda.l #4, a0
dbra d1, @MakeJmpTbl ; loop for all vectors
@InitDone
movem.l (sp)+, scsiRegs ; restore registers
rts
NAME 'Init_SCSIXlate'
;-------------------------------------------------------------
;
Macro
DispatchVector &ROMAddress
IF forC96Init OR forROM THEN ;
dc.l &ROMAddress-OffsetTbl
ELSE
dcImportResident &ROMAddress
ENDIF
EndM
OffsetTbl
DispatchVector CI_SCSIReset ; 0: SCSIReset
DispatchVector CI_SCSIGet ; 1: SCSIGet
DispatchVector CI_SCSISelect ; 2: SCSISelect
DispatchVector CI_SCSICmd ; 3: SCSICmd
DispatchVector CI_SCSIComplete ; 4: SCSIComplete
DispatchVector CI_SCSIRead ; 5: SCSIRead
DispatchVector CI_SCSIWrite ; 6: SCSIWrite
DispatchVector CI_Unimplemented ; 7: Was SCSIInstall
DispatchVector CI_SCSIRBlind ; 8: SCSIRBlind
DispatchVector CI_SCSIWBlind ; 9: SCSIWBlind
DispatchVector CI_SCSIStat ; 10: SCSIStat
DispatchVector CI_SCSISelAtn ; 11: SCSISelAtn
DispatchVector CI_SCSIMsgIn ; 12: SCSIMsgIn <SM3>
DispatchVector CI_SCSIMsgOut ; 13: SCSIMsgOut <SM3>
;==========================================================================
END