aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/target/riscv/riscv-013.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 6251765..c2d888f 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1408,6 +1408,30 @@ static int execute_fence(struct target *target)
return result;
}
+static int execute_fence_i(struct target *target)
+{
+ struct riscv_program program;
+ riscv_program_init(&program, target);
+ riscv_program_fence_i(&program);
+ int result = riscv_program_exec(&program, target);
+ if (result != ERROR_OK)
+ LOG_ERROR("Unable to execute fence.i");
+ return result;
+}
+
+static int execute_fences(struct target *target)
+{
+ if (execute_fence(target) != ERROR_OK)
+ {
+ return ERROR_FAIL;
+ }
+ if (execute_fence_i(target) != ERROR_OK)
+ {
+ return ERROR_FAIL;
+ }
+ return ERROR_OK;
+}
+
/**
* Read the requested memory, taking care to execute every read exactly once,
* even if cmderr=busy is encountered.
@@ -1822,7 +1846,7 @@ error:
if (register_write_direct(target, GDB_REGNO_S0, s0) != ERROR_OK)
return ERROR_FAIL;
- if (execute_fence(target) != ERROR_OK)
+ if (execute_fences(target) != ERROR_OK)
return ERROR_FAIL;
return result;