Fix onReadCapacity calculation

This commit is contained in:
Eric Helgeson 2022-06-24 13:39:43 -05:00
parent 4dbba493d7
commit 52a0936fbc

View File

@ -999,16 +999,18 @@ byte onRequestSense(SCSI_DEVICE *dev, const byte *cdb)
* READ CAPACITY command processing.
*/
byte onReadCapacity(SCSI_DEVICE *dev, const byte *cdb)
{
{
uint32_t blocksize = dev->m_blocksize;
uint32_t blockcount = dev->m_fileSize / blocksize - 1; // Points to last LBA
uint8_t buf[8] = {
dev->m_blockcount >> 24,
dev->m_blockcount >> 16,
dev->m_blockcount >> 8,
dev->m_blockcount - 1, // Points to last LBA
dev->m_blocksize >> 24,
dev->m_blocksize >> 16,
dev->m_blocksize >> 8,
dev->m_blocksize
blockcount >> 24,
blockcount >> 16,
blockcount >> 8,
blockcount,
blocksize >> 24,
blocksize >> 16,
blocksize >> 8,
blocksize
};
writeDataPhase(8, buf);
return SCSI_STATUS_GOOD;