Commit 13dfbf90 authored by Ben Avison's avatar Ben Avison
Browse files

Shiny new version for Tungsten.

Detail:
  * Removed IOMD dependency - reimplemented to use ADFS_ATAPIOp and
    ADFS_IDEDeviceInfo
  * Supports 4 drives (previously 2)
  * Support for SCSIUserOp entry included
Admin:
  Requires ADFS 3.34 (or intermediate version after 3.33).

Version 1.29. Tagged as 'ATAPI-1_29'
parent f33177d5
......@@ -9,4 +9,22 @@ NotAudT:Not an audio track
BadDisc:Compact disc is faulty
NotSupp:Drive does not support that
BadHandle:Bad handle
CantLock:Cannot lock IDE bus
SCSITO:Timeout
SCSITS:Target status - Check condition
SCSITE0:Target error - No sense
SCSITE1:Target error - Recovered error
SCSITE2:Target error - Not ready
SCSITE3:Target error - Medium error
SCSITE4:Target error - Hardware error
SCSITE5:Target error - Illegal request
SCSITE6:Target error - Unit attention
SCSITE7:Target error - Data protect
SCSITE8:Target error - Blank check
SCSITE9:Target error - Vendor unique
SCSITEA:Target error - Copy aborted
SCSITEB:Target error - Aborted command
SCSITEC:Target error - Equal
SCSITED:Target error - Volume overflow
SCSITEE:Target error - Miscompare
SCSITEF:Target error - Reserved sense key
SCSITEU:Target error - Unknown
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.28"
Module_Version SETA 128
Module_MajorVersion SETS "1.29"
Module_Version SETA 129
Module_MinorVersion SETS ""
Module_Date SETS "07 Nov 2002"
Module_ApplicationDate SETS "07-Nov-02"
Module_Date SETS "22 Nov 2002"
Module_ApplicationDate SETS "22-Nov-02"
Module_ComponentName SETS "ATAPI"
Module_ComponentPath SETS "RiscOS/Sources/HWSupport/CD/ATAPI"
Module_FullVersion SETS "1.28"
Module_HelpVersion SETS "1.28 (07 Nov 2002)"
Module_FullVersion SETS "1.29"
Module_HelpVersion SETS "1.29 (22 Nov 2002)"
END
/* (1.28)
/* (1.29)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68.
*
*/
#define Module_MajorVersion_CMHG 1.28
#define Module_MajorVersion_CMHG 1.29
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 07 Nov 2002
#define Module_Date_CMHG 22 Nov 2002
#define Module_MajorVersion "1.28"
#define Module_Version 128
#define Module_MajorVersion "1.29"
#define Module_Version 129
#define Module_MinorVersion ""
#define Module_Date "07 Nov 2002"
#define Module_Date "22 Nov 2002"
#define Module_ApplicationDate "07-Nov-02"
#define Module_ApplicationDate "22-Nov-02"
#define Module_ComponentName "ATAPI"
#define Module_ComponentPath "RiscOS/Sources/HWSupport/CD/ATAPI"
#define Module_FullVersion "1.28"
#define Module_HelpVersion "1.28 (07 Nov 2002)"
#define Module_LibraryVersionInfo "1:28"
#define Module_FullVersion "1.29"
#define Module_HelpVersion "1.29 (22 Nov 2002)"
#define Module_LibraryVersionInfo "1:29"
......@@ -42,8 +42,13 @@
;*end of change record*
[ HAL
MAX_NUMBER_OF_ATAPI_DRIVES * 4
|
MAX_NUMBER_OF_ATAPI_DRIVES * 2
]
[ :LNOT: HAL
IRQ__INTERRUPT_CLEAR * &03200014
IRQA__INTERRUPT_STATUS * &03200010
IRQA__INTERRUPT_REQUEST * &03200014
......@@ -83,6 +88,7 @@ TASKFILE__W_DRIVE_SELECT * &0018
TASKFILE__W_COMMAND * &001C
TASKFILE__W_DIGITAL_OUTPUT * &0818
TASKFILE__W_UNUSED * &081C
]
; ATAPI feature register
......@@ -174,11 +180,17 @@ TARGETERROR__UNIT_ATTENTION * (6 + TARGETERROR__BASE):SHL:ZERRORFLAGS__SE
TARGETERROR__DATA_PROTECT * (7 + TARGETERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
TARGETERROR__ABORTED_COMMAND * (&B + TARGETERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
TARGETERROR__MISCOMPARE * (&E + TARGETERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
[ HAL
TARGETERROR__UNKNOWN * (&10 + TARGETERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
]
DRIVERERROR__UNKNOWN_REASON * (&2 + DRIVERERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
DRIVERERROR__INVALID_PARAMETER * (&4 + DRIVERERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
DRIVERERROR__SELECTION_TIMEOUT * (&A + DRIVERERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
DRIVERERROR__OTHER_TIMEOUT * (&B + DRIVERERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
[ HAL
DRIVERERROR__UK_SCSI_ERROR * (&C + DRIVERERROR__BASE):SHL:ZERRORFLAGS__SENSEKEY_SHIFT
]
[ long_command_timeout
......@@ -210,7 +222,10 @@ LARGEST_DATA_CHUNK_PLUS_ONE * 2800 ; The reason for this small size is Son
ATAPICONTROL__SEND_COMMAND * 0
ATAPICONTROL__SOFT_RESET * 1
[ full_drive_detection
ATAPICONTROL__CheckForDrive * 2
ATAPICONTROL__CheckForDrive * 2
]
[ HAL ; could be implemented for non-HAL case, but would be a waste of time
ATAPICONTROL__RAW_OP * 3
]
; *********************************************************************************************
......@@ -256,9 +271,11 @@ readdata * 2_01:SHL:24
writedata * 2_10:SHL:24
ATAPIOP__COMMAND_PACKET * 0:SHL:26
[ :LNOT: HAL
ATAPIOP__IDENTIFY_DEVICE * 1:SHL:26
ATAPIOP__DONT_USE_R7 * 1:SHL:27
ATAPIOP__DONT_RETRY * 1:SHL:28
]
; *********************************************************************************************
; ** ATAPI identify device structure **
......
......@@ -145,6 +145,15 @@ $label ADD$cc r13, r13, #4
]
MEND
; ********************************************
; *** Macro for returning from the drive ***
; ********************************************
MACRO
$label MACRO__EXIT_DRIVER_WITHOUT_RESTORING_REGISTERS $cc
$label ADD$cc r13, r13, #4*9
GRAB "pc", "$cc"
MEND
; *******************************
; *** String immediate out. ***
; *******************************
......
......@@ -207,7 +207,7 @@ test_long_timeouts SETL {FALSE}
bodge_sony_selection SETL {TRUE}
faster_startup SETL {TRUE}
bodge_50e_sole_drive SETL {TRUE}
full_drive_detection SETL {TRUE}
full_drive_detection SETL :LNOT: HAL
]
[ Module_Version < 122
......@@ -377,6 +377,7 @@ XCD_ReadUserData # 1 ; 39
XCD_SeekUserData # 1 ; 40
XCD_GetAudioParms # 1 ; 41
XCD_SetAudioParms # 1 ; 42
XCD_SCSIUserOp # 1 ; 43
;***************************************************************************
......@@ -411,9 +412,6 @@ OFF * 0
TRUE * 1
FALSE * 0
debug * OFF ; prints debugging information
commanddebug * OFF ; Keeps a list of SWI's called
;------------------------------------------------------------------
; Structure of r7 -> control block
;------------------------------------------------------------------
......@@ -538,7 +536,7 @@ Equal # 1 ; 12
VolumeOverflow # 1 ; 13
Miscompare # 1 ; 14
ReservedSenseKey # 1 ; 15
SenseUnknown # 1 ; 16
;***************** SCSI status byte numbers *******************************
......@@ -550,6 +548,24 @@ Busy # 1
Unknown # 1
;******************* Other error numbers **************************
BadAddress * &FC
ADFSDriverInUse * &108A0
ADFSBadDrive * &108AC
;******************* Disc error numbers ***************************
WinIDEErrABRT * &02
WinIDEErrWFT * &07
WinIDEErrCmdNotRdy * &08
WinIDEErrCmdBusy * &21
WinIDEErrBusy * &22
WinIDEErrTimeout * &23
WinIDEErrPacket * &25
;******************* Retry count for all operations *********************
DefaultInternalRetryCount * 1600
......@@ -591,7 +607,8 @@ WRITEDATA * 2
; The Sony 561 supports 2 speeds, so will return 1.
; 14 CD_ReadAudio supported
; 15 CD_Get/SetAudioParms supported
; 16 - 31 RESERVED ( 0 )
; 16 CD_SCSIUserOp supported
; 17 - 31 RESERVED ( 0 )
;----------------------------------------------------------------------------------------------
NOAUDIOCONTROLSUPPORT * 0
......@@ -615,14 +632,7 @@ SUPPORT__READ_AUDIO * 1:SHL:14
SUPPORT__AUDIO_PARMS * 1:SHL:15
[ Module_Version >= 105
ATAPI_VERSIONBITS * (SUPPORT__SPEED_MULTIPLIER * 4) + SUPPORT__READ_AUDIO + SUPPORT__CLOSE_DRAWER + SUPPORT__AUDIO_PARMS
|
ATAPI_VERSIONBITS * (SUPPORT__SPEED_MULTIPLIER * 4) + SUPPORT__READ_AUDIO + SUPPORT__CLOSE_DRAWER
]
ATAPI_VERSIONBITS * (SUPPORT__SPEED_MULTIPLIER * 255) + SUPPORT__READ_AUDIO + SUPPORT__CLOSE_DRAWER + SUPPORT__AUDIO_PARMS
;****************
; Audio status returns
......@@ -676,6 +686,7 @@ USE_PROPRIETARY_RUD * 1<<17 ; = 1 if support own method of reading dat
USE_COMPLEX_RUD * 1<<18 ; = 1 if want SCSI scatter list method of reading data
USE_PROPRIETARY_SUD * 1<<19 ; = 1 if support own method of seeking to data
USE_COMPLEX_SUD * 1<<20 ; = 1 if want SCSI scatter list method of seeking to data
USE_SCSI_OP * 1<<21
INFORMATION_WORD * CD_COMMANDS + USE_PROPRIETARY_RUD
......
......@@ -107,6 +107,346 @@
;*end of change record*
; ============= HAL case ======================================================
[ HAL
;------------------------------------------------------------------------------
; ATAPI_Control
;
; on entry:
; r0 - r6 may be used depending on reason code in r8
; r7 -> CDFS control block
; r8 = reason code (IDECONTROL__ ... )
; r12 -> workspace
; r13 -> FD stack
;
; on exit:
; r8 = corrupted (probably not - cpartington)
;
; if OK then
; all regs preserved
; if ERROR then
; r0 = error number
; or r0 -> error block if r0 >= &1000
;
;------------------------------------------------------------------------------
ATAPI_Control ROUT
CMP r8,#(ATAPIC_EndOfJumpTable - ATAPIC_StartOfJumpTable) / 4
BHS ATAPIC_UnknownReason
ADD pc,pc,r8,LSL #2 ; call routine
NOP
ATAPIC_StartOfJumpTable
B ATAPI_Op
B ATAPI_Reset
MOV pc, r14 ; obsolete reason code
B ATAPI_RawOp
ATAPIC_EndOfJumpTable
ATAPIC_UnknownReason
;
; Bad reason code
MOV r0,#DRIVERERROR__UNKNOWN_REASON
MOV r1,#0
SETV
MOV pc,r14
;------------------------------------------------------------------------------
; ATAPI_Op - ATAPICONTROL__SEND_COMMAND reason code
;
; Only functionality required for HAL version is to send command packet with retries
;
; on entry:
; r0 = b24 to b25 00 no data, 01 = read, 10=write, 11=reserved
; other bits reserved
; r1 = length of control block
; r2 -> control block
; r3 -> start of transfer
; r4 = length of transfer (in bytes)
; r7 -> CDFS control block
;
; on exit:
; if OK then
; all regs preserved
; if ERROR then
; r0 = internal error number (DRIVERERROR or TARGETERROR ranges)
; or r0 -> error block if r0 >= &1000
;
;
; COMMENT:
; This will do up to 3 retries as well as setting the disc changed flags.
;
;------------------------------------------------------------------------------
ATAPI_Op ROUT
STASH "r0-r5,r14"
MOV r5,#0
BL ATAPI_RawOp
ADDVC sp,sp,#4*3
GRAB "r3-r5,pc",VC ; no-error case
TEQ r0,#DRIVERERROR__SELECTION_TIMEOUT
TEQNE r0,#DRIVERERROR__OTHER_TIMEOUT
BEQ %FT90 ; serious problems, try resetting before retrying
TEQ r0,#DRIVERERROR__UK_SCSI_ERROR
BEQ %FT95 ; might be UNIT ATTENTION or NOT READY, so retry
; Convert SCSI sense errors to internal TARGETERROR errors before proceeding
CMP r0,#&1000
BCC %FT10 ; not an error pointer
LDR r14,[r0]
SUB r14,r14,#SCSISenseNumber:AND:&FF000
SUB r14,r14,#SCSISenseNumber:AND:&00FF0
CMP r14,#&40
BCS %FT10 ; not a SCSI sense error block
AND r1,r1,#3:SHL:5 ; extract EOM and ILI bits
MOV r14,r0,LSL #ZERRORFLAGS__SENSEKEY_SHIFT
ORR r0,r14,r1,LSR #5
TEQ r14,#TARGETERROR__UNIT_ATTENTION
TEQNE r14,#TARGETERROR__NOT_READY
BEQ %FT95 ; retry if we got one of those two
10 ; Return any remaining errors
ADD sp,sp,#4
SETV
GRAB "r1-r5,pc"
90 ; Reset drive before retrying command
STASH "r0"
BL ATAPI_Reset
GRAB "r0"
95 ; Retry command unless number of retries has been reached
ADDS r14,SWIN,#1:SHL:30
BCS %BT10
MOV SWIN,r14
BL Extras_ConvertControlBlockToDrive
; Set the disc changed flag
BL Extras_SetDiscChanged
; The drawer must be unlocked (why?)
MOV r1,#0
BL Extras_SetDrawerStatus
GRAB "r0-r5,r14"
B ATAPI_Op
;------------------------------------------------------------------------------
; ATAPI_Reset - ATAPICONTROL__SOFT_RESET reason code
;
; on entry:
; r7 -> CDFS control block
;
; on exit:
; all registers preserved except r0, error may be returned if drive not known
;
;------------------------------------------------------------------------------
ATAPI_Reset ROUT
STASH "r5,r14"
BL Extras_ConvertControlBlockToDrive ; sets up r0
GRAB "r5,pc", VS ; return error if bad drive
MOV r0,r0,LSL #15 ; device -> bit15, controller -> bits 16-23
ORR r0,r0,#1 ; do DEVICE RESET command
MOV r5,#10*100 ; 10 second timeout
SWI XADFS_ATAPIOp
BVS %FT90
TEQ r0,#0 ; not a disc error?
GRAB "r5,pc" ; exit with V clear
; Any disc error at this point is bound to be a timeout
MOV r0,#DRIVERERROR__OTHER_TIMEOUT
SETV
GRAB "r5,pc"
90 ; Error pointer returned from SWI - is it "Bad drive"?
LDR r14,[r0]
LDR r5,=ADFSBadDrive
TEQ r14,r5
MOVEQ r0,#DRIVERERROR__INVALID_PARAMETER
; Otherwise (eg "Driver in use") pass error pointer back
GRAB "r5,pc"
;------------------------------------------------------------------------------
; ATAPI_RawOp - ATAPICONTROL__RAW_OP reason code
;
; on entry:
; r0 = b24 to b25 00 no data, 01 = read, 10=write, 11=reserved
; other bits reserved
; r1 = length of control block
; r2 -> control block
; r3 -> start of transfer
; r4 = length of transfer (in bytes)
; r5 = timeout in cs (0 = default)
; r7 -> CDFS control block
;
; on exit:
; if OK then
; r3,r4 updated
; all other regs preserved
; if ERROR then
; r0 = internal error number (DRIVERERROR range only)
; or r0 -> error block if r0 >= &1000
; r1,r2 may contain relevant information if SCSI error, else corrupted
;
; COMMENT:
; Doesn't do retries, it relies on ATAPI_Op or CDFSDriver to do them instead.
;
;------------------------------------------------------------------------------
ATAPI_RawOp ROUT
STASH "r0-r1,r14"
BL Extras_ConvertControlBlockToDrive ; sets up r0
MOVVS r0,#DRIVERERROR__SELECTION_TIMEOUT ; different error required
ADDVS sp,sp,#8
GRAB "pc",VS
ADR r14,DriveRecognisedStatus
LDRB r14,[r14,r0] ; get packet size for device
CMP r1,r14
MOVLO r1,r14 ; ensure we transfer at least that much
LDR r14,[sp]
ORR r0,r14,r0,LSL #15 ; add device/controller bits into original r0
SWI XADFS_ATAPIOp
BVS %FT90
TEQ r0,#0 ; not a disc error?
GRAB "r0-r1,pc" ; exit with V clear
; A disc error occurred - convert into appropriate internal error number
; or SCSI error register set
ADD sp,sp,#8
SETV
TEQ r0,#WinIDEErrCmdBusy
TEQNE r0,#WinIDEErrCmdNotRdy
MOVEQ r0,#DRIVERERROR__SELECTION_TIMEOUT
GRAB "pc",EQ
TEQ r0,#WinIDEErrWFT
TEQNE r0,#WinIDEErrABRT
TEQNE r0,#WinIDEErrPacket
MOVNE r0,#DRIVERERROR__OTHER_TIMEOUT ; the only disc errors I expect here
GRAB "pc",NE ; are &22 or &23, but treat all
; unexpected ones the same
; Do a REQUEST SENSE command
STASH "r3-r6"
ADRAL r6,%FT50 ; r6 = where to go if command fails
TEQ r0,#WinIDEErrABRT
ADREQ r6,%FT60
TEQ r0,#WinIDEErrPacket
ADREQ r6,%FT70
BL Extras_ConvertControlBlockToDrive ; can't return error this time
ORR r0,r0,#1:SHL:24 ; read operation
MOV r4,#8:SHL:16 ; alloc length = 8, reserved = Flag = Link = 0
MOV r3,#3:SHL:16 ; operation = REQUEST SENSE, LUN = reserved = 0
MOV r2,#0
MOV r1,#0
STASH "r1-r4" ; command block at sp+10,
; result block at sp+1
MOV r1,#12 ; actually a 6-byte comand, but padded
ADD r2,sp,#10
ADD r3,sp,#1
MOV r4,#8 ; result is 8 bytes long
MOV r5,#0
SWI XADFS_ATAPIOp
TEQ r0,#0
SETV NE ; if this call failed we have to fake up
MOVVS pc,r6 ; an appropriate error for the first call
MOV r3,#0 ; build 'segment number' here
MOV r4,#0 ; build filemark/EOM/ILI/sense key here
LDRB r1,[sp,#1+0] ; first stab at valid bit & error class/code
AND r0,r1,#&7F ; error class and code
TEQ r0,#&70
TEQNE r0,#&71
BICNE r1,r1,#&80 ; these are only cases when r2 will be valid
CMP r0,#&70
RSBCSS r14,r0,#&73
MOVCC r0,#16 ; can't find sense key - return "unknown"
BCC %FT30
CMP r0,#&72
LDRCCB r4,[sp,#1+2] ; fixed sense data format has sense key at +2
LDRCCB r3,[sp,#1+1] ; and segment number at +1
LDRCSB r4,[sp,#1+1] ; descriptor sense data just has sense key
AND r0,r4,#15 ; extract sense key
MOVCS r4,r0 ; descriptor sense data has no filemark/EOM/ILI
CMP r0,#0
MOVEQ pc,r6 ; if "no sense" we may want to fake again
20 LDR r2,[sp,#1+3] ; r2 = information bytes (big-endian)
EOR r14,r2,r2,ROR #16
BIC r14,r14,#&FF0000
MOV r2,r2,ROR #8
EOR r2,r2,r14,LSR #8 ; now little-endian
30 ; r0 = sense key (0-16)
; r1 = valid bit & error class/code
; r2 = information bytes
; r3 = segment number
; r4 = filemark/ROM/ILI/reserved/sense key
ORR r1,r1,r0,LSL #8
ORR r1,r3,r1,LSL #8
ORR r1,r4,r1,LSL #8
ORR r1,r1,#NoSense :SHL: 24 ; r1 is now as for SCSI_Op
ASSERT sense_error_spacing = 12
ADD r0,r0,r0,LSL #1
ADRL r14,scsi_sense_0_error
ADD r0,r14,r0,LSL #2 ; r0 -> error block, not yet looked up
40 ADD sp,sp,#16
SETV
GRAB "r3-r6,pc"
50 ; REQUEST SENSE failed, or "no sense" returned, after WinIDEErrWFT
MOVVS r4,#0 ; can't suppose any filemark/EOM/ILI bits
; else r4 already contains filemark/EOM/ILI (if applicable) and no sense bits
MOV r0,#4 ; sense key := hardware error
MOV r1,#&70
MOV r2,#0
MOV r3,#0
ORR r4,r4,r0
B %BT30
60 ; REQUEST SENSE failed, or "no sense" returned, after WinIDEErrABRT
MOVVS r4,#0 ; can't suppose any filemark/EOM/ILI bits
; else r4 already contains filemark/EOM/ILI (if applicable) and no sense bits
MOV r0,#11 ; sense key := aborted command
MOV r1,#&70
MOV r2,#0
MOV r3,#0
ORR r4,r4,r0
B %BT30
70 ; REQUEST SENSE failed, or "no sense" returned, after WinIDEErrPacket
; here because of a "no sense"?
BVC %BT20 ; it's okay to report it in this case
MOV r0,#DRIVERERROR__UK_SCSI_ERROR
; this converts to "Compact disc is faulty"
; or "Target status - Check condition"
B %BT40
90 ; Error pointer returned from first SWI - is it "Bad drive"?
LDR r14,[r0]
LDR r5,=ADFSBadDrive
TEQ r14,r5
MOVEQ r0,#DRIVERERROR__SELECTION_TIMEOUT
; Otherwise (eg "Driver in use", "Bad address") pass error pointer back
ADD sp,sp,#4
GRAB "r1,pc"
; ============= Non-HAL case ==================================================
|
; Routines in thisfile
; ATAPI_Control
; ATAPI_Op
......@@ -1578,4 +1918,6 @@ ALU_ADFS
;------------------------------------------------------------------------------
] ; end big HAL switch
END
......@@ -190,13 +190,15 @@ jump_table_start
DCW notsupported - jump_table_start - 4 ; 29
DCW Identify - jump_table_start - 4 ; 30
DCW ReadAudio - jump_table_start - 4 ; 31
[ Module_Version >= 105
DCW ReadUserData - jump_table_start - 4 ; 32
DCW notsupported - jump_table_start - 4 ; 33
DCW GetAudioParms - jump_table_start - 4 ; 34
DCW SetAudioParms - jump_table_start - 4 ; 35
]
[ HAL
DCW SCSIUserOp - jump_table_start - 4 ; 36
]
jump_table_end
......@@ -2589,10 +2591,12 @@ Reset ROUT
;
;-----------------------------------------------------------------------------------------------
[ :LNOT: HAL ; what was this for?
LDR r0, [ r7, # 0 ]
CMP r0, # -1
MOVEQ r8, # ATAPICONTROL__SOFT_RESET
MOVEQ r0, # 0 + ATAPIOP__DONT_USE_R7
]
MOV r8, # ATAPICONTROL__SOFT_RESET
BL ATAPI_Control
......@@ -2714,7 +2718,7 @@ Identify ROUT
; r12 -> their workspace
; r13 -> full descending stack
; on exit: