hla_transport: split command registration per transport

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
This commit is contained in:
Antonio Borneo 2019-01-27 15:49:34 +01:00
parent 1457a1ab42
commit 60f104f450
3 changed files with 50 additions and 38 deletions

View File

@ -46,7 +46,29 @@ COMMAND_HANDLER(hl_transport_reset_command)
} }
static const struct command_registration static const struct command_registration
hl_transport_stlink_subcommand_handlers[] = { hl_swd_transport_subcommand_handlers[] = {
{
.name = "newdap",
.mode = COMMAND_CONFIG,
.jim_handler = jim_hl_newtap,
.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[] = {
{ {
.name = "newtap", .name = "newtap",
.mode = COMMAND_CONFIG, .mode = COMMAND_CONFIG,
@ -56,15 +78,6 @@ hl_transport_stlink_subcommand_handlers[] = {
.usage = "basename tap_type '-irlen' count " .usage = "basename tap_type '-irlen' count "
"['-expected_id' number] ", "['-expected_id' number] ",
}, },
COMMAND_REGISTRATION_DONE
};
static const struct command_registration
hl_transport_jtag_subcommand_handlers[] = {
{
.chain = hl_transport_stlink_subcommand_handlers,
},
{ {
.name = "init", .name = "init",
.mode = COMMAND_ANY, .mode = COMMAND_ANY,
@ -120,18 +133,11 @@ hl_transport_jtag_subcommand_handlers[] = {
COMMAND_REGISTRATION_DONE COMMAND_REGISTRATION_DONE
}; };
static const struct command_registration stlink_transport_command_handlers[] = { static const struct command_registration hl_jtag_transport_command_handlers[] = {
{
.name = "hla",
.mode = COMMAND_ANY,
.help = "perform hl adapter actions",
.usage = "",
.chain = hl_transport_stlink_subcommand_handlers,
},
{ {
.name = "jtag", .name = "jtag",
.mode = COMMAND_ANY, .mode = COMMAND_ANY,
.help = "perform jtag tap actions",
.usage = "", .usage = "",
.chain = hl_transport_jtag_subcommand_handlers, .chain = hl_transport_jtag_subcommand_handlers,
}, },
@ -144,11 +150,6 @@ static const struct command_registration stlink_transport_command_handlers[] = {
COMMAND_REGISTRATION_DONE 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) 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); 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"); LOG_DEBUG("hl_jtag_transport_select");
int retval;
/* NOTE: interface init must already have been done. /* NOTE: interface init must already have been done.
* That works with only C code ... no Tcl glue required. * That works with only C code ... no Tcl glue required.
*/ */
retval = hl_transport_register_commands(ctx); return register_commands(cmd_ctx, NULL,
hl_jtag_transport_command_handlers);
}
if (retval != ERROR_OK) static int hl_swd_transport_select(struct command_context *cmd_ctx)
return retval; {
LOG_DEBUG("hl_swd_transport_select");
return ERROR_OK; return register_commands(cmd_ctx, NULL,
hl_swd_transport_command_handlers);
} }
static struct transport hl_swd_transport = { static struct transport hl_swd_transport = {
.name = "hla_swd", .name = "hla_swd",
.select = hl_transport_select, .select = hl_swd_transport_select,
.init = hl_transport_init, .init = hl_transport_init,
.override_target = hl_interface_override_target, .override_target = hl_interface_override_target,
}; };
static struct transport hl_jtag_transport = { static struct transport hl_jtag_transport = {
.name = "hla_jtag", .name = "hla_jtag",
.select = hl_transport_select, .select = hl_jtag_transport_select,
.init = hl_transport_init, .init = hl_transport_init,
.override_target = hl_interface_override_target, .override_target = hl_interface_override_target,
}; };

View File

@ -226,4 +226,13 @@ proc xds110_supply_voltage args {
eval xds110 supply $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 # END MIGRATION AIDS

View File

@ -24,11 +24,12 @@ if [catch {transport select}] {
} }
proc swj_newdap {chip tag args} { proc swj_newdap {chip tag args} {
if [using_hla] { if [using_jtag] {
eval hla newtap $chip $tag $args
} elseif [using_jtag] {
eval jtag newtap $chip $tag $args eval jtag newtap $chip $tag $args
} elseif [using_swd] { } elseif [using_swd] {
eval swd newdap $chip $tag $args eval swd newdap $chip $tag $args
} else {
echo "Error: transport '[ transport select ]' not supported by swj_newdap"
shutdown
} }
} }