target: arc: rewrite command 'arc num-actionpoints' as COMMAND_HANDLER 12/7412/2
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 19 Dec 2022 16:14:15 +0000 (17:14 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 3 Feb 2023 22:47:17 +0000 (22:47 +0000)
Also drop arc_cmd_jim_get_uint32() that is now unused.

Change-Id: Ic26c3f008376db3f01215bf736fca736dd1c1a4f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7412
Tested-by: jenkins
Reviewed-by: Evgeniy Didin <didin@synopsys.com>
src/target/arc_cmd.c

index 264adc0b5c6808aeff445db24d2401203e04b31a..e7c54446e25c0f7f48aadf7c616f208e0cd29694 100644 (file)
  * ------------------------------------------------------------------------- */
 
 
-static int arc_cmd_jim_get_uint32(struct jim_getopt_info *goi, uint32_t *value)
-{
-       jim_wide value_wide;
-       JIM_CHECK_RETVAL(jim_getopt_wide(goi, &value_wide));
-       *value = (uint32_t)value_wide;
-       return JIM_OK;
-}
-
 enum add_reg_types {
        CFG_ADD_REG_TYPE_FLAG,
        CFG_ADD_REG_TYPE_STRUCT,
@@ -863,27 +855,17 @@ COMMAND_HANDLER(arc_l2_cache_disable_auto_cmd)
                &arc->has_l2cache, "target has l2 cache enabled");
 }
 
-static int jim_handle_actionpoints_num(Jim_Interp *interp, int argc,
-       Jim_Obj * const *argv)
+COMMAND_HANDLER(arc_handle_actionpoints_num)
 {
-       struct jim_getopt_info goi;
-       jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
-
        LOG_DEBUG("-");
 
-       if (goi.argc >= 2) {
-               Jim_WrongNumArgs(interp, goi.argc, goi.argv, "[<unsigned integer>]");
-               return JIM_ERR;
-       }
-
-       struct command_context *context = current_command_context(interp);
-       assert(context);
-
-       struct target *target = get_current_target(context);
+       if (CMD_ARGC >= 2)
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
+       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;
        }
 
        struct arc_common *arc = target_to_arc(target);
@@ -892,19 +874,19 @@ static int jim_handle_actionpoints_num(Jim_Interp *interp, int argc,
         * "actionpoint reset, initiated by arc_set_actionpoints_num.  */
        uint32_t ap_num = arc->actionpoints_num;
 
-       if (goi.argc == 1) {
-               JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi, &ap_num));
+       if (CMD_ARGC == 1) {
+               COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], ap_num);
                int e = arc_set_actionpoints_num(target, ap_num);
                if (e != ERROR_OK) {
-                       Jim_SetResultFormatted(goi.interp,
+                       command_print(CMD,
                                "Failed to set number of actionpoints");
-                       return JIM_ERR;
+                       return e;
                }
        }
 
-       Jim_SetResultInt(interp, ap_num);
+       command_print(CMD, "%" PRIu32, ap_num);
 
-       return JIM_OK;
+       return ERROR_OK;
 }
 
 /* ----- Exported target commands ------------------------------------------ */
@@ -1004,7 +986,7 @@ static const struct command_registration arc_core_command_handlers[] = {
        },
        {
                .name = "num-actionpoints",
-               .jim_handler = jim_handle_actionpoints_num,
+               .handler = arc_handle_actionpoints_num,
                .mode = COMMAND_ANY,
                .usage = "[<unsigned integer>]",
                .help = "Prints or sets amount of actionpoints in the processor.",

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)