From 3286d223fd715a79accfc66039f3f6f52e9a8896 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 9 Dec 2020 19:42:44 +0100 Subject: sandbox: implement invalidate_icache_all() Before executing code that we have loaded from a file we need to flush the data cache and invalidate the instruction flash. Implement functions flush_cache() and invalidate_icache_all(). Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- arch/sandbox/cpu/cache.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 arch/sandbox/cpu/cache.c (limited to 'arch/sandbox/cpu/cache.c') diff --git a/arch/sandbox/cpu/cache.c b/arch/sandbox/cpu/cache.c new file mode 100644 index 00000000000..46c62c0b446 --- /dev/null +++ b/arch/sandbox/cpu/cache.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020, Heinrich Schuchardt + */ + +#include +#include +#include + +void flush_cache(unsigned long addr, unsigned long size) +{ + /* Clang uses (char *) parameters, GCC (void *) */ + __builtin___clear_cache((void *)addr, (void *)(addr + size)); +} + +void invalidate_icache_all(void) +{ + struct sandbox_state *state = state_get_current(); + + /* Clang uses (char *) parameters, GCC (void *) */ + __builtin___clear_cache((void *)state->ram_buf, + (void *)(state->ram_buf + state->ram_size)); +} -- cgit v1.2.3