瀏覽代碼

Merge pull request #196 from BlueSCSI/eric/152

scsi: fix std inquiry len set when vendor info is added.
Eric Helgeson 1 年之前
父節點
當前提交
58ae67e5d4

+ 1 - 1
lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.h

@@ -16,7 +16,7 @@ extern const char *g_platform_name;
 #define PLATFORM_NAME "BlueSCSI"
 #define PLATFORM_REVISION "2.0"
 #define PLATFORM_TOOLBOX_API 0
-#define PLATFORM_INQUIRY PLATFORM_NAME " v" BLUESCSI_FW_VERSION
+#define PLATFORM_INQUIRY PLATFORM_NAME "v" FW_VER_NUM
 #define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_10
 #define PLATFORM_OPTIMAL_MIN_SD_WRITE_SIZE 32768
 #define PLATFORM_OPTIMAL_MAX_SD_WRITE_SIZE 65536

+ 15 - 15
lib/SCSI2SD/src/firmware/inquiry.c

@@ -29,13 +29,13 @@ static uint8_t StandardResponse[] =
 0x00, // device type modifier
 0x02, // Complies with ANSI SCSI-2.
 0x01, // Response format is compatible with the old CCS format.
-0x1f, // standard length.
+INQUIRY_STD_RESPONSE_LEN, // Additional data size. standard length: 0x1f (31)
 0, 0, // Reserved
 0x18 // Enable sync and linked commands
 };
-// Vendor set by config 'c','o','d','e','s','r','c',' ',
-// prodId set by config'S','C','S','I','2','S','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',
-// Revision set by config'2','.','0','a'
+// Vendor set by config - 8
+// prodId set by config - 16
+// Revision set by config - 4
 
 
 static const uint8_t SupportedVitalPages[] =
@@ -258,22 +258,22 @@ uint32_t s2s_getStandardInquiry(
 		sizeof(cfg->vendor) +
 		sizeof(cfg->prodId) +
 		sizeof(cfg->revision);
-
+    // Vendor Unique Parameters
     if(cfg->deviceType == S2S_CFG_ZIP100) {
         memcpy(&out[size], IOMegaVendorInquiry, sizeof(IOMegaVendorInquiry));
         size += sizeof(IOMegaVendorInquiry);
         out[7] = 0x00; // Disable sync and linked commands
-        out[4] = 0x75; // 117 length
+        out[INQUIRY_STD_RESPONSE_LEN_OFFSET] = 0x75; // 117 length
+    } else if(cfg->deviceType != S2S_CFG_NETWORK) {
+        // Mac Daynaport Driver does not like this added.
+        memcpy(&out[size], PLATFORM_INQUIRY, sizeof(PLATFORM_INQUIRY) - 1);
+        size += sizeof(PLATFORM_INQUIRY) - 1;
+        out[size++] = PLATFORM_TOOLBOX_API;
+        out[INQUIRY_STD_RESPONSE_LEN_OFFSET] = INQUIRY_STD_RESPONSE_LEN +
+                                               (sizeof(PLATFORM_INQUIRY) - 1)
+                                               + 1; // PLATFORM_TOOLBOX_API
     }
-	// Mac Daynaport Driver does not like this added.
-    // IOMega already has a vendor inquiry
-	if(cfg->deviceType != S2S_CFG_NETWORK && cfg->deviceType != S2S_CFG_ZIP100) {
-		memcpy(&out[size], PLATFORM_INQUIRY, sizeof(PLATFORM_INQUIRY));
-		size += sizeof(PLATFORM_INQUIRY);
-		out[size] = PLATFORM_TOOLBOX_API;
-		size += 1;
-	}
-	return size;
+    return size;
 }
 
 uint8_t getDeviceTypeQualifier()

+ 3 - 0
lib/SCSI2SD/src/firmware/inquiry.h

@@ -17,6 +17,9 @@
 #ifndef S2S_INQUIRY_H
 #define S2S_INQUIRY_H
 
+#define INQUIRY_STD_RESPONSE_LEN_OFFSET 4
+#define INQUIRY_STD_RESPONSE_LEN 0x1f // 31
+
 void s2s_scsiInquiry(void);
 uint32_t s2s_getStandardInquiry(const S2S_TargetCfg* cfg, uint8_t* out, uint32_t maxlen);
 uint8_t getDeviceTypeQualifier(void);