Information Technology Reference
In-Depth Information
byte *ptrNextData;
void MSDReadHandler()
{
byte Flags;
word i;
DWORD LBA;
dword sectorNumber;
SDC_Error status;
WORD
TransferLength;
/// The command block stores the MSB first. Device firmware stores the LSB first.
// The starting LBA to read is in bytes 2-5 of the command block.
LBA.v[3] = gblCBW.CBWCB[2];
LBA.v[2] = gblCBW.CBWCB[3];
LBA.v[1] = gblCBW.CBWCB[4];
LBA.v[0] = gblCBW.CBWCB[5];
// The number of blocks to transfer is in bytes 7 and 8 of the CBW.
TransferLength.v[1] = gblCBW.CBWCB[7];
TransferLength.v[0] = gblCBW.CBWCB[8];
// The data-transport phase is device to host.
Flags = gblCBW.CBWCB[1];
// Set default values in the CSW.
msd_csw.bCSWStatus = 0x0; // Success.
msd_csw.dCSWDataResidue = 0x0;
if (LBA._dword + TransferLength._word > gblNumBLKS._dword) {
// The requested blocks extend beyond the available blocks in the media.
// Set bCSWStatus to “command failed.”
// Store sense data to describe the error.
msd_csw.bCSWStatus = 0x01;
gblSenseData.SenseKey = S_ILLEGAL_REQUEST;
gblSenseData.ASC = ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
gblSenseData.ASCQ = ASCQ_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
Search WWH ::




Custom Search