forked from auracaster/openocd
transport: use a bitmask for the transport
Move the transport's names in a local array in the transport framework. Replace the string struct transport::name, that identifies the transport, with a bitmask where each bit corresponds to one of the available transports. Change-Id: I6bdf7264d5979c355299f63fcf80bf54dcd95cee Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8674 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de>
This commit is contained in:
@@ -1823,7 +1823,7 @@ static int jtag_select(struct command_context *ctx)
|
||||
}
|
||||
|
||||
static struct transport jtag_transport = {
|
||||
.name = "jtag",
|
||||
.id = TRANSPORT_JTAG,
|
||||
.select = jtag_select,
|
||||
.init = jtag_init,
|
||||
};
|
||||
@@ -1868,7 +1868,7 @@ int adapter_resets(int trst, int srst)
|
||||
transport_is_swim()) {
|
||||
if (trst == TRST_ASSERT) {
|
||||
LOG_ERROR("transport %s has no trst signal",
|
||||
get_current_transport()->name);
|
||||
get_current_transport_name());
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -1884,7 +1884,7 @@ int adapter_resets(int trst, int srst)
|
||||
return ERROR_OK;
|
||||
|
||||
LOG_ERROR("reset is not supported on transport %s",
|
||||
get_current_transport()->name);
|
||||
get_current_transport_name());
|
||||
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -1903,7 +1903,7 @@ int adapter_assert_reset(void)
|
||||
return adapter_system_reset(1);
|
||||
else if (get_current_transport())
|
||||
LOG_ERROR("reset is not supported on %s",
|
||||
get_current_transport()->name);
|
||||
get_current_transport_name());
|
||||
else
|
||||
LOG_ERROR("transport is not selected");
|
||||
return ERROR_FAIL;
|
||||
@@ -1920,7 +1920,7 @@ int adapter_deassert_reset(void)
|
||||
return adapter_system_reset(0);
|
||||
else if (get_current_transport())
|
||||
LOG_ERROR("reset is not supported on %s",
|
||||
get_current_transport()->name);
|
||||
get_current_transport_name());
|
||||
else
|
||||
LOG_ERROR("transport is not selected");
|
||||
return ERROR_FAIL;
|
||||
|
||||
@@ -177,15 +177,20 @@ static int hl_transport_init(struct command_context *cmd_ctx)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
LOG_DEBUG("current transport %s", transport->name);
|
||||
LOG_DEBUG("current transport %s", get_current_transport_name());
|
||||
|
||||
/* get selected transport as enum */
|
||||
tr = HL_TRANSPORT_UNKNOWN;
|
||||
|
||||
if (strcmp(transport->name, "hla_swd") == 0)
|
||||
switch (transport->id) {
|
||||
case TRANSPORT_HLA_SWD:
|
||||
tr = HL_TRANSPORT_SWD;
|
||||
else if (strcmp(transport->name, "hla_jtag") == 0)
|
||||
break;
|
||||
case TRANSPORT_HLA_JTAG:
|
||||
tr = HL_TRANSPORT_JTAG;
|
||||
break;
|
||||
default:
|
||||
tr = HL_TRANSPORT_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
int retval = hl_interface_open(tr);
|
||||
|
||||
@@ -213,14 +218,14 @@ static int hl_swd_transport_select(struct command_context *cmd_ctx)
|
||||
}
|
||||
|
||||
static struct transport hl_swd_transport = {
|
||||
.name = "hla_swd",
|
||||
.id = TRANSPORT_HLA_SWD,
|
||||
.select = hl_swd_transport_select,
|
||||
.init = hl_transport_init,
|
||||
.override_target = hl_interface_override_target,
|
||||
};
|
||||
|
||||
static struct transport hl_jtag_transport = {
|
||||
.name = "hla_jtag",
|
||||
.id = TRANSPORT_HLA_JTAG,
|
||||
.select = hl_jtag_transport_select,
|
||||
.init = hl_transport_init,
|
||||
.override_target = hl_interface_override_target,
|
||||
|
||||
@@ -136,7 +136,7 @@ static int swim_transport_init(struct command_context *cmd_ctx)
|
||||
}
|
||||
|
||||
static struct transport swim_transport = {
|
||||
.name = "swim",
|
||||
.id = TRANSPORT_SWIM,
|
||||
.select = swim_transport_select,
|
||||
.init = swim_transport_init,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user