target: arc: rewrite command 'arc jtag get-aux-reg' as COMMAND_HANDLER
[openocd.git] / src / target / arc_cmd.c
index 7a8004678e4c5cbec3c2039578ea1d9279820e4c..56eb0ec2d20cfcab3022440c31af981cc08f1bb7 100644 (file)
@@ -318,39 +318,28 @@ static int jim_arc_set_aux_reg(Jim_Interp *interp, int argc, Jim_Obj * const *ar
        return ERROR_OK;
 }
 
-static int jim_arc_get_aux_reg(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
+COMMAND_HANDLER(arc_handle_get_aux_reg)
 {
-       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 != 1) {
-               Jim_SetResultFormatted(goi.interp,
-                       "usage: %s <aux_reg_num>", Jim_GetString(argv[0], NULL));
-               return JIM_ERR;
-       }
-
-       context = current_command_context(interp);
-       assert(context);
+       if (CMD_ARGC != 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
-       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, &regnum));
+       uint32_t regnum;
+       COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], regnum);
 
        struct arc_common *arc = target_to_arc(target);
        assert(arc);
 
+       uint32_t value;
        CHECK_RETVAL(arc_jtag_read_aux_reg_one(&arc->jtag_info, regnum, &value));
-       Jim_SetResultInt(interp, value);
+
+       command_print(CMD, "0x%" PRIx32, value);
 
        return ERROR_OK;
 }
@@ -445,7 +434,7 @@ static int jim_arc_set_core_reg(Jim_Interp *interp, int argc, Jim_Obj * const *a
 static const struct command_registration arc_jtag_command_group[] = {
        {
                .name = "get-aux-reg",
-               .jim_handler = jim_arc_get_aux_reg,
+               .handler = arc_handle_get_aux_reg,
                .mode = COMMAND_EXEC,
                .help = "Get AUX register by number. This command does a "
                        "raw JTAG request that bypasses OpenOCD register cache "

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)