Bladeren bron

Attempt at supporting the vendor 0xD8 command

This is a CD data read that is mainly for Plextor CDROM drives.
It is a vendor CD Data read used mainly in duplicating CDs.
It support reading more raw data then the other CD Read commands
for better CD cloning.

This is an attempt to address issue https://github.com/ZuluSCSI/ZuluSCSI-firmware/issues/258
Morio 1 jaar geleden
bovenliggende
commit
de540b811d
3 gewijzigde bestanden met toevoegingen van 44 en 0 verwijderingen
  1. 6 0
      lib/SCSI2SD/src/firmware/scsi.c
  2. 37 0
      src/ZuluSCSI_cdrom.cpp
  3. 1 0
      src/ZuluSCSI_log_trace.cpp

+ 6 - 0
lib/SCSI2SD/src/firmware/scsi.c

@@ -301,6 +301,12 @@ static void process_Command()
 
 	group = scsiDev.cdb[0] >> 5;
 	scsiDev.cdbLen = CmdGroupBytes[group];
+	// vendor specific SCSI command lengths
+	if (scsiDev.cdb[0] == 0xD8)
+	{
+		// Plextor CD-ROM drive - Vendor Read Command
+		scsiDev.cdbLen =  12;
+	}
 	if (parityError &&
 		(scsiDev.boardCfg.flags & S2S_CFG_ENABLE_PARITY))
 	{

+ 37 - 0
src/ZuluSCSI_cdrom.cpp

@@ -2140,6 +2140,43 @@ extern "C" int scsiCDRomCommand()
 
         doReadCD(lba, blocks, 0, 0x10, 0, true);
     }
+    else if (command == 0xD8)
+    {
+        const uint32_t CD_DATA_SIZE = 2352;
+        const uint32_t CD_C2_SIZE = 294;
+        const uint32_t CD_SUBCODE_SIZE = 96;
+        const uint32_t CD_RAW_DATA_SIZE = CD_DATA_SIZE + CD_C2_SIZE + CD_SUBCODE_SIZE;
+        uint8_t lun = scsiDev.cdb[1] & 0x7;
+        uint8_t subcode = scsiDev.cdb[10];
+        if (lun != 0)
+        {
+            logmsg("Error - only LUN 0 supported for plextor vender 0xD8 command CDDA Read. Given ", (int)lun);
+            commandHandled = 0;
+        }
+        else if (subcode != 0)
+        {
+            logmsg("Error - Subcodes not supported yet. Given ", subcode);
+            commandHandled = 0;
+        }
+        else
+        {
+            uint32_t lba =
+                (((uint32_t) scsiDev.cdb[2]) << 24) +
+                (((uint32_t) scsiDev.cdb[3]) << 16) +
+                (((uint32_t) scsiDev.cdb[4]) << 8) +
+                scsiDev.cdb[5];
+            uint32_t blocks =
+                (((uint32_t) scsiDev.cdb[6]) << 24) +
+                (((uint32_t) scsiDev.cdb[7]) << 16) +
+                (((uint32_t) scsiDev.cdb[8]) << 8) +
+                scsiDev.cdb[9];
+            uint32_t original_bytes_per_sector = scsiDev.target->liveCfg.bytesPerSector;
+            scsiDev.target->liveCfg.bytesPerSector = CD_RAW_DATA_SIZE; 
+            dbgmsg("Doing a Plextor 0xD8 CDDA Read, starting: ", (int)lba, " length: ",(int)blocks, " byte-per-sector:", (int) CD_RAW_DATA_SIZE );
+            scsiDiskStartRead(lba, blocks);
+            scsiDev.target->liveCfg.bytesPerSector = original_bytes_per_sector;
+        }
+    }
     else if (command == 0x4E)
     {
         // STOP PLAY/SCAN

+ 1 - 0
src/ZuluSCSI_log_trace.cpp

@@ -100,6 +100,7 @@ static const char *getCommandName(uint8_t cmd)
         case 0xA8: return "Read12";
         case 0xC0: return "OMTI-5204 DefineFlexibleDiskFormat";
         case 0xC2: return "OMTI-5204 AssignDiskParameters";
+        case 0xD8: return "Plextor ReadCD";
         default:   return "Unknown";
     }
 }