mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-30 12:10:03 +02:00
[ion/cache] Improve cache cleaning
- Avoid fetching CCSIDR twice - Use for loop instead of do/while - Only compute the target register once - Avoid an useless nop
This commit is contained in:
committed by
EmilieNumworks
parent
67302a90c7
commit
273834ee84
@@ -17,28 +17,29 @@ void privateCleanInvalidateDisableDCache(bool clean, bool invalidate, bool disab
|
||||
dsb();
|
||||
}
|
||||
|
||||
uint32_t sets = CORTEX.CCSIDR()->getNUMSETS();
|
||||
uint32_t ways = CORTEX.CCSIDR()->getASSOCIATIVITY();
|
||||
// Pick the right DC??SW register according to invalidate/disable parameters
|
||||
volatile CORTEX::DCSW * target = nullptr;
|
||||
if (clean && invalidate) {
|
||||
target = CORTEX.DCCISW();
|
||||
} else if (clean) {
|
||||
target = CORTEX.DCCSW();
|
||||
} else {
|
||||
assert(invalidate);
|
||||
target = CORTEX.DCISW();
|
||||
}
|
||||
|
||||
do {
|
||||
uint32_t w = ways;
|
||||
do {
|
||||
class CORTEX::CCSIDR ccsidr = CORTEX.CCSIDR()->get();
|
||||
uint32_t sets = ccsidr.getNUMSETS();
|
||||
uint32_t ways = ccsidr.getASSOCIATIVITY();
|
||||
|
||||
for (int set = sets; set >= 0; set--) {
|
||||
for (int way = ways; way >= 0; way--) {
|
||||
class CORTEX::DCSW dcsw;
|
||||
dcsw.setSET(sets);
|
||||
dcsw.setWAY(w);
|
||||
volatile CORTEX::DCSW * target = nullptr;
|
||||
if (clean && invalidate) {
|
||||
target = CORTEX.DCCISW();
|
||||
} else if (clean) {
|
||||
target = CORTEX.DCCSW();
|
||||
} else {
|
||||
assert(invalidate);
|
||||
target = CORTEX.DCISW();
|
||||
}
|
||||
dcsw.setSET(set);
|
||||
dcsw.setWAY(way);
|
||||
target->set(dcsw);
|
||||
__asm volatile("nop");
|
||||
} while (w-- != 0);
|
||||
} while (sets-- != 0);
|
||||
}
|
||||
}
|
||||
|
||||
dsb();
|
||||
isb();
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
#if REGS_CORTEX_CONFIG_CACHE
|
||||
class CCSIDR : public Register32 {
|
||||
public:
|
||||
using Register32::Register32;
|
||||
REGS_FIELD(ASSOCIATIVITY, uint16_t, 12, 3);
|
||||
REGS_FIELD(NUMSETS, uint16_t, 27, 13);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user