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  .jim_handler = jim_jtag_newtap,
62  .help = "declare a new TAP"
63  },
64  {
65  .name = "init",
66  .mode = COMMAND_ANY,
67  .handler = dapdirect_jtag_empty_command,
68  .usage = ""
69  },
70  {
71  .name = "arp_init",
72  .mode = COMMAND_ANY,
73  .handler = dapdirect_jtag_empty_command,
74  .usage = ""
75  },
76  {
77  .name = "arp_init-reset",
78  .mode = COMMAND_ANY,
79  .handler = dapdirect_jtag_reset_command,
80  .usage = ""
81  },
82  {
83  .name = "tapisenabled",
84  .mode = COMMAND_EXEC,
85  .jim_handler = jim_jtag_tap_enabler,
86  },
87  {
88  .name = "tapenable",
89  .mode = COMMAND_EXEC,
90  .jim_handler = jim_jtag_tap_enabler,
91  },
92  {
93  .name = "tapdisable",
94  .mode = COMMAND_EXEC,
95  .handler = dapdirect_jtag_empty_command,
96  .usage = "",
97  },
98  {
99  .name = "configure",
100  .mode = COMMAND_ANY,
101  .handler = dapdirect_jtag_empty_command,
102  .usage = "",
103  },
104  {
105  .name = "cget",
106  .mode = COMMAND_EXEC,
107  .jim_handler = jim_jtag_configure,
108  },
109  {
110  .name = "names",
111  .mode = COMMAND_ANY,
112  .handler = dapdirect_jtag_empty_command,
113  .usage = "",
114  },
116 };
117 
118 static const struct command_registration dapdirect_jtag_handlers[] = {
119  {
120  .name = "jtag",
121  .mode = COMMAND_ANY,
123  .usage = "",
124  },
125  {
126  .name = "jtag_ntrst_delay",
127  .mode = COMMAND_ANY,
128  .handler = dapdirect_jtag_empty_command,
129  .usage = "",
130  },
132 };
133 
135  {
136  .name = "newdap",
137  .mode = COMMAND_CONFIG,
138  .jim_handler = jim_jtag_newtap,
139  .help = "declare a new SWD DAP",
140  },
142 };
143 
144 static const struct command_registration dapdirect_swd_handlers[] = {
145  {
146  .name = "swd",
147  .mode = COMMAND_ANY,
148  .help = "SWD command group",
149  .usage = "",
151  },
153 };
154 
155 static int dapdirect_jtag_select(struct command_context *ctx)
156 {
157  LOG_DEBUG("dapdirect_jtag_select()");
158 
160 }
161 
162 static int dapdirect_swd_select(struct command_context *ctx)
163 {
164  LOG_DEBUG("dapdirect_swd_select()");
165 
167 }
168 
169 static int dapdirect_init(struct command_context *ctx)
170 {
172 
173  LOG_DEBUG("dapdirect_init()");
174 
178  else
179  LOG_WARNING("\'srst_nogate\' reset_config option is required");
180  } else
182 
183  return ERROR_OK;
184 }
185 
186 static struct transport dapdirect_jtag_transport = {
187  .name = "dapdirect_jtag",
188  .select = dapdirect_jtag_select,
189  .init = dapdirect_init,
190 };
191 
192 static struct transport dapdirect_swd_transport = {
193  .name = "dapdirect_swd",
194  .select = dapdirect_swd_select,
195  .init = dapdirect_init,
196 };
197 
198 static void dapdirect_constructor(void) __attribute__((constructor));
199 static void dapdirect_constructor(void)
200 {
203 }
204 
210 {
212 }
213 
219 {
221 }
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:160
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
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:268
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
struct esp_usb_jtag __attribute__
Definition: armv8.c:804
static enum reset_types jtag_reset_config
Definition: jtag/core.c:87
int adapter_deassert_reset(void)
Definition: jtag/core.c:1900
enum reset_types jtag_get_reset_config(void)
Definition: jtag/core.c:1734
int adapter_assert_reset(void)
Definition: jtag/core.c:1880
int jim_jtag_tap_enabler(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: jtag/tcl.c:753
int jim_jtag_configure(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: jtag/tcl.c:791
reset_types
Definition: jtag.h:212
@ RESET_SRST_NO_GATING
Definition: jtag.h:221
@ RESET_CNCT_UNDER_SRST
Definition: jtag.h:222
int jim_jtag_newtap(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: jtag/tcl.c:715
#define LOG_WARNING(expr ...)
Definition: log.h:120
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:155
const char * name
Definition: command.h:229
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:235
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