Heinrich Schuchardt | 47c5e19 | 2020-12-09 19:42:44 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2020, Heinrich Schuchardt <xypron.glpk@gmx.de> |
| 4 | */ |
| 5 | |
Heinrich Schuchardt | 47c5e19 | 2020-12-09 19:42:44 +0100 | [diff] [blame] | 6 | #include <cpu_func.h> |
Simon Glass | 567b62c | 2024-11-27 11:17:19 -0600 | [diff] [blame^] | 7 | #include <mapmem.h> |
Heinrich Schuchardt | 47c5e19 | 2020-12-09 19:42:44 +0100 | [diff] [blame] | 8 | #include <asm/state.h> |
| 9 | |
| 10 | void flush_cache(unsigned long addr, unsigned long size) |
| 11 | { |
Simon Glass | 567b62c | 2024-11-27 11:17:19 -0600 | [diff] [blame^] | 12 | void *ptr; |
| 13 | |
| 14 | ptr = map_sysmem(addr, size); |
| 15 | |
Heinrich Schuchardt | 47c5e19 | 2020-12-09 19:42:44 +0100 | [diff] [blame] | 16 | /* Clang uses (char *) parameters, GCC (void *) */ |
Simon Glass | 567b62c | 2024-11-27 11:17:19 -0600 | [diff] [blame^] | 17 | __builtin___clear_cache(map_sysmem(addr, size), ptr + size); |
| 18 | unmap_sysmem(ptr); |
Heinrich Schuchardt | 47c5e19 | 2020-12-09 19:42:44 +0100 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | void invalidate_icache_all(void) |
| 22 | { |
| 23 | struct sandbox_state *state = state_get_current(); |
| 24 | |
| 25 | /* Clang uses (char *) parameters, GCC (void *) */ |
| 26 | __builtin___clear_cache((void *)state->ram_buf, |
| 27 | (void *)(state->ram_buf + state->ram_size)); |
| 28 | } |