aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2023-08-18 09:32:51 -0700
committerGitHub <noreply@github.com>2023-08-18 09:32:51 -0700
commit5cb60e3f7d1b2eca5e376a6a829bdd3659c35f54 (patch)
tree0241050ae0b1180be523c8cb705fa6e4541c9a6b /src
parentf0616235681544ee574b829c3da0ff53765de293 (diff)
parent373b8f1a899402828d84190da57af4e27f118909 (diff)
downloadriscv-openocd-5cb60e3f7d1b2eca5e376a6a829bdd3659c35f54.zip
riscv-openocd-5cb60e3f7d1b2eca5e376a6a829bdd3659c35f54.tar.gz
riscv-openocd-5cb60e3f7d1b2eca5e376a6a829bdd3659c35f54.tar.bz2
Merge pull request #903 from wxjstz/riscv
target/riscv: fix execute_fence
Diffstat (limited to 'src')
-rw-r--r--src/target/riscv/riscv-013.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 59bd869..6f5c142 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -2920,15 +2920,35 @@ static int execute_fence(struct target *target)
/* FIXME: For non-coherent systems we need to flush the caches right
* here, but there's no ISA-defined way of doing that. */
+ int result;
struct riscv_program program;
- riscv_program_init(&program, target);
- riscv_program_fence_i(&program);
- riscv_program_fence_rw_rw(&program);
- int result = riscv_program_exec(&program, target);
- if (result != ERROR_OK)
- LOG_TARGET_DEBUG(target, "Unable to execute pre-fence");
- return ERROR_OK;
+ if (has_sufficient_progbuf(target, 3)) {
+ riscv_program_init(&program, target);
+ riscv_program_fence_rw_rw(&program);
+ riscv_program_fence_i(&program);
+ result = riscv_program_exec(&program, target);
+ if (result != ERROR_OK)
+ LOG_TARGET_DEBUG(target, "Unable to execute pre-fence");
+ return ERROR_OK;
+ }
+
+ if (has_sufficient_progbuf(target, 2)) {
+ riscv_program_init(&program, target);
+ riscv_program_fence_i(&program);
+ result = riscv_program_exec(&program, target);
+ if (result != ERROR_OK)
+ LOG_TARGET_DEBUG(target, "Unable to execute fence.i");
+
+ riscv_program_init(&program, target);
+ riscv_program_fence_rw_rw(&program);
+ result = riscv_program_exec(&program, target);
+ if (result != ERROR_OK)
+ LOG_TARGET_DEBUG(target, "Unable to execute fence rw, rw");
+ return ERROR_OK;
+ }
+
+ return ERROR_FAIL;
}
static void log_memory_access128(target_addr_t address, uint64_t value_h,
@@ -5070,7 +5090,7 @@ void riscv013_fill_dm_nop_u64(struct target *target, char *buf)
static int maybe_execute_fence_i(struct target *target)
{
- if (has_sufficient_progbuf(target, 3))
+ if (has_sufficient_progbuf(target, 2))
return execute_fence(target);
return ERROR_OK;
}