From 1ff75babbef6a75b75e92bc891eff6d56bc2960b Mon Sep 17 00:00:00 2001 From: Federico Berti Date: Thu, 7 Dec 2023 17:08:57 +0000 Subject: [PATCH] 32x: implement soft reset --- src/main/java/s32x/Md32x.java | 13 +++++++++++++ src/main/java/s32x/StaticBootstrapSupport.java | 1 + src/main/java/s32x/util/MarsLauncherHelper.java | 9 +++++++++ src/main/java/s32x/util/Md32xRuntimeData.java | 6 ++++++ 4 files changed, 29 insertions(+) diff --git a/src/main/java/s32x/Md32x.java b/src/main/java/s32x/Md32x.java index 0ae34a32..afc4d67a 100644 --- a/src/main/java/s32x/Md32x.java +++ b/src/main/java/s32x/Md32x.java @@ -298,4 +298,17 @@ public void setNextCycle(CpuDeviceAccess cpu, int value) { nextSSh2Cycle = value; } } + + //TODO buggy + @Override + protected void handleSoftReset() { + if (softReset) { + sh2.reset(masterCtx); + sh2.reset(slaveCtx); + launchCtx.reset(); + Md32xRuntimeData.resetAllCpuDelayExt(); + StaticBootstrapSupport.initStatic(this); + } + super.handleSoftReset(); + } } diff --git a/src/main/java/s32x/StaticBootstrapSupport.java b/src/main/java/s32x/StaticBootstrapSupport.java index ad762b3a..e8a61e9f 100644 --- a/src/main/java/s32x/StaticBootstrapSupport.java +++ b/src/main/java/s32x/StaticBootstrapSupport.java @@ -29,6 +29,7 @@ public static void initStatic(NextCycleResettable instance) { assert instance != null; PollSysEventManager.instance.reset(); PollSysEventManager.instance.addSysEventListener(instance.getClass().getSimpleName(), instance); + //TODO soft reset shouldn't do this DmaFifo68k.rv = false; Sh2Helper.clear(); StaticBootstrapSupport.instance = instance; diff --git a/src/main/java/s32x/util/MarsLauncherHelper.java b/src/main/java/s32x/util/MarsLauncherHelper.java index 115c7a02..1c21babd 100644 --- a/src/main/java/s32x/util/MarsLauncherHelper.java +++ b/src/main/java/s32x/util/MarsLauncherHelper.java @@ -150,5 +150,14 @@ public void initContext() { sh2.reset(slaveCtx); marsVdp = bus.getMarsVdp(); } + + public void reset() { + mDevCtx.sh2MMREG.reset(); + sDevCtx.sh2MMREG.reset(); + pwm.reset(); + s32XMMREG.reset(); + memory.reset(); + dmaFifo68k.reset(); + } } } diff --git a/src/main/java/s32x/util/Md32xRuntimeData.java b/src/main/java/s32x/util/Md32xRuntimeData.java index e01b287a..0dcb4405 100644 --- a/src/main/java/s32x/util/Md32xRuntimeData.java +++ b/src/main/java/s32x/util/Md32xRuntimeData.java @@ -89,6 +89,12 @@ public static void resetCpuDelayExt(CpuDeviceAccess cpu, int value) { rt.cpuDelay[cpu.ordinal()] = value; } + public static void resetAllCpuDelayExt() { + for (CpuDeviceAccess v : cdaValues) { + rt.cpuDelay[v.ordinal()] = 0; + } + } + public static int resetCpuDelayExt() { return resetCpuDelayExt(0); }