From 569177e29cdc777e84e5e8cf633ebef761e82f83 Mon Sep 17 00:00:00 2001 From: Ed Robbins Date: Tue, 5 Dec 2023 16:56:36 +0000 Subject: [PATCH] Define CLEAR_INSN_CACHE in arm.h and implement for v7em targets --- gcc/config/arm/arm.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index f479540812a..666d98611bc 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2518,4 +2518,37 @@ const char *arm_be8_option (int argc, const char **argv); representation for SHF_ARM_PURECODE in GCC. */ #define SECTION_ARM_PURECODE SECTION_MACH_DEP +#ifndef CLEAR_INSN_CACHE +/* When defined CLEAR_INSN_CACHE is called by __clear_cache in libgcc/libgcc2.c + It needs to always be _defined_, otherwise maybe_emit_call_builtin___clear_cache + from gcc/builtins.cc will not generate a call to __clear_cache, however we + only want it _implemented_ for the multilib version of libgcc.a built for + v7em targets. */ +#ifdef __ARM_ARCH_7EM__ +#define CLEAR_INSN_CACHE(BEG, END) \ + { \ + const void *scb_base = (const void*)0xe000e000; \ + const unsigned dccmvac_offset = 0x268; \ + const unsigned icimvau_offset = 0x258; \ + const unsigned cache_line_size = 32; \ + void *addr = (void*)((unsigned)BEG & ~(cache_line_size - 1)); \ + void *end = (void*)((unsigned)(END + cache_line_size - 1) & ~(cache_line_size - 1)); \ + __asm__ __volatile__("dsb" : : : "memory"); \ + while (addr < end) { \ + *(unsigned**)(scb_base + dccmvac_offset) = addr; \ + addr += cache_line_size; \ + } \ + __asm__ __volatile__("dsb; isb" : : : "memory"); \ + addr = (void*)((unsigned)BEG & ~(cache_line_size - 1)); \ + while (addr < end) { \ + *(unsigned**)(scb_base + icimvau_offset) = addr; \ + addr += cache_line_size; \ + } \ + __asm__ __volatile__("dsb; isb" : : : "memory"); \ + } +#else +#define CLEAR_INSN_CACHE(BEG, END) ; +#endif +#endif + #endif /* ! GCC_ARM_H */ -- 2.34.1