openocd: declare struct command_registration in a single line
[openocd.git] / src / jtag / hla / hla_transport.c
1 /***************************************************************************
2 * Copyright (C) 2011 by Mathias Kuester *
3 * Mathias Kuester <kesmtp@freenet.de> *
4 * *
5 * Copyright (C) 2012 by Spencer Oliver *
6 * spen@spen-soft.co.uk *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
20 ***************************************************************************/
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 /* project specific includes */
27 #include <jtag/interface.h>
28 #include <jtag/tcl.h>
29 #include <transport/transport.h>
30 #include <helper/time_support.h>
31 #include <target/target.h>
32 #include <jtag/hla/hla_tcl.h>
33 #include <jtag/hla/hla_transport.h>
34 #include <jtag/hla/hla_interface.h>
35
36 COMMAND_HANDLER(hl_transport_jtag_command)
37 {
38 LOG_DEBUG("hl_transport_jtag_command");
39
40 return ERROR_OK;
41 }
42
43 COMMAND_HANDLER(hl_transport_reset_command)
44 {
45 return hl_interface_init_reset();
46 }
47
48 static const struct command_registration hl_swd_transport_subcommand_handlers[] = {
49 {
50 .name = "newdap",
51 .mode = COMMAND_CONFIG,
52 .jim_handler = jim_hl_newtap,
53 .help = "declare a new SWD DAP",
54 },
55 COMMAND_REGISTRATION_DONE
56 };
57
58 static const struct command_registration hl_swd_transport_command_handlers[] = {
59 {
60 .name = "swd",
61 .mode = COMMAND_ANY,
62 .help = "SWD command group",
63 .usage = "",
64 .chain = hl_swd_transport_subcommand_handlers,
65 },
66 COMMAND_REGISTRATION_DONE
67 };
68
69 static const struct command_registration hl_transport_jtag_subcommand_handlers[] = {
70 {
71 .name = "newtap",
72 .mode = COMMAND_CONFIG,
73 .jim_handler = jim_hl_newtap,
74 .help = "Create a new TAP instance named basename.tap_type, "
75 "and appends it to the scan chain.",
76 .usage = "basename tap_type '-irlen' count "
77 "['-expected_id' number]",
78 },
79 {
80 .name = "init",
81 .mode = COMMAND_ANY,
82 .handler = hl_transport_jtag_command,
83 .usage = ""
84 },
85 {
86 .name = "arp_init",
87 .mode = COMMAND_ANY,
88 .handler = hl_transport_jtag_command,
89 .usage = ""
90 },
91 {
92 .name = "arp_init-reset",
93 .mode = COMMAND_ANY,
94 .handler = hl_transport_reset_command,
95 .usage = ""
96 },
97 {
98 .name = "tapisenabled",
99 .mode = COMMAND_EXEC,
100 .jim_handler = jim_jtag_tap_enabler,
101 },
102 {
103 .name = "tapenable",
104 .mode = COMMAND_EXEC,
105 .jim_handler = jim_jtag_tap_enabler,
106 },
107 {
108 .name = "tapdisable",
109 .mode = COMMAND_EXEC,
110 .handler = hl_transport_jtag_command,
111 .usage = "",
112 },
113 {
114 .name = "configure",
115 .mode = COMMAND_EXEC,
116 .handler = hl_transport_jtag_command,
117 .usage = "",
118 },
119 {
120 .name = "cget",
121 .mode = COMMAND_EXEC,
122 .jim_handler = jim_jtag_configure,
123 },
124 {
125 .name = "names",
126 .mode = COMMAND_ANY,
127 .handler = hl_transport_jtag_command,
128 .usage = "",
129 },
130
131 COMMAND_REGISTRATION_DONE
132 };
133
134 static const struct command_registration hl_jtag_transport_command_handlers[] = {
135 {
136 .name = "jtag",
137 .mode = COMMAND_ANY,
138 .help = "perform jtag tap actions",
139 .usage = "",
140 .chain = hl_transport_jtag_subcommand_handlers,
141 },
142 {
143 .name = "jtag_ntrst_delay",
144 .mode = COMMAND_ANY,
145 .handler = hl_transport_jtag_command,
146 .usage = "",
147 },
148 COMMAND_REGISTRATION_DONE
149 };
150
151
152 static int hl_transport_init(struct command_context *cmd_ctx)
153 {
154 LOG_DEBUG("hl_transport_init");
155 struct target *t = get_current_target(cmd_ctx);
156 struct transport *transport;
157 enum hl_transports tr;
158
159 if (!t) {
160 LOG_ERROR("no current target");
161 return ERROR_FAIL;
162 }
163
164 transport = get_current_transport();
165
166 if (!transport) {
167 LOG_ERROR("no transport selected");
168 return ERROR_FAIL;
169 }
170
171 LOG_DEBUG("current transport %s", transport->name);
172
173 /* get selected transport as enum */
174 tr = HL_TRANSPORT_UNKNOWN;
175
176 if (strcmp(transport->name, "hla_swd") == 0)
177 tr = HL_TRANSPORT_SWD;
178 else if (strcmp(transport->name, "hla_jtag") == 0)
179 tr = HL_TRANSPORT_JTAG;
180
181 int retval = hl_interface_open(tr);
182
183 if (retval != ERROR_OK)
184 return retval;
185
186 return hl_interface_init_target(t);
187 }
188
189 static int hl_jtag_transport_select(struct command_context *cmd_ctx)
190 {
191 LOG_DEBUG("hl_jtag_transport_select");
192
193 /* NOTE: interface init must already have been done.
194 * That works with only C code ... no Tcl glue required.
195 */
196
197 return register_commands(cmd_ctx, NULL, hl_jtag_transport_command_handlers);
198 }
199
200 static int hl_swd_transport_select(struct command_context *cmd_ctx)
201 {
202 LOG_DEBUG("hl_swd_transport_select");
203 return register_commands(cmd_ctx, NULL, hl_swd_transport_command_handlers);
204 }
205
206 static struct transport hl_swd_transport = {
207 .name = "hla_swd",
208 .select = hl_swd_transport_select,
209 .init = hl_transport_init,
210 .override_target = hl_interface_override_target,
211 };
212
213 static struct transport hl_jtag_transport = {
214 .name = "hla_jtag",
215 .select = hl_jtag_transport_select,
216 .init = hl_transport_init,
217 .override_target = hl_interface_override_target,
218 };
219
220 const char *hl_transports[] = { "hla_swd", "hla_jtag", NULL };
221
222 static void hl_constructor(void) __attribute__ ((constructor));
223 static void hl_constructor(void)
224 {
225 transport_register(&hl_swd_transport);
226 transport_register(&hl_jtag_transport);
227 }
228
229 bool transport_is_hla(void)
230 {
231 struct transport *t;
232 t = get_current_transport();
233 return t == &hl_swd_transport || t == &hl_jtag_transport;
234 }

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)