Support ATAPI raw sector reading with READ CD command #3622
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains 2 fixes for the ATAPI IDE emulation regarding the READ CD command.
What issue(s) does this PR address?
Maybe #585? It was the only one that came up with my searches.
Together with the PR #3623 it partially addresses #211.
Does this PR introduce new feature(s)?
Fix the ATAPI READ CD (0xBE) command by adding a missing break statement. Without it, it would accidentally fall through into the next case which would then overwrite
TransferLength
with an invalid value which then can cause memory corruption in the following call toon_atapi_busy_time
by callingReadSectorsHost
with aTransferLength
that fills the 64ksector
buffer past its length.Add support for reading raw and CDDA sectors of size 2352 bytes. It does so by passing
true
for theraw
argument of theReadSectorsHost
function which is already equipped to read 2352 bytes that way. Implementations for other transfer types and lengths are not part of this PR.Does this PR introduce any breaking change(s)?
No, it only adds new functionality where otherwise "Unsupported sector type" warnings would have been logged.
Additional information
To fully comply with the READ CD command described in the ATAPI standard, ide.cpp would need to know more about the track layout of the CD. For example information if it's a MODE2 track or track boundaries to refuse when requested to read across them.
Maybe it would make more sense to change
ReadSectorsHost
to something likeReadSectorsATAPI
which gets called with all the information (TransferSectorType
,TransferSectorSize
,TransferLength
) and have theCDROM_Interface
implementation comply with the request in a manner that matches the standard.