From: Michael McMaster Date: Wed, 22 May 2019 10:53:14 +0000 (+1000) Subject: Add scsi mode page 0 support (merge from v5) X-Git-Tag: v6.2.5~2 X-Git-Url: http://git.codesrc.com/gitweb.cgi?a=commitdiff_plain;h=304f5acd613f9bbc39efe826cf536eb6908ddc5a;p=SCSI2SD-V6.git Add scsi mode page 0 support (merge from v5) --- diff --git a/src/firmware/inquiry.c b/src/firmware/inquiry.c index 70dca308..99bb8dc0 100755 --- a/src/firmware/inquiry.c +++ b/src/firmware/inquiry.c @@ -171,20 +171,19 @@ void s2s_scsiInquiry() scsiDev.dataLen = allocationLength; // Set the device type as needed. + scsiDev.data[0] = getDeviceTypeQualifier(); + switch (scsiDev.target->cfg->deviceType) { case S2S_CFG_OPTICAL: - scsiDev.data[0] = 0x05; // device type scsiDev.data[1] |= 0x80; // Removable bit. break; case S2S_CFG_SEQUENTIAL: - scsiDev.data[0] = 0x01; // device type scsiDev.data[1] |= 0x80; // Removable bit. break; case S2S_CFG_MO: - scsiDev.data[0] = 0x07; // device type scsiDev.data[1] |= 0x80; // Removable bit. break; @@ -227,3 +226,32 @@ uint32_t s2s_getStandardInquiry( sizeof(cfg->prodId) + sizeof(cfg->revision); } + +uint8_t getDeviceTypeQualifier() +{ + // Set the device type as needed. + switch (scsiDev.target->cfg->deviceType) + { + case S2S_CFG_OPTICAL: + return 0x05; + break; + + case S2S_CFG_SEQUENTIAL: + return 0x01; + break; + + case S2S_CFG_MO: + return 0x07; + break; + + case S2S_CFG_FLOPPY_14MB: + case S2S_CFG_REMOVEABLE: + return 0; + break; + + default: + // Accept defaults for a fixed disk. + return 0; + } +} + diff --git a/src/firmware/inquiry.h b/src/firmware/inquiry.h index 29da7776..963b6595 100755 --- a/src/firmware/inquiry.h +++ b/src/firmware/inquiry.h @@ -19,5 +19,7 @@ void s2s_scsiInquiry(void); uint32_t s2s_getStandardInquiry(const S2S_TargetCfg* cfg, uint8_t* out, uint32_t maxlen); +uint8_t getDeviceTypeQualifier(void); + #endif diff --git a/src/firmware/mode.c b/src/firmware/mode.c index 773059a8..fd4ba344 100755 --- a/src/firmware/mode.c +++ b/src/firmware/mode.c @@ -19,9 +19,26 @@ #include "scsi.h" #include "mode.h" #include "disk.h" +#include "inquiry.h" #include +// "Vendor" defined page which was included by Seagate, and required for\r +// Amiga 500 using DKB SpitFire controller.\r +static const uint8_t OperatingPage[] = +{ +0x00, // Page code +0x02, // Page length + +// Bit 4 = unit attension (0 = on, 1 = off). +// Bit 7 = usage bit, EEPROM life exceeded warning = 1. +0x80, + +// Bit 7 = reserved. +// Bits 0:6: Device type qualifier, as per Inquiry data +0x00 +}; + static const uint8_t ReadWriteErrorRecoveryPage[] = { 0x01, // Page code @@ -508,6 +525,21 @@ static void doModeSense( idx += sizeof(CCSCachingPage); } + // SCSI 2 standard says page 0 is always last. + if (pageCode == 0x00 || pageCode == 0x3F) + { + pageFound = 1; + pageIn(pc, idx, OperatingPage, sizeof(OperatingPage)); + + // Note inverted logic for the flag. + scsiDev.data[idx+2] = + (scsiDev.boardCfg.flags & S2S_CFG_ENABLE_UNIT_ATTENTION) ? 0x80 : 0x90; + + scsiDev.data[idx+3] = getDeviceTypeQualifier(); + + idx += sizeof(OperatingPage); + } + if (!pageFound) { // Unknown Page Code