Skip to content

Commit

Permalink
get rid of DTCMSize
Browse files Browse the repository at this point in the history
  • Loading branch information
RSDuck committed Oct 28, 2021
1 parent 635a470 commit 6c2ea93
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ARM.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class ARMv5 : public ARM
// 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];
Expand Down
14 changes: 7 additions & 7 deletions src/ARMJIT_Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions src/CP15.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void ARMv5::CP15Reset()
ITCMSize = 0;
DTCMBase = 0xFFFFFFFF;
DTCMMask = 0;
DTCMSize = 0;

memset(ICache, 0, 0x2000);
ICacheInvalidateAll();
Expand Down Expand Up @@ -127,7 +126,6 @@ void ARMv5::UpdateDTCMSetting()
#endif
DTCMBase = newDTCMBase;
DTCMMask = newDTCMMask;
DTCMSize = newDTCMSize;
}
}

Expand Down

0 comments on commit 6c2ea93

Please sign in to comment.