Add READ DEFECT DATA command emulation
authorMichael McMaster <michael@codesrc.com>
Mon, 2 Dec 2019 09:25:08 +0000 (19:25 +1000)
committerMichael McMaster <michael@codesrc.com>
Mon, 2 Dec 2019 09:25:08 +0000 (19:25 +1000)
software/SCSI2SD/src/disk.c

index 0afe03f..6122133 100755 (executable)
@@ -522,11 +522,21 @@ int scsiDiskCommand()
        else if (unlikely(command == 0x37))\r
        {\r
                // READ DEFECT DATA\r
-               scsiDev.status = CHECK_CONDITION;\r
-               scsiDev.target->sense.code = NO_SENSE;\r
-               scsiDev.target->sense.asc = DEFECT_LIST_NOT_FOUND;\r
-               scsiDev.phase = STATUS;\r
+               uint32_t allocLength = (((uint16_t)scsiDev.cdb[7]) << 8) |\r
+                       scsiDev.cdb[8];\r
+\r
+               scsiDev.data[0] = 0;\r
+               scsiDev.data[1] = scsiDev.cdb[1]\r
+               scsiDev.data[2] = 0;\r
+               scsiDev.data[3] = 0;\r
+               scsiDev.dataLen = 4;\r
 \r
+               if (scsiDev.dataLen > allocLength)\r
+               {\r
+                       scsiDev.dataLen = allocLength;\r
+               }\r
+\r
+               scsiDev.phase = DATA_IN;\r
        }\r
        else\r
        {\r