mirror of
https://github.com/elliotnunn/sys7.1-doc-wip.git
synced 2024-12-13 11:29:15 +00:00
369 lines
15 KiB
Plaintext
369 lines
15 KiB
Plaintext
|
;__________________________________________________________________________________________________
|
|||
|
;
|
|||
|
; File: ACAM.a
|
|||
|
;
|
|||
|
; Contains: Apple CAM, variables and data structures
|
|||
|
;
|
|||
|
; Written by: Paul Wolf
|
|||
|
;
|
|||
|
; Copyright © 1989-1993 by Apple Computer, Inc. All rights reserved.
|
|||
|
;
|
|||
|
; This file is used in these builds:
|
|||
|
;
|
|||
|
; Change History (most recent first):
|
|||
|
;
|
|||
|
; <SM20> 11/10/93 chp Fix “include once” SET variable naming conventions.
|
|||
|
; <SM19> 10/29/93 DCB <MC> roll-in.
|
|||
|
; <MC2> 10/28/93 pdw Brought the error codes up to date.
|
|||
|
; <SM18> 10/14/93 pdw <MC> roll-in.
|
|||
|
; <SM17> 7/17/93 pdw Changed phz to phase.
|
|||
|
; <SM16> 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.
|
|||
|
; <SM15> 5/5/93 PW Converted names to meanies-friendly names. Updated with latest
|
|||
|
; from Ludwig stuff.
|
|||
|
; <LW7> 5/1/93 PW Changed one last name: SCSI_RegisterWithNewXPT. Changed
|
|||
|
; xxxResidualLength to xxxResidual.
|
|||
|
; <LW5> 3/26/93 PW Removing noLUNinID flag and adding RenegotiateSense flag.
|
|||
|
; <SM13> 3/20/93 PW Rolled in Ludwig changes.
|
|||
|
; <LW4> 3/1/93 DCB Changed scsiConnectionTimeout to reserved since it isn't needed anymore.
|
|||
|
; <LW3> 2/17/93 PW Added scsiBusNotFree flag for scsiResultFlags field.
|
|||
|
; <SM12> 2/1/93 PW Update from the latest of Ludwig. Also changes required for PDM
|
|||
|
; (will update Ludwig with these as needed myself).
|
|||
|
; <LW2> 1/27/93 PW Added spare field in header and scsiDataTypes field in SCSI_IO.
|
|||
|
; <SM11> 12/9/92 PW Changed SCStats record name to SCResults.
|
|||
|
; <SM10> 12/9/92 PW Fixed arrangement of error codes.
|
|||
|
; <SM9> 12/9/92 PW Rearranged error codes.
|
|||
|
; <SM8> 12/5/92 PW Changed some names of some fields.
|
|||
|
; <SM7> 11/20/92 DCB Some changes to the SCSIHdr for async aborts etc.
|
|||
|
; <SM6> 10/30/92 DCB Fixing Broken Build :-(
|
|||
|
; <SM5> 10/30/92 DCB Moved scCallback from SCSI_ExecIOPB to SCSIPBHdr
|
|||
|
; <SM4> 10/30/92 DCB Added function codes from ACAM.h
|
|||
|
; <SM3> 10/8/92 PW Whole loads of name changes. See ACAM.h for details.
|
|||
|
; <SM2> 8/20/92 DCB Added Select w/o Atn flag
|
|||
|
;__________________________________________________________________________________________________
|
|||
|
|
|||
|
|
|||
|
IF &TYPE('__INCLUDINGACAM__') = 'UNDEFINED' THEN
|
|||
|
__INCLUDINGACAM__ SET 1
|
|||
|
|
|||
|
|
|||
|
; General allocation length defines for the Parameter Block structures.
|
|||
|
|
|||
|
IOCDBLEN EQU 12 ; Space for the CDB bytes/pointer
|
|||
|
VUHBA EQU 16 ; Vendor Unique HBA length
|
|||
|
SIM_ID EQU 16 ; ASCII string len for SIM ID
|
|||
|
HBA_ID EQU 16 ; ASCII string len for HBA ID
|
|||
|
|
|||
|
;*************************************************
|
|||
|
|
|||
|
SCSIphase RECORD 0, INCREMENT
|
|||
|
|
|||
|
kDataOutPhase ds.b 1 ; 1st 8 phases (here thru MessageInPhase)
|
|||
|
kDataInPhase ds.b 1 ; are straight off the c96's phase bits
|
|||
|
kCommandPhase ds.b 1 ;
|
|||
|
kStatusPhase ds.b 1 ;
|
|||
|
kPhaseIllegal0 ds.b 1 ;
|
|||
|
kPhaseIllegal1 ds.b 1 ;
|
|||
|
kMessageOutPhase ds.b 1 ;
|
|||
|
kMessageInPhase ds.b 1 ;
|
|||
|
kBusFreePhase ds.b 1 ; these last few phases are formed explicitly
|
|||
|
kArbitratePhase ds.b 1 ; by the code
|
|||
|
kSelectPhase ds.b 1 ;
|
|||
|
kMessageInPhaseNACK ds.b 1 ;
|
|||
|
|
|||
|
ENDR
|
|||
|
|
|||
|
;********************************************************************/
|
|||
|
; Defines for the SCSIMgr function codes <SM4>
|
|||
|
;********************************************************************/
|
|||
|
|
|||
|
;------------ Common Functions ------------
|
|||
|
|
|||
|
SCSINop EQU $00 ; XPT
|
|||
|
SCSIExecIO EQU $01 ; SIM
|
|||
|
SCSIBusInquiry EQU $03 ; SIM
|
|||
|
SCSIReleaseQ EQU $04 ; SIM
|
|||
|
SCSISetAsyncCallback EQU $05 ; SIM
|
|||
|
|
|||
|
;------------ SCSI Control Functions ------------
|
|||
|
|
|||
|
SCSIAbortCommand EQU $10 ; SIM
|
|||
|
SCSIResetBus EQU $11 ; SIM
|
|||
|
SCSIResetDevice EQU $12 ; SIM
|
|||
|
SCSITerminateIO EQU $13 ; SIM
|
|||
|
|
|||
|
;------------ Target Mode ------------
|
|||
|
|
|||
|
SCSIEnableLUN EQU $30 ; Enable LUN, Target mode support
|
|||
|
SCSITargetIO EQU $31 ; Execute the target IO request
|
|||
|
|
|||
|
;------------ Apple Unique ------------
|
|||
|
|
|||
|
SCSIGetVirtualIDInfo EQU $80 ; Find out which bus old ID is on
|
|||
|
SCSIGenerateInterleaveID EQU $81 ; Generate a new interleave factor
|
|||
|
SCSIOldCall EQU $84 ; XPT->SIM private call for old-API
|
|||
|
SCSICreateRefNumXref EQU $85 ; Register a DeviceIdent to drvr RefNum xref
|
|||
|
SCSILookupRefNumXref EQU $86 ; Get DeviceIdent to drvr RefNum xref
|
|||
|
SCSIRemoveRefNumXref EQU $87 ; Remove a DeviceIdent to drvr RefNum xref
|
|||
|
|
|||
|
;------------ Third-party Vendor Unique ------------ <SM6> pdw
|
|||
|
|
|||
|
; $C0 thru $FF <SM6> pdw
|
|||
|
|
|||
|
|
|||
|
SGRecord RECORD 0, INCREMENT
|
|||
|
|
|||
|
SGAddr ds.l 1 ; address of this block
|
|||
|
SGCount ds.l 1 ; number of bytes
|
|||
|
SGNextBlock equ *
|
|||
|
|
|||
|
ENDR
|
|||
|
|
|||
|
|
|||
|
DeviceIdent RECORD 0, INCREMENT
|
|||
|
|
|||
|
diReserved ds.b 1 ;
|
|||
|
bus ds.b 1 ;
|
|||
|
targetID ds.b 1 ;
|
|||
|
LUN ds.b 1 ;
|
|||
|
|
|||
|
ENDR
|
|||
|
|
|||
|
;----------------------------------------------------------------------
|
|||
|
; Defines for the scsiTransferType field
|
|||
|
;----------------------------------------------------------------------
|
|||
|
|
|||
|
scsiTransferBlind equ 0
|
|||
|
scsiTransferPolled equ 1
|
|||
|
|
|||
|
;----------------------------------------------------------------------
|
|||
|
; Defines for the scsiDataType field
|
|||
|
;----------------------------------------------------------------------
|
|||
|
|
|||
|
scsiDataTIB equ $0000 ; TIB supplied (ptr in scsiDataPtr)
|
|||
|
scsiDataBuffer equ $0001 ; single contiguous buffer supplied
|
|||
|
scsiDataSG equ $0002 ; scatter/gather list supplied
|
|||
|
|
|||
|
|
|||
|
|
|||
|
;*************************************************
|
|||
|
|
|||
|
MACRO
|
|||
|
SCSIPBHdr ; Header information fields
|
|||
|
qLink ds.l 1 ; q stuff that MUST be at top if Enqueue is used
|
|||
|
scsiReserved1 ds.w 1 ;
|
|||
|
scsiPBLength ds.w 1 ; -> Length of the entire PB
|
|||
|
scsiFunctionCode ds.b 1 ; -> function scsiSelector
|
|||
|
scsiReserved2 ds.b 1 ; <SM3> pdw
|
|||
|
scsiResult ds.w 1 ; <- Returned result (OSErr)
|
|||
|
scsiDevice ds DeviceIdent ; -> Device Identifier (bus+target+lun) <SM4>
|
|||
|
scsiCompletion ds.l 1 ; -> Callback on completion function <SM3> pdw
|
|||
|
scsiFlags ds.l 1 ; -> Flags for operation of the subsystem
|
|||
|
scsiDriverStorage ds.l 1 ; <> Ptr used by the driver for whatever <SM9>
|
|||
|
scsiXPTprivate ds.l 1 ; private field for use in XPT
|
|||
|
scsiReserved3 ds.l 1 ; -- reserved
|
|||
|
MEND
|
|||
|
|
|||
|
|
|||
|
MACRO
|
|||
|
SCSI_IO_Macro ; MACRO for all of the IO PB <SM3> pdw
|
|||
|
SCSIPBHdr
|
|||
|
scsiResultFlags ds.w 1 ; <- flags which modify the scsiResult field
|
|||
|
scsiInterleaveID ds.w 1 ; -> used to designate interleavability of request
|
|||
|
scsiDataPtr ds.l 1 ; -> Pointer to the data buf/SG list
|
|||
|
scsiDataLength ds.l 1 ; -> Data xfer length
|
|||
|
scsiSensePtr ds.l 1 ; -> Ptr to autosense data buffer
|
|||
|
scsiSenseLength ds.b 1 ; -> size of the autosense buffer
|
|||
|
scsiCDBLength ds.b 1 ; -> Number of bytes for the CDB
|
|||
|
scsiSGListCount ds.w 1 ; -> num of scatter gather list entries
|
|||
|
scsiReserved4 ds.l 1 ; reserved <SM3> pdw
|
|||
|
scsiSCSIstatus ds.b 1 ; <- Returned scsi device status
|
|||
|
scsiSenseResidual ds.b 1 ; <- Autosense residual length
|
|||
|
scsiReserved5 ds.w 1 ; reserved <SM3> pdw
|
|||
|
scsiDataResidual ds.l 1 ; <- Returned Transfer residual length
|
|||
|
scsiCDB ds.b 16 ; -> Actual CDB or pointer to CDB
|
|||
|
scsiTimeout ds.l 1 ; -> Timeout value (in seconds)
|
|||
|
scsiMessagePtr ds.l 1 ; -> Pointer to the message buffer
|
|||
|
scsiMessageLen ds.w 1 ; -> Num of bytes in the message buf
|
|||
|
scsiIOFlags ds.w 1 ; -> Vendor (Apple) unique flags
|
|||
|
scsiTagAction ds.b 1 ; -> What to do for tag queuing
|
|||
|
scsiReserved6 ds.b 1 ; reserved <SM3> pdw
|
|||
|
scsiReserved7 ds.w 1 ; reserved
|
|||
|
scsiSelectTimeout ds.w 1 ; -> Select timeout value
|
|||
|
scsiDataType ds.b 1 ; -> Data description type (i.e. buffer, TIB, S/G)
|
|||
|
scsiTransferType ds.b 1 ; -> Transfer type
|
|||
|
scsiReserved8 ds.l 1 ; reserved
|
|||
|
scsiReserved9 ds.l 1 ; reserved
|
|||
|
scsiHandshake ds.w 8 ; -> handshaking structure (null terminated) <SM3> pdw
|
|||
|
scsiReserved10 ds.l 1 ; reserved <SM3> pdw
|
|||
|
scsiReserved11 ds.l 1 ; reserved
|
|||
|
scsiCommandLink ds.l 1 ; -> Ptr to the next linked cmd in chain
|
|||
|
|
|||
|
scsiSIMpublics ds.b 8 ; for use by 3rd-party SIMs <SM3> pdw
|
|||
|
publicExtras ds.b 8 ; for a total of 48 bytes <SM6> dcb
|
|||
|
|
|||
|
;// XPT layer privates (for old-API emulation mostly; direction XPT<->SIM)
|
|||
|
|
|||
|
scsiCurrentPhase ds.w 1 ; <- phase upon completing old call
|
|||
|
scsiSelector ds.w 1 ; -> scsiSelector specified in old calls
|
|||
|
scsiOldCallResult ds.w 1 ; <- result of old call <SM3> pdw
|
|||
|
scsiSCSImessage ds.b 1 ; <- Returned scsi device message (for SCSIComplete)
|
|||
|
XPTprivateFlags ds.b 1 ; <> XPT private flags (for this PB)
|
|||
|
XPTextras ds.b 12 ; for a total of 16 bytes <SM6> dcb
|
|||
|
|
|||
|
MEND; <SM3> pdw thru next <SM3>
|
|||
|
|
|||
|
|
|||
|
SCSI_IO RECORD 0, INCREMENT
|
|||
|
SCSI_IO_Macro
|
|||
|
ENDR ;SCSI_IO
|
|||
|
|
|||
|
|
|||
|
|
|||
|
;***********************************************************
|
|||
|
; Defines for the SCSIMgr scsiResult field in the PB header.
|
|||
|
;***********************************************************
|
|||
|
|
|||
|
SCResults RECORD 1, INCREMENT
|
|||
|
|
|||
|
scsiRequestInProgress ds.b 1 ; $01 - PB request is in progress
|
|||
|
ORG $E102
|
|||
|
scsiRequestAborted ds.b 1 ; $E102 - PB request aborted by the host
|
|||
|
scsiUnableToAbort ds.b 1 ; $E103 - Unable to Abort PB request
|
|||
|
scsiNonZeroStatus ds.b 1 ; $E104 - PB request completed with an err
|
|||
|
scsiUnused05 ds.b 1
|
|||
|
scsiUnused06 ds.b 1
|
|||
|
scsiUnused07 ds.b 1
|
|||
|
scsiUnused08 ds.b 1
|
|||
|
scsiUnableToTerminate ds.b 1 ; $E109 - Unable to Terminate I/O PB req
|
|||
|
scsiSelectTimeout ds.b 1 ; $E10A - Target selection timeout
|
|||
|
scsiCommandTimeout ds.b 1 ; $E10B - Command timeout
|
|||
|
scsiUnused0C ds.b 1
|
|||
|
scsiMessageRejectReceived ds.b 1 ; $E10D - Message reject received
|
|||
|
scsiSCSIBusReset ds.b 1 ; $E10E - SCSI bus reset sent/received
|
|||
|
scsiParityError ds.b 1 ; $E10F - Uncorrectable parity error occured
|
|||
|
scsiAutosenseFailed ds.b 1 ; $E110 - Autosense: Request sense cmd fail
|
|||
|
scsiUnused11 ds.b 1
|
|||
|
scsiDataRunError ds.b 1 ; $E112 - Data overrun/underrun error
|
|||
|
scsiUnexpectedBusFree ds.b 1 ; $E113 - Unexpected BUS free
|
|||
|
scsiSequenceFailed ds.b 1 ; $E114 - Target bus phase sequence failure
|
|||
|
scsiWrongDirection ds.b 1
|
|||
|
scsiUnused16 ds.b 1
|
|||
|
scsiBDRsent ds.b 1 ; $E117 - A SCSI BDR msg was sent to target
|
|||
|
scsiTerminated ds.b 1 ; $E118 - PB request terminated by the host
|
|||
|
scsiNoNexus ds.b 1 ; $E119 - Nexus is not established
|
|||
|
scsiCDBReceived ds.b 1 ; $E11A - The SCSI CDB has been received
|
|||
|
|
|||
|
ORG $E130
|
|||
|
scsiTooManyBuses ds.b 1 ; $E130 - Register failed because we're full
|
|||
|
scsiBusy ds.b 1 ; $E131 - sc subsystem is busy
|
|||
|
scsiProvideFail ds.b 1 ; $E132 - Unable to provide requ. capability
|
|||
|
scsiDeviceNotThere ds.b 1 ; $E133 - SCSI device not installed/there
|
|||
|
scsiNoHBA ds.b 1 ; $E134 - No HBA detected Error
|
|||
|
scsiDeviceConflict ds.b 1 ; $E135 - sorry, max 1 refNum per DeviceIdent
|
|||
|
scsiNoSuchXref ds.b 1 ; $E136 - no such RefNum xref
|
|||
|
|
|||
|
ORG $E140
|
|||
|
scsiPBLengthError ds.b 1 ; $E140 - PB length supplied is inadaquate
|
|||
|
scsiFunctionNotAvailable ds.b 1 ; $E141 - The requ. func is not available
|
|||
|
scsiRequestInvalid ds.b 1 ; $E142 - PB request is invalid
|
|||
|
scsiBusInvalid ds.b 1 ; $E143 - Bus ID supplied is invalid
|
|||
|
scsiTIDInvalid ds.b 1 ; $E144 - Target ID supplied is invalid
|
|||
|
scsiLUNInvalid ds.b 1 ; $E145 - LUN supplied is invalid
|
|||
|
scsiIIDInvalid ds.b 1 ; $E146 - The initiator ID is invalid
|
|||
|
scsiDataTypeInvalid ds.b 1 ; $E147 - scsiDataType requested is not supported
|
|||
|
scsiTransferTypeInvalid ds.b 1 ; $E148 - scsiTransferType field is too high
|
|||
|
|
|||
|
ENDR ;SCResults
|
|||
|
|
|||
|
scsiSIMQFrozen equ $0001 ; The LUN queue is frozen w/this err
|
|||
|
scsiAutosenseValid equ $0002 ; Autosense data valid for target
|
|||
|
scsiBusNotFree equ $0004 ; At time of callback, SCSI bus is not free
|
|||
|
|
|||
|
|
|||
|
;*************************************************
|
|||
|
|
|||
|
; Defines for the SCSIMgr flags field in the PB header.
|
|||
|
|
|||
|
; 1st Byte
|
|||
|
scsiDirectionMask equ $C0000000 ; Data direction mask
|
|||
|
|
|||
|
scsiDirectionNone equ $C0000000 ; Data direction (11: no data)
|
|||
|
scsiDirectionReserved equ $00000000 ; Data direction (00: reserved)
|
|||
|
scsiDirectionOut equ $80000000 ; Data direction (10: DATA OUT)
|
|||
|
scsiDirectionIn equ $40000000 ; Data direction (01: DATA IN)
|
|||
|
scsiDisableAutosense equ $20000000 ; Disable auto sense feature
|
|||
|
scsiFlagReservedA equ $10000000 ;
|
|||
|
|
|||
|
scsiFlagReserved0 equ $08000000 ;
|
|||
|
scsiCDBLinked equ $04000000 ; The PB contains a linked CDB
|
|||
|
scsiQEnable equ $02000000 ; Target queue actions are enabled
|
|||
|
scsiCDBIsPointer equ $01000000 ; The CDB field contains a pointer
|
|||
|
|
|||
|
; 2nd Byte
|
|||
|
scsiInitiateSyncData equ $00400000 ; Attempt Sync data xfer, and SDTR
|
|||
|
scsiDisableSyncData equ $00200000 ; Disable sync, go to async
|
|||
|
scsiSIMQHead equ $00100000 ; Place PB at the head of SIM Q
|
|||
|
|
|||
|
scsiSIMQFreeze equ $00080000 ; Return the SIM Q to frozen state
|
|||
|
scsiSIMQNoFreeze equ $00040000 ; Disallow SIM Q freezing
|
|||
|
scsiDoDisconnect equ $00020000 ; Definitely do disconnect
|
|||
|
scsiDontDisconnect equ $00010000 ; Definitely dont disconnect
|
|||
|
|
|||
|
; 3rd Byte
|
|||
|
scsiDataDMAable equ $00004000 ; Data buffer(s) are ready for DMA
|
|||
|
scsiDataPhys equ $00002000 ; SG/Buffer data ptrs are physical
|
|||
|
|
|||
|
; 4th Byte - Target Mode Flags
|
|||
|
scsiDataBufferValid equ $00000080 ; Data buffer valid
|
|||
|
scsiStatusBufferValid equ $00000040 ; Status buffer valid
|
|||
|
scsiMessageBufferValid equ $00000020 ; Message buffer valid
|
|||
|
scsiTargetPhaseMode equ $00000008 ; The SIM will run in phase mode
|
|||
|
scsiTargetPBAvail equ $00000004 ; Target PB available
|
|||
|
scsiDisableAutoDisconnect equ $00000002 ; Disable autodisconnect
|
|||
|
scsiDisAutsaveRest equ $00000001 ; Disable autosave/restore ptrs
|
|||
|
|
|||
|
scsiTargetModeFlagsMask equ $000000FF ; all of the target mode bits
|
|||
|
|
|||
|
|
|||
|
; scsiIOFlags
|
|||
|
|
|||
|
scsiNoParityCheck equ $0002 ; disable parity checking
|
|||
|
scsiDisableSelectWAtn equ $0004 ; disable select w/Atn
|
|||
|
scsiSavePtrOnDisconnect equ $0008 ; do SAVE_DATA_POINTER when DISCONNECT
|
|||
|
scsiNoBucketIn equ $0010 ; don’t bit bucket in during this I/O
|
|||
|
scsiNoBucketOut equ $0020 ; don’t bit bucket out during this I/O
|
|||
|
scsiDisableWide equ $0040 ; disable wide transfer negotiation
|
|||
|
scsiRenegotiateSense equ $0080 ; renegotiate on autosense
|
|||
|
|
|||
|
; <SM3> pdw from prev <SM3>
|
|||
|
|
|||
|
|
|||
|
SIMinitInfo RECORD 0, INCREMENT
|
|||
|
|
|||
|
SIMstaticPtr ds.l 1 ; <- alloc. ptr to the SIM's static vars
|
|||
|
staticSize ds.l 1 ; -> num bytes SIM needs for static vars
|
|||
|
SIMinit ds.l 1 ; -> pointer to the SIM init routine
|
|||
|
SIMaction ds.l 1 ; -> pointer to the SIM action routine
|
|||
|
SIM_ISR ds.l 1 ; -> pointer to the SIM ISR routine
|
|||
|
SIMInterruptPoll ds.l 1 ; -> pointer to the SIM interrupt poll routine
|
|||
|
NewOldCall ds.l 1 ; -> pointer to the SIM NewOldCall routine
|
|||
|
ioPBSize ds.w 1 ; -> size of SCSI_IO_PBs required for this SIM <SM3> pdw
|
|||
|
oldCallCapable ds.b 1 ; -> true if this SIM can handle old-API calls
|
|||
|
simInfoUnused1 ds.b 1 ; ->
|
|||
|
simInfoUnused2 ds.l 1 ; ->
|
|||
|
XPT_ISR ds.l 1 ; <- ptr to the XPT ISR
|
|||
|
EnteringSIM ds.l 1 ; <- ptr to the XPT routine
|
|||
|
ExitingSIM ds.l 1 ; <- ptr to the XPT routine
|
|||
|
MakeCallback ds.l 1 ; <- ptr to the XPT routine
|
|||
|
busID ds.w 1 ; <- bus number for the registered bus
|
|||
|
siminfoUnused3 ds.w 1 ; <-
|
|||
|
siminfoUnused4 ds.l 1 ; <-
|
|||
|
|
|||
|
ENDR
|
|||
|
|
|||
|
|
|||
|
|
|||
|
ENDIF ; already included...
|