mac-rom/Interfaces/AIncludes/SCSI.a
Elliot Nunn 4325cdcc78 Bring in CubeE sources
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included.

The Tools directory, containing mostly junk, is also excluded.
2017-12-26 09:52:23 +08:00

381 lines
13 KiB
Plaintext

;
; File: SCSI.a
;
; Copyright: © 1990-1992 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <9> 7/1/92 DCL This file is the replacement for the now obsolete SCSIEqu.a.
; Changed the 'including' name to match the new file name.
; <8> 11/27/91 MH Add include of traps.a for _SCSIDispatch trap definition
; <7> 11/27/91 MH Remove unsupported NewSCSI trap macros and selectors
; <6> 1/30/91 gbm sab, #38: Change the Ôalready including this fileÕ variable to
; all uppercase (for security reasons)
; <5> 11/12/90 JL Added scsiInstall equate
;
; To Do:
;
; Version: 3.19
; Created: Friday, October 20, 1989 at 9:50:00 PM
;
;
; Equates for SCSI boot, mgr routines
; SCSI Traps
;
; 1.5 jwk 07/15/1989 NEEDED FOR AURORA - Added BusDevRst bit, and changed error codes to SysErr range
; 1.4 jwk 06/29/1989 NEEDED FOR AURORA - Renamed HeadOfQ bit to Immed bit (more accurate)
; 1.3 jwk 06/13/1989 Reorganized source to be Universal-ROM friendly
; 1.2 jwk 02/26/1989 Padded PB for longword alignment
; 1.1 jwk 02/26/1989 Adding equates for async SCSI Mgr trap
; 1.0 CCH 11/ 9/1988 Adding to EASE.
; END EASE MODIFICATION HISTORY
;¥1.1 CCH 9/14/1988 Updated EASE with the current rev of this file.
;________________________________________________________________________________
IF &TYPE('__INCLUDINGSCSI__') = 'UNDEFINED' THEN
__INCLUDINGSCSI__ SET 1
IF &TYPE('__INCLUDINGTRAPS__') = 'UNDEFINED' THEN
INCLUDE 'Traps.a'
ENDIF
; misc SCSI driver equates
scMacID EQU $80 ; SCSI ID for Macintosh Plus (bit 7)
SCSIDrvrs EQU $B2E ; (word) bitmap for loaded SCSI drivers
; SCSI error codes
scCommErr EQU 2 ; communications error (operation timeout)
scArbNBErr EQU 3 ; arbitration timeout waiting for not BSY
scBadparmsErr EQU 4 ; bad parameter or TIB opcode
scPhaseErr EQU 5 ; SCSI bus not in correct phase for attempted operation
scCompareErr EQU 6 ; data compare error
scMgrBusyErr EQU 7 ; SCSI Manager busy with another operation
; when SCSIGet was called
scSequenceErr EQU 8 ; attempted operation is out of sequence;
; e.g., calling SCSISelect before doing
; SCSIGet. Incorrectly written drivers
; can cause this error.
scBusTOErr EQU 9 ; CPU bus timeout when attempting read or
; write in pseudo-DMA mode -- indicates
; that the data wasn't ready within the
; 'bus timeout' period. (Mac SE & Mac II only)
scComplPhaseErr EQU 10 ; SCSI bus wasn't in Status phase when
; SCSIComplete was called -- the SCSI
; Manager may have had to throw away data
; (or write 'filler' bytes) in order to
; reach the Status phase. Indicates that
; the driver didn't handle SCSI bus phase
; changes correctly.
; misc SCSI driver equates
scDefaultID EQU 7 ; default CPU SCSI id
;---------------------------------------------------
;
; the information pertaining to the read/write
; command block interpreter.
;
; SCSI command block equates.
;
scOpcode EQU 0 ; offsets into command "line" for data xfer
scParam1 EQU 2
scParam2 EQU 6
scSize EQU 10 ; size of a command line
scInc EQU 1 ; xfer with address increment
scNoInc EQU 2 ; xfer without address increment
scAdd EQU 3 ; add count to address
scMove EQU 4 ; MOVE data from addr1 to addr2
scLoop EQU 5 ; decrement loop counter and branch
scNop EQU 6 ; do very little
scStop EQU 7 ; then stop doing even that
scComp EQU 8 ; compare bytes with address increment
;
; The layout of block 0 of a bootable SCSI device.
;
sbSigWord EQU $4552 ; block 0 validator
sbSig EQU 0 ; signature word
sbBlkSize EQU 2 ; block size of device
sbBlkCount EQU 4 ; # blocks on device
sbDevType EQU 8 ; device type code
sbDevID EQU 10
sbData EQU 12 ; start of data section
sbDrvCount EQU 16 ; # drivers following
sbDrvrs EQU 18 ; start of driver descriptors
; Driver descriptors
ddBlock EQU 0 ; physical block of driver
ddSize EQU 4 ; block count of driver
ddType EQU 6 ; Processor type of driver
ddLen EQU 8
sbMac EQU 1 ; Macintosh driver type
;
; Partition Descriptors
;
pdSigWord EQU $5453 ; block 1 validator
pmSig EQU 0 ; unique value for map entry blk
pmSigPad EQU 2 ; currently unused
pmMapBlkCnt EQU 4 ; # of blks in partition map
pmPyPartStart EQU 8 ; first physical block of partition
pmPartBlkCnt EQU 12 ; number of blocks in partition
pmPartName EQU 16 ; ASCII partition name
pmParType EQU 48 ; ASCII partition type
pmLgDataStart EQU 80 ; log. # of partition's 1st data blk
pmDataCnt EQU 84 ; # of blks in partition's data area
pmPartStatus EQU 88 ; bit field for partition status
pmLgBootStart EQU 92 ; logical blk of partition's boot code
pmBootSize EQU 96 ; number of bytes in boot code
pmBootAddr EQU 100 ; memory load address of boot code
pmBootAddr2 EQU 104 ; currently unused
pmBootEntry EQU 108 ; entry point of boot code
pmBootEntry2 EQU 112 ; currently unused
pmBootCksum EQU 116 ; checksum of boot code
pmProcessor EQU 120 ; ASCII for the processor type
pmPad EQU 124 ; 512 bytes long, currently unused
hfsID EQU 'TFS1' ; The HFS filesystem ID
;Routine Selectors
scsiReset EQU 0
scsiGet EQU 1
scsiSelect EQU 2
scsiCmd EQU 3
scsiComplete EQU 4
scsiRead EQU 5
scsiWrite EQU 6
scsiInstall EQU 7
scsiRBlind EQU 8
scsiWBlind EQU 9
scsiStat EQU 10
scsiSelAtn EQU 11
scsiMsgIn EQU 12
scsiMsgOut EQU 13
numSelectors EQU 14
MACRO
_SCSIReset
MOVE #scsiReset,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIGet
MOVE #scsiGet,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSISelect
MOVE #scsiSelect,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSICmd
MOVE #scsiCmd,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIComplete
MOVE #scsiComplete,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIRead
MOVE #scsiRead,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIWrite
MOVE #scsiWrite,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIInstall
MOVE #scsiInstall,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIRBlind
MOVE #scsiRBlind,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIWBlind
MOVE #scsiWBlind,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIStat
MOVE #scsiStat,-(sp)
_SCSIDispatch
ENDM
MACRO
_scsiSelAtn
MOVE #scsiSelAtn,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIMsgIn
MOVE #scsiMsgIn,-(sp)
_SCSIDispatch
ENDM
MACRO
_SCSIMsgOut
MOVE #scsiMsgOut,-(sp)
_SCSIDispatch
ENDM
;
; New SCSI Manager
;
; SCSI request parameter block
;
scsiPB RECORD 0, INCREMENT
scsiQLink DS.L 1 ; --- link to next request block
scsiPrivate DS.L 1 ; --- SCSI Mgr private storage
scsiVersion DS.W 1 ; --> version of the parameter block
scsiBus DS.W 1 ; --> SCSI bus number
scsiReqID DS.B 1 ; --> SCSI ID
scsiReqLUN DS.B 1 ; --> logical unit number
scsiResult DS.W 1 ; <-- return code from SCSI Manager
scsiCompletion DS.L 1 ; --> address of completion routine
scsiUsrData DS.L 1 ; --> pointer to user's storage
scsiReqTO DS.L 1 ; --> in ms
scsiUsrFlags DS.W 1 ; --> user's operation flag bits
scsiSelTO DS.W 1 ; --> in ms
scsiMgrFlags DS.L 1 ; --> SCSI operation flags
scsiLinkCmd DS.L 1 ; --> ptr to next linked command
scsiSnsBuf DS.L 1 ; --> sense buffer pointer
scsiSnsLen DS.B 1 ; --> length of sense buffer ( at least 4 bytes )
scsiSnsXfer DS.B 1 ; <-- actual sense bytes transferred
scsiStatus DS.B 1 ; --> SCSI status byte
scsiCmdLen DS.B 1 ; --> length of the command buffer
scsiCmdBuf DS.L 1 ; --> command buffer pointer
scsiDCInstr DS.L 1 ; --> ptr to array of data-chaining instructions
scsiDataLen DS.L 1 ; --> requested data transfer length
scsiDataXfer DS.L 1 ; <-- actual data bytes transferred
scsiPBSize EQU *-scsiPB ; size of SCSI request parameter block
ENDR
;
; flags
;
; SCSI Mgr flags:
;
scsiFParity EQU $00000001 ; Enable parity checking
scsiFNoDisc EQU $00000002 ; Disconnection not allowed for this request
scsiFWrite EQU $00000004 ; output data to the SCSI bus
scsiFFast EQU $00000008 ; Transfer data in the "fast" mode
scsiFPhysical EQU $00000010 ; physical addresses are used (enables DMA)
scsiFAsync EQU $00000020 ; asynchronous request
scsiFBusDevRst EQU $00000040 ; attempt to send a Bus Device Reset message
scsiFImmed EQU $00000080 ; Immediate ("page fault") service requested
; SCSI Mgr bits:
scsiBParity EQU 0 ; enable parity checking
scsiBNoDisc EQU 1 ; disconnection not allowed for this request
scsiBWrite EQU 2 ; output data to the SCSI bus
scsiBFast EQU 3 ; transfer data in the "fast" mode
scsiBPhysical EQU 4 ; physical addresses are used (enables DMA)
scsiBAsync EQU 5 ; asynchronous request
scsiBBusDevRst EQU 6 ; attempt to send a Bus Device Reset message
scsiBImmed EQU 7 ; Immediate ("page fault") service requested
;
; Data-chaining related equates
;
dcLoop EQU -1 ; loop opcode (dcLoop,count,offset,store)
dcStop EQU 0 ; stop opcode (dcStop,-----,------,-----)
; ; move opcode ( addr ,count,offset,store)
dcInstr RECORD 0, INCREMENT
dcAddr DS.L 1 ; buffer start address (0,-1,other)
dcCount DS.L 1 ; generic count
dcOffset DS.L 1 ; generic "offset"
dcStore DS.L 1 ; used to create "Saved Data Pointer"
dcSize EQU *-dcInstr ; size of one data-chaining instruction
ENDR
;
; Status byte equates
;
statusInitial EQU $FF ; initial "invalid" status byte value
statusByteCode EQU $9E ; mask to clear vendor-unique bits in status byte
statusRsrvBit EQU 7 ; reserved bit in status byte (must be zero for autosense)
statusGood EQU $00 ; status byte values with VU and reserved bits masked
statusChkCond EQU $02
statusCondMetGood EQU $04
statusBusy EQU $08
statusIntGood EQU $10
statusIntCMGood EQU $14
statusRsrvConflict EQU $18
;
; error codes on the original call
;
scsiBadPBErr EQU -470 ; invalid field(s) in the parameter block
;
; error codes in the "scsiResult" field
;
scsiOverrunErr EQU -471 ; attempted to transfer too many bytes
scsiTransferErr EQU -472 ; write flag conflicts with data transfer phase
scsiBusTOErr EQU -473 ; bus error during transfer
scsiSelectTOErr EQU -474 ; scsiSelTO exceeded (selection failed)
scsiTimeOutErr EQU -475 ; scsiReqTO exceeded
scsiBusResetErr EQU -476 ; the bus was reset, so your request was aborted
scsiBadStatus EQU -477 ; non-zero (not "Good") status returned
scsiNoStatusErr EQU -478 ; device did not go through a status phase
scsiLinkFailErr EQU -479 ; linked command never executed
scsiUnimpVctErr EQU -489 ; unimplemented routine was called
;
; "in progress" codes in the "scsiResult" field
;
scsiEnqueued EQU $0001 ; enqueued, waiting to start
scsiArbitrated EQU $0002 ; arbitration in progress, or attempted
scsiSelection EQU $0003 ; selection in progress, or target selected
scsiDisc EQU $0004 ; disconnected
scsiDataOut EQU $0010 ; Data Out phase
scsiDataIn EQU $0011 ; Data In phase
scsiCommand EQU $0012 ; Command phase
scsiStatus EQU $0013 ; Status phase
scsiIllegal1 EQU $0014 ; Unknown (illegal) phase
scsiIllegal2 EQU $0015 ; Unknown (illegal) phase
scsiMessageOut EQU $0016 ; Message Out phase
scsiMessageIn EQU $0017 ; Message In phase
;
; SCSIBusInfo information selectors
;
scsiIntfLvl EQU 0 ; SCSI Mgr interface level (1-n)
scsiBusTO EQU 1 ; byte-to-byte time limit (in us, 0=no timeout)
scsiBusDMA EQU 2 ; bus has a dedicated DMA channel (1=has DMA)
ENDIF ; ...already included