Procházet zdrojové kódy

Merge pull request #434 from ZuluSCSI/fix/reorder-vendor-logic

Adjust logic for supported vendor commands
Alex Perez před 1 rokem
rodič
revize
c0d8027c1d

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

@@ -599,8 +599,15 @@ static void process_Command()
 	{
 		enter_Status(CONFLICT);
 	}
+	// Handle Toolbox commands, overriding other vendor commands if enabled
+	else if (scsiToolboxEnabled() && scsiToolboxCommand())
+	{
+		// already handled
+	}
 	// Handle odd device types first that may override basic read and
 	// write commands. Will fall-through to generic disk handling.
+	// Some device specific vendor commands are located here instead
+	// of in scsiVendorCommand()
 	else if (((cfg->deviceType == S2S_CFG_OPTICAL) && scsiCDRomCommand()) ||
 		((cfg->deviceType == S2S_CFG_SEQUENTIAL) && scsiTapeCommand()) ||
 #ifdef ZULUSCSI_NETWORK

+ 12 - 17
lib/SCSI2SD/src/firmware/vendor.c

@@ -171,10 +171,6 @@ int scsiVendorCommand()
 	  // XEBEC S1410 controller
 	  // Stub, return success
 	}   	
-	else if (scsiToolboxEnabled() && scsiToolboxCommand())
-	{
-		// already handled
-	}
 	else
 	{
 		commandHandled = 0;
@@ -185,7 +181,16 @@ int scsiVendorCommand()
 
 void scsiVendorCommandSetLen(uint8_t command, uint8_t* command_length)
 {
-	if (scsiDev.target->cfg->deviceType == S2S_CFG_OPTICAL)
+	if (scsiToolboxEnabled())
+	{
+		// Conflicts with Apple CD-ROM audio over SCSI bus and Plextor CD-ROM D8 extension
+		// Will override those commands if enabled
+		if (0xD0 <= command && command <= 0xDA)
+		{
+			*command_length = 10;
+		}
+	}
+	else if (scsiDev.target->cfg->deviceType == S2S_CFG_OPTICAL)
 	{
 		// Apple CD-ROM with CD audio over the SCSI bus
 		if (scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_APPLE && (command == 0xD8 || command == 0xD9))
@@ -193,19 +198,9 @@ void scsiVendorCommandSetLen(uint8_t command, uint8_t* command_length)
 			*command_length =  12;
 		}
 		// Plextor CD-ROM vendor extensions 0xD8
-		if (unlikely(scsiDev.target->cfg->vendorExtensions & VENDOR_EXTENSION_OPTICAL_PLEXTOR) && command == 0xD8)
+		else if (unlikely(scsiDev.target->cfg->vendorExtensions & VENDOR_EXTENSION_OPTICAL_PLEXTOR) && command == 0xD8)
 		{
 			*command_length =  12;
 		}
 	}
-
-	if (scsiToolboxEnabled())
-	{
-		// Conflicts with Apple CD-ROM audio over SCSI bus and Plextor CD-ROM D8 extension
-		// Will override those commands if enabled
-		if (0xD0 <= command && command <= 0xDA)
-		{
-			*command_length = 10;
-		}
-	}
-}
+}

+ 1 - 1
src/ZuluSCSI.cpp

@@ -580,7 +580,7 @@ bool findHDDImages()
     }
   }
   // count the removable drives and drive with eject enabled
-  for (uint8_t id; id < S2S_MAX_TARGETS; id++)
+  for (uint8_t id = 0; id < S2S_MAX_TARGETS; id++)
   {
     const S2S_TargetCfg* cfg = s2s_getConfigByIndex(id);
     if (cfg  && (cfg->scsiId & S2S_CFG_TARGET_ENABLED ))