Reduce size of mode pages for SCSI1 hosts
[SCSI2SD.git] / software / SCSI2SD / src / mode.c
index 4ed790f..b234549 100755 (executable)
@@ -51,6 +51,18 @@ static const uint8 ReadWriteErrorRecoveryPage[] =
 0x00, 0x00 // Recovery time limit 0 (use default)*/\r
 };\r
 \r
 0x00, 0x00 // Recovery time limit 0 (use default)*/\r
 };\r
 \r
+static const uint8 ReadWriteErrorRecoveryPage_SCSI1[] =\r
+{\r
+0x01, // Page code\r
+0x06, // Page length\r
+0x26,\r
+0x00, // Don't try recovery algorithm during reads\r
+0x00, // Correction span 0\r
+0x00, // Head offset count 0,\r
+0x00, // Data strobe offset count 0,\r
+0xFF // Reserved\r
+};\r
+\r
 static const uint8 DisconnectReconnectPage[] =\r
 {\r
 0x02, // Page code\r
 static const uint8 DisconnectReconnectPage[] =\r
 {\r
 0x02, // Page code\r
@@ -65,6 +77,18 @@ static const uint8 DisconnectReconnectPage[] =
 0x00, 0x00, 0x00 // Reserved\r
 };\r
 \r
 0x00, 0x00, 0x00 // Reserved\r
 };\r
 \r
+static const uint8 DisconnectReconnectPage_SCSI1[] =\r
+{\r
+0x02, // Page code\r
+0x0A, // Page length\r
+0, // Buffer full ratio\r
+0, // Buffer empty ratio\r
+0x00, 10, // Bus inactivity limit, 100us increments. Allow 1ms.\r
+0x00, 0x00, // Disconnect time limit\r
+0x00, 0x00, // Connect time limit\r
+0x00, 0x00 // Maximum burst size\r
+};\r
+\r
 static const uint8 FormatDevicePage[] =\r
 {\r
 0x03 | 0x80, // Page code | PS (persist) bit.\r
 static const uint8 FormatDevicePage[] =\r
 {\r
 0x03 | 0x80, // Page code | PS (persist) bit.\r
@@ -99,6 +123,21 @@ SCSI_HEADS_PER_CYLINDER, // Number of heads
 0x00, 0x00 // Reserved\r
 };\r
 \r
 0x00, 0x00 // Reserved\r
 };\r
 \r
+static const uint8 RigidDiskDriveGeometry_SCSI1[] =\r
+{\r
+0x04, // Page code\r
+0x12, // Page length\r
+0xFF, 0xFF, 0xFF, // Number of cylinders\r
+SCSI_HEADS_PER_CYLINDER, // Number of heads\r
+0xFF, 0xFF, 0xFF, // Starting cylinder-write precompensation\r
+0xFF, 0xFF, 0xFF, // Starting cylinder-reduced write current\r
+0x00, 0x1, // Drive step rate (units of 100ns)\r
+0x00, 0x00, 0x00, // Landing zone cylinder\r
+0x00, // RPL\r
+0x00, // Rotational offset\r
+0x00 // Reserved\r
+};\r
+\r
 static const uint8 CachingPage[] =\r
 {\r
 0x08, // Page Code\r
 static const uint8 CachingPage[] =\r
 {\r
 0x08, // Page Code\r
@@ -239,15 +278,31 @@ static void doModeSense(
        if (pageCode == 0x01 || pageCode == 0x3F)\r
        {\r
                pageFound = 1;\r
        if (pageCode == 0x01 || pageCode == 0x3F)\r
        {\r
                pageFound = 1;\r
-               pageIn(pc, idx, ReadWriteErrorRecoveryPage, sizeof(ReadWriteErrorRecoveryPage));\r
-               idx += sizeof(ReadWriteErrorRecoveryPage);\r
+               if ((scsiDev.compatMode >= COMPAT_SCSI2))\r
+               {\r
+                       pageIn(pc, idx, ReadWriteErrorRecoveryPage, sizeof(ReadWriteErrorRecoveryPage));\r
+                       idx += sizeof(ReadWriteErrorRecoveryPage);\r
+               }\r
+               else\r
+               {\r
+                       pageIn(pc, idx, ReadWriteErrorRecoveryPage_SCSI1, sizeof(ReadWriteErrorRecoveryPage_SCSI1));\r
+                       idx += sizeof(ReadWriteErrorRecoveryPage_SCSI1);\r
+               }\r
        }\r
 \r
        if (pageCode == 0x02 || pageCode == 0x3F)\r
        {\r
                pageFound = 1;\r
        }\r
 \r
        if (pageCode == 0x02 || pageCode == 0x3F)\r
        {\r
                pageFound = 1;\r
-               pageIn(pc, idx, DisconnectReconnectPage, sizeof(DisconnectReconnectPage));\r
-               idx += sizeof(DisconnectReconnectPage);\r
+               if ((scsiDev.compatMode >= COMPAT_SCSI2))\r
+               {\r
+                       pageIn(pc, idx, DisconnectReconnectPage, sizeof(DisconnectReconnectPage));\r
+                       idx += sizeof(DisconnectReconnectPage);\r
+               }\r
+               else\r
+               {\r
+                       pageIn(pc, idx, DisconnectReconnectPage_SCSI1, sizeof(DisconnectReconnectPage_SCSI1));\r
+                       idx += sizeof(DisconnectReconnectPage_SCSI1);\r
+               }\r
        }\r
 \r
        if (pageCode == 0x03 || pageCode == 0x3F)\r
        }\r
 \r
        if (pageCode == 0x03 || pageCode == 0x3F)\r
@@ -274,7 +329,14 @@ static void doModeSense(
        if (pageCode == 0x04 || pageCode == 0x3F)\r
        {\r
                pageFound = 1;\r
        if (pageCode == 0x04 || pageCode == 0x3F)\r
        {\r
                pageFound = 1;\r
-               pageIn(pc, idx, RigidDiskDriveGeometry, sizeof(RigidDiskDriveGeometry));\r
+               if ((scsiDev.compatMode >= COMPAT_SCSI2))\r
+               {\r
+                       pageIn(pc, idx, RigidDiskDriveGeometry, sizeof(RigidDiskDriveGeometry));\r
+               }\r
+               else\r
+               {\r
+                       pageIn(pc, idx, RigidDiskDriveGeometry_SCSI1, sizeof(RigidDiskDriveGeometry_SCSI1));\r
+               }\r
 \r
                if (pc != 0x01)\r
                {\r
 \r
                if (pc != 0x01)\r
                {\r
@@ -299,7 +361,14 @@ static void doModeSense(
                        memcpy(&scsiDev.data[idx+9], &scsiDev.data[idx+2], 3);\r
                }\r
 \r
                        memcpy(&scsiDev.data[idx+9], &scsiDev.data[idx+2], 3);\r
                }\r
 \r
-               idx += sizeof(RigidDiskDriveGeometry);\r
+               if ((scsiDev.compatMode >= COMPAT_SCSI2))\r
+               {\r
+                       idx += sizeof(RigidDiskDriveGeometry);\r
+               }\r
+               else\r
+               {\r
+                       idx += sizeof(RigidDiskDriveGeometry_SCSI1);\r
+               }\r
        }\r
 \r
        // DON'T output the following pages for SCSI1 hosts. They get upset when\r
        }\r
 \r
        // DON'T output the following pages for SCSI1 hosts. They get upset when\r