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

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


Please discard the previous patch and use this one.

> Hi,
> 
> Thank you. Attached there is a patch for nf_scsidrv.c.
> 
> Best regards
> 
> Uwe
> 
> > Le 11/10/2018 à 22:11, Uwe Seimet a écrit :
> > > Hi,
> > > 
> > >> I don't see these flushes in your nf_scsidrv.c Hatari code.
> > >>
> > >> Tested patches welcome! :-)
> > > 
> > > Since I cannot reproduce the original issue anymore, which is not that
> > > surprising if it's about caches, I will only be able to test that currently
> > > with this patch on my machine it works as expected.
> > > 
> > > But first I need a hint how to correctly convert "unsigned char *" to
> > > uaecptr. Of course, I could just pass 0, becausing flushing ignores
> > > the address and size anyway :-).
> > > 
> > 
> > uaecptr is just a 32 bit pointer to somewhere in the emulated machine 
> > memory, so it's just an unsigned int
> > 
> > src/cpu/sysdeps.h:typedef uae_u32 uaecptr;
> > 
> > for example, look at GemDOS_SNext() in gemdos.c
> > 
> > Nicolas
> > 
> > 

> 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 22:51:41 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_Data_Cache(st_buffer, transfer_len);
> +        }
> +
> +        return status;
>  }
>  
>  // SCSI Driver: Error()

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:08:51 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_Data_Cache(st_buffer, transfer_len);
+        }
+
+        return status;
 }
 
 // SCSI Driver: Error()


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