Commit c5fb0382 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Go straight to READ(12) rather than using READ CD emulation on new ATAPI drives

In the central data transfer step (DriverCode.s around line 450) there are up to 3 goes at doing the transfer, attempting to work around some problems in <unspecified model> Sony drive and Panasonic CD-571B. Others may be affected similarly.
However, the very latest combined DVD/CD reader, eg. SATA attached SH-224DB/BEBE, have given up entirely with READ CD. In particular, they do not error it, nor are any bytes transferred to the buffer. This falls foul of CDFSSoftATAPI's 3 step approach, because the absence of an error is taken as success and the (junk RMA) block passed up to CDFS.
Unfortunately because the model of Sony reader is not mentioned in the sources nor CVS history we can't do a string match on the model name.
Instead, we now look at the reply to IDENTIFY and look for any declaring ATAPI-5 or later. ATAPI-5 was released in 2000, which definitely post dates the workaround by 4 or 5 years.
hdr/IDEdefs: declare offset for IDENTIFY to the version fields.
Module.s: hook out the version (being careful that pre ATAPI-4 don't have this field). Make a note in the DriveFlag if READ(12) is suspect vintage.
Variables.s: reintroduce the DriveFlag in the HAL case
DriverCode.s: free up a register to load DriveFlag into, look at the DriveFlag, skip straight to READ(12) on ATAPI-5 or later.

Tested on Titanium.
Fixes bogus "CDFS does not support that type of disc" with a simple ISO9660 formatted DVD, due to an untouched RMA block being parsed by CDFS.

Version 1.43. Tagged as 'ATAPI-1_43'
parent 0ca30d30
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.42"
Module_Version SETA 142
Module_MajorVersion SETS "1.43"
Module_Version SETA 143
Module_MinorVersion SETS ""
Module_Date SETS "22 May 2016"
Module_ApplicationDate SETS "22-May-16"
Module_Date SETS "22 Apr 2017"
Module_ApplicationDate SETS "22-Apr-17"
Module_ComponentName SETS "ATAPI"
Module_ComponentPath SETS "castle/RiscOS/Sources/HWSupport/CD/ATAPI"
Module_FullVersion SETS "1.42"
Module_HelpVersion SETS "1.42 (22 May 2016)"
Module_FullVersion SETS "1.43"
Module_HelpVersion SETS "1.43 (22 Apr 2017)"
END
/* (1.42)
/* (1.43)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.42
#define Module_MajorVersion_CMHG 1.43
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 22 May 2016
#define Module_Date_CMHG 22 Apr 2017
#define Module_MajorVersion "1.42"
#define Module_Version 142
#define Module_MajorVersion "1.43"
#define Module_Version 143
#define Module_MinorVersion ""
#define Module_Date "22 May 2016"
#define Module_Date "22 Apr 2017"
#define Module_ApplicationDate "22-May-16"
#define Module_ApplicationDate "22-Apr-17"
#define Module_ComponentName "ATAPI"
#define Module_ComponentPath "castle/RiscOS/Sources/HWSupport/CD/ATAPI"
#define Module_FullVersion "1.42"
#define Module_HelpVersion "1.42 (22 May 2016)"
#define Module_LibraryVersionInfo "1:42"
#define Module_FullVersion "1.43"
#define Module_HelpVersion "1.43 (22 Apr 2017)"
#define Module_LibraryVersionInfo "1:43"
......@@ -159,7 +159,7 @@ ATAPI__PAUSE_RESUME * &4B
ATAPI__MODE_SELECT * &55
ATAPI__MODE_SENSE * &5A
ATAPI__PLAY_AUDIO_12 * &A5
ATAPI__READ_DATA * &A8
ATAPI__READ_DATA_12 * &A8
ATAPI__PLAY_TRACK_RELATIVE_12 * &A9
ATAPI__READ_CD_MSF * &B9
ATAPI__SET_CDROM_SPEED * &BB
......@@ -282,6 +282,8 @@ ATAPIOP__DONT_RETRY * 1:SHL:28
ATAPIID__GENERAL_CONFIGURATION * (2* 0)
ATAPIID__MODEL_NUMBER * (2* 27)
ATAPIID__MAJOR_VERSION * (2* 80)
ATAPIID__MINOR_VERSION * (2* 81)
ATAPIID__STRUCTURE_SIZE * (2*256)
......
......@@ -335,15 +335,21 @@ ReadData ROUT
RD_MultiSessionSorted
MOV r8, r2
; Find out what the current drive mode is
BL Extras_ConvertControlBlockToDrive
BVS error_handler
ADR r14, DriveFlags
LDRB r2, [ r0, r14 ]
ADR r14, DriveMode
LDRB r0, [ r0, r14 ]
; r0 = disc mode (1, 2 or 3)
; r0 = drive mode (1, 2 or 3)
; r2 = drive flags
; r8 = number of blocks
[ cdebug2
CDebug_StrReg8 ", mode ",r0
......@@ -351,14 +357,13 @@ RD_MultiSessionSorted
; If only want one block, then load it into my buffer and copy it out later
MOV r8, r2
TEQ r2, # 1
TEQ r8, # 1
BNE RD_HowManyBlocks
TEQ r0, # 1
TEQNE r0, # 3
MOVEQ r4, # 2048
ASSERT mode1datasize = USERDATA__MODE2FORM1
LDREQ r4, = mode1datasize
LDRNE r4, = mode2datasize
ADR r3, buffer + 16
......@@ -377,21 +382,23 @@ RD_HowManyBlocks
ORR r6, r6, r14, ROR #24
; Only 3 bytes available for transfer length
MOV r2, r2, LSL # 8
AND r1, r5, r2, ROR #8
AND r14, r5, r2
MOV r14, r8, LSL # 8
AND r1, r5, r14, ROR #8
AND r14, r5, r14
ORR r5, r1, r14, ROR #24
|
MOV r2, r2, LSL #8
MOV r14, r8, LSL #8
REV r6, r1
REV r5, r2
REV r5, r14
]
; r0 = mode we think this is
; r2 = drive flags
; r3 -> data buffer
; r4 = byte count
; r5 = reversed transfer length
; r6 = reversed LBA
; r8 = transfer length
;
; mode 1, 3 (mode 2 form 1) => user data only
; mode 2 => all headers + user data, + EDC & ECC
......@@ -410,10 +417,16 @@ RD_HowManyBlocks
; internal mode 3 anyway.
; However, other drives are very literal about READ CD and can only read
; data from CDs and not DVDs with this command, so having worked round the
; above problem with Panasonic drives we may end up rejecting perfectly good
; DVDs instead, as a last attempt use READ(12) to read the data. Note that
; READ(10) only has a 2 byte block count, which would be retrograde having
; allowed 3 byte block counts for READ CD.
; above problem with Panasonic/Sony drives we may end up rejecting perfectly
; good DVDs instead, as a last attempt use READ(12) to read the data. Note
; that READ(10) only has a 2 byte block count, which would be retrograde
; having allowed 3 byte block counts for READ CD.
;
; Could match on model string "Matsushita CD-ROM CR-571B", but not sure
; what the Sony model numbers were?
; Look at the IDENTIFY PACKET DEVICE response and only apply the above
; emulation logic for pre ATAPI-5 drives, since ATAPI-5 came out in 2000
; that covers all the affected models.
; First: trap access to mode 0 discs and treat them as 1/3 i.e. the same as
; READ(10) would do. If the disc is not mode 0, the read will succeed.
......@@ -428,7 +441,8 @@ RD_HowManyBlocks
; retry 1: READ CD mode 2 form 1, else
; retry 0: READ(12), else error
ORR r0,r0,#1<<31
TST r2,#DriveFlag_Read12Unreliable ; skip straight to READ(12) if possible
ORRNE r0,r0,#1<<31 ; retries 2/1/0 to be attempted
Push "r0,r8"
10
; r0 = expected mode 1,2,3
......@@ -447,10 +461,10 @@ RD_HowManyBlocks
ORREQ r14,r5,#2_01111000 << 24 ; flags = all headers/user/EDC/ECC
MOVEQ r2,#2_000 << (24 + 2) ; any type of sector
MOV r1,r0,LSR #30 ; retry
MOV r1,r0,LSR #30 ; look which retry this is
CMP r1,#1
ORRCS r2,r2,#ATAPI__READ_CD << 16 ; opcode
ORRCC r2,r2,#ATAPI__READ_DATA << 16
ORRCC r2,r2,#ATAPI__READ_DATA_12 << 16
BICCC r2,r2,#2_1111 << (24 + 1) ; DPO=0 FUA=0
MOVCC r14,r14,LSL #8 ; knock out flags, make transfer length MSB=0
......
......@@ -333,6 +333,22 @@ MIC_IDEDevInfo
; be achieved by the CD_SCSIUserOp caller specifying larger size
STRB r6, [r5, r4] ; flag this drive is present
; check it supports any recent ATAPI standard, emulate READ(12) otherwise
LDRB r9, [r3, #ATAPIID__MAJOR_VERSION + 1]
LDRB r14,[r3, #ATAPIID__MAJOR_VERSION]
ORR r9,r14,r9,LSL # 8
ADD r14, r9, #1
TEQ r14, #&10000 ; r9 == &FFFF, doesn't report version
MOVEQ r9, #2_10000 ; treat as ATAPI-4
TST r9, #2_1111:SHL:5 ; any of ATAPI-5 to ATAPI-8
ADR r6, DriveFlags ; r6 -> drive flags
MOV r14, #0
ORREQ r14, r14, #DriveFlag_Read12Unreliable
STRB r14, [r6, r4]
; remember that I found one
ORR r8,r8,#1:SHL:16 ; doesn't affect bottom byte
......@@ -431,6 +447,16 @@ MIC_IdentifyLoop
TEQ r5,#5
BNE MIC_DoneCheckForATAPI
; check it supports any recent ATAPI standard, emulate READ(12) otherwise
LDRB r14,buffer + ATAPIID__MAJOR_VERSION
LDRB r8,buffer + ATAPIID__MAJOR_VERSION + 1
ORR r8,r14,r8,LSL # 8
ADD r14,r8,#1
TEQ r14,#&FFFF+1
MOVEQ r8,#0 ; equate &FFFF and &0000 as not reporting version
; check the CMD DRQ type and save a flag to indicate which it is
; note: this assumes that a "microprocessor DRQ" drive can be treated like
; an "accelerated DRQ" - I've not seen one
......@@ -440,16 +466,11 @@ MIC_IdentifyLoop
TEQS r6,#2_00100000 ; interrupt DRQ
MOVEQ r6,#DriveFlag_InterruptDRQ
MOVNE r6,#0 ; treat others as accelerated DRQ
TST r8, #2_1111:SHL:5 ; any of ATAPI-5 to ATAPI-8
ORREQ r6,r6,#DriveFlag_Read12Unreliable
ADR r5,DriveFlags ; r5 -> drive flags
STRB r6,[r5,r0]
[ cdebug
BNE %F01
CDebug_WriteS "This is an interrupt DRQ drive"
B %F02
01
CDebug_WriteS "This is an accelerated DRQ drive"
02
]
STRB r2,[ r1, r0 ] ; flag this drive is present
; remember that I found one
......@@ -646,7 +667,7 @@ SWI__ATAPI_GetDrives
MACRO__EXIT_DRIVER_WITH_R0 , noexit
CMP pc, pc
MOVEQ pc, r14
BICS pc, r14, # Overflow_Flag
BICS pc, r14, # V_bit
swi_error_lookup ; based on error_handler_lookup, but has to be different because of the
......@@ -683,7 +704,7 @@ swi_error_lookup ; based on error_handler_lookup, but has to be different becaus
TEQ pc, pc
MSREQ CPSR_f, #Z_bit :OR: V_bit
MOVEQ pc, r14
ORRS pc, r14, #Overflow_Flag
ORRS pc, r14, #V_bit
;******************************************************************************
;
......
......@@ -65,11 +65,9 @@ DriveRecognisedStatus # MAX_NUMBER_OF_ATAPI_DRIVES ; ATAPI drive co
; ]
DriveMode # MAX_NUMBER_OF_ATAPI_DRIVES ; For SetParameters (1, 2 or 3)
DriveCtlPrtDev # 4*MAX_NUMBER_OF_ATAPI_DRIVES ; For ADFS_ATAPIOp bits 12-23
[ :LNOT: HAL
DriveFlags # MAX_NUMBER_OF_ATAPI_DRIVES ; bits defined below
DriveFlag_InterruptDRQ * 1 << 0 ; CMD DRQ mode
]
DriveFlag_Read12Unreliable * 1 << 1 ; Try READ CD first, then READ 12
; These need to be word aligned - MEW
AlignSpace 4,0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment