BOOL CDisk::SendIOCommand( DWORD dwStartSector, DWORD dwNumberOfSectors, BYTE bCmd ) { DEBUGMSG(ZONE_IO, (TEXT( "Atapi!CDisk::SendIOCommand> sector(%d), sectors left(%x), command(%x)\r\n" ), dwStartSector,dwNumberOfSectors,bCmd)); if (ZONE_CELOG) CeLogData(TRUE, CELID_ATAPI_IOCOMMAND, &bCmd, sizeof(bCmd), 0, CELZONE_ALWAYSON, 0, FALSE); SelectDevice(); if (WaitOnBusy(FALSE)) { DEBUGMSG(ZONE_IO, (TEXT( "Atapi!CDisk::SendIOCommand> Failed to send command; status(%x), error(%x)\r\n" ), GetAltStatus(),GetError())); return FALSE; } // to transfer 256 sectors, set number of sectors to 0 if (dwNumberOfSectors == MAX_SECT_PER_COMMAND) { dwNumberOfSectors = 0; } WriteSectorCount((BYTE)dwNumberOfSectors); if (m_fLBAMode == TRUE) { WriteSectorNumber( (BYTE)dwStartSector); WriteLowCount((BYTE)(dwStartSector >> 8)); WriteHighCount((BYTE)(dwStartSector >> 16)); WriteDriveHeadReg((BYTE)((dwStartSector >> 24) | ATA_HEAD_LBA_MODE) | ((m_dwDevice == 0 ) ? ATA_HEAD_DRIVE_1 : ATA_HEAD_DRIVE_2)); }
BOOL CDisk::SendIOCommand( DWORD dwStartSector, DWORD dwNumberOfSectors, BYTE bCmd ) { DEBUGMSG(ZONE_IO, (TEXT( "Atapi!CDisk::SendIOCommand> sector(%d), sectors left(%x), command(%x)\r\n" ), dwStartSector,dwNumberOfSectors,bCmd)); RETAILMSG(0, (TEXT( "Atapi!CDisk::SendIOCommand> sector(%d), sectors left(%x), command(%x)\r\n" ), dwStartSector,dwNumberOfSectors,bCmd)); if (ZONE_CELOG) CeLogData(TRUE, CELID_ATAPI_IOCOMMAND, &bCmd, sizeof(bCmd), 0, CELZONE_ALWAYSON, 0, FALSE); SelectDevice(); if (WaitOnBusy(FALSE)) { DEBUGMSG(ZONE_IO, (TEXT( "Atapi!CDisk::SendIOCommand> Failed to send command; status(%x), error(%x)\r\n" ), GetAltStatus(),GetError())); RETAILMSG(1, (TEXT( "Atapi!CDisk::SendIOCommand> Failed to send command; status(%x), error(%x)\r\n" ), GetAltStatus(),GetError())); return FALSE; } if (m_fUseLBA48) { ASSERT(dwNumberOfSectors <= MAX_SECT_PER_EXT_COMMAND); // to transfer 65536 sectors, set number of sectors to 0 if (dwNumberOfSectors == MAX_SECT_PER_EXT_COMMAND) { dwNumberOfSectors = 0; } WriteSectorCount((BYTE)(dwNumberOfSectors >> 8)); // Sector Count 15:8 WriteSectorCount((BYTE)(dwNumberOfSectors)); // Sector Count 7:0 // CE supports only 32-bit LBA as of now. Therefore, clear the upper 16 bits of LBA. WriteHighCount(0); // LBA 47:40 WriteLowCount(0); // LBA 39:32 WriteSectorNumber((BYTE)(dwStartSector >> 24)); // LBA 31:24 WriteHighCount((BYTE)(dwStartSector >> 16)); // LBA 23:16 WriteLowCount((BYTE)(dwStartSector >> 8)); // LBA 15:8 WriteSectorNumber((BYTE)dwStartSector); // LBA 7:0 WriteDriveHeadReg( ATA_HEAD_LBA_MODE | ((m_dwDevice == 0 ) ? ATA_HEAD_DRIVE_1 : ATA_HEAD_DRIVE_2)); } else {