Fix SCSI inquiry command with 0 byte allocation length
authorMichael McMaster <michael@codesrc.com>
Tue, 24 Jan 2017 10:23:29 +0000 (20:23 +1000)
committerMichael McMaster <michael@codesrc.com>
Tue, 24 Jan 2017 10:23:29 +0000 (20:23 +1000)
rtl/fpga_bitmap.o
src/firmware/inquiry.c
src/firmware/scsi.c
src/firmware/scsi.h

index c4ec7a4..6cbce7c 100644 (file)
Binary files a/rtl/fpga_bitmap.o and b/rtl/fpga_bitmap.o differ
index d51b3c0..70dca30 100755 (executable)
@@ -85,7 +85,11 @@ void s2s_scsiInquiry()
        uint32_t allocationLength = scsiDev.cdb[4];\r
 \r
        // SASI standard, X3T9.3_185_RevE  states that 0 == 256 bytes\r
-       if (allocationLength == 0) allocationLength = 256;\r
+       // BUT SCSI 2 standard says 0 == 0.\r
+       if (scsiDev.compatMode <= COMPAT_SCSI1) // excludes COMPAT_SCSI2_DISABLED\r
+       {\r
+               if (allocationLength == 0) allocationLength = 256;\r
+       }\r
 \r
        if (!evpd)\r
        {\r
@@ -210,6 +214,11 @@ uint32_t s2s_getStandardInquiry(
 \r
        memcpy(out, StandardResponse, buflen);\r
        out[1] = cfg->deviceTypeModifier;\r
+\r
+       if (scsiDev.compatMode >= COMPAT_SCSI2)\r
+       {\r
+               out[3] = 2; // SCSI 2 response format.\r
+       }\r
        memcpy(&out[8], cfg->vendor, sizeof(cfg->vendor));\r
        memcpy(&out[16], cfg->prodId, sizeof(cfg->prodId));\r
        memcpy(&out[32], cfg->revision, sizeof(cfg->revision));\r
index bf20f9d..0b9b807 100755 (executable)
@@ -596,7 +596,7 @@ static void process_SelectionPhase()
                }\r
                else if (!(scsiDev.boardCfg.flags & S2S_CFG_ENABLE_SCSI2))\r
                {\r
-                       scsiDev.compatMode = COMPAT_SCSI1;\r
+                       scsiDev.compatMode = COMPAT_SCSI2_DISABLED;\r
                }\r
                else\r
                {\r
index 33f3c08..5072456 100755 (executable)
@@ -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;