openocd: trivial replace of jim-nvp with new nvp

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
This commit is contained in:
Antonio Borneo
2022-12-26 22:46:19 +01:00
parent 160288137a
commit 599f1cf763
6 changed files with 43 additions and 37 deletions

View 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;