Be a bit stricter about fences
This commit is contained in:
parent
d6a0023bab
commit
9d975bf8f0
|
@ -1718,13 +1718,26 @@ static void write_to_buf(uint8_t *buffer, uint64_t value, unsigned size)
|
||||||
|
|
||||||
static int execute_fence(struct target *target)
|
static int execute_fence(struct target *target)
|
||||||
{
|
{
|
||||||
struct riscv_program program;
|
int old_hartid = riscv_current_hartid(target);
|
||||||
riscv_program_init(&program, target);
|
|
||||||
riscv_program_fence(&program);
|
for (int i = 0; i < riscv_count_harts(target); ++i) {
|
||||||
int result = riscv_program_exec(&program, target);
|
if (!riscv_hart_enabled(target, i))
|
||||||
if (result != ERROR_OK)
|
continue;
|
||||||
LOG_ERROR("Unable to execute fence");
|
|
||||||
return result;
|
riscv_set_current_hartid(target, i);
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
riscv_set_current_hartid(target, old_hartid);
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void log_memory_access(target_addr_t address, uint64_t value,
|
static void log_memory_access(target_addr_t address, uint64_t value,
|
||||||
|
@ -2899,19 +2912,7 @@ int riscv013_dmi_write_u64_bits(struct target *target)
|
||||||
|
|
||||||
static int maybe_execute_fence_i(struct target *target)
|
static int maybe_execute_fence_i(struct target *target)
|
||||||
{
|
{
|
||||||
RISCV013_INFO(info);
|
return execute_fence(target);
|
||||||
RISCV_INFO(r);
|
|
||||||
if (info->progbufsize + r->impebreak >= 2) {
|
|
||||||
struct riscv_program program;
|
|
||||||
riscv_program_init(&program, target);
|
|
||||||
if (riscv_program_fence_i(&program) != ERROR_OK)
|
|
||||||
return ERROR_FAIL;
|
|
||||||
if (riscv_program_exec(&program, target) != ERROR_OK) {
|
|
||||||
LOG_ERROR("Failed to execute fence.i");
|
|
||||||
return ERROR_FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ERROR_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper Functions. */
|
/* Helper Functions. */
|
||||||
|
|
|
@ -499,6 +499,8 @@ static int add_trigger(struct target *target, struct trigger *trigger)
|
||||||
int riscv_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
|
int riscv_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
|
||||||
{
|
{
|
||||||
if (breakpoint->type == BKPT_SOFT) {
|
if (breakpoint->type == BKPT_SOFT) {
|
||||||
|
LOG_DEBUG("Adding software breakpoint at 0x%016lx", breakpoint->address);
|
||||||
|
|
||||||
if (target_read_memory(target, breakpoint->address, breakpoint->length, 1,
|
if (target_read_memory(target, breakpoint->address, breakpoint->length, 1,
|
||||||
breakpoint->orig_instr) != ERROR_OK) {
|
breakpoint->orig_instr) != ERROR_OK) {
|
||||||
LOG_ERROR("Failed to read original instruction at 0x%" TARGET_PRIxADDR,
|
LOG_ERROR("Failed to read original instruction at 0x%" TARGET_PRIxADDR,
|
||||||
|
|
Loading…
Reference in New Issue