mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-28 05:52:39 +02:00
kern: update initial cache management to match latest kernel
This commit is contained in:
parent
e96b24f842
commit
525254b32b
@ -172,10 +172,8 @@ namespace ams::kern::arch::arm64::cpu {
|
|||||||
|
|
||||||
/* Cache management helpers. */
|
/* Cache management helpers. */
|
||||||
void ClearPageToZeroImpl(void *);
|
void ClearPageToZeroImpl(void *);
|
||||||
void FlushEntireDataCacheSharedForInit();
|
|
||||||
void FlushEntireDataCacheLocalForInit();
|
|
||||||
void InvalidateEntireInstructionCacheForInit();
|
|
||||||
void StoreEntireCacheForInit();
|
void StoreEntireCacheForInit();
|
||||||
|
void FlushEntireCacheForInit();
|
||||||
|
|
||||||
void FlushEntireDataCache();
|
void FlushEntireDataCache();
|
||||||
|
|
||||||
|
@ -262,27 +262,6 @@ namespace ams::kern::arch::arm64::cpu {
|
|||||||
__asm__ __volatile__("dc csw, %[v]" :: [v]"r"(sw_value) : "memory");
|
__asm__ __volatile__("dc csw, %[v]" :: [v]"r"(sw_value) : "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool Init, typename F>
|
|
||||||
ALWAYS_INLINE void PerformCacheOperationBySetWayShared(F f) {
|
|
||||||
CacheLineIdRegisterAccessor clidr_el1;
|
|
||||||
const int levels_of_coherency = clidr_el1.GetLevelsOfCoherency();
|
|
||||||
const int levels_of_unification = clidr_el1.GetLevelsOfUnification();
|
|
||||||
|
|
||||||
for (int level = levels_of_coherency; level >= levels_of_unification; level--) {
|
|
||||||
PerformCacheOperationBySetWayImpl<Init>(level, f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<bool Init, typename F>
|
|
||||||
ALWAYS_INLINE void PerformCacheOperationBySetWayLocal(F f) {
|
|
||||||
CacheLineIdRegisterAccessor clidr_el1;
|
|
||||||
const int levels_of_unification = clidr_el1.GetLevelsOfUnification();
|
|
||||||
|
|
||||||
for (int level = levels_of_unification - 1; level >= 0; level--) {
|
|
||||||
PerformCacheOperationBySetWayImpl<Init>(level, f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StoreDataCacheBySetWay(int level) {
|
void StoreDataCacheBySetWay(int level) {
|
||||||
PerformCacheOperationBySetWayImpl<false>(level, StoreDataCacheLineBySetWayImpl);
|
PerformCacheOperationBySetWayImpl<false>(level, StoreDataCacheLineBySetWayImpl);
|
||||||
cpu::DataSynchronizationBarrier();
|
cpu::DataSynchronizationBarrier();
|
||||||
@ -361,24 +340,63 @@ namespace ams::kern::arch::arm64::cpu {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlushEntireDataCacheSharedForInit() {
|
void StoreEntireCacheForInit() {
|
||||||
return PerformCacheOperationBySetWayShared<true>(FlushDataCacheLineBySetWayImpl);
|
/* Store local. */
|
||||||
|
{
|
||||||
|
CacheLineIdRegisterAccessor clidr_el1;
|
||||||
|
const int levels_of_unification = clidr_el1.GetLevelsOfUnification();
|
||||||
|
|
||||||
|
for (int level = 0; level != levels_of_unification; ++level) {
|
||||||
|
PerformCacheOperationBySetWayImpl<true>(level, StoreDataCacheLineBySetWayImpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store shared. */
|
||||||
|
{
|
||||||
|
CacheLineIdRegisterAccessor clidr_el1;
|
||||||
|
const int levels_of_coherency = clidr_el1.GetLevelsOfCoherency();
|
||||||
|
const int levels_of_unification = clidr_el1.GetLevelsOfUnification();
|
||||||
|
|
||||||
|
for (int level = levels_of_unification; level <= levels_of_coherency; ++level) {
|
||||||
|
PerformCacheOperationBySetWayImpl<true>(level, StoreDataCacheLineBySetWayImpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Data synchronization barrier. */
|
||||||
|
DataSynchronizationBarrierInnerShareable();
|
||||||
|
|
||||||
|
/* Invalidate instruction cache. */
|
||||||
|
InvalidateEntireInstructionCacheLocalImpl();
|
||||||
|
|
||||||
|
/* Ensure local instruction consistency. */
|
||||||
|
DataSynchronizationBarrierInnerShareable();
|
||||||
|
InstructionMemoryBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlushEntireDataCacheLocalForInit() {
|
void FlushEntireCacheForInit() {
|
||||||
return PerformCacheOperationBySetWayLocal<true>(FlushDataCacheLineBySetWayImpl);
|
/* Flush data cache. */
|
||||||
}
|
{
|
||||||
|
/* Get levels of coherence/unificaiton. */
|
||||||
|
CacheLineIdRegisterAccessor clidr_el1;
|
||||||
|
const int levels_of_coherency = clidr_el1.GetLevelsOfCoherency();
|
||||||
|
|
||||||
void InvalidateEntireInstructionCacheForInit() {
|
/* Store cache from L1 up to (level of coherence - 1). */
|
||||||
|
for (int level = 0; level < levels_of_coherency - 1; ++level) {
|
||||||
|
PerformCacheOperationBySetWayImpl<true>(level, StoreDataCacheLineBySetWayImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flush cache from (level of coherence - 1) down to L0. */
|
||||||
|
for (int level = levels_of_coherency; level > 0; --level) {
|
||||||
|
PerformCacheOperationBySetWayImpl<true>(level - 1, FlushDataCacheLineBySetWayImpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Invalidate instruction cache. */
|
||||||
InvalidateEntireInstructionCacheLocalImpl();
|
InvalidateEntireInstructionCacheLocalImpl();
|
||||||
EnsureInstructionConsistency();
|
EnsureInstructionConsistency();
|
||||||
}
|
|
||||||
|
|
||||||
void StoreEntireCacheForInit() {
|
/* Invalidate entire TLB. */
|
||||||
PerformCacheOperationBySetWayLocal<true>(StoreDataCacheLineBySetWayImpl);
|
InvalidateEntireTlb();
|
||||||
PerformCacheOperationBySetWayShared<true>(StoreDataCacheLineBySetWayImpl);
|
|
||||||
DataSynchronizationBarrierInnerShareable();
|
|
||||||
InvalidateEntireInstructionCacheForInit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlushEntireDataCache() {
|
void FlushEntireDataCache() {
|
||||||
|
Loading…
Reference in New Issue
Block a user