diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2022-12-19 13:32:56 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2023-02-03 22:46:19 +0000 |
commit | 551d85b123b38d34e15b4e978250ebdfe7b952f7 (patch) | |
tree | b162537a3bf7afd449b062cd5e80c6b4567af8e7 | |
parent | 700cdbfac41014d9f3a9c12cbb13f01e59fb53d8 (diff) | |
download | riscv-openocd-551d85b123b38d34e15b4e978250ebdfe7b952f7.zip riscv-openocd-551d85b123b38d34e15b4e978250ebdfe7b952f7.tar.gz riscv-openocd-551d85b123b38d34e15b4e978250ebdfe7b952f7.tar.bz2 |
target: arc: rewrite command 'arc jtag set-aux-reg' as COMMAND_HANDLER
This also fixes an incorrect return ERROR_OK from a jim command.
Change-Id: Iab9bc7c25181341a632f608a8ef2d8b0bea72520
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7408
Tested-by: jenkins
Reviewed-by: Evgeniy Didin <didin@synopsys.com>
-rw-r--r-- | src/target/arc_cmd.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/src/target/arc_cmd.c b/src/target/arc_cmd.c index 56eb0ec..a6eb14f 100644 --- a/src/target/arc_cmd.c +++ b/src/target/arc_cmd.c @@ -278,37 +278,24 @@ static struct jim_nvp nvp_add_reg_type_struct_opts[] = { { .name = NULL, .value = -1 } }; -static int jim_arc_set_aux_reg(Jim_Interp *interp, int argc, Jim_Obj * const *argv) +COMMAND_HANDLER(arc_handle_set_aux_reg) { + if (CMD_ARGC != 2) + return ERROR_COMMAND_SYNTAX_ERROR; - struct command_context *context; - struct target *target; - uint32_t regnum; - uint32_t value; - - struct jim_getopt_info goi; - JIM_CHECK_RETVAL(jim_getopt_setup(&goi, interp, argc-1, argv+1)); - - if (goi.argc != 2) { - Jim_SetResultFormatted(goi.interp, - "usage: %s <aux_reg_num> <aux_reg_value>", Jim_GetString(argv[0], NULL)); - return JIM_ERR; - } - - context = current_command_context(interp); - assert(context); - - target = get_current_target(context); + struct target *target = get_current_target(CMD_CTX); if (!target) { - Jim_SetResultFormatted(goi.interp, "No current target"); - return JIM_ERR; + command_print(CMD, "No current target"); + return ERROR_FAIL; } /* Register number */ - JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi, ®num)); + uint32_t regnum; + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], regnum); /* Register value */ - JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi, &value)); + uint32_t value; + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); struct arc_common *arc = target_to_arc(target); assert(arc); @@ -444,7 +431,7 @@ static const struct command_registration arc_jtag_command_group[] = { }, { .name = "set-aux-reg", - .jim_handler = jim_arc_set_aux_reg, + .handler = arc_handle_set_aux_reg, .mode = COMMAND_EXEC, .help = "Set AUX register by number. This command does a " "raw JTAG request that bypasses OpenOCD register cache " |