openocd: trivial replace of jim-nvp with new nvp 53/7553/2
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 26 Dec 2022 21:46:19 +0000 (22:46 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 13 May 2023 08:49:05 +0000 (08:49 +0000)
For some trivial case only, replace calls to jim-nvp with calls
to the new OpenOCD nvp.

Change-Id: Ifd9aff32b67748af8ab808e6a6b6e64f5271b888
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7553
Tested-by: jenkins
src/jtag/drivers/ftdi.c
src/target/aarch64.c
src/target/armv8.c
src/target/cortex_a.c
src/target/cortex_m.c
src/target/target.c

index 85b45130832bbb97d8847283ffb0ad43566a79b4..7175925e420c031f266731f98efdb5030c576fc8 100644 (file)
@@ -64,6 +64,7 @@
 #include <transport/transport.h>
 #include <helper/time_support.h>
 #include <helper/log.h>
+#include <helper/nvp.h>
 
 #if IS_CYGWIN == 1
 #include <windows.h>
@@ -896,22 +897,22 @@ COMMAND_HANDLER(ftdi_handle_vid_pid_command)
 
 COMMAND_HANDLER(ftdi_handle_tdo_sample_edge_command)
 {
-       struct jim_nvp *n;
-       static const struct jim_nvp nvp_ftdi_jtag_modes[] = {
+       const struct nvp *n;
+       static const struct nvp nvp_ftdi_jtag_modes[] = {
                { .name = "rising", .value = JTAG_MODE },
                { .name = "falling", .value = JTAG_MODE_ALT },
                { .name = NULL, .value = -1 },
        };
 
        if (CMD_ARGC > 0) {
-               n = jim_nvp_name2value_simple(nvp_ftdi_jtag_modes, CMD_ARGV[0]);
+               n = nvp_name2value(nvp_ftdi_jtag_modes, CMD_ARGV[0]);
                if (!n->name)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                ftdi_jtag_mode = n->value;
 
        }
 
-       n = jim_nvp_value2name_simple(nvp_ftdi_jtag_modes, ftdi_jtag_mode);
+       n = nvp_value2name(nvp_ftdi_jtag_modes, ftdi_jtag_mode);
        command_print(CMD, "ftdi samples TDO on %s edge of TCK", n->name);
 
        return ERROR_OK;
index c6ebfb01136aafff0f4bd2dbd27bd28a10a7f673..5a16b3a3bf90f5bccd774a0f62f889b36ee9c49e 100644 (file)
@@ -21,6 +21,7 @@
 #include "arm_semihosting.h"
 #include "jtag/interface.h"
 #include "smp.h"
+#include <helper/nvp.h>
 #include <helper/time_support.h>
 
 enum restart_mode {
@@ -2957,15 +2958,15 @@ COMMAND_HANDLER(aarch64_mask_interrupts_command)
        struct target *target = get_current_target(CMD_CTX);
        struct aarch64_common *aarch64 = target_to_aarch64(target);
 
-       static const struct jim_nvp nvp_maskisr_modes[] = {
+       static const struct nvp nvp_maskisr_modes[] = {
                { .name = "off", .value = AARCH64_ISRMASK_OFF },
                { .name = "on", .value = AARCH64_ISRMASK_ON },
                { .name = NULL, .value = -1 },
        };
-       const struct jim_nvp *n;
+       const struct nvp *n;
 
        if (CMD_ARGC > 0) {
-               n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
+               n = nvp_name2value(nvp_maskisr_modes, CMD_ARGV[0]);
                if (!n->name) {
                        LOG_ERROR("Unknown parameter: %s - should be off or on", CMD_ARGV[0]);
                        return ERROR_COMMAND_SYNTAX_ERROR;
@@ -2974,7 +2975,7 @@ COMMAND_HANDLER(aarch64_mask_interrupts_command)
                aarch64->isrmasking_mode = n->value;
        }
 
-       n = jim_nvp_value2name_simple(nvp_maskisr_modes, aarch64->isrmasking_mode);
+       n = nvp_value2name(nvp_maskisr_modes, aarch64->isrmasking_mode);
        command_print(CMD, "aarch64 interrupt mask %s", n->name);
 
        return ERROR_OK;
index b01afdbc7bc452ba925ca38f841604fdbacebbe3..ffed263a9ffd60f04a83ab1495eed4350966db66 100644 (file)
@@ -19,6 +19,7 @@
 #include "register.h"
 #include <helper/binarybuffer.h>
 #include <helper/command.h>
+#include <helper/nvp.h>
 
 #include <stdlib.h>
 #include <string.h>
@@ -1043,7 +1044,7 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
        unsigned int argp = 0;
        int retval;
 
-       static const struct jim_nvp nvp_ecatch_modes[] = {
+       static const struct nvp nvp_ecatch_modes[] = {
                { .name = "off",       .value = 0 },
                { .name = "nsec_el1",  .value = (1 << 5) },
                { .name = "nsec_el2",  .value = (2 << 5) },
@@ -1053,7 +1054,7 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
                { .name = "sec_el13",  .value = (5 << 1) },
                { .name = NULL, .value = -1 },
        };
-       const struct jim_nvp *n;
+       const struct nvp *n;
 
        if (CMD_ARGC == 0) {
                const char *sec = NULL, *nsec = NULL;
@@ -1063,11 +1064,11 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
                if (retval != ERROR_OK)
                        return retval;
 
-               n = jim_nvp_value2name_simple(nvp_ecatch_modes, edeccr & 0x0f);
+               n = nvp_value2name(nvp_ecatch_modes, edeccr & 0x0f);
                if (n->name)
                        sec = n->name;
 
-               n = jim_nvp_value2name_simple(nvp_ecatch_modes, edeccr & 0xf0);
+               n = nvp_value2name(nvp_ecatch_modes, edeccr & 0xf0);
                if (n->name)
                        nsec = n->name;
 
@@ -1081,7 +1082,7 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
        }
 
        while (argp < CMD_ARGC) {
-               n = jim_nvp_name2value_simple(nvp_ecatch_modes, CMD_ARGV[argp]);
+               n = nvp_name2value(nvp_ecatch_modes, CMD_ARGV[argp]);
                if (!n->name) {
                        LOG_ERROR("Unknown option: %s", CMD_ARGV[argp]);
                        return ERROR_FAIL;
index 3db9c62a55f03b63e6a3a58b62c75b706d087251..d9688be13b6d09d26fe693a1b44920569e924feb 100644 (file)
@@ -52,6 +52,7 @@
 #include "transport/transport.h"
 #include "smp.h"
 #include <helper/bits.h>
+#include <helper/nvp.h>
 #include <helper/time_support.h>
 
 static int cortex_a_poll(struct target *target);
@@ -3246,15 +3247,15 @@ COMMAND_HANDLER(handle_cortex_a_mask_interrupts_command)
        struct target *target = get_current_target(CMD_CTX);
        struct cortex_a_common *cortex_a = target_to_cortex_a(target);
 
-       static const struct jim_nvp nvp_maskisr_modes[] = {
+       static const struct nvp nvp_maskisr_modes[] = {
                { .name = "off", .value = CORTEX_A_ISRMASK_OFF },
                { .name = "on", .value = CORTEX_A_ISRMASK_ON },
                { .name = NULL, .value = -1 },
        };
-       const struct jim_nvp *n;
+       const struct nvp *n;
 
        if (CMD_ARGC > 0) {
-               n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
+               n = nvp_name2value(nvp_maskisr_modes, CMD_ARGV[0]);
                if (!n->name) {
                        LOG_ERROR("Unknown parameter: %s - should be off or on", CMD_ARGV[0]);
                        return ERROR_COMMAND_SYNTAX_ERROR;
@@ -3263,7 +3264,7 @@ COMMAND_HANDLER(handle_cortex_a_mask_interrupts_command)
                cortex_a->isrmasking_mode = n->value;
        }
 
-       n = jim_nvp_value2name_simple(nvp_maskisr_modes, cortex_a->isrmasking_mode);
+       n = nvp_value2name(nvp_maskisr_modes, cortex_a->isrmasking_mode);
        command_print(CMD, "cortex_a interrupt mask %s", n->name);
 
        return ERROR_OK;
@@ -3274,22 +3275,22 @@ COMMAND_HANDLER(handle_cortex_a_dacrfixup_command)
        struct target *target = get_current_target(CMD_CTX);
        struct cortex_a_common *cortex_a = target_to_cortex_a(target);
 
-       static const struct jim_nvp nvp_dacrfixup_modes[] = {
+       static const struct nvp nvp_dacrfixup_modes[] = {
                { .name = "off", .value = CORTEX_A_DACRFIXUP_OFF },
                { .name = "on", .value = CORTEX_A_DACRFIXUP_ON },
                { .name = NULL, .value = -1 },
        };
-       const struct jim_nvp *n;
+       const struct nvp *n;
 
        if (CMD_ARGC > 0) {
-               n = jim_nvp_name2value_simple(nvp_dacrfixup_modes, CMD_ARGV[0]);
+               n = nvp_name2value(nvp_dacrfixup_modes, CMD_ARGV[0]);
                if (!n->name)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                cortex_a->dacrfixup_mode = n->value;
 
        }
 
-       n = jim_nvp_value2name_simple(nvp_dacrfixup_modes, cortex_a->dacrfixup_mode);
+       n = nvp_value2name(nvp_dacrfixup_modes, cortex_a->dacrfixup_mode);
        command_print(CMD, "cortex_a domain access control fixup %s", n->name);
 
        return ERROR_OK;
index 88e9bb299f7fcbc5c6208a99736ecc02e1e55586..8e55014f9b022c3c208b613f31b3e30c08dfcc03 100644 (file)
@@ -29,6 +29,7 @@
 #include "arm_opcodes.h"
 #include "arm_semihosting.h"
 #include "smp.h"
+#include <helper/nvp.h>
 #include <helper/time_support.h>
 #include <rtt/rtt.h>
 
@@ -2935,14 +2936,14 @@ COMMAND_HANDLER(handle_cortex_m_mask_interrupts_command)
        struct cortex_m_common *cortex_m = target_to_cm(target);
        int retval;
 
-       static const struct jim_nvp nvp_maskisr_modes[] = {
+       static const struct nvp nvp_maskisr_modes[] = {
                { .name = "auto", .value = CORTEX_M_ISRMASK_AUTO },
                { .name = "off", .value = CORTEX_M_ISRMASK_OFF },
                { .name = "on", .value = CORTEX_M_ISRMASK_ON },
                { .name = "steponly", .value = CORTEX_M_ISRMASK_STEPONLY },
                { .name = NULL, .value = -1 },
        };
-       const struct jim_nvp *n;
+       const struct nvp *n;
 
 
        retval = cortex_m_verify_pointer(CMD, cortex_m);
@@ -2955,14 +2956,14 @@ COMMAND_HANDLER(handle_cortex_m_mask_interrupts_command)
        }
 
        if (CMD_ARGC > 0) {
-               n = jim_nvp_name2value_simple(nvp_maskisr_modes, CMD_ARGV[0]);
+               n = nvp_name2value(nvp_maskisr_modes, CMD_ARGV[0]);
                if (!n->name)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                cortex_m->isrmasking_mode = n->value;
                cortex_m_set_maskints_for_halt(target);
        }
 
-       n = jim_nvp_value2name_simple(nvp_maskisr_modes, cortex_m->isrmasking_mode);
+       n = nvp_value2name(nvp_maskisr_modes, cortex_m->isrmasking_mode);
        command_print(CMD, "cortex_m interrupt mask %s", n->name);
 
        return ERROR_OK;
index c55b67cc953c1f7c8f8932348ea32cb5d5ba2c59..fb5ef72193725bb27b91f1d443e52255b62df352 100644 (file)
@@ -31,6 +31,7 @@
 #endif
 
 #include <helper/align.h>
+#include <helper/nvp.h>
 #include <helper/time_support.h>
 #include <jtag/jtag.h>
 #include <flash/nor/core.h>
@@ -166,7 +167,7 @@ static const struct jim_nvp nvp_assert[] = {
        { .name = NULL, .value = -1 }
 };
 
-static const struct jim_nvp nvp_error_target[] = {
+static const struct nvp nvp_error_target[] = {
        { .value = ERROR_TARGET_INVALID, .name = "err-invalid" },
        { .value = ERROR_TARGET_INIT_FAILED, .name = "err-init-failed" },
        { .value = ERROR_TARGET_TIMEOUT, .name = "err-timeout" },
@@ -183,9 +184,9 @@ static const struct jim_nvp nvp_error_target[] = {
 
 static const char *target_strerror_safe(int err)
 {
-       const struct jim_nvp *n;
+       const struct nvp *n;
 
-       n = jim_nvp_value2name_simple(nvp_error_target, err);
+       n = nvp_value2name(nvp_error_target, err);
        if (!n->name)
                return "unknown";
        else
@@ -253,7 +254,7 @@ static const struct jim_nvp nvp_target_state[] = {
        { .name = NULL, .value = -1 },
 };
 
-static const struct jim_nvp nvp_target_debug_reason[] = {
+static const struct nvp nvp_target_debug_reason[] = {
        { .name = "debug-request",             .value = DBG_REASON_DBGRQ },
        { .name = "breakpoint",                .value = DBG_REASON_BREAKPOINT },
        { .name = "watchpoint",                .value = DBG_REASON_WATCHPOINT },
@@ -274,7 +275,7 @@ static const struct jim_nvp nvp_target_endian[] = {
        { .name = NULL,     .value = -1 },
 };
 
-static const struct jim_nvp nvp_reset_modes[] = {
+static const struct nvp nvp_reset_modes[] = {
        { .name = "unknown", .value = RESET_UNKNOWN },
        { .name = "run",     .value = RESET_RUN },
        { .name = "halt",    .value = RESET_HALT },
@@ -286,7 +287,7 @@ const char *debug_reason_name(struct target *t)
 {
        const char *cp;
 
-       cp = jim_nvp_value2name_simple(nvp_target_debug_reason,
+       cp = nvp_value2name(nvp_target_debug_reason,
                        t->debug_reason)->name;
        if (!cp) {
                LOG_ERROR("Invalid debug reason: %d", (int)(t->debug_reason));
@@ -324,7 +325,7 @@ const char *target_event_name(enum target_event event)
 const char *target_reset_mode_name(enum target_reset_mode reset_mode)
 {
        const char *cp;
-       cp = jim_nvp_value2name_simple(nvp_reset_modes, reset_mode)->name;
+       cp = nvp_value2name(nvp_reset_modes, reset_mode)->name;
        if (!cp) {
                LOG_ERROR("Invalid target reset mode: %d", (int)(reset_mode));
                cp = "(*BUG*unknown*BUG*)";
@@ -668,8 +669,8 @@ static int target_process_reset(struct command_invocation *cmd, enum target_rese
 {
        char buf[100];
        int retval;
-       struct jim_nvp *n;
-       n = jim_nvp_value2name_simple(nvp_reset_modes, reset_mode);
+       const struct nvp *n;
+       n = nvp_value2name(nvp_reset_modes, reset_mode);
        if (!n->name) {
                LOG_ERROR("invalid reset mode");
                return ERROR_FAIL;
@@ -1856,7 +1857,7 @@ int target_call_reset_callbacks(struct target *target, enum target_reset_mode re
        struct target_reset_callback *callback;
 
        LOG_DEBUG("target reset %i (%s)", reset_mode,
-                       jim_nvp_value2name_simple(nvp_reset_modes, reset_mode)->name);
+                       nvp_value2name(nvp_reset_modes, reset_mode)->name);
 
        list_for_each_entry(callback, &target_reset_callback_list, list)
                callback->callback(target, reset_mode, callback->priv);
@@ -3338,8 +3339,8 @@ COMMAND_HANDLER(handle_reset_command)
 
        enum target_reset_mode reset_mode = RESET_RUN;
        if (CMD_ARGC == 1) {
-               const struct jim_nvp *n;
-               n = jim_nvp_name2value_simple(nvp_reset_modes, CMD_ARGV[0]);
+               const struct nvp *n;
+               n = nvp_name2value(nvp_reset_modes, CMD_ARGV[0]);
                if ((!n->name) || (n->value == RESET_UNKNOWN))
                        return ERROR_COMMAND_SYNTAX_ERROR;
                reset_mode = n->value;

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)