8000 stm32: Simplify D-cache clean and invalidate macros. · mancausoft/micropython@5fe9901 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fe9901

Browse files
projectgusdpgeorge
authored andcommitted
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>
1 parent bf68bb9 commit 5fe9901

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ports/stm32/mpconfigboard_common.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,12 @@
632632

633633
// D-cache clean/invalidate helpers
634634
#if __DCACHE_PRESENT == 1
635-
#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size) \
636-
(SCB_CleanInvalidateDCache_by_Addr((uint32_t *)((uint32_t)addr & ~0x1f), \
637-
((uint32_t)((uint8_t *)addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
638-
#define MP_HAL_CLEAN_DCACHE(addr, size) \
639-
(SCB_CleanDCache_by_Addr((uint32_t *)((uint32_t)addr & ~0x1f), \
640-
((uint32_t)((uint8_t *)addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
635+
// Note: The SCB_Clean<...> functions automatically align their arguments to cover full cache lines.
636+
// CLEANINVALIDATE will write back (flush) any dirty lines in this region to RAM, then
637+
// invalidate (evict) the whole region from the cache.
638+
#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size) SCB_CleanInvalidateDCache_by_Addr((volatile void *)(addr), (size))
639+
// CLEAN will write back (flush) any dirty lines in this region to RAM.
640+
#define MP_HAL_CLEAN_DCACHE(addr, size) SCB_CleanDCache_by_Addr((volatile void *)(addr), (size))
641641
#else
642642
#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size)
643643
#define MP_HAL_CLEAN_DCACHE(addr, size)

0 commit comments

Comments
 (0)
0