hla_transport: split command registration per transport 77/4877/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Sun, 27 Jan 2019 14:49:34 +0000 (15:49 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 5 Sep 2020 16:10:38 +0000 (17:10 +0100)
All the HLA transports (hla_swd and hla_jtag) register the same
set of commands. Such commands are mainly aimed at handling JTAG
compatibility that is required for the transport hla_jtag only.

Split per transport the command registration and limit the
commands to only those required by the transport itself.
Replace the command "hla newtap" with the transport specific
"swd newdap" or "jtag newtap".
Deprecate the command "hla".

Change-Id: I79c78fa97b707482608516d3824151a4d07644c0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4877
Tested-by: jenkins
src/jtag/hla/hla_transport.c
src/jtag/startup.tcl
tcl/target/swj-dp.tcl

index 3383577481df8492d9c77f34a942850616f85409..10028260d9089c6a07ef4fb34c5aa397364b3378 100644 (file)
@@ -46,24 +46,37 @@ COMMAND_HANDLER(hl_transport_reset_command)
 }
 
 static const struct command_registration
-hl_transport_stlink_subcommand_handlers[] = {
+hl_swd_transport_subcommand_handlers[] = {
        {
-        .name = "newtap",
+        .name = "newdap",
         .mode = COMMAND_CONFIG,
         .jim_handler = jim_hl_newtap,
-        .help = "Create a new TAP instance named basename.tap_type, "
-        "and appends it to the scan chain.",
-        .usage = "basename tap_type '-irlen' count "
-        "['-expected_id' number] ",
+        .help = "declare a new SWD DAP",
         },
+       COMMAND_REGISTRATION_DONE
+};
 
+static const struct command_registration hl_swd_transport_command_handlers[] = {
+       {
+        .name = "swd",
+        .mode = COMMAND_ANY,
+        .help = "SWD command group",
+        .usage = "",
+        .chain = hl_swd_transport_subcommand_handlers,
+        },
        COMMAND_REGISTRATION_DONE
 };
 
 static const struct command_registration
 hl_transport_jtag_subcommand_handlers[] = {
        {
-        .chain = hl_transport_stlink_subcommand_handlers,
+        .name = "newtap",
+        .mode = COMMAND_CONFIG,
+        .jim_handler = jim_hl_newtap,
+        .help = "Create a new TAP instance named basename.tap_type, "
+        "and appends it to the scan chain.",
+        .usage = "basename tap_type '-irlen' count "
+        "['-expected_id' number] ",
         },
        {
         .name = "init",
@@ -120,18 +133,11 @@ hl_transport_jtag_subcommand_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static const struct command_registration stlink_transport_command_handlers[] = {
-
-       {
-        .name = "hla",
-        .mode = COMMAND_ANY,
-        .help = "perform hl adapter actions",
-        .usage = "",
-        .chain = hl_transport_stlink_subcommand_handlers,
-        },
+static const struct command_registration hl_jtag_transport_command_handlers[] = {
        {
         .name = "jtag",
         .mode = COMMAND_ANY,
+        .help = "perform jtag tap actions",
         .usage = "",
         .chain = hl_transport_jtag_subcommand_handlers,
         },
@@ -144,11 +150,6 @@ static const struct command_registration stlink_transport_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int hl_transport_register_commands(struct command_context *cmd_ctx)
-{
-       return register_commands(cmd_ctx, NULL,
-                                stlink_transport_command_handlers);
-}
 
 static int hl_transport_init(struct command_context *cmd_ctx)
 {
@@ -187,34 +188,35 @@ static int hl_transport_init(struct command_context *cmd_ctx)
        return hl_interface_init_target(t);
 }
 
-static int hl_transport_select(struct command_context *ctx)
+static int hl_jtag_transport_select(struct command_context *cmd_ctx)
 {
-       LOG_DEBUG("hl_transport_select");
-
-       int retval;
+       LOG_DEBUG("hl_jtag_transport_select");
 
        /* NOTE:  interface init must already have been done.
         * That works with only C code ... no Tcl glue required.
         */
 
-       retval = hl_transport_register_commands(ctx);
-
-       if (retval != ERROR_OK)
-               return retval;
+       return register_commands(cmd_ctx, NULL,
+                               hl_jtag_transport_command_handlers);
+}
 
-       return ERROR_OK;
+static int hl_swd_transport_select(struct command_context *cmd_ctx)
+{
+       LOG_DEBUG("hl_swd_transport_select");
+       return register_commands(cmd_ctx, NULL,
+                               hl_swd_transport_command_handlers);
 }
 
 static struct transport hl_swd_transport = {
        .name = "hla_swd",
-       .select = hl_transport_select,
+       .select = hl_swd_transport_select,
        .init = hl_transport_init,
        .override_target = hl_interface_override_target,
 };
 
 static struct transport hl_jtag_transport = {
        .name = "hla_jtag",
-       .select = hl_transport_select,
+       .select = hl_jtag_transport_select,
        .init = hl_transport_init,
        .override_target = hl_interface_override_target,
 };
index 90b675f180328c8637bcd82fef441f79c6825b27..82327a39b6510aafb88797f119bff322bcd3b262 100644 (file)
@@ -226,4 +226,13 @@ proc xds110_supply_voltage args {
        eval xds110 supply $args
 }
 
+proc hla {cmd args} {
+        tailcall "hla $cmd" {*}$args
+}
+
+proc "hla newtap" {args} {
+       echo "DEPRECATED! use 'swj_newdap' not 'hla newtap'"
+       eval swj_newdap $args
+}
+
 # END MIGRATION AIDS
index 1d274cb1290cbb73e6efdd64d2ef82b529732ac0..3fb0263f1c6d24884497e65ee4236ee920cb478a 100644 (file)
@@ -24,11 +24,12 @@ if [catch {transport select}] {
 }
 
 proc swj_newdap {chip tag args} {
- if [using_hla] {
-     eval hla newtap $chip $tag $args
- } elseif [using_jtag] {
+ if [using_jtag] {
      eval jtag newtap $chip $tag $args
  } elseif [using_swd] {
      eval swd newdap $chip $tag $args
+ } else {
+     echo "Error: transport '[ transport select ]' not supported by swj_newdap"
+     shutdown
  }
 }

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)