From 6db8afb9d63e01e370d38cf54adbc53a0dda935b Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Wed, 30 May 2018 21:31:53 -0700 Subject: [PATCH] Flush the current cache first --- src/target/riscv/riscv-013.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 9946976ad..655df5a9b 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1720,6 +1720,18 @@ static int execute_fence(struct target *target) { int old_hartid = riscv_current_hartid(target); + /* FIXME: For non-coherent systems we need to flush the caches right + * here, but there's no ISA-defined way of doing that. */ + { + struct riscv_program program; + riscv_program_init(&program, target); + riscv_program_fence_i(&program); + riscv_program_fence(&program); + int result = riscv_program_exec(&program, target); + if (result != ERROR_OK) + LOG_ERROR("Unable to execute fence"); + } + for (int i = 0; i < riscv_count_harts(target); ++i) { if (!riscv_hart_enabled(target, i)) continue;