Jelajahi Sumber

Squashed commit of the following:

commit ad2e0d3da7c029d657826ee68fe5d02c7ef883c1
Merge: ce3dc03c 894d48b7
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Tue Feb 27 15:01:52 2024 +0000

    Merge branch 'main' of https://github.com/RobSmithDev/BlueSCSI-v2 into main

commit ce3dc03c8a85a0932697ad4178c6bdb0aab65cdd
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Sat Feb 24 10:26:59 2024 +0000

    Tidy-up to move all Amiga read operations to alt command so there shouldn't be any conflict with original use

commit bf6df5e84d38ad46b953a6999750a6f4fdb9d3b6
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Tue Feb 20 18:52:47 2024 +0000

    Extra support to make the gvpscsi.device happy on the Amiga

commit 2322ee95b0ad6d99e92a8a59da495d996af28554
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Mon Feb 19 15:20:54 2024 +0000

    Small comment change

commit 2a54038a19baa67b052d2e9414a0e1276c24b7b1
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Sun Feb 18 18:05:06 2024 +0000

    Changes required for amiga scsi.device and gvpscsi.device to use the daynaport properly

commit 894d48b749071ba3038237b780fd4a75e695d6f1
Merge: d7765dfd 23a42129
Author: Rob Smith <RobSmithDev@users.noreply.github.com>
Date:   Tue Feb 27 14:53:33 2024 +0000

    Merge branch 'BlueSCSI:main' into main

commit d7765dfdb8e1c68957592eefebff01a952e7ad16
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Sat Feb 24 10:26:59 2024 +0000

    Tidy-up to move all Amiga read operations to alt command so there shouldn't be any conflict with original use

commit a5abecb0c29f40f1533b4be07ed8133f29fd92cb
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Tue Feb 20 18:52:47 2024 +0000

    Extra support to make the gvpscsi.device happy on the Amiga

commit 9d029fbc67b0b7338ac0e13f5111201bf1f4c6e2
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Mon Feb 19 15:20:54 2024 +0000

    Small comment change

commit 77e901e7096db6684fa3f452e11ace7b403139ae
Author: Rob Smith <rob@robsmithdev.co.uk>
Date:   Sun Feb 18 18:05:06 2024 +0000

    Changes required for amiga scsi.device and gvpscsi.device to use the daynaport properly
Rob Smith 1 tahun lalu
induk
melakukan
d8fc0b17ee
2 mengubah file dengan 74 tambahan dan 16 penghapusan
  1. 67 16
      lib/SCSI2SD/src/firmware/network.c
  2. 7 0
      lib/SCSI2SD/src/firmware/network.h

+ 67 - 16
lib/SCSI2SD/src/firmware/network.c

@@ -104,6 +104,12 @@ int scsiNetworkCommand()
 
 	DBGMSG_F("------ in scsiNetworkCommand with command 0x%02x (size %d)", command, size);
 
+	// Rather than duplicating code, this just diverts a 'fake' read request to make the gvpscsi.device happy on the Amiga
+	if ((scsiDev.cdb[0] == SCSI_NETWORK_WIFI_CMD) && (scsiDev.cdb[1] == SCSI_NETWORK_WIFI_CMD_ALTREAD)) {
+		// Redirect the command as a READ.
+		command = 0x08;
+	}
+
 	switch (command) {
 	case 0x08:
 		// read(6)
@@ -156,26 +162,62 @@ int scsiNetworkCommand()
 
 			DBGMSG_BUF(scsiDev.data, scsiDev.dataLen);
 		}
+		// Patches around the weirdness on the Amiga SCSI devices
+		if ((scsiDev.cdb[0] == SCSI_NETWORK_WIFI_CMD) && (scsiDev.cdb[1] == SCSI_NETWORK_WIFI_CMD_ALTREAD)) {
+			scsiDev.data[2] = scsiDev.cdb[2];    // for me really
+			int extra = 0;
+			if (scsiDev.cdb[2] == AMIGASCSI_PATCH_24BYTE_BLOCKSIZE) {
+				if (scsiDev.dataLen<90) scsiDev.dataLen = 90;
+				int missing = (scsiDev.dataLen-90) % 24;
+				if (missing) {
+					scsiDev.dataLen += 24 - missing;
+					if (scsiDev.dataLen>NETWORK_PACKET_MAX_SIZE) {
+						extra = scsiDev.dataLen - NETWORK_PACKET_MAX_SIZE;
+						scsiDev.dataLen = NETWORK_PACKET_MAX_SIZE;
+					}
+				}
+				scsiEnterPhase(DATA_IN);
+				scsiWrite(scsiDev.data, scsiDev.dataLen);
+				while (!scsiIsWriteFinished(NULL))
+				{
+					platform_poll();
+				}
+				scsiFinishWrite();
+			} else {
+				extra = scsiDev.dataLen;     // F9 means send in ONE transaction
+				if (extra) scsiEnterPhase(DATA_IN);
+			}
 
-		// DaynaPort driver needs a delay between reading the initial packet size and the data so manually do two transfers
-		scsiEnterPhase(DATA_IN);
-		scsiWrite(scsiDev.data, 6);
-		while (!scsiIsWriteFinished(NULL))
-		{
-			platform_poll();
-		}
-		scsiFinishWrite();
-
-		if (scsiDev.dataLen > 6)
-		{
-			s2s_delay_us(80);
-
-			scsiWrite(scsiDev.data + 6, scsiDev.dataLen - 6);
+			if (extra) {
+				// Just write the extra data to make the padding work for such a large packet
+				scsiWrite(scsiDev.data, extra);
+				while (!scsiIsWriteFinished(NULL))
+				{
+					platform_poll();
+				}
+				scsiFinishWrite();
+			}
+		} else {
+			// DaynaPort driver needs a delay between reading the initial packet size and the data so manually do two transfers
+			scsiEnterPhase(DATA_IN);
+			scsiWrite(scsiDev.data, 6);
 			while (!scsiIsWriteFinished(NULL))
 			{
 				platform_poll();
 			}
 			scsiFinishWrite();
+
+			if (scsiDev.dataLen > 6)
+			{
+				s2s_delay_us(80);
+
+				scsiWrite(scsiDev.data + 6, scsiDev.dataLen - 6);
+				while (!scsiIsWriteFinished(NULL))
+				{
+					platform_poll();
+				}
+				scsiFinishWrite();
+			}
 		}
 
 		scsiDev.status = GOOD;
@@ -396,6 +438,14 @@ int scsiNetworkCommand()
 			scsiDev.phase = STATUS;
 			break;
 		}
+
+		case SCSI_NETWORK_WIFI_CMD_GETMACADDRESS:
+			// Update for the gvpscsi.device on the Amiga as it doesn't like 0x09 command being called! - NOTE this only sends 6 bytes back
+			memcpy(scsiDev.data, scsiDev.boardCfg.wifiMACAddress, sizeof(scsiDev.boardCfg.wifiMACAddress));
+			memset(scsiDev.data + sizeof(scsiDev.boardCfg.wifiMACAddress), 0, sizeof(scsiDev.data) - sizeof(scsiDev.boardCfg.wifiMACAddress));
+
+			scsiDev.dataLen = 6;
+			scsiDev.phase = DATA_IN;
 		}
 		break;
 
@@ -403,6 +453,7 @@ int scsiNetworkCommand()
 		handled = 0;
 	}
 
+
 	return handled;
 }
 
@@ -435,7 +486,7 @@ int scsiNetworkEnqueue(const uint8_t *buf, size_t len)
 	{
 		DBGMSG_F("%s: dropping packets in ring, write index caught up to read index", __func__);
 	}
-	
+
 	return 1;
 }
 
@@ -454,7 +505,7 @@ int scsiNetworkPurge(void)
 			scsiNetworkOutboundQueue.readIndex = 0;
 		else
 			scsiNetworkOutboundQueue.readIndex++;
-		
+
 		sent++;
 	}
 

+ 7 - 0
lib/SCSI2SD/src/firmware/network.h

@@ -30,6 +30,13 @@ extern "C" {
 #define SCSI_NETWORK_WIFI_CMD_INFO			0x04
 #define SCSI_NETWORK_WIFI_CMD_JOIN			0x05
 
+// Patches to make the DaynaPORT (or whats left of it) work on the Amiga - RobSmithDev
+#define SCSI_NETWORK_WIFI_CMD_ALTREAD       0x08   // gvpscsi.device on AMIGA doesnt like the standard version
+#define SCSI_NETWORK_WIFI_CMD_GETMACADDRESS 0x09   // gvpscsi.device on AMIGA doesnt like the standard version
+
+#define AMIGASCSI_PATCH_24BYTE_BLOCKSIZE 	0xA8   // In this mode, data written is rounded up to the nearest 24-byte boundary
+#define AMIGASCSI_PATCH_SINGLEWRITE_ONLY 	0xA9   // In this mode, data written is always ONLY as one single write command
+
 #define NETWORK_PACKET_QUEUE_SIZE   20		// must be <= 255
 #define NETWORK_PACKET_MAX_SIZE     1520