Re: [hatari-devel] Cycle exact setting affects nf_scsidrv

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

> Is st_buffer data something that could be program code read from
> the SCSI disk?  If yes, all caches would need to be flushed for that.

Yes, you are probably right. Just checked that I'm also flushing both in
HDDRIVER. One more updated patch attached. The sense data buffer and
the buffer for the bus name do not need flushing the instruction cache
because you cannot transfer program code this way.

Best regards

Uwe 
diff -r e87617b4fe45 src/nf_scsidrv.c
--- a/src/nf_scsidrv.c	Thu Oct 11 18:30:37 2018 +0200
+++ b/src/nf_scsidrv.c	Thu Oct 11 23:23:59 2018 +0200
@@ -28,6 +28,7 @@
 #include "stMemory.h"
 #include "log.h"
 #include "gemdos_defines.h"
+#include "m68000.h"
 #include "nf_scsidrv.h"
 
 // The driver interface version, 1.02
@@ -173,11 +174,13 @@
 
 static int scsidrv_interface_features(Uint32 stack)
 {
+        Uint32 st_bus_name = STMemory_ReadLong(stack);
 	char *busName = read_stack_pointer(&stack);
 	Uint32 features = read_stack_long(&stack);
 	Uint32 transferLen = read_stack_long(&stack);
 
 	strncpy(busName, BUS_NAME, 20);
+        M68000_Flush_Data_Cache(st_bus_name, 20);
 	write_word(features, BUS_FEATURES);
 	write_long(transferLen, BUS_TRANSFER_LEN);
 
@@ -288,8 +291,10 @@
 	Uint32 dir = read_stack_long(&stack);
 	unsigned char *cmd = read_stack_pointer(&stack);
 	Uint32 cmd_len = read_stack_long(&stack);
+        Uint32 st_buffer = STMemory_ReadLong(stack);
 	unsigned char *buffer = read_stack_pointer(&stack);
 	Uint32 transfer_len = read_stack_long(&stack);
+        Uint32 st_sense_buffer = STMemory_ReadLong(stack);
 	unsigned char *sense_buffer = read_stack_pointer(&stack);
 	Uint32 timeout;
 	int status;
@@ -331,6 +336,7 @@
 			// Sense Key and ASC
 			sense_buffer[2] = 0x05;
 			sense_buffer[12] = 0x25;
+                        M68000_Flush_Data_Cache(st_sense_buffer, 18);
 
 			LOG_TRACE(TRACE_SCSIDRV,
 			          "\n               Sense Key=$%02X, ASC=$%02X, ASCQ=$00",
@@ -415,7 +421,13 @@
 		}
 	}
 
-	return status;
+        M68000_Flush_Data_Cache(st_sense_buffer, 18);
+        if (!dir)
+        {
+            M68000_Flush_All_Caches(st_buffer, transfer_len);
+        }
+
+        return status;
 }
 
 // SCSI Driver: Error()


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/