jtag: remove minidriver code and minidriver-dummy
authorAntonio Borneo <borneo.antonio@gmail.com>
Tue, 3 Nov 2020 15:50:49 +0000 (16:50 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 19 Mar 2021 21:56:06 +0000 (21:56 +0000)
With zy1000 removed, there is no other implementation that uses
the minidriver, apart from the test/example minidriver-dummy.
While the idea of the minidriver is probably still valid (that is
to intercept jtag primitives before serialization), there is no
current use case, no guarantee it is really working, and the way
it was implemented (by macros and #if conditionals) is really hard
to maintain and test.

Let's let it rip in git history, from where it could eventually be
taken back in a more modern implementation.
The entry points of minidriver API are still in the code with the
original names.

Change-Id: I882e32cb26cf5842f9cba14e3badaf8948e3760d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6091
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
13 files changed:
configure.ac
src/jtag/Makefile.am
src/jtag/adapter.c
src/jtag/core.c
src/jtag/interfaces.c
src/jtag/jtag.h
src/jtag/minidriver.h
src/jtag/minidriver/minidriver_imp.h [deleted file]
src/jtag/minidummy/jtag_minidriver.h [deleted file]
src/jtag/minidummy/minidummy.c [deleted file]
src/target/arm11_dbgtap.c
src/target/embeddedice.c
src/transport/transport.h

index 71cfe21d68fccd52bf73ee8b86add497561c9484..269452bb6631238fb07e0470e25213bf7efdc4ee 100644 (file)
@@ -351,10 +351,6 @@ AS_CASE([$host_os],
     ])
 ])
 
-AC_ARG_ENABLE([minidriver_dummy],
-  AS_HELP_STRING([--enable-minidriver-dummy], [Enable the dummy minidriver.]),
-  [build_minidriver_dummy=$enableval], [build_minidriver_dummy=no])
-
 AC_ARG_ENABLE([internal-jimtcl],
   AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
   [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
@@ -364,33 +360,10 @@ AC_ARG_ENABLE([internal-libjaylink],
   [Disable building internal libjaylink]),
   [use_internal_libjaylink=$enableval], [use_internal_libjaylink=yes])
 
-build_minidriver=no
-
 AC_ARG_ENABLE([remote-bitbang],
   AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
   [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
 
-AC_MSG_CHECKING([whether to enable dummy minidriver])
-AS_IF([test "x$build_minidriver_dummy" = "xyes"], [
-  AS_IF([test "x$build_minidriver" = "xyes"], [
-    AC_MSG_ERROR([Multiple minidriver options have been enabled.])
-  ])
-  build_minidriver=yes
-  AC_DEFINE([BUILD_MINIDRIVER_DUMMY], [1], [Use the dummy minidriver.])
-  AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
-      [Define to 1 if you have the <jtag_minidriver.h> header file.])
-])
-AC_MSG_RESULT([$build_minidriver_dummy])
-
-AC_MSG_CHECKING([whether standard drivers can be built])
-AS_IF([test "x$build_minidriver" = "xyes"], [
-  AC_MSG_RESULT([no])
-  AC_MSG_WARN([Using the minidriver disables all other drivers.])
-  sleep 2
-], [
-  AC_MSG_RESULT([yes])
-])
-
 AS_CASE(["${host_cpu}"],
   [i?86|x86*], [],
   [
@@ -745,9 +718,6 @@ AM_CONDITIONAL([USE_LIBJAYLINK], [test "x$use_libjaylink" = "xyes"])
 AM_CONDITIONAL([RSHIM], [test "x$build_rshim" = "xyes"])
 AM_CONDITIONAL([HAVE_CAPSTONE], [test "x$enable_capstone" != "xno"])
 
-AM_CONDITIONAL([MINIDRIVER], [test "x$build_minidriver" = "xyes"])
-AM_CONDITIONAL([MINIDRIVER_DUMMY], [test "x$build_minidriver_dummy" = "xyes"])
-
 AM_CONDITIONAL([INTERNAL_JIMTCL], [test "x$use_internal_jimtcl" = "xyes"])
 AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test "x$use_internal_libjaylink" = "xyes"])
 
index 8bc87a48452b5abeb8763a923adc2c1ca35ac92a..4ed5e7aa0b1b384d4328e3ebae85647862a2cc43 100644 (file)
@@ -3,29 +3,6 @@ noinst_LTLIBRARIES += %D%/libjtag.la
 JTAG_SRCS = %D%/commands.c
 %C%_libjtag_la_LIBADD =
 
-BUILT_SOURCES += %D%/minidriver_imp.h
-CLEANFILES += %D%/minidriver_imp.h
-
-if MINIDRIVER
-
-if MINIDRIVER_DUMMY
-JTAG_SRCS += %D%/minidummy/minidummy.c
-JTAG_MINIDRIVER_DIR = %D%/minidummy
-endif
-
-MINIDRIVER_IMP_DIR = %D%/minidriver
-
-%D%/jtag_minidriver.h: $(JTAG_MINIDRIVER_DIR)/jtag_minidriver.h
-       cp $< $@
-
-BUILT_SOURCES += %D%/jtag_minidriver.h
-
-CLEANFILES += %D%/jtag_minidriver.h
-
-else
-
-MINIDRIVER_IMP_DIR = %D%/drivers
-
 if HLADAPTER
 include %D%/hla/Makefile.am
 %C%_libjtag_la_LIBADD += $(top_builddir)/%D%/hla/libocdhla.la
@@ -39,13 +16,6 @@ endif
 include %D%/drivers/Makefile.am
 %C%_libjtag_la_LIBADD += $(top_builddir)/%D%/drivers/libocdjtagdrivers.la
 
-endif
-# endif // MINIDRIVER
-
-%D%/minidriver_imp.h: $(MINIDRIVER_IMP_DIR)/minidriver_imp.h
-       cp $< $@
-
-
 %C%_libjtag_la_SOURCES = \
        %D%/adapter.c \
        %D%/core.c \
@@ -59,8 +29,6 @@ endif
        %D%/interfaces.h \
        %D%/minidriver.h \
        %D%/jtag.h \
-       %D%/minidriver/minidriver_imp.h \
-       %D%/minidummy/jtag_minidriver.h \
        %D%/swd.h \
        %D%/swim.h \
        %D%/tcl.h \
index af75917a32d795471aed41c4887e7202fc56055f..cf579ede069d773746955fa28cd76dbf327c17c5 100644 (file)
@@ -497,7 +497,6 @@ COMMAND_HANDLER(handle_adapter_reset_de_assert)
                                                  (srst == VALUE_DEASSERT) ? SRST_DEASSERT : SRST_ASSERT);
 }
 
-#ifndef HAVE_JTAG_MINIDRIVER_H
 #ifdef HAVE_LIBUSB_GET_PORT_NUMBERS
 COMMAND_HANDLER(handle_usb_location_command)
 {
@@ -522,7 +521,6 @@ static const struct command_registration adapter_usb_command_handlers[] = {
 #endif /* HAVE_LIBUSB_GET_PORT_NUMBERS */
        COMMAND_REGISTRATION_DONE
 };
-#endif /* MINIDRIVER */
 
 static const struct command_registration adapter_srst_command_handlers[] = {
        {
@@ -588,7 +586,6 @@ static const struct command_registration adapter_command_handlers[] = {
                .help = "Declare transports the adapter supports.",
                .usage = "transport ... ",
        },
-#ifndef HAVE_JTAG_MINIDRIVER_H
        {
                .name = "usb",
                .mode = COMMAND_ANY,
@@ -596,7 +593,6 @@ static const struct command_registration adapter_command_handlers[] = {
                .usage = "",
                .chain = adapter_usb_command_handlers,
        },
-#endif /* MINIDRIVER */
        {
                .name = "assert",
                .handler = handle_adapter_reset_de_assert,
index 5abf832f8502710e4b139fb8f545f24ab3d0ac51..6604c5ae84f94ede3020d7fe9afe8d83a44288a5 100644 (file)
@@ -426,7 +426,6 @@ static void jtag_add_scan_check(struct jtag_tap *active, void (*jtag_add_scan)(
 
        for (int i = 0; i < in_num_fields; i++) {
                if ((in_fields[i].check_value != NULL) && (in_fields[i].in_value != NULL)) {
-                       /* this is synchronous for a minidriver */
                        jtag_add_callback4(jtag_check_value_mask_callback,
                                (jtag_callback_data_t)in_fields[i].in_value,
                                (jtag_callback_data_t)in_fields[i].check_value,
@@ -953,12 +952,6 @@ int default_interface_jtag_execute_queue(void)
 
        int result = jtag->jtag_ops->execute_queue();
 
-#if !HAVE_JTAG_MINIDRIVER_H
-       /* Only build this if we use a regular driver with a command queue.
-        * Otherwise jtag_command_queue won't be found at compile/link time. Its
-        * definition is in jtag/commands.c, which is only built/linked by
-        * jtag/Makefile.am if MINIDRIVER_DUMMY || !MINIDRIVER, but those variables
-        * aren't accessible here. Use HAVE_JTAG_MINIDRIVER_H */
        struct jtag_command *cmd = jtag_command_queue;
        while (debug_level >= LOG_LVL_DEBUG_IO && cmd) {
                switch (cmd->type) {
@@ -1017,7 +1010,6 @@ int default_interface_jtag_execute_queue(void)
                }
                cmd = cmd->next;
        }
-#endif
 
        return result;
 }
index d229d8cb07b7e92e1f134b4c0176dfb6d93ef147..63faa95610c9143a2d36cd923cd61fbe7260ed48 100644 (file)
@@ -42,9 +42,6 @@
  * that contain an adapter_driver structure that can added to this list.
  */
 
-#if defined(BUILD_MINIDRIVER_DUMMY)
-extern struct adapter_driver minidummy_adapter_driver;
-#else /* standard drivers */
 #if BUILD_PARPORT == 1
 extern struct adapter_driver parport_adapter_driver;
 #endif
@@ -150,19 +147,12 @@ extern struct adapter_driver stlink_dap_adapter_driver;
 #if BUILD_RSHIM == 1
 extern struct adapter_driver rshim_dap_adapter_driver;
 #endif
-#endif /* standard drivers */
 
 /**
  * The list of built-in JTAG interfaces, containing entries for those
  * drivers that were enabled by the @c configure script.
- *
- * The list should be defined to contain either one minidriver interface
- * or some number of standard driver interfaces, never both.
  */
 struct adapter_driver *adapter_drivers[] = {
-#if defined(BUILD_MINIDRIVER_DUMMY)
-               &minidummy_adapter_driver,
-#else /* standard drivers */
 #if BUILD_PARPORT == 1
                &parport_adapter_driver,
 #endif
@@ -268,6 +258,5 @@ struct adapter_driver *adapter_drivers[] = {
 #if BUILD_RSHIM == 1
                &rshim_dap_adapter_driver,
 #endif
-#endif /* standard drivers */
                NULL,
        };
index 044d7c0c29f99e05108746beb4d111e7f36ffb02..86091e6a7103d7d22ec42aaf3f2abc9976c5410c 100644 (file)
@@ -624,9 +624,6 @@ bool jtag_poll_get_enabled(void);
  */
 void jtag_poll_set_enabled(bool value);
 
-
-/* The minidriver may have inline versions of some of the low
- * level APIs that are used in inner loops. */
 #include <jtag/minidriver.h>
 
 int jim_jtag_newtap(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
index ad830cc1356369a88dacdca3553865594370baeb..c6fdfafd39b5874fe81828afd7527a49f0cc9b56 100644 (file)
@@ -45,7 +45,7 @@
 
 /* this header will be provided by the minidriver implementation, */
 /* and it may provide additional declarations that must be defined. */
-#include <jtag/minidriver_imp.h>
+#include <jtag/drivers/minidriver_imp.h>
 
 int interface_jtag_add_ir_scan(struct jtag_tap *active,
                const struct scan_field *fields,
diff --git a/src/jtag/minidriver/minidriver_imp.h b/src/jtag/minidriver/minidriver_imp.h
deleted file mode 100644 (file)
index 11d0fae..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de>              *
- *   Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com>       *
- *   Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#ifndef OPENOCD_JTAG_MINIDRIVER_MINIDRIVER_IMP_H
-#define OPENOCD_JTAG_MINIDRIVER_MINIDRIVER_IMP_H
-
-#include <jtag/jtag_minidriver.h>
-
-#define jtag_add_callback(callback, in) interface_jtag_add_callback(callback, in)
-
-#define jtag_add_callback4(callback, in, data1, data2, data3) \
-       interface_jtag_add_callback4(callback, in, data1, data2, data3)
-
-#endif /* OPENOCD_JTAG_MINIDRIVER_MINIDRIVER_IMP_H */
diff --git a/src/jtag/minidummy/jtag_minidriver.h b/src/jtag/minidummy/jtag_minidriver.h
deleted file mode 100644 (file)
index 1708356..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007-2008 by Øyvind Harboe                              *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#define interface_jtag_add_callback(callback, in) callback(in)
-
-#define interface_jtag_add_callback4(callback, in, data1, data2, data3) \
-       jtag_set_error(callback(in, data1, data2, data3))
diff --git a/src/jtag/minidummy/minidummy.c b/src/jtag/minidummy/minidummy.c
deleted file mode 100644 (file)
index 7ee2067..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007-2008 by Øyvind Harboe                              *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <jtag/jtag.h>
-#include <target/embeddedice.h>
-#include <jtag/minidriver.h>
-#include <jtag/interface.h>
-
-static struct jtag_interface minidummy_interface = {
-       .execute_queue = NULL,
-};
-
-struct adapter_driver minidummy_adapter_driver = {
-       .name = "minidummy",
-       .transports = jtag_only,
-       .commands = NULL,
-
-       .init = NULL,
-       .quit = NULL,
-       .speed = NULL,
-       .khz = NULL,
-       .speed_div = NULL,
-       .power_dropout = NULL,
-       .srst_asserted = NULL,
-
-       .jtag_ops = &minidummy_interface,
-};
-
-int interface_jtag_execute_queue(void)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_ir_scan(struct jtag_tap *active, const struct scan_field *fields,
-               tap_state_t state)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits,
-               uint8_t *in_bits, tap_state_t state)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_dr_scan(struct jtag_tap *active, int num_fields,
-               const struct scan_field *fields, tap_state_t state)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_plain_dr_scan(int num_bits, const uint8_t *out_bits,
-               uint8_t *in_bits, tap_state_t state)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_tlr(void)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_reset(int req_trst, int req_srst)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_clocks(int num_cycles)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_jtag_add_sleep(uint32_t us)
-{
-       jtag_sleep(us);
-       return ERROR_OK;
-}
-
-int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
-{
-       int state_count;
-       int tms = 0;
-
-       state_count = 0;
-
-       tap_state_t cur_state = cmd_queue_cur_state;
-
-       while (num_states) {
-               if (tap_state_transition(cur_state, false) == path[state_count])
-                       tms = 0;
-               else if (tap_state_transition(cur_state, true) == path[state_count])
-                       tms = 1;
-               else {
-                       LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
-                                       tap_state_name(cur_state), tap_state_name(path[state_count]));
-                       exit(-1);
-               }
-
-               /* synchronously do the operation here */
-
-               cur_state = path[state_count];
-               state_count++;
-               num_states--;
-       }
-
-
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-int interface_add_tms_seq(unsigned num_bits, const uint8_t *seq, enum tap_state state)
-{
-       /* synchronously do the operation here */
-
-       return ERROR_OK;
-}
-
-void embeddedice_write_dcc(struct jtag_tap *tap, int reg_addr, const uint8_t *buffer,
-               int little, int count)
-{
-       int i;
-       for (i = 0; i < count; i++) {
-               embeddedice_write_reg_inner(tap, reg_addr, fast_target_buffer_get_u32(buffer, little));
-               buffer += 4;
-       }
-}
-
-int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap *tap, uint32_t opcode,
-               uint32_t *data, size_t count)
-{
-       int arm11_run_instr_data_to_core_noack_inner_default(struct jtag_tap *tap,
-                       uint32_t opcode, uint32_t *data, size_t count);
-       return arm11_run_instr_data_to_core_noack_inner_default(tap, opcode, data, count);
-}
index 60be0096ff332167e0a06bc8f0e4d5f1e6d6466d..823ce5cc16ac19a580067742263629a1428c8edd 100644 (file)
@@ -562,11 +562,7 @@ static const tap_state_t arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay[] = {
        TAP_DRSHIFT
 };
 
-/* This inner loop can be implemented by the minidriver, oftentimes in hardware... The
- * minidriver can call the default implementation as a fallback or implement it
- * from scratch.
- */
-int arm11_run_instr_data_to_core_noack_inner_default(struct jtag_tap *tap,
+static int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap *tap,
        uint32_t opcode,
        uint32_t *data,
        size_t count)
@@ -629,21 +625,6 @@ int arm11_run_instr_data_to_core_noack_inner_default(struct jtag_tap *tap,
        return retval;
 }
 
-int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap *tap,
-                                            uint32_t opcode,
-                                            uint32_t *data,
-                                            size_t count);
-
-#ifndef HAVE_JTAG_MINIDRIVER_H
-int arm11_run_instr_data_to_core_noack_inner(struct jtag_tap *tap,
-       uint32_t opcode,
-       uint32_t *data,
-       size_t count)
-{
-       return arm11_run_instr_data_to_core_noack_inner_default(tap, opcode, data, count);
-}
-#endif
-
 /** Execute one instruction via ITR repeatedly while
  *  passing data to the core via DTR on each execution.
  *
index 7c53c45c57fac9bee752145fa09d149f2653a186..a29508baf347133ec5b892b8056f16cb6621bffd 100644 (file)
@@ -645,7 +645,6 @@ int embeddedice_handshake(struct arm_jtag *jtag_info, int hsbit, uint32_t timeou
        return ERROR_TARGET_TIMEOUT;
 }
 
-#ifndef HAVE_JTAG_MINIDRIVER_H
 /**
  * This is an inner loop of the open loop DCC write of data to target
  */
@@ -660,6 +659,3 @@ void embeddedice_write_dcc(struct jtag_tap *tap,
                buffer += 4;
        }
 }
-#else
-/* provided by minidriver */
-#endif
index 6bf6aaced9ca3e3173e59ba107f7e33cf9faddd1..e04f78063529996396b3f7a4a81d07b85d6ff762 100644 (file)
@@ -98,7 +98,7 @@ bool transport_is_dapdirect_jtag(void);
 bool transport_is_dapdirect_swd(void);
 bool transport_is_swim(void);
 
-#if BUILD_HLADAPTER && !HAVE_JTAG_MINIDRIVER_H
+#if BUILD_HLADAPTER
 bool transport_is_hla(void);
 #else
 static inline bool transport_is_hla(void)