Re: [hatari-devel] WinUAE core freeze with ST emulation, solved but another question about gemdos drive.

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


Hi,

On maanantai 28 toukokuu 2012, Thomas Huth wrote:
> It's all about black magic .... ;-) No, honestly, the culprit here was
> currprefs.cpu_level which is used in GemDOS_OpCode() to find the right
> offset to the parameters on the stack.
>
> currprefs.cpu_level is a old-UAE only variable, the WinUAE core uses
> currprefs.cpu_model instead. So to keep both happy, the Hatari code and
> the WinUAE code, both variables need to stay in sync. They were synced
> already in Init680x0(), but when the CPU model was changed on the fly,
> currprefs.cpu_level was not updated anymore. I committed a fix for this
> problem now, so GEMDOS HD should now also work with the WinUAE core as
> expected.

Thanks, I've verified that the case I listed works now!

So does starting with --machine st --tos <ST tos>, and after
that switching to Falcon TOS (with my patch applied[1] that
adds WinUAE specific stuff to TOS based machine type switching).

However, starting with --machine falcon --tos tos404.img,
and then switching to ST TOS freezes Hatari when emulation
resets.  Hatari spends its time in m68k_run_1_ce() and some
opcode calls to OpCode_SysInit(), see attachment.



[1] Attached.

Btw. Does your this patch:
http://hg.tuxfamily.org/mercurialroot/hatari/hatari/rev/a941332bd17b

make it unnecessary to turn cycle exact / compatible (prefetch)
options off for ST?


	- Eero
CPU: Intel Architectural Perfmon, speed 1197 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (No unit mask) count 100000
samples  %        image name               symbol name
7188770  94.1186  hatari                   m68k_run_1_ce
396728    5.1941  hatari                   OpCode_SysInit
37951     0.4969  libasound.so.2.0.0       /usr/lib/libasound.so.2.0.0
13736     0.1798  no-vmlinux               /no-vmlinux
154       0.0020  libSDL-1.2.so.0.11.3     /usr/lib/libSDL-1.2.so.0.11.3
124       0.0016  [vdso] (tgid:3746 range:0xb76f1000-0xb76f2000) [vdso] (tgid:3746 range:0xb76f1000-0xb76f2000)
119       0.0016  libc-2.11.3.so           memcpy
78        0.0010  libc-2.11.3.so           memset
45       5.9e-04  libc-2.11.3.so           ioctl
41       5.4e-04  hatari                   Audio_CallBack
35       4.6e-04  libpthread-2.11.3.so     pthread_mutex_lock
33       4.3e-04  libc-2.11.3.so           semop
28       3.7e-04  libc-2.11.3.so           __i686.get_pc_thunk.bx
26       3.4e-04  libc-2.11.3.so           poll
25       3.3e-04  libpthread-2.11.3.so     read
23       3.0e-04  libc-2.11.3.so           __libc_disable_asynccancel
16       2.1e-04  libc-2.11.3.so           __libc_enable_asynccancel
12       1.6e-04  libpthread-2.11.3.so     __pthread_enable_asynccancel
11       1.4e-04  libpthread-2.11.3.so     __pthread_mutex_unlock_usercnt
9        1.2e-04  libpthread-2.11.3.so     __i686.get_pc_thunk.bx
9        1.2e-04  libpthread-2.11.3.so     pthread_mutex_unlock
8        1.0e-04  libpthread-2.11.3.so     __read_nocancel
7        9.2e-05  libpthread-2.11.3.so     __pthread_disable_asynccancel

               :static void m68k_run_1_ce (void)
               :{ /* m68k_run_1_ce total: 7188770 94.1186 */
               :	struct regstruct *r = &regs;
               :
               :	currcycle = 0;
               :
               :	ipl_fetch ();
               :	for (;;) {
   923  0.0121 :		uae_u32 opcode = r->ir;
               :
               :		/*m68k_dumpstate(stderr, NULL);*/
3133254 41.0220 :		if (LOG_TRACE_LEVEL(TRACE_CPU_DISASM))
               :		{
               :			int FrameCycles, HblCounterVideo, LineCycles;
               :			Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
               :			LOG_TRACE_PRINT ( "cpu video_cyc=%6d %3d@%3d : " , FrameCycles, LineCycles, HblCounterVideo );
               :			m68k_disasm(stderr, m68k_getpc (), NULL, 1);
               :		}
               :
               :#if DEBUG_CD32CDTVIO
               :		out_cd32io (m68k_getpc ());
               :#endif
2258328 29.5671 :		(*cpufunctbl[opcode])(opcode);
               :
               :		/* HACK for Hatari: Adding cycles should of course not be done
               :		 * here in CE mode (so this should be removed later), but until
               :		 * we're really there, this helps to get this mode running at
               :		 * at least to a basic extend! */
  1143  0.0150 :		M68000_AddCyclesWithPairing(currcycle * 2 / CYCLE_UNIT);
 18632  0.2439 :		currcycle = 0;
 77737  1.0178 :		while ( ( PendingInterruptCount <= 0 ) && ( PendingInterruptFunction ) && ( ( regs.spcflags & SPCFLAG_STOP ) == 0 ) ) {
               :			CALL_VAR(PendingInterruptFunction);		/* call the interrupt handler */
               :			do_specialties_interrupt(false);		/* test if there's an mfp/video interrupt and add non pending jitter */
               :		}
               :
168247  2.2028 :		if (r->spcflags) {
               :			if (do_specialties (0))
               :				return;
               :		}
1337689 17.5136 :		if (!currprefs.cpu_cycle_exact || currprefs.cpu_model > 68000)
               :			return;
               :	}
               :}
diff -r 06bf8c690bed src/change.c
--- a/src/change.c	Mon May 28 23:44:41 2012 +0300
+++ b/src/change.c	Mon May 28 23:49:50 2012 +0300
@@ -119,13 +119,17 @@
 		return true;
 
 	/* Did change CPU prefetch mode? */
-	if (changed->System.bCompatibleCpu != current->System.bCompatibleCpu)
+	if (changed->System.bPrefetchCpu != current->System.bPrefetchCpu)
 		return true;
 
 	/* Did change CPU cycle exact? */
 	if (changed->System.bCycleExactCpu != current->System.bCycleExactCpu)
 		return true;
 
+	/* Did change FPU? */
+	if (changed->System.n_FPUType != current->System.n_FPUType)
+		return true;
+
 	/* Did change MMU? */
 	if (changed->System.bMMU != current->System.bMMU)
 		return true;
diff -r 06bf8c690bed src/configuration.c
--- a/src/configuration.c	Mon May 28 23:44:41 2012 +0300
+++ b/src/configuration.c	Mon May 28 23:49:50 2012 +0300
@@ -331,6 +331,7 @@
 
 #if ENABLE_WINUAE_CPU
 	{ "bAddressSpace24", Bool_Tag, &ConfigureParams.System.bAddressSpace24 },
+	{ "bPrefetchCpu", Bool_Tag, &ConfigureParams.System.bPrefetchCpu },
 	{ "bCycleExactCpu", Bool_Tag, &ConfigureParams.System.bCycleExactCpu },
 	{ "n_FPUType", Int_Tag, &ConfigureParams.System.n_FPUType },
 	{ "bCompatibleFPU", Bool_Tag, &ConfigureParams.System.bCompatibleFPU },
@@ -512,23 +513,32 @@
 	strcpy(ConfigureParams.Rom.szCartridgeImageFileName, "");
 
 	/* Set defaults for System */
+#if ENABLE_WINUAE_CPU
+	/* Default to Falcon with WinUAE CPU core... */
+	ConfigureParams.System.nMachineType = MACHINE_FALCON;
+	ConfigureParams.System.nCpuLevel = 3;
+	ConfigureParams.System.nCpuFreq = 16;
+	ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
+
+	ConfigureParams.System.bAddressSpace24 = true;
+	ConfigureParams.System.bPrefetchCpu = true;
+	ConfigureParams.System.bCycleExactCpu = true;
+	ConfigureParams.System.n_FPUType = FPU_68882;
+	ConfigureParams.System.bCompatibleFPU = true;
+	ConfigureParams.System.bMMU = false;
+#else
+	/* ...and to ST with old UAE CPU core */
+	ConfigureParams.System.nMachineType = MACHINE_ST;
 	ConfigureParams.System.nCpuLevel = 0;
 	ConfigureParams.System.nCpuFreq = 8;
+	ConfigureParams.System.nDSPType = DSP_TYPE_NONE;
+#endif
 	ConfigureParams.System.bCompatibleCpu = true;
-	ConfigureParams.System.nMachineType = MACHINE_ST;
 	ConfigureParams.System.bBlitter = false;
-	ConfigureParams.System.nDSPType = DSP_TYPE_NONE;
 	ConfigureParams.System.bPatchTimerD = true;
 	ConfigureParams.System.bFastBoot = true;
 	ConfigureParams.System.bRealTimeClock = true;
 	ConfigureParams.System.bFastForward = false;
-#if ENABLE_WINUAE_CPU
-	ConfigureParams.System.bAddressSpace24 = true;
-	ConfigureParams.System.bCycleExactCpu = false;
-	ConfigureParams.System.n_FPUType = FPU_NONE;
-	ConfigureParams.System.bCompatibleFPU = false;
-	ConfigureParams.System.bMMU = false;
-#endif
 
 	/* Set defaults for Video */
 #if HAVE_LIBPNG
@@ -786,6 +796,7 @@
 
 #if ENABLE_WINUAE_CPU
 	MemorySnapShot_Store(&ConfigureParams.System.bAddressSpace24, sizeof(ConfigureParams.System.bAddressSpace24));
+	MemorySnapShot_Store(&ConfigureParams.System.bPrefetchCpu, sizeof(ConfigureParams.System.bPrefetchCpu));
 	MemorySnapShot_Store(&ConfigureParams.System.bCycleExactCpu, sizeof(ConfigureParams.System.bCycleExactCpu));
 	MemorySnapShot_Store(&ConfigureParams.System.n_FPUType, sizeof(ConfigureParams.System.n_FPUType));
 	MemorySnapShot_Store(&ConfigureParams.System.bCompatibleFPU, sizeof(ConfigureParams.System.bCompatibleFPU));
diff -r 06bf8c690bed src/cpu/hatari-glue.c
--- a/src/cpu/hatari-glue.c	Mon May 28 23:44:41 2012 +0300
+++ b/src/cpu/hatari-glue.c	Mon May 28 23:49:50 2012 +0300
@@ -99,7 +99,7 @@
 		default: fprintf (stderr, "Init680x0() : Error, cpu_level unknown\n");
 	}
 	
-	currprefs.cpu_compatible = changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
+	currprefs.cpu_compatible = changed_prefs.cpu_compatible = ConfigureParams.System.bPrefetchCpu;
 	currprefs.address_space_24 = changed_prefs.address_space_24 = ConfigureParams.System.bAddressSpace24;
 	currprefs.cpu_cycle_exact = changed_prefs.cpu_cycle_exact = ConfigureParams.System.bCycleExactCpu;
 	currprefs.fpu_model = changed_prefs.fpu_model = ConfigureParams.System.n_FPUType;
diff -r 06bf8c690bed src/gui-sdl/dlgSystem.c
--- a/src/gui-sdl/dlgSystem.c	Mon May 28 23:44:41 2012 +0300
+++ b/src/gui-sdl/dlgSystem.c	Mon May 28 23:49:50 2012 +0300
@@ -343,7 +343,7 @@
 		systemdlg[DLGSYS_DSPON].state |= SG_SELECTED;
 
 	/* More compatible CPU, Prefetch mode */
-	if (ConfigureParams.System.bCompatibleCpu)
+	if (ConfigureParams.System.bPrefetchCpu)
 		systemdlg[DLGSYS_PREFETCH].state |= SG_SELECTED;
 	else
 		systemdlg[DLGSYS_PREFETCH].state &= ~SG_SELECTED;
@@ -442,7 +442,7 @@
 	else
 		ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
 
-	ConfigureParams.System.bCompatibleCpu = (systemdlg[DLGSYS_PREFETCH].state & SG_SELECTED);
+	ConfigureParams.System.bPrefetchCpu = (systemdlg[DLGSYS_PREFETCH].state & SG_SELECTED);
 	ConfigureParams.System.bBlitter = (systemdlg[DLGSYS_BLITTER].state & SG_SELECTED);
 	ConfigureParams.System.bRealTimeClock = (systemdlg[DLGSYS_RTC].state & SG_SELECTED);
 	ConfigureParams.System.bPatchTimerD = (systemdlg[DLGSYS_TIMERD].state & SG_SELECTED);
diff -r 06bf8c690bed src/includes/configuration.h
--- a/src/includes/configuration.h	Mon May 28 23:44:41 2012 +0300
+++ b/src/includes/configuration.h	Mon May 28 23:49:50 2012 +0300
@@ -283,6 +283,7 @@
 
 #if ENABLE_WINUAE_CPU
   bool bAddressSpace24;
+  bool bPrefetchCpu;
   bool bCycleExactCpu;
   FPUTYPE n_FPUType;
   bool bCompatibleFPU;            /* More compatible FPU */
diff -r 06bf8c690bed src/m68000.c
--- a/src/m68000.c	Mon May 28 23:44:41 2012 +0300
+++ b/src/m68000.c	Mon May 28 23:49:50 2012 +0300
@@ -276,7 +276,6 @@
 		nCpuFreqShift = 1;
 	}
 	changed_prefs.cpu_level = ConfigureParams.System.nCpuLevel;
-	changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
 
 #if ENABLE_WINUAE_CPU
 	/* WinUAE core uses cpu_model instead of cpu_level, so we've got to
@@ -297,6 +296,10 @@
 	changed_prefs.fpu_model = ConfigureParams.System.n_FPUType;
 	changed_prefs.fpu_strict = ConfigureParams.System.bCompatibleFPU;
 	changed_prefs.mmu_model = ConfigureParams.System.bMMU;
+
+	changed_prefs.cpu_compatible = ConfigureParams.System.bPrefetchCpu;
+#else
+	changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
 #endif
 	if (table68k)
 		check_prefs_changed_cpu();
diff -r 06bf8c690bed src/options.c
--- a/src/options.c	Mon May 28 23:44:41 2012 +0300
+++ b/src/options.c	Mon May 28 23:49:50 2012 +0300
@@ -114,7 +114,8 @@
 	OPT_CPUCLOCK,
 	OPT_COMPATIBLE,
 #if ENABLE_WINUAE_CPU
-	OPT_CPU_CYCLE_EXACT,	/* WinUAE CPU/FPU/bus options */
+	OPT_CPU_PREFETCH,	/* WinUAE CPU/FPU/bus options */
+	OPT_CPU_CYCLE_EXACT,
 	OPT_CPU_ADDR24,
 	OPT_FPU_TYPE,
 	OPT_FPU_COMPATIBLE,
@@ -312,8 +313,10 @@
 
 #if ENABLE_WINUAE_CPU
 	{ OPT_HEADER, NULL, NULL, NULL, "WinUAE CPU/FPU/bus" },
+	{ OPT_CPU_PREFETCH, NULL, "--cpu-prefetch",
+	  "<bool>", "Better/more accurate (030) CPU prefetch" },
 	{ OPT_CPU_CYCLE_EXACT, NULL, "--cpu-exact",
-	  "<bool>", "Use cycle exact CPU emulation" },
+	  "<bool>", "Use (030) cycle exact CPU emulation" },
 	{ OPT_CPU_ADDR24, NULL, "--addr24",
 	  "<bool>", "Use 24-bit instead of 32-bit addressing mode" },
 	{ OPT_FPU_TYPE, NULL, "--fpu-type",
@@ -1368,6 +1371,11 @@
 			bLoadAutoSave = false;
 			break;
 
+		case OPT_CPU_PREFETCH:
+			ok = Opt_Bool(argv[++i], OPT_CPU_PREFETCH, &ConfigureParams.System.bPrefetchCpu);
+			bLoadAutoSave = false;
+			break;
+
 		case OPT_CPU_CYCLE_EXACT:
 			ok = Opt_Bool(argv[++i], OPT_CPU_CYCLE_EXACT, &ConfigureParams.System.bCycleExactCpu);
 			bLoadAutoSave = false;
@@ -1432,7 +1440,7 @@
 			else if (strcasecmp(argv[i], "falcon") == 0)
 			{
 #if ENABLE_DSP_EMU
-		ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
+				ConfigureParams.System.nDSPType = DSP_TYPE_EMU;
 #endif
 				ConfigureParams.System.nMachineType = MACHINE_FALCON;
 				ConfigureParams.System.nCpuLevel = 3;
@@ -1442,6 +1450,22 @@
 			{
 				return Opt_ShowError(OPT_MACHINE, argv[i], "Unknown machine type");
 			}
+#if ENABLE_WINUAE_CPU
+			ConfigureParams.System.bMMU = false;	/* does this affect also other than 040 CPUs? */
+			ConfigureParams.System.bAddressSpace24 = true;
+			if (ConfigureParams.System.nCpuLevel > 0) {
+				/* TT / Falcon selected above */
+				ConfigureParams.System.bPrefetchCpu = true;
+				ConfigureParams.System.bCycleExactCpu = true;
+				ConfigureParams.System.bCompatibleFPU = true;
+				ConfigureParams.System.n_FPUType = FPU_68882;
+			} else {
+				/* WinUAE cycles are configured for Falcon/030, so disable this for ST/STE */
+				ConfigureParams.System.bPrefetchCpu = false;
+				ConfigureParams.System.bCycleExactCpu = false;
+				ConfigureParams.System.n_FPUType = FPU_NONE;	/* TODO: or leave it as-is? */
+			}
+#endif
 			bLoadAutoSave = false;
 			break;
 
diff -r 06bf8c690bed src/tos.c
--- a/src/tos.c	Mon May 28 23:44:41 2012 +0300
+++ b/src/tos.c	Mon May 28 23:49:50 2012 +0300
@@ -437,6 +437,9 @@
  */
 static void TOS_CheckSysConfig(void)
 {
+#if ENABLE_WINUAE_CPU
+	int oldCpuLevel = ConfigureParams.System.nCpuLevel;
+#endif
 	if ((TosVersion == 0x0106 || TosVersion == 0x0162) && ConfigureParams.System.nMachineType != MACHINE_STE)
 	{
 		Log_AlertDlg(LOG_ERROR, "TOS versions 1.06 and 1.62 are for Atari STE only.\n"
@@ -511,6 +514,26 @@
 		ConfigureParams.System.nCpuLevel = 2;
 		M68000_CheckCpuSettings();
 	}
+#if ENABLE_WINUAE_CPU
+	/* TOS version triggered machine type change? */
+	if (ConfigureParams.System.nCpuLevel != oldCpuLevel &&
+	    ConfigureParams.System.nCpuLevel != 2)
+	{
+		ConfigureParams.System.bMMU = false;		/* TODO: does this affect also other than 040 CPUs? */
+		ConfigureParams.System.bAddressSpace24 = true;
+		if (ConfigureParams.System.nCpuLevel > 0) {
+			/* TT / Falcon selected above */
+			ConfigureParams.System.bPrefetchCpu = true;
+			ConfigureParams.System.bCycleExactCpu = true;
+			ConfigureParams.System.n_FPUType = FPU_68882;
+		} else {
+			/* WinUAE cycles are configured for Falcon/030, so disable this for ST/STE */
+			ConfigureParams.System.bPrefetchCpu = false;
+			ConfigureParams.System.bCycleExactCpu = false;
+			ConfigureParams.System.n_FPUType = FPU_NONE;	/* TODO: or leave it as-is? */
+		}
+	}
+#endif
 	if (TosVersion < 0x0104 && ConfigureParams.HardDisk.bUseHardDiskDirectories)
 	{
 		Log_AlertDlg(LOG_ERROR, "Please use at least TOS v1.04 for the HD directory emulation "


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