소스 검색

Added additional commands, fix for 0xE0 command that have diffrent meaning for Xebec and Iomega, allow basic command for LUN devices for fit LUN to target, and have 0xE4 report GOOD

Per Mårtensson 1 개월 전
부모
커밋
fe4e973baa
1개의 변경된 파일42개의 추가작업 그리고 15개의 파일을 삭제
  1. 42 15
      lib/SCSI2SD/src/firmware/scsi.c

+ 42 - 15
lib/SCSI2SD/src/firmware/scsi.c

@@ -323,17 +323,17 @@ static void process_DataOut()
 }
 
 static const uint8_t CmdGroupBytes[] = {
-	6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
-	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
-	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
-	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
-	10,10,10,10,10,10,10,10,10,10,10,10,10,16,16,16,16,16,16,16,16,
-	16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-	16,16,16,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
-	12,12,12,12,12,12,12,12,12,12,12,12,12,12,10,10,10,10,10,10,10,
-	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
-	10,10,10,10,10,10,10,10,10,10,10,10,10,10
+	6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
+	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
+	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
+	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
+	10,10,10,10,10,10,10,10,10,10,10,10,10,16,16,16,16,16,16,16,16,16,
+	16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
+	16,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+	12,12,12,12,12,12,12,12,12,12,12,10,10,10,10,10,10,10,10,10,10,10,
+	10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,6,6,6,6,
+	6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
 };
 
 static void process_Command()
@@ -360,7 +360,11 @@ static void process_Command()
 
 	scsiDev.cdbLen = CmdGroupBytes[scsiDev.cdb[0]];
 	scsiVendorCommandSetLen(scsiDev.cdb[0], &scsiDev.cdbLen);
-
+	// Special handling for Xebec commands - 0xE0 should be 6 bytes, not 10 as for Iomega
+	if (scsiDev.cdb[0] == 0xE0) {
+		scsiDev.cdbLen = 6;  // Xebec Drive Status is 6 bytes
+		DBGMSG_F("SCSI: 0xE0 Xebec command, forcing cdbLen=6");
+	}
 	if (parityError &&
 		(scsiDev.boardCfg.flags & S2S_CFG_ENABLE_PARITY))
 	{
@@ -654,9 +658,24 @@ static void process_Command()
 	}
 	else if (scsiDev.lun && (command < 0xD0))
 	{
-		scsiDev.target->sense.code = ILLEGAL_REQUEST;
-		scsiDev.target->sense.asc = LOGICAL_UNIT_NOT_SUPPORTED;
-		enter_Status(CHECK_CONDITION);
+		// For Xebec controllers, allow basic commands to LUNs 1-3 but report drive not ready
+		// instead of rejecting the LUN entirely
+		if (scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_XEBEC && scsiDev.lun >= 1 && scsiDev.lun <= 3)
+		{
+			// Xebec hosts probe LUNs 1-3 to see if additional drives exist
+			// Since we only have LUN 0 configured, report LUNs 1-3 as not ready
+			DBGMSG_F("SCSI: Xebec LUN %d command 0x%02X - reporting drive not ready", scsiDev.lun, command);
+			scsiDev.target->sense.code = NOT_READY;
+			scsiDev.target->sense.asc = MEDIUM_NOT_PRESENT;
+			enter_Status(CHECK_CONDITION);
+			return;
+		}
+		else
+		{
+			scsiDev.target->sense.code = ILLEGAL_REQUEST;
+			scsiDev.target->sense.asc = LOGICAL_UNIT_NOT_SUPPORTED;
+			enter_Status(CHECK_CONDITION);
+		}
 	}
 	else if (command == 0x17 || command == 0x16)
 	{
@@ -707,6 +726,14 @@ static void process_Command()
 	{
 		scsiReadBuffer();
 	}
+	else if (command == 0xE4 && 
+	         scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_XEBEC)
+	{
+		// 0xE4 is drive diagnostic
+		DBGMSG_F("Xebec 0xE4 Drive Diagnostic - direct handling");
+		// No data transfer needed, go directly to STATUS
+		enter_Status(GOOD);
+	}
 	else if (scsiModeCommand())
 	{
 		// handled