target: arc: rewrite command 'arc jtag get-core-reg' as COMMAND_HANDLER
This also fixes an incorrect return ERROR_OK from a jim command. Change-Id: I1f9cf5d1dfa38b8a06042b5f54209e6ee2fc4e0e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7409 Tested-by: jenkins Reviewed-by: Evgeniy Didin <didin@synopsys.com>
This commit is contained in:
parent
551d85b123
commit
16af56f600
|
@ -331,45 +331,34 @@ COMMAND_HANDLER(arc_handle_get_aux_reg)
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int jim_arc_get_core_reg(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
|
COMMAND_HANDLER(arc_handle_get_core_reg)
|
||||||
{
|
{
|
||||||
struct command_context *context;
|
if (CMD_ARGC != 1)
|
||||||
struct target *target;
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||||
uint32_t regnum;
|
|
||||||
uint32_t value;
|
|
||||||
|
|
||||||
struct jim_getopt_info goi;
|
struct target *target = get_current_target(CMD_CTX);
|
||||||
JIM_CHECK_RETVAL(jim_getopt_setup(&goi, interp, argc-1, argv+1));
|
|
||||||
|
|
||||||
if (goi.argc != 1) {
|
|
||||||
Jim_SetResultFormatted(goi.interp,
|
|
||||||
"usage: %s <core_reg_num>", Jim_GetString(argv[0], NULL));
|
|
||||||
return JIM_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
context = current_command_context(interp);
|
|
||||||
assert(context);
|
|
||||||
|
|
||||||
target = get_current_target(context);
|
|
||||||
if (!target) {
|
if (!target) {
|
||||||
Jim_SetResultFormatted(goi.interp, "No current target");
|
command_print(CMD, "No current target");
|
||||||
return JIM_ERR;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register number */
|
/* Register number */
|
||||||
JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi, ®num));
|
uint32_t regnum;
|
||||||
|
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], regnum);
|
||||||
if (regnum > CORE_REG_MAX_NUMBER || regnum == ARC_R61 || regnum == ARC_R62) {
|
if (regnum > CORE_REG_MAX_NUMBER || regnum == ARC_R61 || regnum == ARC_R62) {
|
||||||
Jim_SetResultFormatted(goi.interp, "Core register number %i "
|
command_print(CMD, "Core register number %i "
|
||||||
"is invalid. Must less then 64 and not 61 and 62.", regnum);
|
"is invalid. Must less then 64 and not 61 and 62.", regnum);
|
||||||
return JIM_ERR;
|
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct arc_common *arc = target_to_arc(target);
|
struct arc_common *arc = target_to_arc(target);
|
||||||
assert(arc);
|
assert(arc);
|
||||||
|
|
||||||
/* Read value */
|
/* Read value */
|
||||||
|
uint32_t value;
|
||||||
CHECK_RETVAL(arc_jtag_read_core_reg_one(&arc->jtag_info, regnum, &value));
|
CHECK_RETVAL(arc_jtag_read_core_reg_one(&arc->jtag_info, regnum, &value));
|
||||||
Jim_SetResultInt(interp, value);
|
|
||||||
|
command_print(CMD, "0x%" PRIx32, value);
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +430,7 @@ static const struct command_registration arc_jtag_command_group[] = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "get-core-reg",
|
.name = "get-core-reg",
|
||||||
.jim_handler = jim_arc_get_core_reg,
|
.handler = arc_handle_get_core_reg,
|
||||||
.mode = COMMAND_EXEC,
|
.mode = COMMAND_EXEC,
|
||||||
.help = "Get/Set core register by number. This command does a "
|
.help = "Get/Set core register by number. This command does a "
|
||||||
"raw JTAG request that bypasses OpenOCD register cache "
|
"raw JTAG request that bypasses OpenOCD register cache "
|
||||||
|
|
Loading…
Reference in New Issue