get rid of DTCMSize

This commit is contained in:
RSDuck 2021-10-29 01:35:22 +02:00
parent 635a47014f
commit 6c2ea93173
3 changed files with 8 additions and 10 deletions

View File

@ -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];

View File

@ -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;
}

View File

@ -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;
}
}