[hatari-devel] ACSI: READ/WRITE (10) incorrectly evaluate block number

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi all,

When reading/writing sectors with READ (10) and WRITE (10) the block number
is not correctly evaluated. This results in the drive image being
damaged when writing with WRITE (10). At least images > 1 GB are affected.

This is from hdc.c:

static unsigned long HDC_GetOffset(void)
{
	/* offset = logical block address * 512 */
	return HDCCommand.opcode < 0x20?
		// class 0
		(HDC_ReadInt24(HDCCommand.command, 1) & 0x1FFFFF) << 9 :
		// class 1
		HDC_ReadInt32(HDCCommand.command, 2) << 9;
}

I think that the last line is wrong because the 32 bit block number is
shifted to the left for no apparent reason. This should be:

        return HDCCommand.opcode < 0x20?
                // class 0
                (HDC_ReadInt24(HDCCommand.command, 1) & 0x1FFFFF) << 9 :
                // class 1
                HDC_ReadInt32(HDCCommand.command, 2);

I stumbled upon this problem when running a small test program that
compares the data read by various SCSI READ commands. Before applying
this change a mismatch was reported, after applying the patch the same
data are returned for both READ (6) and READ (10).

Take care

Uwe




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/