Skip to content

Commit

Permalink
py/asmarm: Use builtin func to flush I- and D-cache on ARM 7 archs.
Browse files Browse the repository at this point in the history
The inline assembler code does not work for __ARM_ARCH == 7.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed May 26, 2021
1 parent c732b80 commit 4ee8ec6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions py/asmarm.c
Expand Up @@ -40,18 +40,18 @@

void asm_arm_end_pass(asm_arm_t *as) {
if (as->base.pass == MP_ASM_PASS_EMIT) {
#if defined(__linux__) && defined(__GNUC__)
#if (defined(__linux__) && defined(__GNUC__)) || __ARM_ARCH == 7
char *start = mp_asm_base_get_code(&as->base);
char *end = start + mp_asm_base_get_code_size(&as->base);
__builtin___clear_cache(start, end);
#elif defined(__arm__)
// flush I- and D-cache
asm volatile (
"0:"
"mrc p15, 0, r15, c7, c10, 3\n"
"mrc p15, 0, r15, c7, c10, 3\n" // test and clean D-cache
"bne 0b\n"
"mov r0, #0\n"
"mcr p15, 0, r0, c7, c7, 0\n"
"mcr p15, 0, r0, c7, c7, 0\n" // invalidate I-cache and D-cache
: : : "r0", "cc");
#endif
}
Expand Down

0 comments on commit 4ee8ec6

Please sign in to comment.