aboutsummaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
authorEvgeniy Naydanov <109669442+en-sc@users.noreply.github.com>2024-07-01 09:59:07 +0300
committerGitHub <noreply@github.com>2024-07-01 09:59:07 +0300
commitad871cb11b814d950eaad6b40b06341f29251ee0 (patch)
tree8a27b3ebbdddb49c32477151bc66e339e84b46fe /src/target
parentfdd07f127998f8669784fa64b67a43dea97c1837 (diff)
parent2eedd74197f12fb8c30f259207430713291e8ec0 (diff)
downloadriscv-openocd-ad871cb11b814d950eaad6b40b06341f29251ee0.zip
riscv-openocd-ad871cb11b814d950eaad6b40b06341f29251ee0.tar.gz
riscv-openocd-ad871cb11b814d950eaad6b40b06341f29251ee0.tar.bz2
Merge pull request #1094 from en-sc/en-sc/from_upstream
Merge up to ad87fbd1cf28760795c4e18f3318a2d720e5a8a6 from upstream
Diffstat (limited to 'src/target')
-rw-r--r--src/target/arc_jtag.c4
-rw-r--r--src/target/arm_tpiu_swo.c6
-rw-r--r--src/target/armv7m_trace.c22
-rw-r--r--src/target/armv7m_trace.h2
-rw-r--r--src/target/armv8.c180
-rw-r--r--src/target/armv8_dpm.c4
-rw-r--r--src/target/cortex_m.c10
-rw-r--r--src/target/hla_target.c28
-rw-r--r--src/target/target.c15
-rw-r--r--src/target/xtensa/xtensa.c2
-rw-r--r--src/target/xtensa/xtensa.h4
11 files changed, 184 insertions, 93 deletions
diff --git a/src/target/arc_jtag.c b/src/target/arc_jtag.c
index ddb4f62..a186709 100644
--- a/src/target/arc_jtag.c
+++ b/src/target/arc_jtag.c
@@ -298,7 +298,7 @@ static int arc_jtag_read_registers(struct arc_jtag *jtag_info, uint32_t type,
ARC_JTAG_READ_FROM_CORE_REG : ARC_JTAG_READ_FROM_AUX_REG);
arc_jtag_enque_set_transaction(jtag_info, transaction, TAP_DRPAUSE);
- uint8_t *data_buf = calloc(sizeof(uint8_t), count * 4);
+ uint8_t *data_buf = calloc(count * 4, sizeof(uint8_t));
arc_jtag_enque_register_rw(jtag_info, addr, data_buf, NULL, count);
@@ -498,7 +498,7 @@ int arc_jtag_read_memory(struct arc_jtag *jtag_info, uint32_t addr,
if (!count)
return ERROR_OK;
- data_buf = calloc(sizeof(uint8_t), count * 4);
+ data_buf = calloc(count * 4, sizeof(uint8_t));
arc_jtag_enque_reset_transaction(jtag_info);
/* We are reading from memory. */
diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c
index b5a4882..55a9778 100644
--- a/src/target/arm_tpiu_swo.c
+++ b/src/target/arm_tpiu_swo.c
@@ -965,8 +965,7 @@ static int jim_arm_tpiu_swo_create(Jim_Interp *interp, int argc, Jim_Obj *const
obj->out_filename = strdup("external");
if (!obj->out_filename) {
LOG_ERROR("Out of memory");
- free(obj);
- return JIM_ERR;
+ goto err_exit;
}
Jim_Obj *n;
@@ -974,8 +973,7 @@ static int jim_arm_tpiu_swo_create(Jim_Interp *interp, int argc, Jim_Obj *const
obj->name = strdup(Jim_GetString(n, NULL));
if (!obj->name) {
LOG_ERROR("Out of memory");
- free(obj);
- return JIM_ERR;
+ goto err_exit;
}
/* Do the rest as "configure" options */
diff --git a/src/target/armv7m_trace.c b/src/target/armv7m_trace.c
index 45117d2..556568d 100644
--- a/src/target/armv7m_trace.c
+++ b/src/target/armv7m_trace.c
@@ -92,11 +92,14 @@ COMMAND_HANDLER(handle_itm_port_command)
else
armv7m->trace_config.itm_ter[reg_idx] &= ~(1 << port);
- if (CMD_CTX->mode == COMMAND_EXEC)
- return armv7m_trace_itm_config(target);
+ /*
+ * In config mode ITM is not accessible yet.
+ * Keep the value and it will be programmed at target init.
+ */
+ if (CMD_CTX->mode == COMMAND_CONFIG)
+ return ERROR_OK;
- armv7m->trace_config.itm_deferred_config = true;
- return ERROR_OK;
+ return armv7m_trace_itm_config(target);
}
COMMAND_HANDLER(handle_itm_ports_command)
@@ -112,11 +115,14 @@ COMMAND_HANDLER(handle_itm_ports_command)
memset(armv7m->trace_config.itm_ter, enable ? 0xff : 0,
sizeof(armv7m->trace_config.itm_ter));
- if (CMD_CTX->mode == COMMAND_EXEC)
- return armv7m_trace_itm_config(target);
+ /*
+ * In config mode ITM is not accessible yet.
+ * Keep the value and it will be programmed at target init.
+ */
+ if (CMD_CTX->mode == COMMAND_CONFIG)
+ return ERROR_OK;
- armv7m->trace_config.itm_deferred_config = true;
- return ERROR_OK;
+ return armv7m_trace_itm_config(target);
}
static const struct command_registration itm_command_handlers[] = {
diff --git a/src/target/armv7m_trace.h b/src/target/armv7m_trace.h
index 5abb0b9..02eca93 100644
--- a/src/target/armv7m_trace.h
+++ b/src/target/armv7m_trace.h
@@ -35,8 +35,6 @@ struct armv7m_trace_config {
bool itm_async_timestamps;
/** Enable synchronisation packet transmission (for sync port only) */
bool itm_synchro_packets;
- /** Config ITM after target examine */
- bool itm_deferred_config;
};
extern const struct command_registration armv7m_trace_command_handlers[];
diff --git a/src/target/armv8.c b/src/target/armv8.c
index bf582ff..b54ef13 100644
--- a/src/target/armv8.c
+++ b/src/target/armv8.c
@@ -278,10 +278,14 @@ static int armv8_get_pauth_mask(struct armv8_common *armv8, uint64_t *mask)
static int armv8_read_reg(struct armv8_common *armv8, int regnum, uint64_t *regval)
{
struct arm_dpm *dpm = &armv8->dpm;
+ unsigned int curel = armv8_curel_from_core_mode(dpm->arm->core_mode);
int retval;
uint32_t value;
uint64_t value_64;
+ if (!regval)
+ return ERROR_FAIL;
+
switch (regnum) {
case 0 ... 30:
retval = dpm->instr_read_data_dcc_64(dpm,
@@ -311,46 +315,85 @@ static int armv8_read_reg(struct armv8_common *armv8, int regnum, uint64_t *regv
value_64 = value;
break;
case ARMV8_ELR_EL1:
+ if (curel < SYSTEM_CUREL_EL1) {
+ LOG_DEBUG("ELR_EL1 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
retval = dpm->instr_read_data_r0_64(dpm,
ARMV8_MRS(SYSTEM_ELR_EL1, 0), &value_64);
break;
case ARMV8_ELR_EL2:
+ if (curel < SYSTEM_CUREL_EL2) {
+ LOG_DEBUG("ELR_EL2 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
retval = dpm->instr_read_data_r0_64(dpm,
ARMV8_MRS(SYSTEM_ELR_EL2, 0), &value_64);
break;
case ARMV8_ELR_EL3:
+ if (curel < SYSTEM_CUREL_EL3) {
+ LOG_DEBUG("ELR_EL3 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
retval = dpm->instr_read_data_r0_64(dpm,
ARMV8_MRS(SYSTEM_ELR_EL3, 0), &value_64);
break;
case ARMV8_ESR_EL1:
- retval = dpm->instr_read_data_r0(dpm,
- ARMV8_MRS(SYSTEM_ESR_EL1, 0), &value);
- value_64 = value;
+ if (curel < SYSTEM_CUREL_EL1) {
+ LOG_DEBUG("ESR_EL1 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_read_data_r0_64(dpm,
+ ARMV8_MRS(SYSTEM_ESR_EL1, 0), &value_64);
break;
case ARMV8_ESR_EL2:
- retval = dpm->instr_read_data_r0(dpm,
- ARMV8_MRS(SYSTEM_ESR_EL2, 0), &value);
- value_64 = value;
+ if (curel < SYSTEM_CUREL_EL2) {
+ LOG_DEBUG("ESR_EL2 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_read_data_r0_64(dpm,
+ ARMV8_MRS(SYSTEM_ESR_EL2, 0), &value_64);
break;
case ARMV8_ESR_EL3:
- retval = dpm->instr_read_data_r0(dpm,
- ARMV8_MRS(SYSTEM_ESR_EL3, 0), &value);
- value_64 = value;
+ if (curel < SYSTEM_CUREL_EL3) {
+ LOG_DEBUG("ESR_EL3 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_read_data_r0_64(dpm,
+ ARMV8_MRS(SYSTEM_ESR_EL3, 0), &value_64);
break;
case ARMV8_SPSR_EL1:
- retval = dpm->instr_read_data_r0(dpm,
- ARMV8_MRS(SYSTEM_SPSR_EL1, 0), &value);
- value_64 = value;
+ if (curel < SYSTEM_CUREL_EL1) {
+ LOG_DEBUG("SPSR_EL1 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_read_data_r0_64(dpm,
+ ARMV8_MRS(SYSTEM_SPSR_EL1, 0), &value_64);
break;
case ARMV8_SPSR_EL2:
- retval = dpm->instr_read_data_r0(dpm,
- ARMV8_MRS(SYSTEM_SPSR_EL2, 0), &value);
- value_64 = value;
+ if (curel < SYSTEM_CUREL_EL2) {
+ LOG_DEBUG("SPSR_EL2 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_read_data_r0_64(dpm,
+ ARMV8_MRS(SYSTEM_SPSR_EL2, 0), &value_64);
break;
case ARMV8_SPSR_EL3:
- retval = dpm->instr_read_data_r0(dpm,
- ARMV8_MRS(SYSTEM_SPSR_EL3, 0), &value);
- value_64 = value;
+ if (curel < SYSTEM_CUREL_EL3) {
+ LOG_DEBUG("SPSR_EL3 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_read_data_r0_64(dpm,
+ ARMV8_MRS(SYSTEM_SPSR_EL3, 0), &value_64);
break;
case ARMV8_PAUTH_CMASK:
case ARMV8_PAUTH_DMASK:
@@ -361,10 +404,8 @@ static int armv8_read_reg(struct armv8_common *armv8, int regnum, uint64_t *regv
break;
}
- if (retval == ERROR_OK && regval)
+ if (retval == ERROR_OK)
*regval = value_64;
- else
- retval = ERROR_FAIL;
return retval;
}
@@ -395,6 +436,7 @@ static int armv8_read_reg_simdfp_aarch64(struct armv8_common *armv8, int regnum,
static int armv8_write_reg(struct armv8_common *armv8, int regnum, uint64_t value_64)
{
struct arm_dpm *dpm = &armv8->dpm;
+ unsigned int curel = armv8_curel_from_core_mode(dpm->arm->core_mode);
int retval;
uint32_t value;
@@ -434,46 +476,85 @@ static int armv8_write_reg(struct armv8_common *armv8, int regnum, uint64_t valu
break;
/* registers clobbered by taking exception in debug state */
case ARMV8_ELR_EL1:
+ if (curel < SYSTEM_CUREL_EL1) {
+ LOG_DEBUG("ELR_EL1 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
retval = dpm->instr_write_data_r0_64(dpm,
ARMV8_MSR_GP(SYSTEM_ELR_EL1, 0), value_64);
break;
case ARMV8_ELR_EL2:
+ if (curel < SYSTEM_CUREL_EL2) {
+ LOG_DEBUG("ELR_EL2 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
retval = dpm->instr_write_data_r0_64(dpm,
ARMV8_MSR_GP(SYSTEM_ELR_EL2, 0), value_64);
break;
case ARMV8_ELR_EL3:
+ if (curel < SYSTEM_CUREL_EL3) {
+ LOG_DEBUG("ELR_EL3 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
retval = dpm->instr_write_data_r0_64(dpm,
ARMV8_MSR_GP(SYSTEM_ELR_EL3, 0), value_64);
break;
case ARMV8_ESR_EL1:
- value = value_64;
- retval = dpm->instr_write_data_r0(dpm,
- ARMV8_MSR_GP(SYSTEM_ESR_EL1, 0), value);
+ if (curel < SYSTEM_CUREL_EL1) {
+ LOG_DEBUG("ESR_EL1 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_write_data_r0_64(dpm,
+ ARMV8_MSR_GP(SYSTEM_ESR_EL1, 0), value_64);
break;
case ARMV8_ESR_EL2:
- value = value_64;
- retval = dpm->instr_write_data_r0(dpm,
- ARMV8_MSR_GP(SYSTEM_ESR_EL2, 0), value);
+ if (curel < SYSTEM_CUREL_EL2) {
+ LOG_DEBUG("ESR_EL2 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_write_data_r0_64(dpm,
+ ARMV8_MSR_GP(SYSTEM_ESR_EL2, 0), value_64);
break;
case ARMV8_ESR_EL3:
- value = value_64;
- retval = dpm->instr_write_data_r0(dpm,
- ARMV8_MSR_GP(SYSTEM_ESR_EL3, 0), value);
+ if (curel < SYSTEM_CUREL_EL3) {
+ LOG_DEBUG("ESR_EL3 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_write_data_r0_64(dpm,
+ ARMV8_MSR_GP(SYSTEM_ESR_EL3, 0), value_64);
break;
case ARMV8_SPSR_EL1:
- value = value_64;
- retval = dpm->instr_write_data_r0(dpm,
- ARMV8_MSR_GP(SYSTEM_SPSR_EL1, 0), value);
+ if (curel < SYSTEM_CUREL_EL1) {
+ LOG_DEBUG("SPSR_EL1 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_write_data_r0_64(dpm,
+ ARMV8_MSR_GP(SYSTEM_SPSR_EL1, 0), value_64);
break;
case ARMV8_SPSR_EL2:
- value = value_64;
- retval = dpm->instr_write_data_r0(dpm,
- ARMV8_MSR_GP(SYSTEM_SPSR_EL2, 0), value);
+ if (curel < SYSTEM_CUREL_EL2) {
+ LOG_DEBUG("SPSR_EL2 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_write_data_r0_64(dpm,
+ ARMV8_MSR_GP(SYSTEM_SPSR_EL2, 0), value_64);
break;
case ARMV8_SPSR_EL3:
- value = value_64;
- retval = dpm->instr_write_data_r0(dpm,
- ARMV8_MSR_GP(SYSTEM_SPSR_EL3, 0), value);
+ if (curel < SYSTEM_CUREL_EL3) {
+ LOG_DEBUG("SPSR_EL3 not accessible in EL%u", curel);
+ retval = ERROR_FAIL;
+ break;
+ }
+ retval = dpm->instr_write_data_r0_64(dpm,
+ ARMV8_MSR_GP(SYSTEM_SPSR_EL3, 0), value_64);
break;
default:
retval = ERROR_FAIL;
@@ -512,6 +593,9 @@ static int armv8_read_reg32(struct armv8_common *armv8, int regnum, uint64_t *re
uint32_t value = 0;
int retval;
+ if (!regval)
+ return ERROR_FAIL;
+
switch (regnum) {
case ARMV8_R0 ... ARMV8_R14:
/* return via DCC: "MCR p14, 0, Rnum, c0, c5, 0" */
@@ -559,7 +643,7 @@ static int armv8_read_reg32(struct armv8_common *armv8, int regnum, uint64_t *re
ARMV4_5_MRC(15, 4, 0, 5, 2, 0),
&value);
break;
- case ARMV8_ESR_EL3: /* FIXME: no equivalent in aarch32? */
+ case ARMV8_ESR_EL3: /* no equivalent in aarch32 */
retval = ERROR_FAIL;
break;
case ARMV8_SPSR_EL1: /* mapped to SPSR_svc */
@@ -587,7 +671,7 @@ static int armv8_read_reg32(struct armv8_common *armv8, int regnum, uint64_t *re
break;
}
- if (retval == ERROR_OK && regval)
+ if (retval == ERROR_OK)
*regval = value;
return retval;
@@ -695,7 +779,7 @@ static int armv8_write_reg32(struct armv8_common *armv8, int regnum, uint64_t va
ARMV4_5_MCR(15, 4, 0, 5, 2, 0),
value);
break;
- case ARMV8_ESR_EL3: /* FIXME: no equivalent in aarch32? */
+ case ARMV8_ESR_EL3: /* no equivalent in aarch32 */
retval = ERROR_FAIL;
break;
case ARMV8_SPSR_EL1: /* mapped to SPSR_svc */
@@ -1504,23 +1588,23 @@ static const struct {
{ ARMV8_ELR_EL1, "ELR_EL1", 64, ARMV8_64_EL1H, REG_TYPE_CODE_PTR, "banked", "net.sourceforge.openocd.banked",
NULL},
- { ARMV8_ESR_EL1, "ESR_EL1", 32, ARMV8_64_EL1H, REG_TYPE_UINT32, "banked", "net.sourceforge.openocd.banked",
+ { ARMV8_ESR_EL1, "ESR_EL1", 64, ARMV8_64_EL1H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
NULL},
- { ARMV8_SPSR_EL1, "SPSR_EL1", 32, ARMV8_64_EL1H, REG_TYPE_UINT32, "banked", "net.sourceforge.openocd.banked",
+ { ARMV8_SPSR_EL1, "SPSR_EL1", 64, ARMV8_64_EL1H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
NULL},
{ ARMV8_ELR_EL2, "ELR_EL2", 64, ARMV8_64_EL2H, REG_TYPE_CODE_PTR, "banked", "net.sourceforge.openocd.banked",
NULL},
- { ARMV8_ESR_EL2, "ESR_EL2", 32, ARMV8_64_EL2H, REG_TYPE_UINT32, "banked", "net.sourceforge.openocd.banked",
+ { ARMV8_ESR_EL2, "ESR_EL2", 64, ARMV8_64_EL2H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
NULL},
- { ARMV8_SPSR_EL2, "SPSR_EL2", 32, ARMV8_64_EL2H, REG_TYPE_UINT32, "banked", "net.sourceforge.openocd.banked",
+ { ARMV8_SPSR_EL2, "SPSR_EL2", 64, ARMV8_64_EL2H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
NULL},
{ ARMV8_ELR_EL3, "ELR_EL3", 64, ARMV8_64_EL3H, REG_TYPE_CODE_PTR, "banked", "net.sourceforge.openocd.banked",
NULL},
- { ARMV8_ESR_EL3, "ESR_EL3", 32, ARMV8_64_EL3H, REG_TYPE_UINT32, "banked", "net.sourceforge.openocd.banked",
+ { ARMV8_ESR_EL3, "ESR_EL3", 64, ARMV8_64_EL3H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
NULL},
- { ARMV8_SPSR_EL3, "SPSR_EL3", 32, ARMV8_64_EL3H, REG_TYPE_UINT32, "banked", "net.sourceforge.openocd.banked",
+ { ARMV8_SPSR_EL3, "SPSR_EL3", 64, ARMV8_64_EL3H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
NULL},
{ ARMV8_PAUTH_DMASK, "pauth_dmask", 64, ARM_MODE_ANY, REG_TYPE_UINT64, NULL, "org.gnu.gdb.aarch64.pauth", NULL},
{ ARMV8_PAUTH_CMASK, "pauth_cmask", 64, ARM_MODE_ANY, REG_TYPE_UINT64, NULL, "org.gnu.gdb.aarch64.pauth", NULL},
diff --git a/src/target/armv8_dpm.c b/src/target/armv8_dpm.c
index 8bb24f2..271bd91 100644
--- a/src/target/armv8_dpm.c
+++ b/src/target/armv8_dpm.c
@@ -677,7 +677,7 @@ static int dpmv8_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum)
}
if (retval != ERROR_OK)
- LOG_ERROR("Failed to read %s register", r->name);
+ LOG_DEBUG("Failed to read %s register", r->name);
return retval;
}
@@ -719,7 +719,7 @@ static int dpmv8_write_reg(struct arm_dpm *dpm, struct reg *r, unsigned regnum)
}
if (retval != ERROR_OK)
- LOG_ERROR("Failed to write %s register", r->name);
+ LOG_DEBUG("Failed to write %s register", r->name);
return retval;
}
diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c
index c225b1a..34c7cd4 100644
--- a/src/target/cortex_m.c
+++ b/src/target/cortex_m.c
@@ -931,8 +931,12 @@ static int cortex_m_poll_one(struct target *target)
if (target->state != TARGET_RESET) {
target->state = TARGET_RESET;
LOG_TARGET_INFO(target, "external reset detected");
+ /* In case of an unexpected S_RESET_ST set TARGET_RESET state
+ * and keep it until the next poll to allow its detection */
+ return ERROR_OK;
}
- return ERROR_OK;
+ /* S_RESET_ST was expected (in a reset command). Continue processing
+ * to quickly get out of TARGET_RESET state */
}
if (target->state == TARGET_RESET) {
@@ -2655,8 +2659,8 @@ int cortex_m_examine(struct target *target)
if (retval != ERROR_OK)
return retval;
- if (armv7m->trace_config.itm_deferred_config)
- armv7m_trace_itm_config(target);
+ /* Configure ITM */
+ armv7m_trace_itm_config(target);
/* NOTE: FPB and DWT are both optional. */
diff --git a/src/target/hla_target.c b/src/target/hla_target.c
index c1bda99..d6f2afb 100644
--- a/src/target/hla_target.c
+++ b/src/target/hla_target.c
@@ -36,7 +36,7 @@
#define ARMV7M_SCS_DCRSR DCB_DCRSR
#define ARMV7M_SCS_DCRDR DCB_DCRDR
-static inline struct hl_interface_s *target_to_adapter(struct target *target)
+static inline struct hl_interface *target_to_adapter(struct target *target)
{
return target->tap->priv;
}
@@ -44,14 +44,14 @@ static inline struct hl_interface_s *target_to_adapter(struct target *target)
static int adapter_load_core_reg_u32(struct target *target,
uint32_t regsel, uint32_t *value)
{
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
return adapter->layout->api->read_reg(adapter->handle, regsel, value);
}
static int adapter_store_core_reg_u32(struct target *target,
uint32_t regsel, uint32_t value)
{
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
return adapter->layout->api->write_reg(adapter->handle, regsel, value);
}
@@ -65,7 +65,7 @@ static int adapter_examine_debug_reason(struct target *target)
return ERROR_OK;
}
-static int hl_dcc_read(struct hl_interface_s *hl_if, uint8_t *value, uint8_t *ctrl)
+static int hl_dcc_read(struct hl_interface *hl_if, uint8_t *value, uint8_t *ctrl)
{
uint16_t dcrdr;
int retval = hl_if->layout->api->read_mem(hl_if->handle,
@@ -90,7 +90,7 @@ static int hl_dcc_read(struct hl_interface_s *hl_if, uint8_t *value, uint8_t *ct
static int hl_target_request_data(struct target *target,
uint32_t size, uint8_t *buffer)
{
- struct hl_interface_s *hl_if = target_to_adapter(target);
+ struct hl_interface *hl_if = target_to_adapter(target);
uint8_t data;
uint8_t ctrl;
uint32_t i;
@@ -113,7 +113,7 @@ static int hl_handle_target_request(void *priv)
if (!target_was_examined(target))
return ERROR_OK;
- struct hl_interface_s *hl_if = target_to_adapter(target);
+ struct hl_interface *hl_if = target_to_adapter(target);
if (!target->dbg_msg_enabled)
return ERROR_OK;
@@ -227,7 +227,7 @@ static int adapter_load_context(struct target *target)
static int adapter_debug_entry(struct target *target)
{
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
struct armv7m_common *armv7m = target_to_armv7m(target);
struct arm *arm = &armv7m->arm;
struct reg *r;
@@ -286,7 +286,7 @@ static int adapter_debug_entry(struct target *target)
static int adapter_poll(struct target *target)
{
enum target_state state;
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
struct armv7m_common *armv7m = target_to_armv7m(target);
enum target_state prev_target_state = target->state;
@@ -329,7 +329,7 @@ static int adapter_poll(struct target *target)
static int hl_assert_reset(struct target *target)
{
int res = ERROR_OK;
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
struct armv7m_common *armv7m = target_to_armv7m(target);
bool use_srst_fallback = true;
@@ -412,7 +412,7 @@ static int hl_deassert_reset(struct target *target)
static int adapter_halt(struct target *target)
{
int res;
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
LOG_DEBUG("%s", __func__);
@@ -439,7 +439,7 @@ static int adapter_resume(struct target *target, int current,
int debug_execution)
{
int res;
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
struct armv7m_common *armv7m = target_to_armv7m(target);
uint32_t resume_pc;
struct breakpoint *breakpoint = NULL;
@@ -529,7 +529,7 @@ static int adapter_step(struct target *target, int current,
target_addr_t address, int handle_breakpoints)
{
int res;
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
struct armv7m_common *armv7m = target_to_armv7m(target);
struct breakpoint *breakpoint = NULL;
struct reg *pc = armv7m->arm.pc;
@@ -593,7 +593,7 @@ static int adapter_read_memory(struct target *target, target_addr_t address,
uint32_t size, uint32_t count,
uint8_t *buffer)
{
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
if (!count || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -608,7 +608,7 @@ static int adapter_write_memory(struct target *target, target_addr_t address,
uint32_t size, uint32_t count,
const uint8_t *buffer)
{
- struct hl_interface_s *adapter = target_to_adapter(target);
+ struct hl_interface *adapter = target_to_adapter(target);
if (!count || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;
diff --git a/src/target/target.c b/src/target/target.c
index 5187006..fd9c34f 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4675,9 +4675,8 @@ void target_handle_event(struct target *target, enum target_event e)
if (retval != JIM_OK) {
Jim_MakeErrorMessage(teap->interp);
- LOG_USER("Error executing event %s on target %s:\n%s",
+ LOG_TARGET_ERROR(target, "Execution of event %s failed:\n%s",
target_event_name(e),
- target_name(target),
Jim_GetString(Jim_GetResult(teap->interp), NULL));
/* clean both error code and stacktrace before return */
Jim_Eval(teap->interp, "error \"\" \"\"");
@@ -5349,17 +5348,19 @@ COMMAND_HANDLER(handle_target_reset)
return ERROR_FAIL;
}
- if (target->defer_examine)
- target_reset_examined(target);
-
/* determine if we should halt or not. */
target->reset_halt = (a != 0);
/* When this happens - all workareas are invalid. */
target_free_all_working_areas_restore(target, 0);
/* do the assert */
- if (n->value == NVP_ASSERT)
- return target->type->assert_reset(target);
+ if (n->value == NVP_ASSERT) {
+ int retval = target->type->assert_reset(target);
+ if (target->defer_examine)
+ target_reset_examined(target);
+ return retval;
+ }
+
return target->type->deassert_reset(target);
}
diff --git a/src/target/xtensa/xtensa.c b/src/target/xtensa/xtensa.c
index f7c82ef..702b8fc 100644
--- a/src/target/xtensa/xtensa.c
+++ b/src/target/xtensa/xtensa.c
@@ -331,7 +331,7 @@ union xtensa_reg_val_u {
uint8_t buf[4];
};
-static const struct xtensa_keyval_info_s xt_qerr[XT_QERR_NUM] = {
+static const struct xtensa_keyval_info xt_qerr[XT_QERR_NUM] = {
{ .chrval = "E00", .intval = ERROR_FAIL },
{ .chrval = "E01", .intval = ERROR_FAIL },
{ .chrval = "E02", .intval = ERROR_COMMAND_ARGUMENT_INVALID },
diff --git a/src/target/xtensa/xtensa.h b/src/target/xtensa/xtensa.h
index a220021..1d56f83 100644
--- a/src/target/xtensa/xtensa.h
+++ b/src/target/xtensa/xtensa.h
@@ -97,7 +97,7 @@ enum xtensa_ar_scratch_set_e {
XT_AR_SCRATCH_NUM
};
-struct xtensa_keyval_info_s {
+struct xtensa_keyval_info {
char *chrval;
int intval;
};
@@ -283,7 +283,7 @@ struct xtensa {
bool halt_request;
uint32_t nx_stop_cause;
uint32_t nx_reg_idx[XT_NX_REG_IDX_NUM];
- struct xtensa_keyval_info_s scratch_ars[XT_AR_SCRATCH_NUM];
+ struct xtensa_keyval_info scratch_ars[XT_AR_SCRATCH_NUM];
bool regs_fetched; /* true after first register fetch completed successfully */
};