OpenOCD
adi_v5_dapdirect.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /*
4  * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
5  * Author(s): Antonio Borneo <borneo.antonio@gmail.com> for STMicroelectronics
6  */
7 
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26 
27 #include <jtag/interface.h>
28 #include <jtag/tcl.h>
29 #include <transport/transport.h>
30 
31 COMMAND_HANDLER(dapdirect_jtag_empty_command)
32 {
33  LOG_DEBUG("dapdirect_jtag_empty_command(\"%s\")", CMD_NAME);
34 
35  return ERROR_OK;
36 }
37 
38 COMMAND_HANDLER(dapdirect_jtag_reset_command)
39 {
41 
42  /*
43  * in case the adapter has not already handled asserting srst
44  * we will attempt it again
45  */
49  return ERROR_OK;
50  }
51  LOG_WARNING("\'srst_nogate\' reset_config option is required");
52  }
54  return ERROR_OK;
55 }
56 
58  {
59  .name = "newtap",
60  .mode = COMMAND_CONFIG,
61  .handler = handle_jtag_newtap,
62  .help = "declare a new TAP",
63  .usage = "basename tap_type '-irlen' count "
64  "['-enable'|'-disable'] "
65  "['-expected_id' number] "
66  "['-ignore-version'] "
67  "['-ignore-bypass'] "
68  "['-ircapture' number] "
69  "['-ir-bypass' number] "
70  "['-mask' number]",
71  },
72  {
73  .name = "init",
74  .mode = COMMAND_ANY,
75  .handler = dapdirect_jtag_empty_command,
76  .usage = ""
77  },
78  {
79  .name = "arp_init",
80  .mode = COMMAND_ANY,
81  .handler = dapdirect_jtag_empty_command,
82  .usage = ""
83  },
84  {
85  .name = "arp_init-reset",
86  .mode = COMMAND_ANY,
87  .handler = dapdirect_jtag_reset_command,
88  .usage = ""
89  },
90  {
91  .name = "tapisenabled",
92  .mode = COMMAND_EXEC,
93  .handler = handle_jtag_tap_enabler,
94  .help = "Returns a Tcl boolean (0/1) indicating whether "
95  "the TAP is enabled (1) or not (0).",
96  .usage = "tap_name",
97  },
98  {
99  .name = "tapenable",
100  .mode = COMMAND_EXEC,
101  .handler = handle_jtag_tap_enabler,
102  .help = "Try to enable the specified TAP using the "
103  "'tap-enable' TAP event.",
104  .usage = "tap_name",
105  },
106  {
107  .name = "tapdisable",
108  .mode = COMMAND_EXEC,
109  .handler = dapdirect_jtag_empty_command,
110  .usage = "",
111  },
112  {
113  .name = "configure",
114  .mode = COMMAND_ANY,
115  .handler = dapdirect_jtag_empty_command,
116  .usage = "",
117  },
118  {
119  .name = "cget",
120  .mode = COMMAND_EXEC,
121  .handler = handle_jtag_configure,
122  .usage = "",
123  },
124  {
125  .name = "names",
126  .mode = COMMAND_ANY,
127  .handler = dapdirect_jtag_empty_command,
128  .usage = "",
129  },
131 };
132 
133 static const struct command_registration dapdirect_jtag_handlers[] = {
134  {
135  .name = "jtag",
136  .mode = COMMAND_ANY,
138  .usage = "",
139  },
140  {
141  .name = "jtag_ntrst_delay",
142  .mode = COMMAND_ANY,
143  .handler = dapdirect_jtag_empty_command,
144  .usage = "",
145  },
147 };
148 
150  {
151  .name = "newdap",
152  .mode = COMMAND_CONFIG,
153  .handler = handle_jtag_newtap,
154  .help = "declare a new SWD DAP",
155  .usage = "basename dap_type ['-irlen' count] "
156  "['-enable'|'-disable'] "
157  "['-expected_id' number] "
158  "['-ignore-version'] "
159  "['-ignore-bypass'] "
160  "['-ircapture' number] "
161  "['-ir-bypass' number] "
162  "['-mask' number]",
163  },
165 };
166 
167 static const struct command_registration dapdirect_swd_handlers[] = {
168  {
169  .name = "swd",
170  .mode = COMMAND_ANY,
171  .help = "SWD command group",
172  .usage = "",
174  },
176 };
177 
178 static int dapdirect_jtag_select(struct command_context *ctx)
179 {
180  LOG_DEBUG("dapdirect_jtag_select()");
181 
183 }
184 
185 static int dapdirect_swd_select(struct command_context *ctx)
186 {
187  LOG_DEBUG("dapdirect_swd_select()");
188 
190 }
191 
192 static int dapdirect_init(struct command_context *ctx)
193 {
195 
196  LOG_DEBUG("dapdirect_init()");
197 
201  else
202  LOG_WARNING("\'srst_nogate\' reset_config option is required");
203  } else
205 
206  return ERROR_OK;
207 }
208 
209 static struct transport dapdirect_jtag_transport = {
210  .name = "dapdirect_jtag",
211  .select = dapdirect_jtag_select,
212  .init = dapdirect_init,
213 };
214 
215 static struct transport dapdirect_swd_transport = {
216  .name = "dapdirect_swd",
217  .select = dapdirect_swd_select,
218  .init = dapdirect_init,
219 };
220 
221 static void dapdirect_constructor(void) __attribute__((constructor));
222 static void dapdirect_constructor(void)
223 {
226 }
227 
233 {
235 }
236 
242 {
244 }
static const struct command_registration dapdirect_jtag_handlers[]
bool transport_is_dapdirect_swd(void)
Returns true if the current debug session is using SWD as its transport.
bool transport_is_dapdirect_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
static struct transport dapdirect_jtag_transport
static void dapdirect_constructor(void)
COMMAND_HANDLER(dapdirect_jtag_empty_command)
static int dapdirect_init(struct command_context *ctx)
static const struct command_registration dapdirect_jtag_subcommand_handlers[]
static const struct command_registration dapdirect_swd_handlers[]
static int dapdirect_jtag_select(struct command_context *ctx)
static int dapdirect_swd_select(struct command_context *ctx)
static struct transport dapdirect_swd_transport
static const struct command_registration dapdirect_swd_subcommand_handlers[]
#define CMD_NAME
Use this macro to access the name of the command being handled, rather than accessing the variable di...
Definition: command.h:166
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
static int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends,...
Definition: command.h:274
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
static enum reset_types jtag_reset_config
Definition: jtag/core.c:87
int adapter_deassert_reset(void)
Definition: jtag/core.c:1899
enum reset_types jtag_get_reset_config(void)
Definition: jtag/core.c:1734
int adapter_assert_reset(void)
Definition: jtag/core.c:1879
reset_types
Definition: jtag.h:216
@ RESET_SRST_NO_GATING
Definition: jtag.h:225
@ RESET_CNCT_UNDER_SRST
Definition: jtag.h:226
#define LOG_WARNING(expr ...)
Definition: log.h:129
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:164
struct qn908x_flash_bank __attribute__
Definition: armv8.c:1016
const char * name
Definition: command.h:235
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241
Wrapper for transport lifecycle operations.
Definition: transport.h:35
const char * name
Each transport has a unique name, used to select it from among the alternatives.
Definition: transport.h:41
struct transport * get_current_transport(void)
Returns the transport currently being used by this debug or programming session.
Definition: transport.c:157
int transport_register(struct transport *new_transport)
Registers a transport.
Definition: transport.c:129
#define NULL
Definition: usb.h:16