Applied fence.i fix on memory write to v20171231 release

This commit is contained in:
Gleb Gagarin 2018-02-08 13:02:24 -08:00
parent ab5a98663e
commit 0e2fc08c3b
1 changed files with 25 additions and 1 deletions

View File

@ -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;