From e121953c9a42e853dc71f08e1e342ecd1e2c8753 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 28 Oct 2021 21:15:12 +0200 Subject: more complete (and accurate) CP15 setup for direct boot --- src/ARM.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/ARM.cpp') diff --git a/src/ARM.cpp b/src/ARM.cpp index bdb10bf..1abdbdd 100644 --- a/src/ARM.cpp +++ b/src/ARM.cpp @@ -162,6 +162,8 @@ void ARMv5::Reset() GetMemRegion = NDS::ARM9GetMemRegion; } + //PU_Map = PU_PrivMap; + ARM::Reset(); } @@ -225,10 +227,22 @@ void ARM::DoSavestate(Savestate* file) if (!file->Saving) { + CPSR |= 0x00000010; + R_FIQ[7] |= 0x00000010; + R_SVC[2] |= 0x00000010; + R_ABT[2] |= 0x00000010; + R_IRQ[2] |= 0x00000010; + R_UND[2] |= 0x00000010; + if (!Num) { SetupCodeMem(R[15]); // should fix it ((ARMv5*)this)->RegionCodeCycles = ((ARMv5*)this)->MemTimings[R[15] >> 12][0]; + + /*if ((CPSR & 0x1F) == 0x10) + ((ARMv5*)this)->PU_Map = ((ARMv5*)this)->PU_UserMap; + else + ((ARMv5*)this)->PU_Map = ((ARMv5*)this)->PU_PrivMap;*/ } else { @@ -415,7 +429,7 @@ void ARM::RestoreCPSR() UpdateMode(oldcpsr, CPSR); } -void ARM::UpdateMode(u32 oldmode, u32 newmode) +void ARM::UpdateMode(u32 oldmode, u32 newmode, bool phony) { if ((oldmode & 0x1F) == (newmode & 0x1F)) return; @@ -485,13 +499,12 @@ void ARM::UpdateMode(u32 oldmode, u32 newmode) break; } - if (Num == 0) + if ((!phony) && (Num == 0)) { /*if ((newmode & 0x1F) == 0x10) ((ARMv5*)this)->PU_Map = ((ARMv5*)this)->PU_UserMap; else ((ARMv5*)this)->PU_Map = ((ARMv5*)this)->PU_PrivMap;*/ - //if ((newmode & 0x1F) == 0x10) printf("!! USER MODE\n"); } } -- cgit v1.2.3