target/arm: make 'arm core_state' command compatible with Cortex-M
Tcl command 'arm core_state' was exposed even on Cortex-M devices. However it returned message "Unsupported Command" without error status on such device. Set the only possible arm->core_state ARM_STATE_THUMB in armv7m init. Block setting core_state to arm on Cortex-M. Change-Id: I9525553ac8863a6cf77bbacbcd57e354b6cfe1ca Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7100 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
This commit is contained in:
parent
b6dad912b8
commit
dee7b7d821
|
@ -905,32 +905,33 @@ COMMAND_HANDLER(handle_armv4_5_reg_command)
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(handle_armv4_5_core_state_command)
|
||||
COMMAND_HANDLER(handle_arm_core_state_command)
|
||||
{
|
||||
struct target *target = get_current_target(CMD_CTX);
|
||||
struct arm *arm = target_to_arm(target);
|
||||
int ret = ERROR_OK;
|
||||
|
||||
if (!is_arm(arm)) {
|
||||
command_print(CMD, "current target isn't an ARM");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
if (arm->core_type == ARM_CORE_TYPE_M_PROFILE) {
|
||||
/* armv7m not supported */
|
||||
command_print(CMD, "Unsupported Command");
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
if (CMD_ARGC > 0) {
|
||||
if (strcmp(CMD_ARGV[0], "arm") == 0)
|
||||
arm->core_state = ARM_STATE_ARM;
|
||||
if (strcmp(CMD_ARGV[0], "arm") == 0) {
|
||||
if (arm->core_type == ARM_CORE_TYPE_M_PROFILE) {
|
||||
command_print(CMD, "arm mode not supported on Cortex-M");
|
||||
ret = ERROR_FAIL;
|
||||
} else {
|
||||
arm->core_state = ARM_STATE_ARM;
|
||||
}
|
||||
}
|
||||
if (strcmp(CMD_ARGV[0], "thumb") == 0)
|
||||
arm->core_state = ARM_STATE_THUMB;
|
||||
}
|
||||
|
||||
command_print(CMD, "core state: %s", arm_state_strings[arm->core_state]);
|
||||
|
||||
return ERROR_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(handle_arm_disassemble_command)
|
||||
|
@ -1126,7 +1127,7 @@ static const struct command_registration arm_exec_command_handlers[] = {
|
|||
},
|
||||
{
|
||||
.name = "core_state",
|
||||
.handler = handle_armv4_5_core_state_command,
|
||||
.handler = handle_arm_core_state_command,
|
||||
.mode = COMMAND_EXEC,
|
||||
.usage = "['arm'|'thumb']",
|
||||
.help = "display/change ARM core state",
|
||||
|
|
|
@ -854,6 +854,7 @@ int armv7m_init_arch_info(struct target *target, struct armv7m_common *armv7m)
|
|||
/* Enable stimulus port #0 by default */
|
||||
armv7m->trace_config.itm_ter[0] = 1;
|
||||
|
||||
arm->core_state = ARM_STATE_THUMB;
|
||||
arm->core_type = ARM_CORE_TYPE_M_PROFILE;
|
||||
arm->arch_info = armv7m;
|
||||
arm->setup_semihosting = armv7m_setup_semihosting;
|
||||
|
|
Loading…
Reference in New Issue