Re: [hatari-devel] Problem with ACSI/DMA: partially solved

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


Hi,

> This behavior has definitely something to do with the ACSI emulation as
> it only happens when executing certain ACSI commands. Suddenly the whole
> ACSI emulation appears to be broken and wrong data are returned.

I have found what caused these problems: The command class check in
hdc.c is wrong. It says:

	if ((HDCCommand.opcode < 0x20 && HDCCommand.byteCount >= 6) ||
		(HDCCommand.opcode < 0x40 && HDCCommand.byteCount >=
10))

This should be

        if ((HDCCommand.opcode < 0x20 && HDCCommand.byteCount >= 6) ||
                (HDCCommand.opcode < 0x60 && HDCCommand.byteCount >=
10))

because all commands < 0x60 (and not just 0x40) are 10 byte commands.
(One of the commands I was sending was 0x46.)

Additionally, if this condition evaluates to false the status is
nevertheless set to OK:

		HDCCommand.returnCode = HD_STATUS_OK;

Shouldn't it be HD_STATUS_ERROR in this case, just like with commands <
0x20 if they are not actually implemented?

With these changes (see new attached patch) at least the strange
behavior with ACSI (crash/emulation hanging) is gone.

TEST UNIT READY is still not logged by Hatari, so the potential DMA
start address problem from one of my previous postings is not yet
resolved.

Take care

Uwe
diff -r 558497b06d63 src/hdc.c
--- a/src/hdc.c	Mon Oct 07 23:58:34 2013 +0200
+++ b/src/hdc.c	Fri Oct 11 23:02:29 2013 +0200
@@ -89,12 +89,12 @@
 	0,                /* device type qualifier (nonremovable) */
 	1,                /* ANSI version */
 	0,                /* reserved */
-	26,               /* length of the following data */
-	' ', ' ', ' ',                         /* Vendor specific data */
+	31,               /* length of the following data */
+	0,0,0,                                 /* Vendor specific data */
 	'H','a','t','a','r','i',' ',' ',       /* Vendor */
 	'E','m','u','l','a','t','e','d',       /* Model */
-	' ',' ',' ',' ',                       /* Revision */
-	0,0,0,0,0,0,0,0,0,0                    /* ?? */
+	' ',' ',' ',' ',' ',' ',' ',' ',
+	' ',' ',' ',' '                        /* Revision */
 };
 
 
@@ -192,6 +192,10 @@
 	if (count > (int)sizeof(inquiry_bytes))
 		count = sizeof(inquiry_bytes);
 
+	/* For unsupported LUNs set the Peripheral Qualifier and the
+	   Peripheral Device Type according to the SCSI standard */
+        inquiry_bytes[0] = HDC_GetDevice() == 0 ? 0 : 0x7F;
+
 	inquiry_bytes[4] = count - 8;
 
 	if (STMemory_SafeCopy(nDmaAddr, inquiry_bytes, count, "HDC DMA inquiry"))
@@ -412,7 +416,7 @@
 		STRam[nDmaAddr++] = 0x00;
 
 		/* Update DMA counter */
-		FDC_WriteDMAAddress(nDmaAddr + 8);
+		FDC_WriteDMAAddress(nDmaAddr);
 
 		HDCCommand.returnCode = HD_STATUS_OK;
 		nLastError = HD_REQSENS_OK;
@@ -902,13 +906,14 @@
 
 	/* have we received a complete 6-byte class 0 or 10-byte class 1 packet yet? */
 	if ((HDCCommand.opcode < 0x20 && HDCCommand.byteCount >= 6) ||
-		(HDCCommand.opcode < 0x40 && HDCCommand.byteCount >= 10))
+		(HDCCommand.opcode < 0x60 && HDCCommand.byteCount >= 10))
 	{
 #ifdef HDC_REALLY_VERBOSE
 		HDC_DebugCommandPacket(stderr);
 #endif
-		/* If it's aimed for our drive, emulate it! */
-		if (HDC_GetDevice() == 0)
+		/* If it's aimed for our drive, emulate it!
+		   INQUIRY must always be handled, see SCSI standard */
+		if (HDC_GetDevice() == 0 || HDCCommand.opcode == 0x12)
 		{
 			HDC_EmulateCommandPacket();
 		}
@@ -925,6 +930,6 @@
 	{
 		FDC_AcknowledgeInterrupt();
 		FDC_SetDMAStatus(false);
-		HDCCommand.returnCode = HD_STATUS_OK;
+		HDCCommand.returnCode = HD_STATUS_ERROR;
 	}
 }


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