summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2024-02-20 12:48:04 +1100
committerDamien George <damien@micropython.org>2024-03-08 10:38:35 +1100
commit5fe99013b6a58d6743706c5d76a1dbad133c300a (patch)
treefc5495bad18847e1ea9611cf7905c15b7a3f39e9
parentbf68bb95f9774127a026845e286822ca83bcaa37 (diff)
stm32: Simplify D-cache clean and invalidate macros.
The inline functions that these are wrappers around already account for cache line size. Signed-off-by: Angus Gratton <angus@redyak.com.au>
-rw-r--r--ports/stm32/mpconfigboard_common.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/ports/stm32/mpconfigboard_common.h b/ports/stm32/mpconfigboard_common.h
index 6d9ef8de3..16ee01b67 100644
--- a/ports/stm32/mpconfigboard_common.h
+++ b/ports/stm32/mpconfigboard_common.h
@@ -632,12 +632,12 @@
// D-cache clean/invalidate helpers
#if __DCACHE_PRESENT == 1
-#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size) \
- (SCB_CleanInvalidateDCache_by_Addr((uint32_t *)((uint32_t)addr & ~0x1f), \
- ((uint32_t)((uint8_t *)addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
-#define MP_HAL_CLEAN_DCACHE(addr, size) \
- (SCB_CleanDCache_by_Addr((uint32_t *)((uint32_t)addr & ~0x1f), \
- ((uint32_t)((uint8_t *)addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
+// Note: The SCB_Clean<...> functions automatically align their arguments to cover full cache lines.
+// CLEANINVALIDATE will write back (flush) any dirty lines in this region to RAM, then
+// invalidate (evict) the whole region from the cache.
+#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size) SCB_CleanInvalidateDCache_by_Addr((volatile void *)(addr), (size))
+// CLEAN will write back (flush) any dirty lines in this region to RAM.
+#define MP_HAL_CLEAN_DCACHE(addr, size) SCB_CleanDCache_by_Addr((volatile void *)(addr), (size))
#else
#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size)
#define MP_HAL_CLEAN_DCACHE(addr, size)