-
-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP15 Cache Emulation Work #1955
base: master
Are you sure you want to change the base?
CP15 Cache Emulation Work #1955
Conversation
src/ARM.h
Outdated
@@ -322,6 +322,7 @@ class ARMv5 : public ARM | |||
u32 RNGSeed; | |||
|
|||
u32 DTCMSetting, ITCMSetting; | |||
u32 DCacheLockDown, ICacheLockDown; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to add these to the savestate (and to increment the savestate version).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Could you please increment the major version number in Savestate.h
as well? It's our only way to detect savestate format changes at runtime; if it's not updated, then loading old states may crash (or worse, silently break the emulated console).
I'll add some more changes to the CP15 Caching Instructions and Handling here. |
Marked reading CP15 Cache Dirty Bit as not present
The last commit was a bit bigger / combined, as adding DCache required other things to not break some applications. Instruction cache is working except:
CP15 Registers Operations:
|
b5dedf3
to
b6b0197
Compare
… data to get nearer to hw timings
Update on the status Instruction cache is working except:
Data cache is working except:
CP15 Registers Operations:
JIT:
|
Split the cp15 constants into CP15_Constants.h instead from MemConstants.
Fixed Cache Debug registers were accessible, when op1 != 3 in MCR/MRC instructions Added BIST Test Status register and its cache linefill disable bits
Fixed a bug causing overlapping protection regions priority not taken into account, when access permission or cachability bits were changed only on the least priority overlap
Added const properties to the CP15Write/Read functions
Replaced mogic values with named constants Added const specifier to some argument and subsequent calls
Updated documenting comments for the DCacheClear* methods
…ed constant Encapsuled the cache features in #if to disable the features via compile flags
This turned out to be quite some rework for the CP15. |
src/CP15.cpp
Outdated
|
||
id <<= 2; | ||
if (ICacheTags[id+0] == tag) | ||
for (int set=0;set<ICACHE_SETS;set++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add spaces after the semicolons in all the for loops?
src/CP15.cpp
Outdated
// Do the same as above but instead of using if-else | ||
// utilize the && and || operators to skip parts of the operations | ||
// With the order of comparison we can put the most likely path | ||
// checked first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure whether this abusing shortcircuit evaluation really gives better code. If you want to steer the compiler using likely and unlikely markers could be used for the ifs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed this and added the [[(un)likely]] attributes
for (int i = 0; i < DCACHE_LINELENGTH; i+=sizeof(u32)) | ||
{ | ||
if (tag+i < ITCMSize) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh so you can actually put ITCM and DTCM into cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely sure (I think ) I had a block diagram showing the access passing the write buffer before the TCMs but can't seem to find that diagram. If that is the case, the TCM access will go through the cache when enabled.
However my decision to place the read from TCMs here was to keep the access flow within the line fills in sync to the DataReadXX functions.
src/CP15.cpp
Outdated
{ | ||
if (addr & (DCACHE_LINELENGTH / 2)) | ||
{ | ||
DCacheTags[id+set] |= CACHE_FLAG_DIRTY_UPPERHALF ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the spaces before semicolon
@@ -306,7 +340,7 @@ void ARMv5::UpdateRegionTimings(u32 addrstart, u32 addrend) | |||
MemTimings[i][0] = bustimings[2] << NDS.ARM9ClockShift; | |||
} | |||
|
|||
if (pu & 0x10) | |||
if (pu & CP15_MAP_DCACHEABLE) | |||
{ | |||
MemTimings[i][1] = kDataCacheTiming; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these values will only ever be used when JIT is enabled, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, yes. They are used in ARMv5::CodeRead32, when the JIT is not enabled.
Removed premature optimization and replaced them with [[(un)likely]]
10c70eb
to
a7575ec
Compare
Fixes #380 |
Unfortunately #359 is still occuring |
seems like disabling the pu via the control reg causes melonds to hang under this pr? |
Thanks for the report and sample Jakly, I'll check that as soon i got some time. |
CodeCycles = (NDS.ARM9MemTimings[addr >> 14][2] + (NDS.ARM9MemTimings[addr >> 14][3] * 7)) << NDS.ARM9ClockShift; | ||
CurICacheLine = ptr; | ||
// first N32 remaining S32 | ||
CodeCycles = (NDS.ARM9MemTimings[tag >> 14][2] + (NDS.ARM9MemTimings[tag >> 14][3] * ((DCACHE_LINELENGTH / 4) - 1))) << NDS.ARM9ClockShift; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor error: DCACHE_LINELENGTH should be ICACHE_LINELENGTH
The instruction and data cache register were not yet implemented in MelonDS and would act different against the hardware by just reading/writing them.
They have no impact on the - not yet implemented - data cache nor on the instruction cache until their implementation progresses.