OpenOCD
arm_dap.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2016 by Matthias Welwarsky *
5  * *
6  ***************************************************************************/
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include <stdlib.h>
13 #include <stdint.h>
14 #include "target/arm_adi_v5.h"
15 #include "target/arm.h"
16 #include "helper/list.h"
17 #include "helper/command.h"
18 #include "transport/transport.h"
19 #include "jtag/adapter.h"
20 #include "jtag/interface.h"
21 
22 static OOCD_LIST_HEAD(all_dap);
23 
24 /* DAP command support */
26  struct list_head lh;
27  struct adiv5_dap dap;
28  char *name;
29  const struct swd_driver *swd;
30 };
31 
32 static void dap_instance_init(struct adiv5_dap *dap)
33 {
34  int i;
35  /* Set up with safe defaults */
36  for (i = 0; i <= DP_APSEL_MAX; i++) {
37  dap->ap[i].dap = dap;
38  dap->ap[i].ap_num = DP_APSEL_INVALID;
39  /* memaccess_tck max is 255 */
40  dap->ap[i].memaccess_tck = 255;
41  /* Number of bits for tar autoincrement, impl. dep. at least 10 */
42  dap->ap[i].tar_autoincr_block = (1<<10);
43  /* default CSW value */
44  dap->ap[i].csw_default = CSW_AHB_DEFAULT;
45  dap->ap[i].cfg_reg = MEM_AP_REG_CFG_INVALID; /* mem_ap configuration reg (large physical addr, etc.) */
46  dap->ap[i].refcount = 0;
47  dap->ap[i].config_ap_never_release = false;
48  }
50  INIT_LIST_HEAD(&dap->cmd_pool);
51 }
52 
53 const char *adiv5_dap_name(struct adiv5_dap *self)
54 {
55  struct arm_dap_object *obj = container_of(self, struct arm_dap_object, dap);
56  return obj->name;
57 }
58 
59 const struct swd_driver *adiv5_dap_swd_driver(struct adiv5_dap *self)
60 {
61  struct arm_dap_object *obj = container_of(self, struct arm_dap_object, dap);
62  return obj->swd;
63 }
64 
66 {
67  return &obj->dap;
68 }
69 struct adiv5_dap *dap_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
70 {
71  struct arm_dap_object *obj = NULL;
72  const char *name;
73  bool found = false;
74 
75  name = Jim_GetString(o, NULL);
76 
77  list_for_each_entry(obj, &all_dap, lh) {
78  if (!strcmp(name, obj->name)) {
79  found = true;
80  break;
81  }
82  }
83 
84  if (found)
85  return &obj->dap;
86  return NULL;
87 }
88 
89 static int dap_init_all(void)
90 {
91  struct arm_dap_object *obj;
92  int retval;
93  bool pre_connect = true;
94 
95  LOG_DEBUG("Initializing all DAPs ...");
96 
97  list_for_each_entry(obj, &all_dap, lh) {
98  struct adiv5_dap *dap = &obj->dap;
99 
100  /* with hla, dap is just a dummy */
101  if (transport_is_hla())
102  continue;
103 
104  /* skip taps that are disabled */
105  if (!dap->tap->enabled)
106  continue;
107 
108  if (transport_is_swd()) {
109  dap->ops = &swd_dap_ops;
110  obj->swd = adapter_driver->swd_ops;
111  } else if (transport_is_dapdirect_swd()) {
113  } else if (transport_is_dapdirect_jtag()) {
115  } else
116  dap->ops = &jtag_dp_ops;
117 
118  if (dap->adi_version == 0) {
119  LOG_DEBUG("DAP %s configured by default to use ADIv5 protocol", jtag_tap_name(dap->tap));
120  dap->adi_version = 5;
121  } else {
122  LOG_DEBUG("DAP %s configured to use %s protocol by user cfg file", jtag_tap_name(dap->tap),
123  is_adiv6(dap) ? "ADIv6" : "ADIv5");
124  }
125 
126  if (pre_connect && dap->ops->pre_connect_init) {
127  retval = dap->ops->pre_connect_init(dap);
128  if (retval != ERROR_OK)
129  return retval;
130 
131  pre_connect = false;
132  }
133 
134  retval = dap->ops->connect(dap);
135  if (retval != ERROR_OK)
136  return retval;
137 
138  /* see if address size of ROM Table is greater than 32-bits */
139  if (is_adiv6(dap)) {
140  uint32_t dpidr1;
141 
142  retval = dap->ops->queue_dp_read(dap, DP_DPIDR1, &dpidr1);
143  if (retval != ERROR_OK) {
144  LOG_ERROR("DAP read of DPIDR1 failed...");
145  return retval;
146  }
147  retval = dap_run(dap);
148  if (retval != ERROR_OK) {
149  LOG_ERROR("DAP read of DPIDR1 failed...");
150  return retval;
151  }
152  dap->asize = dpidr1 & DP_DPIDR1_ASIZE_MASK;
153  }
154  }
155 
156  return ERROR_OK;
157 }
158 
160 {
161  struct arm_dap_object *obj, *tmp;
162  struct adiv5_dap *dap;
163 
164  list_for_each_entry_safe(obj, tmp, &all_dap, lh) {
165  dap = &obj->dap;
166  for (unsigned int i = 0; i <= DP_APSEL_MAX; i++) {
167  if (dap->ap[i].refcount != 0)
168  LOG_ERROR("BUG: refcount AP#%u still %u at exit", i, dap->ap[i].refcount);
169  }
170  if (dap->ops && dap->ops->quit)
171  dap->ops->quit(dap);
172 
173  free(obj->name);
174  free(obj);
175  }
176 
177  return ERROR_OK;
178 }
179 
188 };
189 
190 static const struct jim_nvp nvp_config_opts[] = {
191  { .name = "-chain-position", .value = CFG_CHAIN_POSITION },
192  { .name = "-tap", .value = CFG_TAP },
193  { .name = "-ignore-syspwrupack", .value = CFG_IGNORE_SYSPWRUPACK },
194  { .name = "-dp-id", .value = CFG_DP_ID },
195  { .name = "-instance-id", .value = CFG_INSTANCE_ID },
196  { .name = "-adiv6", .value = CFG_ADIV6 },
197  { .name = "-adiv5", .value = CFG_ADIV5 },
198  { .name = NULL, .value = -1 }
199 };
200 
201 static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap)
202 {
203  struct jim_nvp *n;
204  int e;
205 
206  /* parse config ... */
207  while (goi->argc > 0) {
208  Jim_SetEmptyResult(goi->interp);
209 
210  e = jim_getopt_nvp(goi, nvp_config_opts, &n);
211  if (e != JIM_OK) {
213  return e;
214  }
215  switch (n->value) {
216  case CFG_CHAIN_POSITION:
217  LOG_WARNING("[%s] DEPRECATED! '-chain-position' will be removed in the future, use '-tap' instead",
218  dap->name);
219  /* fallthrough */
220  case CFG_TAP: {
221  Jim_Obj *o_t;
222  e = jim_getopt_obj(goi, &o_t);
223  if (e != JIM_OK)
224  return e;
225 
226  struct jtag_tap *tap;
227  tap = jtag_tap_by_jim_obj(goi->interp, o_t);
228  if (!tap) {
229  Jim_SetResultString(goi->interp, "-tap is invalid", -1);
230  return JIM_ERR;
231  }
232  dap->dap.tap = tap;
233  /* loop for more */
234  break;
235  }
237  dap->dap.ignore_syspwrupack = true;
238  break;
239  case CFG_DP_ID: {
240  jim_wide w;
241  e = jim_getopt_wide(goi, &w);
242  if (e != JIM_OK) {
243  Jim_SetResultFormatted(goi->interp,
244  "create %s: bad parameter %s",
245  dap->name, n->name);
246  return JIM_ERR;
247  }
248  if (w < 0 || w > DP_TARGETSEL_DPID_MASK) {
249  Jim_SetResultFormatted(goi->interp,
250  "create %s: %s out of range",
251  dap->name, n->name);
252  return JIM_ERR;
253  }
254  dap->dap.multidrop_targetsel =
256  | (w & DP_TARGETSEL_DPID_MASK);
257  dap->dap.multidrop_dp_id_valid = true;
258  break;
259  }
260  case CFG_INSTANCE_ID: {
261  jim_wide w;
262  e = jim_getopt_wide(goi, &w);
263  if (e != JIM_OK) {
264  Jim_SetResultFormatted(goi->interp,
265  "create %s: bad parameter %s",
266  dap->name, n->name);
267  return JIM_ERR;
268  }
269  if (w < 0 || w > 15) {
270  Jim_SetResultFormatted(goi->interp,
271  "create %s: %s out of range",
272  dap->name, n->name);
273  return JIM_ERR;
274  }
275  dap->dap.multidrop_targetsel =
278  dap->dap.multidrop_instance_id_valid = true;
279  break;
280  }
281  case CFG_ADIV6:
282  dap->dap.adi_version = 6;
283  break;
284  case CFG_ADIV5:
285  dap->dap.adi_version = 5;
286  break;
287  default:
288  break;
289  }
290  }
291 
292  return JIM_OK;
293 }
294 
295 static int dap_check_config(struct adiv5_dap *dap)
296 {
298  return ERROR_OK;
299 
300  struct arm_dap_object *obj;
301  bool new_multidrop = dap_is_multidrop(dap);
302  bool had_multidrop = new_multidrop;
303  uint32_t targetsel = dap->multidrop_targetsel;
304  unsigned int non_multidrop_count = had_multidrop ? 0 : 1;
305 
306  list_for_each_entry(obj, &all_dap, lh) {
307  struct adiv5_dap *dap_it = &obj->dap;
308 
309  if (transport_is_swd()) {
310  if (dap_is_multidrop(dap_it)) {
311  had_multidrop = true;
312  if (new_multidrop && dap_it->multidrop_targetsel == targetsel) {
313  uint32_t dp_id = targetsel & DP_TARGETSEL_DPID_MASK;
314  uint32_t instance_id = targetsel >> DP_TARGETSEL_INSTANCEID_SHIFT;
315  LOG_ERROR("%s and %s have the same multidrop selectors -dp-id 0x%08"
316  PRIx32 " and -instance-id 0x%" PRIx32,
317  obj->name, adiv5_dap_name(dap),
318  dp_id, instance_id);
319  return ERROR_FAIL;
320  }
321  } else {
322  non_multidrop_count++;
323  }
324  } else if (transport_is_dapdirect_swd()) {
325  non_multidrop_count++;
326  }
327  }
328 
329  if (non_multidrop_count > 1) {
330  LOG_ERROR("Two or more SWD non multidrop DAPs are not supported");
331  return ERROR_FAIL;
332  }
333  if (had_multidrop && non_multidrop_count) {
334  LOG_ERROR("Mixing of SWD multidrop DAPs and non multidrop DAPs is not supported");
335  return ERROR_FAIL;
336  }
337 
338  return ERROR_OK;
339 }
340 
341 COMMAND_HANDLER(handle_dap_create)
342 {
343  if (CMD_ARGC < 3)
345 
346  int retval = ERROR_COMMAND_ARGUMENT_INVALID;
347 
348  /* check if the dap name clashes with an existing command name */
349  Jim_Cmd *jimcmd = Jim_GetCommand(CMD_CTX->interp, CMD_JIMTCL_ARGV[0], JIM_NONE);
350  if (jimcmd) {
351  command_print(CMD, "Command/dap: %s Exists", CMD_ARGV[0]);
352  return ERROR_FAIL;
353  }
354 
355  /* Create it */
356  struct arm_dap_object *dap = calloc(1, sizeof(struct arm_dap_object));
357  if (!dap) {
358  LOG_ERROR("Out of memory");
359  return ERROR_FAIL;
360  }
361 
362  dap_instance_init(&dap->dap);
363 
364  dap->name = strdup(CMD_ARGV[0]);
365  if (!dap->name) {
366  LOG_ERROR("Out of memory");
367  free(dap);
368  return ERROR_FAIL;
369  }
370 
371  struct jim_getopt_info goi;
372  jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - 1, CMD_JIMTCL_ARGV + 1);
373  int e = dap_configure(&goi, dap);
374  if (e != JIM_OK) {
375  int reslen;
376  const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
377  if (reslen > 0)
378  command_print(CMD, "%s", result);
379  goto err;
380  }
381 
382  if (!dap->dap.tap) {
383  command_print(CMD, "-tap required when creating DAP");
384  goto err;
385  }
386 
387  retval = dap_check_config(&dap->dap);
388  if (retval != ERROR_OK)
389  goto err;
390 
391  struct command_registration dap_create_commands[] = {
392  {
393  .name = CMD_ARGV[0],
394  .mode = COMMAND_ANY,
395  .help = "dap instance command group",
396  .usage = "",
397  .chain = dap_instance_commands,
398  },
400  };
401 
402  /* don't expose the instance commands when using hla */
403  if (transport_is_hla())
404  dap_create_commands[0].chain = NULL;
405 
406  retval = register_commands_with_data(CMD_CTX, NULL, dap_create_commands, dap);
407  if (retval != ERROR_OK)
408  goto err;
409 
410  list_add_tail(&dap->lh, &all_dap);
411 
412  return ERROR_OK;
413 
414 err:
415  free(dap->name);
416  free(dap);
417  return retval;
418 }
419 
420 static struct adiv5_dap *target_to_dap(const struct target *target)
421 {
423 
424  if (!target->has_dap || !target->dap_configured || !pc)
425  return NULL;
426 
427  return pc->dap;
428 }
429 
430 COMMAND_HANDLER(handle_dap_names)
431 {
432  if (CMD_ARGC != 0)
434 
435  struct arm_dap_object *obj;
436  list_for_each_entry(obj, &all_dap, lh)
437  command_print(CMD, "%s", obj->name);
438 
439  return ERROR_OK;
440 }
441 
442 COMMAND_HANDLER(handle_dap_init)
443 {
444  return dap_init_all();
445 }
446 
447 COMMAND_HANDLER(handle_dap_info_command)
448 {
450  struct adiv5_dap *dap = target_to_dap(target);
451  uint64_t apsel;
452 
453  if (!dap) {
454  command_print(CMD, "target %s has no DAP", target_name(target));
456  }
457 
458  switch (CMD_ARGC) {
459  case 0:
460  apsel = dap->apsel;
461  break;
462  case 1:
463  if (!strcmp(CMD_ARGV[0], "root")) {
464  if (!is_adiv6(dap)) {
465  command_print(CMD, "Option \"root\" not allowed with ADIv5 DAP");
467  }
468  int retval = adiv6_dap_read_baseptr(CMD, dap, &apsel);
469  if (retval != ERROR_OK) {
470  command_print(CMD, "Failed reading DAP baseptr");
471  return retval;
472  }
473  break;
474  }
476  if (!is_ap_num_valid(dap, apsel))
478  break;
479  default:
481  }
482 
483  struct adiv5_ap *ap = dap_get_ap(dap, apsel);
484  if (!ap) {
485  command_print(CMD, "Cannot get AP");
486  return ERROR_FAIL;
487  }
488  int retval = dap_info_command(CMD, ap);
489  dap_put_ap(ap);
490  return retval;
491 }
492 
493 static const struct command_registration dap_subcommand_handlers[] = {
494  {
495  .name = "create",
496  .mode = COMMAND_ANY,
497  .handler = handle_dap_create,
498  .usage = "name '-tap' name",
499  .help = "Creates a new DAP instance",
500  },
501  {
502  .name = "names",
503  .mode = COMMAND_ANY,
504  .handler = handle_dap_names,
505  .usage = "",
506  .help = "Lists all registered DAP instances by name",
507  },
508  {
509  .name = "init",
510  .mode = COMMAND_ANY,
511  .handler = handle_dap_init,
512  .usage = "",
513  .help = "Initialize all registered DAP instances"
514  },
515  {
516  .name = "info",
517  .handler = handle_dap_info_command,
518  .mode = COMMAND_EXEC,
519  .help = "display ROM table for specified MEM-AP (default MEM-AP of current target) "
520  "or the ADIv6 root ROM table of current target's DAP",
521  .usage = "[ap_num | 'root']",
522  },
524 };
525 
526 static const struct command_registration dap_commands[] = {
527  {
528  .name = "dap",
529  .mode = COMMAND_CONFIG,
530  .help = "DAP commands",
531  .chain = dap_subcommand_handlers,
532  .usage = "",
533  },
535 };
536 
538 {
539  return register_commands(cmd_ctx, NULL, dap_commands);
540 }
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.
const struct dap_ops jtag_dp_ops
Definition: adi_v5_jtag.c:898
const struct dap_ops swd_dap_ops
Definition: adi_v5_swd.c:720
bool transport_is_swd(void)
Returns true if the current debug session is using SWD as its transport.
Definition: adi_v5_swd.c:817
Holds the interface to ARM cores.
int dap_info_command(struct command_invocation *cmd, struct adiv5_ap *ap)
Definition: arm_adi_v5.c:2272
bool is_ap_num_valid(struct adiv5_dap *dap, uint64_t ap_num)
Definition: arm_adi_v5.c:1086
int adiv6_dap_read_baseptr(struct command_invocation *cmd, struct adiv5_dap *dap, uint64_t *baseptr)
Definition: arm_adi_v5.c:1299
struct adiv5_ap * dap_get_ap(struct adiv5_dap *dap, uint64_t ap_num)
Definition: arm_adi_v5.c:1222
int dap_put_ap(struct adiv5_ap *ap)
Definition: arm_adi_v5.c:1242
const struct command_registration dap_instance_commands[]
Definition: arm_adi_v5.c:2944
This defines formats and data structures used to talk to ADIv5 entities.
#define CSW_AHB_DEFAULT
Definition: arm_adi_v5.h:193
#define DP_DPIDR1_ASIZE_MASK
Definition: arm_adi_v5.h:75
#define DP_DPIDR1
Definition: arm_adi_v5.h:47
#define DP_APSEL_INVALID
Definition: arm_adi_v5.h:110
#define DP_TARGETSEL_INSTANCEID_MASK
Definition: arm_adi_v5.h:114
#define DP_APSEL_MAX
Definition: arm_adi_v5.h:109
#define DP_TARGETSEL_INSTANCEID_SHIFT
Definition: arm_adi_v5.h:115
static bool is_adiv6(const struct adiv5_dap *dap)
Check if DAP is ADIv6.
Definition: arm_adi_v5.h:523
static int dap_run(struct adiv5_dap *dap)
Perform all queued DAP operations, and clear any errors posted in the CTRL_STAT register when they ar...
Definition: arm_adi_v5.h:648
static bool dap_is_multidrop(struct adiv5_dap *dap)
Check if SWD multidrop configuration is valid.
Definition: arm_adi_v5.h:767
#define DP_TARGETSEL_DPID_MASK
Definition: arm_adi_v5.h:113
#define MEM_AP_REG_CFG_INVALID
Definition: arm_adi_v5.h:209
static int dap_init_all(void)
Definition: arm_dap.c:89
int dap_cleanup_all(void)
Definition: arm_dap.c:159
static const struct jim_nvp nvp_config_opts[]
Definition: arm_dap.c:190
static const struct command_registration dap_subcommand_handlers[]
Definition: arm_dap.c:493
struct adiv5_dap * dap_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
Definition: arm_dap.c:69
static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap)
Definition: arm_dap.c:201
static const struct command_registration dap_commands[]
Definition: arm_dap.c:526
static OOCD_LIST_HEAD(all_dap)
const struct swd_driver * adiv5_dap_swd_driver(struct adiv5_dap *self)
Definition: arm_dap.c:59
static void dap_instance_init(struct adiv5_dap *dap)
Definition: arm_dap.c:32
int dap_register_commands(struct command_context *cmd_ctx)
Definition: arm_dap.c:537
dap_cfg_param
Definition: arm_dap.c:180
@ CFG_IGNORE_SYSPWRUPACK
Definition: arm_dap.c:183
@ CFG_INSTANCE_ID
Definition: arm_dap.c:185
@ CFG_TAP
Definition: arm_dap.c:182
@ CFG_CHAIN_POSITION
Definition: arm_dap.c:181
@ CFG_DP_ID
Definition: arm_dap.c:184
@ CFG_ADIV6
Definition: arm_dap.c:186
@ CFG_ADIV5
Definition: arm_dap.c:187
struct adiv5_dap * adiv5_get_dap(struct arm_dap_object *obj)
Definition: arm_dap.c:65
COMMAND_HANDLER(handle_dap_create)
Definition: arm_dap.c:341
static int dap_check_config(struct adiv5_dap *dap)
Definition: arm_dap.c:295
const char * adiv5_dap_name(struct adiv5_dap *self)
Definition: arm_dap.c:53
static struct adiv5_dap * target_to_dap(const struct target *target)
Definition: arm_dap.c:420
const char * name
Definition: armv4_5.c:75
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:389
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:146
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:161
static int register_commands_with_data(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, void *data)
Register one or more commands, as register_commands(), plus specify a pointer to command private data...
Definition: command.h:318
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:405
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:156
#define CMD_JIMTCL_ARGV
Use this macro to access the jimtcl arguments for the command being handled, rather than accessing th...
Definition: command.h:166
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
Definition: command.h:445
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
Definition: command.h:151
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:256
#define ERROR_COMMAND_ARGUMENT_INVALID
Definition: command.h:407
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:277
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
bool transport_is_hla(void)
int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere)
Remove argv[0] as wide.
Definition: jim-nvp.c:222
int jim_getopt_setup(struct jim_getopt_info *p, Jim_Interp *interp, int argc, Jim_Obj *const *argv)
GetOpt - how to.
Definition: jim-nvp.c:149
int jim_getopt_nvp(struct jim_getopt_info *goi, const struct jim_nvp *nvp, struct jim_nvp **puthere)
Remove argv[0] as NVP.
Definition: jim-nvp.c:237
void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *nvptable, int hadprefix)
Create an appropriate error message for an NVP.
Definition: jim-nvp.c:253
int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere)
Remove argv[0] from the list.
Definition: jim-nvp.c:169
bool transport_is_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
Definition: jtag/core.c:1823
const char * jtag_tap_name(const struct jtag_tap *tap)
Definition: jtag/core.c:263
struct jtag_tap * jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *obj)
Definition: jtag/tcl.c:53
static void list_add_tail(struct list_head *new, struct list_head *head)
Definition: list.h:203
#define list_for_each_entry_safe(p, n, h, field)
Definition: list.h:159
#define list_for_each_entry(p, h, field)
Definition: list.h:155
static void INIT_LIST_HEAD(struct list_head *list)
Definition: list.h:54
#define LOG_WARNING(expr ...)
Definition: log.h:144
#define ERROR_FAIL
Definition: log.h:188
#define LOG_ERROR(expr ...)
Definition: log.h:147
#define LOG_DEBUG(expr ...)
Definition: log.h:124
#define ERROR_OK
Definition: log.h:182
static uint32_t lh(unsigned int rd, unsigned int base, int16_t offset) __attribute__((unused))
Definition: opcodes.h:172
Represents a driver for a debugging interface.
Definition: interface.h:214
const struct swd_driver * swd_ops
Low-level SWD APIs.
Definition: interface.h:360
const struct dap_ops * dap_swd_ops
Definition: interface.h:366
const struct dap_ops * dap_jtag_ops
Definition: interface.h:363
This represents an ARM Debug Interface (v5) Access Port (AP).
Definition: arm_adi_v5.h:250
bool config_ap_never_release
Definition: arm_adi_v5.h:328
uint32_t tar_autoincr_block
Definition: arm_adi_v5.h:309
unsigned int refcount
Definition: arm_adi_v5.h:325
uint64_t ap_num
ADIv5: Number of this AP (0~255) ADIv6: Base address of this AP (4k aligned) TODO: to be more coheren...
Definition: arm_adi_v5.h:261
struct adiv5_dap * dap
DAP this AP belongs to.
Definition: arm_adi_v5.h:254
uint32_t memaccess_tck
Configures how many extra tck clocks are added after starting a MEM-AP access before we try to read i...
Definition: arm_adi_v5.h:306
uint32_t cfg_reg
Definition: arm_adi_v5.h:322
uint32_t csw_default
Default value for (MEM-AP) AP_REG_CSW register.
Definition: arm_adi_v5.h:266
This represents an ARM Debug Interface (v5) Debug Access Port (DAP).
Definition: arm_adi_v5.h:348
unsigned int adi_version
Indicates ADI version (5, 6 or 0 for unknown) being used.
Definition: arm_adi_v5.h:433
struct list_head cmd_journal
Definition: arm_adi_v5.h:352
struct adiv5_ap ap[DP_APSEL_MAX+1]
Definition: arm_adi_v5.h:364
bool multidrop_instance_id_valid
TINSTANCE field of multidrop_targetsel has been configured.
Definition: arm_adi_v5.h:425
const struct dap_ops * ops
Definition: arm_adi_v5.h:349
uint64_t apsel
Definition: arm_adi_v5.h:367
struct jtag_tap * tap
Definition: arm_adi_v5.h:360
uint32_t multidrop_targetsel
Value to select DP in SWD multidrop mode or DP_TARGETSEL_INVALID.
Definition: arm_adi_v5.h:421
bool multidrop_dp_id_valid
TPARTNO and TDESIGNER fields of multidrop_targetsel have been configured.
Definition: arm_adi_v5.h:423
struct list_head cmd_pool
Definition: arm_adi_v5.h:355
unsigned int asize
Definition: arm_adi_v5.h:436
bool ignore_syspwrupack
Flag saying whether to ignore the syspwrupack flag in DAP.
Definition: arm_adi_v5.h:418
struct adiv5_dap * dap
Definition: arm_adi_v5.h:798
const struct swd_driver * swd
Definition: arm_dap.c:29
struct adiv5_dap dap
Definition: arm_dap.c:27
struct list_head lh
Definition: arm_dap.c:26
char * name
Definition: arm_dap.c:28
const char * name
Definition: command.h:239
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
Definition: command.h:252
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:244
int(* connect)(struct adiv5_dap *dap)
connect operation for SWD
Definition: arm_adi_v5.h:451
int(* queue_dp_read)(struct adiv5_dap *dap, unsigned int reg, uint32_t *data)
DP register read.
Definition: arm_adi_v5.h:457
void(* quit)(struct adiv5_dap *dap)
Optional; called at OpenOCD exit.
Definition: arm_adi_v5.h:481
int(* pre_connect_init)(struct adiv5_dap *dap)
Optional; called once on the first enabled dap before connecting.
Definition: arm_adi_v5.h:448
A TCL -ish GetOpt like code.
Definition: jim-nvp.h:136
Jim_Interp * interp
Definition: jim-nvp.h:137
Name Value Pairs, aka: NVP.
Definition: jim-nvp.h:60
const char * name
Definition: jim-nvp.h:61
int value
Definition: jim-nvp.h:62
Definition: jtag.h:101
bool enabled
Is this TAP currently enabled?
Definition: jtag.h:109
Definition: list.h:41
Definition: target.h:119
void * private_config
Definition: target.h:175
bool dap_configured
Definition: target.h:189
bool has_dap
Definition: target.h:188
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:469
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
Definition: target.h:247
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
Definition: target.h:822
#define container_of(ptr, type, member)
Cast a member of a structure out to the containing structure.
Definition: types.h:68
#define NULL
Definition: usb.h:16