diff options
Diffstat (limited to 'payloads/libpayload')
-rw-r--r-- | payloads/libpayload/arch/arm/cache.c | 15 | ||||
-rw-r--r-- | payloads/libpayload/include/arm/arch/cache.h | 3 |
2 files changed, 12 insertions, 6 deletions
diff --git a/payloads/libpayload/arch/arm/cache.c b/payloads/libpayload/arch/arm/cache.c index 3944818110..4c222eab73 100644 --- a/payloads/libpayload/arch/arm/cache.c +++ b/payloads/libpayload/arch/arm/cache.c @@ -195,17 +195,20 @@ void dcache_invalidate_all(void) dcache_foreach(OP_DCISW); } -static unsigned int line_bytes(void) +unsigned int dcache_line_bytes(void) { uint32_t ccsidr; - unsigned int size; + static unsigned int line_bytes = 0; + + if (line_bytes) + return line_bytes; ccsidr = read_ccsidr(); /* [2:0] - Indicates (Log2(number of words in cache line)) - 2 */ - size = 1 << ((ccsidr & 0x7) + 2); /* words per line */ - size *= sizeof(unsigned int); /* bytes per line */ + line_bytes = 1 << ((ccsidr & 0x7) + 2); /* words per line */ + line_bytes *= sizeof(unsigned int); /* bytes per line */ - return size; + return line_bytes; } /* @@ -219,7 +222,7 @@ static void dcache_op_mva(void const *vaddr, size_t len, enum dcache_op op) unsigned long line, linesize; unsigned long paddr = virt_to_phys(vaddr); - linesize = line_bytes(); + linesize = dcache_line_bytes(); line = paddr & ~(linesize - 1); dsb(); diff --git a/payloads/libpayload/include/arm/arch/cache.h b/payloads/libpayload/include/arm/arch/cache.h index ffdb55a706..5210dfe6a8 100644 --- a/payloads/libpayload/include/arm/arch/cache.h +++ b/payloads/libpayload/include/arm/arch/cache.h @@ -304,6 +304,9 @@ void dcache_clean_all(void); /* dcache invalidate all (on current level given by CCSELR) */ void dcache_invalidate_all(void); +/* returns number of bytes per cache line */ +unsigned int dcache_line_bytes(void); + /* dcache and MMU disable */ void dcache_mmu_disable(void); |