]> localhost Git - SCSI2SD.git/commitdiff
Add scsi mode page 0 support
authorMichael McMaster <michael@codesrc.com>
Wed, 22 May 2019 10:01:44 +0000 (20:01 +1000)
committerMichael McMaster <michael@codesrc.com>
Wed, 22 May 2019 10:01:44 +0000 (20:01 +1000)
software/SCSI2SD/src/inquiry.c
software/SCSI2SD/src/inquiry.h
software/SCSI2SD/src/mode.c

index 5e006ca0e6b8a77e24b53d5c565631166fd142c2..463b8ea89c94d89054671f0ee74812f54f8fbb50 100755 (executable)
@@ -157,6 +157,7 @@ void scsiInquiry()
                        memcpy(&scsiDev.data[8], config->vendor, sizeof(config->vendor));
                        memcpy(&scsiDev.data[16], config->prodId, sizeof(config->prodId));
                        memcpy(&scsiDev.data[32], config->revision, sizeof(config->revision));
+
                        scsiDev.dataLen = sizeof(StandardResponse) +
                                sizeof(config->vendor) +
                                sizeof(config->prodId) +
@@ -229,20 +230,19 @@ void scsiInquiry()
                scsiDev.dataLen = allocationLength;
 
                // Set the device type as needed.
+               scsiDev.data[0] = getDeviceTypeQualifier();
+
                switch (scsiDev.target->cfg->deviceType)
                {
                case CONFIG_OPTICAL:
-                       scsiDev.data[0] = 0x05; // device type
                        scsiDev.data[1] |= 0x80; // Removable bit.
                        break;
 
                case CONFIG_SEQUENTIAL:
-                       scsiDev.data[0] = 0x01; // device type
                        scsiDev.data[1] |= 0x80; // Removable bit.
                        break;
                        
                case CONFIG_MO:
-                       scsiDev.data[0] = 0x07; // device type
                        scsiDev.data[1] |= 0x80; // Removable bit.
                        break;
 
@@ -254,6 +254,7 @@ void scsiInquiry()
                        // Accept defaults for a fixed disk.
                        break;
                }
+
        }
 
        // Set the first byte to indicate LUN presence.
@@ -263,3 +264,31 @@ void scsiInquiry()
        }
 }
 
+uint8_t getDeviceTypeQualifier()
+{
+       // Set the device type as needed.
+       switch (scsiDev.target->cfg->deviceType)
+       {
+       case CONFIG_OPTICAL:
+               return 0x05;
+               break;
+
+       case CONFIG_SEQUENTIAL:
+               return 0x01;
+               break;
+
+       case CONFIG_MO:
+               return 0x07;
+               break;
+
+       case CONFIG_FLOPPY_14MB:
+       case CONFIG_REMOVEABLE:
+               return 0;
+               break;
+
+       default:
+               // Accept defaults for a fixed disk.
+               return 0;
+       }
+}
+
index c707b275b8576c984b59e1fd4418ceadbabdb61d..0e0909cb8a0df1ea497634cbec1aa7983c526e0e 100755 (executable)
@@ -19,4 +19,6 @@
 
 void scsiInquiry(void);
 
+uint8_t getDeviceTypeQualifier(void);
+
 #endif
index 95d00e9ab587a5fa5c088cfdcf72a5c9b96f7430..bd9ccc22a5783e83537801689a3278216af2fa93 100755 (executable)
 #include "scsi.h"\r
 #include "mode.h"\r
 #include "disk.h"\r
+#include "inquiry.h"\r
 \r
 #include <string.h>\r
 \r
+// "Vendor" defined page which was included by Seagate, and required for\r
+// Amiga 500 using DKB SpitFire controller.\r
+static const uint8 OperatingPage[] =\r
+{\r
+0x00, // Page code\r
+0x02, // Page length\r
+\r
+// Bit 4 = unit attension (0 = on, 1 = off).\r
+// Bit 7 = usage bit, EEPROM life exceeded warning = 1.\r
+0x80, \r
+\r
+// Bit 7 = reserved.\r
+// Bits 0:6: Device type qualifier, as per Inquiry data\r
+0x00\r
+};\r
+\r
 static const uint8 ReadWriteErrorRecoveryPage[] =\r
 {\r
 0x01, // Page code\r
@@ -518,6 +535,21 @@ static void doModeSense(
                idx += sizeof(AppleVendorPage);\r
        }\r
 \r
+       // SCSI 2 standard says page 0 is always last.\r
+       if (pageCode == 0x00 || pageCode == 0x3F)\r
+       {\r
+               pageFound = 1;\r
+               pageIn(pc, idx, OperatingPage, sizeof(OperatingPage));\r
+\r
+               // Note inverted logic for the flag.\r
+               scsiDev.data[idx+2] =\r
+                       (scsiDev.boardCfg.flags & CONFIG_ENABLE_UNIT_ATTENTION) ? 0x80 : 0x90;\r
+\r
+               scsiDev.data[idx+3] = getDeviceTypeQualifier();\r
+\r
+               idx += sizeof(OperatingPage);\r
+       }\r
+\r
        if (!pageFound)\r
        {\r
                // Unknown Page Code\r