瀏覽代碼

Fix SCSI inquiry command with 0 byte allocation length

Michael McMaster 8 年之前
父節點
當前提交
986562b59c
共有 4 個文件被更改,包括 16 次插入2 次删除
  1. 二進制
      lib/SCSI2SD/rtl/fpga_bitmap.o
  2. 10 1
      lib/SCSI2SD/src/firmware/inquiry.c
  3. 1 1
      lib/SCSI2SD/src/firmware/scsi.c
  4. 5 0
      lib/SCSI2SD/src/firmware/scsi.h

二進制
lib/SCSI2SD/rtl/fpga_bitmap.o


+ 10 - 1
lib/SCSI2SD/src/firmware/inquiry.c

@@ -85,7 +85,11 @@ void s2s_scsiInquiry()
 	uint32_t allocationLength = scsiDev.cdb[4];
 
 	// SASI standard, X3T9.3_185_RevE  states that 0 == 256 bytes
-	if (allocationLength == 0) allocationLength = 256;
+	// BUT SCSI 2 standard says 0 == 0.
+	if (scsiDev.compatMode <= COMPAT_SCSI1) // excludes COMPAT_SCSI2_DISABLED
+	{
+		if (allocationLength == 0) allocationLength = 256;
+	}
 
 	if (!evpd)
 	{
@@ -210,6 +214,11 @@ uint32_t s2s_getStandardInquiry(
 
 	memcpy(out, StandardResponse, buflen);
 	out[1] = cfg->deviceTypeModifier;
+
+	if (scsiDev.compatMode >= COMPAT_SCSI2)
+	{
+		out[3] = 2; // SCSI 2 response format.
+	}
 	memcpy(&out[8], cfg->vendor, sizeof(cfg->vendor));
 	memcpy(&out[16], cfg->prodId, sizeof(cfg->prodId));
 	memcpy(&out[32], cfg->revision, sizeof(cfg->revision));

+ 1 - 1
lib/SCSI2SD/src/firmware/scsi.c

@@ -596,7 +596,7 @@ static void process_SelectionPhase()
 		}
 		else if (!(scsiDev.boardCfg.flags & S2S_CFG_ENABLE_SCSI2))
 		{
-			scsiDev.compatMode = COMPAT_SCSI1;
+			scsiDev.compatMode = COMPAT_SCSI2_DISABLED;
 		}
 		else
 		{

+ 5 - 0
lib/SCSI2SD/src/firmware/scsi.h

@@ -63,6 +63,11 @@ typedef enum
 {
 	COMPAT_UNKNOWN,
 	COMPAT_SCSI1,
+
+	// Messages are being used, yet SCSI 2 mode is disabled.
+	// This impacts interpretation of INQUIRY commands.
+	COMPAT_SCSI2_DISABLED,
+
 	COMPAT_SCSI2
 } SCSI_COMPAT_MODE;