Skip to content

Commit

Permalink
32x: implement soft reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Berti committed Dec 7, 2023
1 parent 13cfa73 commit 1ff75ba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/s32x/Md32x.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
1 change: 1 addition & 0 deletions src/main/java/s32x/StaticBootstrapSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/s32x/util/MarsLauncherHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
6 changes: 6 additions & 0 deletions src/main/java/s32x/util/Md32xRuntimeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 1ff75ba

Please sign in to comment.