1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-18 08:22:04 +00:00

thermosphere: cleanup cache trap

This commit is contained in:
TuxSH 2020-02-20 19:27:05 +00:00
parent c7eaf71896
commit d72fc3e8b9
2 changed files with 9 additions and 20 deletions

View file

@ -129,35 +129,24 @@ namespace ams::hvisor::cpu {
These clearly break coherency and should only be done once, on power on/off/suspend/resume only. And we already These clearly break coherency and should only be done once, on power on/off/suspend/resume only. And we already
do it ourselves... do it ourselves...
- allow ops after the LoUIS, but do it ourselves and ignore the next (numSets*numWay - 1) requests. This is because - allow ops after the LoUIS, but do it ourselves and ignore the next (numSets*numWay - 1) requests. This is because
we have to handle Nintendo's dodgy code we have to handle Nintendo's dodgy code (check if SetWay == 0)
- transform all s/w cache ops into clean and invalidate - transform all s/w cache ops into clean and invalidate
*/ */
void HandleTrappedSetWayOperation() void HandleTrappedSetWayOperation(u32 val)
{ {
u32 clidr = static_cast<u32>(THERMOSPHERE_GET_SYSREG(clidr_el1)); u32 clidr = static_cast<u32>(THERMOSPHERE_GET_SYSREG(clidr_el1));
u32 louis = (clidr >> 21) & 7; u32 louis = (clidr >> 21) & 7;
u32 csselr = static_cast<u32>(THERMOSPHERE_GET_SYSREG(csselr_el1)); u32 level = val >> 1 & 7;
u32 level = (csselr >> 1) & 7; u32 setway = val >> 3;
if (csselr & BIT(0)) { if (level < louis) {
// Icache, ignore
return;
} else if (level < louis) {
return; return;
} }
if (setway == 0) {
u32 ccsidr = static_cast<u32>(THERMOSPHERE_GET_SYSREG(ccsidr_el1));
u32 numWays = 1 + ((ccsidr >> 3) & 0x3FF);
u32 numSets = 1 + ((ccsidr >> 13) & 0x7FFF);
if (currentCoreCtx->setWayCounter++ == 0) {
CleanInvalidateDataCacheLevel(level); CleanInvalidateDataCacheLevel(level);
ams::hvisor::cpu::dsbSy(); dsbSy();
ams::hvisor::cpu::isb(); isb();
}
if (currentCoreCtx->setWayCounter >= numSets * numWays) {
currentCoreCtx->setWayCounter = 0;
} }
} }

View file

@ -66,6 +66,6 @@ namespace ams::hvisor::cpu {
void ClearLocalDataCacheOnBoot(void); void ClearLocalDataCacheOnBoot(void);
// Dunno where else to put that // Dunno where else to put that
void HandleTrappedSetWayOperation(); void HandleTrappedSetWayOperation(u32 val);
} }