From: Michael McMaster Date: Tue, 24 Jan 2017 10:23:29 +0000 (+1000) Subject: Fix SCSI inquiry command with 0 byte allocation length X-Git-Tag: v6.1.0~2 X-Git-Url: http://git.codesrc.com/gitweb.cgi?a=commitdiff_plain;h=63fcb3816de26a52e4b4686e244b8feaf5fbe8ad;p=SCSI2SD-V6.git Fix SCSI inquiry command with 0 byte allocation length --- diff --git a/rtl/fpga_bitmap.o b/rtl/fpga_bitmap.o index c4ec7a48..6cbce7c5 100644 Binary files a/rtl/fpga_bitmap.o and b/rtl/fpga_bitmap.o differ diff --git a/src/firmware/inquiry.c b/src/firmware/inquiry.c index d51b3c0d..70dca308 100755 --- a/src/firmware/inquiry.c +++ b/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)); diff --git a/src/firmware/scsi.c b/src/firmware/scsi.c index bf20f9df..0b9b8078 100755 --- a/src/firmware/scsi.c +++ b/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 { diff --git a/src/firmware/scsi.h b/src/firmware/scsi.h index 33f3c085..50724564 100755 --- a/src/firmware/scsi.h +++ b/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;