Re: [hatari-devel] bugreport: ACSI-diskimage access - bogus/bouncing command byte

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


Hi,

I attach diff -u and second the complete (changed) hdc.c

Martin


Am 17.07.20 um 17:58 schrieb Eero Tamminen:

> The preferred diff format is unified one which
> gives context for the changes, so that there's
> a bit larger chance that it will get applied to
> correct place.
> 
> You can get that either with:
> 
> * "diff -u <old file> <new file>", or
> 


--- hdc.c.original	2019-02-08 09:30:11.000000000 +0100
+++ hdc.c.bugfix	2020-07-17 16:05:37.595296685 +0200
@@ -26,6 +26,7 @@
 #include "tos.h"
 #include "statusbar.h"
 
+#define FIX_BYTECOUNT_BUG	1	// 2020-07-17 Martin van der Koelen
 
 /*
   ACSI emulation: 
@@ -960,9 +961,19 @@
 		ctr->command[ctr->byteCount] = b;
 	++ctr->byteCount;
 
+    // vdk: 2020-07-15:
+    // encountered bogus/superfluous command byte, but A1 still 1
+    // -> so reset byteCount only if A1 is cleared to 0 (not here!) and
+    // drain the garbage ...
+
 	/* have we received a complete 6-byte class 0 or 10-byte class 1 packet yet? */
+   #if FIX_BYTECOUNT_BUG
+	if ((ctr->byteCount == 6  &&  ctr->opcode <  0x20) ||
+	    (ctr->byteCount == 10 &&  ctr->opcode >= 0x20 && ctr->opcode < 0x60))
+   #else    // original:
 	if ((ctr->opcode < 0x20 && ctr->byteCount >= 6) ||
 	    (ctr->opcode < 0x60 && ctr->byteCount >= 10))
+   #endif
 	{
 		/* We currently only support LUN 0, however INQUIRY must
 		 * always be handled, see SCSI standard */
@@ -987,8 +998,12 @@
 				ctr->status = HD_STATUS_ERROR;
 			}
 		}
-
-		ctr->byteCount = 0;
+   #if FIX_BYTECOUNT_BUG
+	  // Dont reset byteCount here!
+	  // => only in Acsi_WriteCommandByte() if A1 is set to zero
+   #else
+	ctr->byteCount = 0;
+   #endif
 	}
 	else if (ctr->opcode >= 0x60)
 	{

Attachment: hdc.c.bugfix.gz
Description: application/gzip



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