1
2
3
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
37
38
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
78
84
90
98
99
100
101
102
103
104
105
106
112
118
124
130
131
132
133
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
177
178
184
185
191
192
193
194
195
196
197
198
204
205
206
207
208
209
214
215
220
221
222
227
228
232
236
237
241
/* ... */
/* ... */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <jtag/interface.h>
#include <jtag/tcl.h>
#include <transport/transport.h>
COMMAND_HANDLER(dapdirect_jtag_empty_command)
{
LOG_DEBUG("dapdirect_jtag_empty_command(\"%s\")", CMD_NAME);
return ERROR_OK;
}{ ... }
COMMAND_HANDLER(dapdirect_jtag_reset_command)
{
enum reset_types jtag_reset_config = jtag_get_reset_config();
/* ... */
if (jtag_reset_config & RESET_CNCT_UNDER_SRST) {
if (jtag_reset_config & RESET_SRST_NO_GATING) {
adapter_assert_reset();
return ERROR_OK;
}if (jtag_reset_config & RESET_SRST_NO_GATING) { ... }
LOG_WARNING("\'srst_nogate\' reset_config option is required");
}if (jtag_reset_config & RESET_CNCT_UNDER_SRST) { ... }
adapter_deassert_reset();
return ERROR_OK;
}{ ... }
static const struct command_registration dapdirect_jtag_subcommand_handlers[] = {
{
.name = "newtap",
.mode = COMMAND_CONFIG,
.handler = handle_jtag_newtap,
.help = "declare a new TAP",
.usage = "basename tap_type '-irlen' count "
"['-enable'|'-disable'] "
"['-expected_id' number] "
"['-ignore-version'] "
"['-ignore-bypass'] "
"['-ircapture' number] "
"['-ir-bypass' number] "
"['-mask' number]",
...},
{
.name = "init",
.mode = COMMAND_ANY,
.handler = dapdirect_jtag_empty_command,
.usage = ""
...},
{
.name = "arp_init",
.mode = COMMAND_ANY,
.handler = dapdirect_jtag_empty_command,
.usage = ""
...},
{
.name = "arp_init-reset",
.mode = COMMAND_ANY,
.handler = dapdirect_jtag_reset_command,
.usage = ""
...},
{
.name = "tapisenabled",
.mode = COMMAND_EXEC,
.handler = handle_jtag_tap_enabler,
.help = "Returns a Tcl boolean (0/1) indicating whether "
"the TAP is enabled (1) or not (0).",
.usage = "tap_name",
...},
{
.name = "tapenable",
.mode = COMMAND_EXEC,
.handler = handle_jtag_tap_enabler,
.help = "Try to enable the specified TAP using the "
"'tap-enable' TAP event.",
.usage = "tap_name",
...},
{
.name = "tapdisable",
.mode = COMMAND_EXEC,
.handler = dapdirect_jtag_empty_command,
.usage = "",
...},
{
.name = "configure",
.mode = COMMAND_ANY,
.handler = dapdirect_jtag_empty_command,
.usage = "",
...},
{
.name = "cget",
.mode = COMMAND_EXEC,
.handler = handle_jtag_configure,
.usage = "",
...},
{
.name = "names",
.mode = COMMAND_ANY,
.handler = dapdirect_jtag_empty_command,
.usage = "",
...},
COMMAND_REGISTRATION_DONE
...};
static const struct command_registration dapdirect_jtag_handlers[] = {
{
.name = "jtag",
.mode = COMMAND_ANY,
.chain = dapdirect_jtag_subcommand_handlers,
.usage = "",
...},
{
.name = "jtag_ntrst_delay",
.mode = COMMAND_ANY,
.handler = dapdirect_jtag_empty_command,
.usage = "",
...},
COMMAND_REGISTRATION_DONE
...};
static const struct command_registration dapdirect_swd_subcommand_handlers[] = {
{
.name = "newdap",
.mode = COMMAND_CONFIG,
.handler = handle_jtag_newtap,
.help = "declare a new SWD DAP",
.usage = "basename dap_type ['-irlen' count] "
"['-enable'|'-disable'] "
"['-expected_id' number] "
"['-ignore-version'] "
"['-ignore-bypass'] "
"['-ircapture' number] "
"['-ir-bypass' number] "
"['-mask' number]",
...},
COMMAND_REGISTRATION_DONE
...};
static const struct command_registration dapdirect_swd_handlers[] = {
{
.name = "swd",
.mode = COMMAND_ANY,
.help = "SWD command group",
.usage = "",
.chain = dapdirect_swd_subcommand_handlers,
...},
COMMAND_REGISTRATION_DONE
...};
static int dapdirect_jtag_select(struct command_context *ctx)
{
LOG_DEBUG("dapdirect_jtag_select()");
return register_commands(ctx, NULL, dapdirect_jtag_handlers);
}{ ... }
static int dapdirect_swd_select(struct command_context *ctx)
{
LOG_DEBUG("dapdirect_swd_select()");
return register_commands(ctx, NULL, dapdirect_swd_handlers);
}{ ... }
static int dapdirect_init(struct command_context *ctx)
{
enum reset_types jtag_reset_config = jtag_get_reset_config();
LOG_DEBUG("dapdirect_init()");
if (jtag_reset_config & RESET_CNCT_UNDER_SRST) {
if (jtag_reset_config & RESET_SRST_NO_GATING)
adapter_assert_reset();
else
LOG_WARNING("\'srst_nogate\' reset_config option is required");
}if (jtag_reset_config & RESET_CNCT_UNDER_SRST) { ... } else
adapter_deassert_reset();
return ERROR_OK;
}{ ... }
static struct transport dapdirect_jtag_transport = {
.name = "dapdirect_jtag",
.select = dapdirect_jtag_select,
.init = dapdirect_init,
...};
static struct transport dapdirect_swd_transport = {
.name = "dapdirect_swd",
.select = dapdirect_swd_select,
.init = dapdirect_init,
...};
static void dapdirect_constructor(void) __attribute__((constructor));
static void dapdirect_constructor(void)
{
transport_register(&dapdirect_jtag_transport);
transport_register(&dapdirect_swd_transport);
}{ ... }
/* ... */
bool transport_is_dapdirect_jtag(void)
{
return get_current_transport() == &dapdirect_jtag_transport;
}{ ... }
/* ... */
bool transport_is_dapdirect_swd(void)
{
return get_current_transport() == &dapdirect_swd_transport;
}{ ... }