diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-12-09 19:42:44 +0100 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-12-22 20:39:25 -0700 |
commit | 3286d223fd715a79accfc66039f3f6f52e9a8896 (patch) | |
tree | f097bac29c0e4024cb18deeaf08dd91006fa7157 /arch/sandbox/cpu/cache.c | |
parent | c589132a1de0c24dd247dbeb31e387f3b945bcfb (diff) |
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 <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/sandbox/cpu/cache.c')
-rw-r--r-- | arch/sandbox/cpu/cache.c | 23 |
1 files changed, 23 insertions, 0 deletions
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 <xypron.glpk@gmx.de> + */ + +#include <common.h> +#include <cpu_func.h> +#include <asm/state.h> + +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)); +} |