aboutsummaryrefslogtreecommitdiff
path: root/src/jtag/hla
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2023-01-01 19:17:18 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2023-01-15 15:12:05 +0000
commitcda39f929e65316478f2f41f461b0cbb3338806c (patch)
tree278a0d042edb6fc05fdb6d8eccee78e1d0b41128 /src/jtag/hla
parent7a890a8f256f28b1c8b0dde3b62ab81c7c139d55 (diff)
downloadriscv-openocd-cda39f929e65316478f2f41f461b0cbb3338806c.zip
riscv-openocd-cda39f929e65316478f2f41f461b0cbb3338806c.tar.gz
riscv-openocd-cda39f929e65316478f2f41f461b0cbb3338806c.tar.bz2
jtag: hla: use generic helper for commands 'jtag newtap' 'swd newdap'
The commands 'jtag newtap' and 'swd newdap' have to work either on HLA transport and on standard JTAG/SWD. Having a dedicated implementation for HLA is a non-sense. Reuse the generic code jim_jtag_newtap() and drop the files hla_tcl.[ch] as they are now empty. Change-Id: I9dabbdc2a6f338f23b2fd3ed1a4dc3da0200c080 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7428 Tested-by: jenkins
Diffstat (limited to 'src/jtag/hla')
-rw-r--r--src/jtag/hla/Makefile.am4
-rw-r--r--src/jtag/hla/hla_interface.c1
-rw-r--r--src/jtag/hla/hla_layout.c1
-rw-r--r--src/jtag/hla/hla_tcl.c143
-rw-r--r--src/jtag/hla/hla_tcl.h17
-rw-r--r--src/jtag/hla/hla_transport.c5
6 files changed, 3 insertions, 168 deletions
diff --git a/src/jtag/hla/Makefile.am b/src/jtag/hla/Makefile.am
index 4111786..ea6e11d 100644
--- a/src/jtag/hla/Makefile.am
+++ b/src/jtag/hla/Makefile.am
@@ -4,10 +4,8 @@ noinst_LTLIBRARIES += %D%/libocdhla.la
%C%_libocdhla_la_SOURCES = \
%D%/hla_transport.c \
- %D%/hla_tcl.c \
%D%/hla_interface.c \
%D%/hla_layout.c \
%D%/hla_transport.h \
%D%/hla_interface.h \
- %D%/hla_layout.h \
- %D%/hla_tcl.h
+ %D%/hla_layout.h
diff --git a/src/jtag/hla/hla_interface.c b/src/jtag/hla/hla_interface.c
index 6198b3d..f4bfeb1 100644
--- a/src/jtag/hla/hla_interface.c
+++ b/src/jtag/hla/hla_interface.c
@@ -17,7 +17,6 @@
#include <transport/transport.h>
#include <helper/time_support.h>
-#include <jtag/hla/hla_tcl.h>
#include <jtag/hla/hla_layout.h>
#include <jtag/hla/hla_transport.h>
#include <jtag/hla/hla_interface.h>
diff --git a/src/jtag/hla/hla_layout.c b/src/jtag/hla/hla_layout.c
index a760f0b..51671d6 100644
--- a/src/jtag/hla/hla_layout.c
+++ b/src/jtag/hla/hla_layout.c
@@ -18,7 +18,6 @@
#include <helper/time_support.h>
#include <jtag/hla/hla_layout.h>
-#include <jtag/hla/hla_tcl.h>
#include <jtag/hla/hla_transport.h>
#include <jtag/hla/hla_interface.h>
diff --git a/src/jtag/hla/hla_tcl.c b/src/jtag/hla/hla_tcl.c
deleted file mode 100644
index 3283399..0000000
--- a/src/jtag/hla/hla_tcl.c
+++ /dev/null
@@ -1,143 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-/***************************************************************************
- * Copyright (C) 2011 by Mathias Kuester *
- * Mathias Kuester <kesmtp@freenet.de> *
- * *
- * Copyright (C) 2012 by Spencer Oliver *
- * spen@spen-soft.co.uk *
- ***************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* project specific includes */
-#include <jtag/interface.h>
-#include <transport/transport.h>
-#include <helper/time_support.h>
-
-static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi,
- struct jtag_tap *tap)
-{
- jim_wide w;
- int e = jim_getopt_wide(goi, &w);
- if (e != JIM_OK) {
- Jim_SetResultFormatted(goi->interp, "option: %s bad parameter",
- n->name);
- return e;
- }
-
- uint32_t *p = realloc(tap->expected_ids,
- (tap->expected_ids_cnt + 1) * sizeof(uint32_t));
- if (!p) {
- Jim_SetResultFormatted(goi->interp, "no memory");
- return JIM_ERR;
- }
-
- tap->expected_ids = p;
- tap->expected_ids[tap->expected_ids_cnt++] = w;
-
- return JIM_OK;
-}
-
-#define NTAP_OPT_IRLEN 0
-#define NTAP_OPT_IRMASK 1
-#define NTAP_OPT_IRCAPTURE 2
-#define NTAP_OPT_ENABLED 3
-#define NTAP_OPT_DISABLED 4
-#define NTAP_OPT_EXPECTED_ID 5
-#define NTAP_OPT_VERSION 6
-#define NTAP_OPT_BYPASS 7
-
-static int jim_hl_newtap_cmd(struct jim_getopt_info *goi)
-{
- struct jtag_tap *tap;
- int x;
- int e;
- struct jim_nvp *n;
- char *cp;
- const struct jim_nvp opts[] = {
- { .name = "-irlen", .value = NTAP_OPT_IRLEN },
- { .name = "-irmask", .value = NTAP_OPT_IRMASK },
- { .name = "-ircapture", .value = NTAP_OPT_IRCAPTURE },
- { .name = "-enable", .value = NTAP_OPT_ENABLED },
- { .name = "-disable", .value = NTAP_OPT_DISABLED },
- { .name = "-expected-id", .value = NTAP_OPT_EXPECTED_ID },
- { .name = "-ignore-version", .value = NTAP_OPT_VERSION },
- { .name = "-ignore-bypass", .value = NTAP_OPT_BYPASS },
- { .name = NULL, .value = -1},
- };
-
- tap = calloc(1, sizeof(struct jtag_tap));
- if (!tap) {
- Jim_SetResultFormatted(goi->interp, "no memory");
- return JIM_ERR;
- }
-
- /*
- * we expect CHIP + TAP + OPTIONS
- * */
- if (goi->argc < 3) {
- Jim_SetResultFormatted(goi->interp,
- "Missing CHIP TAP OPTIONS ....");
- free(tap);
- return JIM_ERR;
- }
-
- const char *tmp;
- jim_getopt_string(goi, &tmp, NULL);
- tap->chip = strdup(tmp);
-
- jim_getopt_string(goi, &tmp, NULL);
- tap->tapname = strdup(tmp);
-
- /* name + dot + name + null */
- x = strlen(tap->chip) + 1 + strlen(tap->tapname) + 1;
- cp = malloc(x);
- sprintf(cp, "%s.%s", tap->chip, tap->tapname);
- tap->dotted_name = cp;
-
- LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
- tap->chip, tap->tapname, tap->dotted_name, goi->argc);
-
- while (goi->argc) {
- e = jim_getopt_nvp(goi, opts, &n);
- if (e != JIM_OK) {
- jim_getopt_nvp_unknown(goi, opts, 0);
- free(cp);
- free(tap);
- return e;
- }
- LOG_DEBUG("Processing option: %s", n->name);
- switch (n->value) {
- case NTAP_OPT_EXPECTED_ID:
- e = jim_newtap_expected_id(n, goi, tap);
- if (e != JIM_OK) {
- free(cp);
- free(tap);
- return e;
- }
- break;
- case NTAP_OPT_IRLEN:
- case NTAP_OPT_IRMASK:
- case NTAP_OPT_IRCAPTURE:
- /* dummy read to ignore the next argument */
- jim_getopt_wide(goi, NULL);
- break;
- } /* switch (n->value) */
- } /* while (goi->argc) */
-
- /* default is enabled-after-reset */
- tap->enabled = !tap->disabled_after_reset;
-
- jtag_tap_init(tap);
- return JIM_OK;
-}
-
-int jim_hl_newtap(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
-{
- struct jim_getopt_info goi;
- jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
- return jim_hl_newtap_cmd(&goi);
-}
diff --git a/src/jtag/hla/hla_tcl.h b/src/jtag/hla/hla_tcl.h
deleted file mode 100644
index b028e4b..0000000
--- a/src/jtag/hla/hla_tcl.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-/***************************************************************************
- * Copyright (C) 2011 by Mathias Kuester *
- * Mathias Kuester <kesmtp@freenet.de> *
- * *
- * Copyright (C) 2012 by Spencer Oliver *
- * spen@spen-soft.co.uk *
- ***************************************************************************/
-
-#ifndef OPENOCD_JTAG_HLA_HLA_TCL_H
-#define OPENOCD_JTAG_HLA_HLA_TCL_H
-
-/** */
-int jim_hl_newtap(Jim_Interp *interp, int argc, Jim_Obj * const *argv);
-
-#endif /* OPENOCD_JTAG_HLA_HLA_TCL_H */
diff --git a/src/jtag/hla/hla_transport.c b/src/jtag/hla/hla_transport.c
index 91228be..004e9f0 100644
--- a/src/jtag/hla/hla_transport.c
+++ b/src/jtag/hla/hla_transport.c
@@ -18,7 +18,6 @@
#include <transport/transport.h>
#include <helper/time_support.h>
#include <target/target.h>
-#include <jtag/hla/hla_tcl.h>
#include <jtag/hla/hla_transport.h>
#include <jtag/hla/hla_interface.h>
@@ -38,7 +37,7 @@ static const struct command_registration hl_swd_transport_subcommand_handlers[]
{
.name = "newdap",
.mode = COMMAND_CONFIG,
- .jim_handler = jim_hl_newtap,
+ .jim_handler = jim_jtag_newtap,
.help = "declare a new SWD DAP",
},
COMMAND_REGISTRATION_DONE
@@ -59,7 +58,7 @@ static const struct command_registration hl_transport_jtag_subcommand_handlers[]
{
.name = "newtap",
.mode = COMMAND_CONFIG,
- .jim_handler = jim_hl_newtap,
+ .jim_handler = jim_jtag_newtap,
.help = "Create a new TAP instance named basename.tap_type, "
"and appends it to the scan chain.",
.usage = "basename tap_type '-irlen' count "