aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ARM.h2
-rw-r--r--src/ARMJIT_Memory.cpp14
-rw-r--r--src/CP15.cpp2
3 files changed, 8 insertions, 10 deletions
diff --git a/src/ARM.h b/src/ARM.h
index b810bb4..e00bf34 100644
--- a/src/ARM.h
+++ b/src/ARM.h
@@ -269,7 +269,7 @@ public:
// for aarch64 JIT they need to go up here
// to be addressable by a 12-bit immediate
u32 ITCMSize;
- u32 DTCMBase, DTCMMask, DTCMSize;
+ u32 DTCMBase, DTCMMask;
s32 RegionCodeCycles;
u8 ITCM[ITCMPhysicalSize];
diff --git a/src/ARMJIT_Memory.cpp b/src/ARMJIT_Memory.cpp
index 2fde711..d72a63c 100644
--- a/src/ARMJIT_Memory.cpp
+++ b/src/ARMJIT_Memory.cpp
@@ -372,7 +372,7 @@ struct Mapping
void Unmap(int region)
{
u32 dtcmStart = NDS::ARM9->DTCMBase;
- u32 dtcmSize = NDS::ARM9->DTCMSize;
+ u32 dtcmSize = ~NDS::ARM9->DTCMMask + 1;
bool skipDTCM = Num == 0 && region != memregion_DTCM;
u8* statuses = Num == 0 ? MappingStatus9 : MappingStatus7;
u32 offset = 0;
@@ -453,8 +453,7 @@ void SetCodeProtection(int region, u32 offset, bool protect)
u32 effectiveAddr = mapping.Addr + (offset - mapping.LocalOffset);
if (mapping.Num == 0
&& region != memregion_DTCM
- && effectiveAddr >= NDS::ARM9->DTCMBase
- && effectiveAddr < (NDS::ARM9->DTCMBase + NDS::ARM9->DTCMSize))
+ && (effectiveAddr & NDS::ARM9->DTCMMask) == NDS::ARM9->DTCMBase)
continue;
u8* states = (u8*)(mapping.Num == 0 ? MappingStatus9 : MappingStatus7);
@@ -481,7 +480,8 @@ void RemapDTCM(u32 newBase, u32 newSize)
// this first part could be made more efficient
// by unmapping DTCM first and then map the holes
u32 oldDTCMBase = NDS::ARM9->DTCMBase;
- u32 oldDTCBEnd = oldDTCMBase + NDS::ARM9->DTCMSize;
+ u32 oldDTCMSize = ~NDS::ARM9->DTCMMask + 1;
+ u32 oldDTCBEnd = oldDTCMBase + NDS::ARM9->DTCMMask;
u32 newEnd = newBase + newSize;
@@ -501,7 +501,7 @@ void RemapDTCM(u32 newBase, u32 newSize)
printf("unmapping %d %x %x %x %x\n", region, mapping.Addr, mapping.Size, mapping.Num, mapping.LocalOffset);
- bool overlap = (NDS::ARM9->DTCMSize > 0 && oldDTCMBase < end && oldDTCBEnd > start)
+ bool overlap = (oldDTCMSize > 0 && oldDTCMBase < end && oldDTCBEnd > start)
|| (newSize > 0 && newBase < end && newEnd > start);
if (mapping.Num == 0 && overlap)
@@ -588,7 +588,7 @@ bool MapAtAddress(u32 addr)
bool isExecutable = ARMJIT::CodeMemRegions[region];
u32 dtcmStart = NDS::ARM9->DTCMBase;
- u32 dtcmSize = NDS::ARM9->DTCMSize;
+ u32 dtcmSize = ~NDS::ARM9->DTCMMask + 1;
u32 dtcmEnd = dtcmStart + dtcmSize;
#ifndef __SWITCH__
#ifndef _WIN32
@@ -1067,7 +1067,7 @@ int ClassifyAddress9(u32 addr)
{
return memregion_ITCM;
}
- else if (addr >= NDS::ARM9->DTCMBase && addr < (NDS::ARM9->DTCMBase + NDS::ARM9->DTCMSize))
+ else if ((addr & NDS::ARM9->DTCMMask) == NDS::ARM9->DTCMBase)
{
return memregion_DTCM;
}
diff --git a/src/CP15.cpp b/src/CP15.cpp
index 69551de..e75201b 100644
--- a/src/CP15.cpp
+++ b/src/CP15.cpp
@@ -51,7 +51,6 @@ void ARMv5::CP15Reset()
ITCMSize = 0;
DTCMBase = 0xFFFFFFFF;
DTCMMask = 0;
- DTCMSize = 0;
memset(ICache, 0, 0x2000);
ICacheInvalidateAll();
@@ -127,7 +126,6 @@ void ARMv5::UpdateDTCMSetting()
#endif
DTCMBase = newDTCMBase;
DTCMMask = newDTCMMask;
- DTCMSize = newDTCMSize;
}
}