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/interface.h"
20 
21 static LIST_HEAD(all_dap);
22 
23 extern struct adapter_driver *adapter_driver;
24 
25 /* DAP command support */
27  struct list_head lh;
28  struct adiv5_dap dap;
29  char *name;
30  const struct swd_driver *swd;
31 };
32 
33 static void dap_instance_init(struct adiv5_dap *dap)
34 {
35  int i;
36  /* Set up with safe defaults */
37  for (i = 0; i <= DP_APSEL_MAX; i++) {
38  dap->ap[i].dap = dap;
39  dap->ap[i].ap_num = DP_APSEL_INVALID;
40  /* memaccess_tck max is 255 */
41  dap->ap[i].memaccess_tck = 255;
42  /* Number of bits for tar autoincrement, impl. dep. at least 10 */
43  dap->ap[i].tar_autoincr_block = (1<<10);
44  /* default CSW value */
45  dap->ap[i].csw_default = CSW_AHB_DEFAULT;
46  dap->ap[i].cfg_reg = MEM_AP_REG_CFG_INVALID; /* mem_ap configuration reg (large physical addr, etc.) */
47  dap->ap[i].refcount = 0;
48  dap->ap[i].config_ap_never_release = false;
49  }
51  INIT_LIST_HEAD(&dap->cmd_pool);
52 }
53 
54 const char *adiv5_dap_name(struct adiv5_dap *self)
55 {
56  struct arm_dap_object *obj = container_of(self, struct arm_dap_object, dap);
57  return obj->name;
58 }
59 
60 const struct swd_driver *adiv5_dap_swd_driver(struct adiv5_dap *self)
61 {
62  struct arm_dap_object *obj = container_of(self, struct arm_dap_object, dap);
63  return obj->swd;
64 }
65 
67 {
68  return &obj->dap;
69 }
70 struct adiv5_dap *dap_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
71 {
72  struct arm_dap_object *obj = NULL;
73  const char *name;
74  bool found = false;
75 
76  name = Jim_GetString(o, NULL);
77 
78  list_for_each_entry(obj, &all_dap, lh) {
79  if (!strcmp(name, obj->name)) {
80  found = true;
81  break;
82  }
83  }
84 
85  if (found)
86  return &obj->dap;
87  return NULL;
88 }
89 
90 static int dap_init_all(void)
91 {
92  struct arm_dap_object *obj;
93  int retval;
94  bool pre_connect = true;
95 
96  LOG_DEBUG("Initializing all DAPs ...");
97 
98  list_for_each_entry(obj, &all_dap, lh) {
99  struct adiv5_dap *dap = &obj->dap;
100 
101  /* with hla, dap is just a dummy */
102  if (transport_is_hla())
103  continue;
104 
105  /* skip taps that are disabled */
106  if (!dap->tap->enabled)
107  continue;
108 
109  if (transport_is_swd()) {
110  dap->ops = &swd_dap_ops;
111  obj->swd = adapter_driver->swd_ops;
112  } else if (transport_is_dapdirect_swd()) {
114  } else if (transport_is_dapdirect_jtag()) {
116  } else
117  dap->ops = &jtag_dp_ops;
118 
119  if (dap->adi_version == 0) {
120  LOG_DEBUG("DAP %s configured by default to use ADIv5 protocol", jtag_tap_name(dap->tap));
121  dap->adi_version = 5;
122  } else {
123  LOG_DEBUG("DAP %s configured to use %s protocol by user cfg file", jtag_tap_name(dap->tap),
124  is_adiv6(dap) ? "ADIv6" : "ADIv5");
125  }
126 
127  if (pre_connect && dap->ops->pre_connect_init) {
128  retval = dap->ops->pre_connect_init(dap);
129  if (retval != ERROR_OK)
130  return retval;
131 
132  pre_connect = false;
133  }
134 
135  retval = dap->ops->connect(dap);
136  if (retval != ERROR_OK)
137  return retval;
138 
139  /* see if address size of ROM Table is greater than 32-bits */
140  if (is_adiv6(dap)) {
141  uint32_t dpidr1;
142 
143  retval = dap->ops->queue_dp_read(dap, DP_DPIDR1, &dpidr1);
144  if (retval != ERROR_OK) {
145  LOG_ERROR("DAP read of DPIDR1 failed...");
146  return retval;
147  }
148  retval = dap_run(dap);
149  if (retval != ERROR_OK) {
150  LOG_ERROR("DAP read of DPIDR1 failed...");
151  return retval;
152  }
153  dap->asize = dpidr1 & DP_DPIDR1_ASIZE_MASK;
154  }
155  }
156 
157  return ERROR_OK;
158 }
159 
161 {
162  struct arm_dap_object *obj, *tmp;
163  struct adiv5_dap *dap;
164 
165  list_for_each_entry_safe(obj, tmp, &all_dap, lh) {
166  dap = &obj->dap;
167  for (unsigned int i = 0; i <= DP_APSEL_MAX; i++) {
168  if (dap->ap[i].refcount != 0)
169  LOG_ERROR("BUG: refcount AP#%u still %u at exit", i, dap->ap[i].refcount);
170  }
171  if (dap->ops && dap->ops->quit)
172  dap->ops->quit(dap);
173 
174  free(obj->name);
175  free(obj);
176  }
177 
178  return ERROR_OK;
179 }
180 
188 };
189 
190 static const struct jim_nvp nvp_config_opts[] = {
191  { .name = "-chain-position", .value = CFG_CHAIN_POSITION },
192  { .name = "-ignore-syspwrupack", .value = CFG_IGNORE_SYSPWRUPACK },
193  { .name = "-dp-id", .value = CFG_DP_ID },
194  { .name = "-instance-id", .value = CFG_INSTANCE_ID },
195  { .name = "-adiv6", .value = CFG_ADIV6 },
196  { .name = "-adiv5", .value = CFG_ADIV5 },
197  { .name = NULL, .value = -1 }
198 };
199 
200 static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap)
201 {
202  struct jim_nvp *n;
203  int e;
204 
205  /* parse config ... */
206  while (goi->argc > 0) {
207  Jim_SetEmptyResult(goi->interp);
208 
209  e = jim_getopt_nvp(goi, nvp_config_opts, &n);
210  if (e != JIM_OK) {
212  return e;
213  }
214  switch (n->value) {
215  case CFG_CHAIN_POSITION: {
216  Jim_Obj *o_t;
217  e = jim_getopt_obj(goi, &o_t);
218  if (e != JIM_OK)
219  return e;
220 
221  struct jtag_tap *tap;
222  tap = jtag_tap_by_jim_obj(goi->interp, o_t);
223  if (!tap) {
224  Jim_SetResultString(goi->interp, "-chain-position is invalid", -1);
225  return JIM_ERR;
226  }
227  dap->dap.tap = tap;
228  /* loop for more */
229  break;
230  }
232  dap->dap.ignore_syspwrupack = true;
233  break;
234  case CFG_DP_ID: {
235  jim_wide w;
236  e = jim_getopt_wide(goi, &w);
237  if (e != JIM_OK) {
238  Jim_SetResultFormatted(goi->interp,
239  "create %s: bad parameter %s",
240  dap->name, n->name);
241  return JIM_ERR;
242  }
243  if (w < 0 || w > DP_TARGETSEL_DPID_MASK) {
244  Jim_SetResultFormatted(goi->interp,
245  "create %s: %s out of range",
246  dap->name, n->name);
247  return JIM_ERR;
248  }
249  dap->dap.multidrop_targetsel =
251  | (w & DP_TARGETSEL_DPID_MASK);
252  dap->dap.multidrop_dp_id_valid = true;
253  break;
254  }
255  case CFG_INSTANCE_ID: {
256  jim_wide w;
257  e = jim_getopt_wide(goi, &w);
258  if (e != JIM_OK) {
259  Jim_SetResultFormatted(goi->interp,
260  "create %s: bad parameter %s",
261  dap->name, n->name);
262  return JIM_ERR;
263  }
264  if (w < 0 || w > 15) {
265  Jim_SetResultFormatted(goi->interp,
266  "create %s: %s out of range",
267  dap->name, n->name);
268  return JIM_ERR;
269  }
270  dap->dap.multidrop_targetsel =
273  dap->dap.multidrop_instance_id_valid = true;
274  break;
275  }
276  case CFG_ADIV6:
277  dap->dap.adi_version = 6;
278  break;
279  case CFG_ADIV5:
280  dap->dap.adi_version = 5;
281  break;
282  default:
283  break;
284  }
285  }
286 
287  return JIM_OK;
288 }
289 
290 static int dap_check_config(struct adiv5_dap *dap)
291 {
293  return ERROR_OK;
294 
295  struct arm_dap_object *obj;
296  bool new_multidrop = dap_is_multidrop(dap);
297  bool had_multidrop = new_multidrop;
298  uint32_t targetsel = dap->multidrop_targetsel;
299  unsigned int non_multidrop_count = had_multidrop ? 0 : 1;
300 
301  list_for_each_entry(obj, &all_dap, lh) {
302  struct adiv5_dap *dap_it = &obj->dap;
303 
304  if (transport_is_swd()) {
305  if (dap_is_multidrop(dap_it)) {
306  had_multidrop = true;
307  if (new_multidrop && dap_it->multidrop_targetsel == targetsel) {
308  uint32_t dp_id = targetsel & DP_TARGETSEL_DPID_MASK;
309  uint32_t instance_id = targetsel >> DP_TARGETSEL_INSTANCEID_SHIFT;
310  LOG_ERROR("%s and %s have the same multidrop selectors -dp-id 0x%08"
311  PRIx32 " and -instance-id 0x%" PRIx32,
312  obj->name, adiv5_dap_name(dap),
313  dp_id, instance_id);
314  return ERROR_FAIL;
315  }
316  } else {
317  non_multidrop_count++;
318  }
319  } else if (transport_is_dapdirect_swd()) {
320  non_multidrop_count++;
321  }
322  }
323 
324  if (non_multidrop_count > 1) {
325  LOG_ERROR("Two or more SWD non multidrop DAPs are not supported");
326  return ERROR_FAIL;
327  }
328  if (had_multidrop && non_multidrop_count) {
329  LOG_ERROR("Mixing of SWD multidrop DAPs and non multidrop DAPs is not supported");
330  return ERROR_FAIL;
331  }
332 
333  return ERROR_OK;
334 }
335 
336 static int dap_create(struct jim_getopt_info *goi)
337 {
338  struct command_context *cmd_ctx;
339  static struct arm_dap_object *dap;
340  Jim_Obj *new_cmd;
341  Jim_Cmd *cmd;
342  const char *cp;
343  int e;
344 
345  cmd_ctx = current_command_context(goi->interp);
346  assert(cmd_ctx);
347 
348  if (goi->argc < 3) {
349  Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ..options...");
350  return JIM_ERR;
351  }
352  /* COMMAND */
353  jim_getopt_obj(goi, &new_cmd);
354  /* does this command exist? */
355  cmd = Jim_GetCommand(goi->interp, new_cmd, JIM_NONE);
356  if (cmd) {
357  cp = Jim_GetString(new_cmd, NULL);
358  Jim_SetResultFormatted(goi->interp, "Command: %s Exists", cp);
359  return JIM_ERR;
360  }
361 
362  /* Create it */
363  dap = calloc(1, sizeof(struct arm_dap_object));
364  if (!dap)
365  return JIM_ERR;
366 
367  dap_instance_init(&dap->dap);
368 
369  cp = Jim_GetString(new_cmd, NULL);
370  dap->name = strdup(cp);
371 
372  e = dap_configure(goi, dap);
373  if (e != JIM_OK)
374  goto err;
375 
376  if (!dap->dap.tap) {
377  Jim_SetResultString(goi->interp, "-chain-position required when creating DAP", -1);
378  e = JIM_ERR;
379  goto err;
380  }
381 
382  e = dap_check_config(&dap->dap);
383  if (e != ERROR_OK) {
384  e = JIM_ERR;
385  goto err;
386  }
387 
388  struct command_registration dap_create_commands[] = {
389  {
390  .name = cp,
391  .mode = COMMAND_ANY,
392  .help = "dap instance command group",
393  .usage = "",
394  .chain = dap_instance_commands,
395  },
397  };
398 
399  /* don't expose the instance commands when using hla */
400  if (transport_is_hla())
401  dap_create_commands[0].chain = NULL;
402 
403  e = register_commands_with_data(cmd_ctx, NULL, dap_create_commands, dap);
404  if (e != ERROR_OK) {
405  e = JIM_ERR;
406  goto err;
407  }
408 
409  list_add_tail(&dap->lh, &all_dap);
410 
411  return JIM_OK;
412 
413 err:
414  free(dap->name);
415  free(dap);
416  return e;
417 }
418 
419 static int jim_dap_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
420 {
421  struct jim_getopt_info goi;
422  jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
423  if (goi.argc < 2) {
424  Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
425  "<name> [<dap_options> ...]");
426  return JIM_ERR;
427  }
428  return dap_create(&goi);
429 }
430 
431 COMMAND_HANDLER(handle_dap_names)
432 {
433  if (CMD_ARGC != 0)
435 
436  struct arm_dap_object *obj;
437  list_for_each_entry(obj, &all_dap, lh)
438  command_print(CMD, "%s", obj->name);
439 
440  return ERROR_OK;
441 }
442 
443 COMMAND_HANDLER(handle_dap_init)
444 {
445  return dap_init_all();
446 }
447 
448 COMMAND_HANDLER(handle_dap_info_command)
449 {
451  struct arm *arm = target_to_arm(target);
452  struct adiv5_dap *dap = arm->dap;
453  uint64_t apsel;
454 
455  if (!dap) {
456  LOG_ERROR("DAP instance not available. Probably a HLA target...");
458  }
459 
460  switch (CMD_ARGC) {
461  case 0:
462  apsel = dap->apsel;
463  break;
464  case 1:
465  if (!strcmp(CMD_ARGV[0], "root")) {
466  if (!is_adiv6(dap)) {
467  command_print(CMD, "Option \"root\" not allowed with ADIv5 DAP");
469  }
470  int retval = adiv6_dap_read_baseptr(CMD, dap, &apsel);
471  if (retval != ERROR_OK) {
472  command_print(CMD, "Failed reading DAP baseptr");
473  return retval;
474  }
475  break;
476  }
478  if (!is_ap_num_valid(dap, apsel))
480  break;
481  default:
483  }
484 
485  struct adiv5_ap *ap = dap_get_ap(dap, apsel);
486  if (!ap) {
487  command_print(CMD, "Cannot get AP");
488  return ERROR_FAIL;
489  }
490  int retval = dap_info_command(CMD, ap);
491  dap_put_ap(ap);
492  return retval;
493 }
494 
495 static const struct command_registration dap_subcommand_handlers[] = {
496  {
497  .name = "create",
498  .mode = COMMAND_ANY,
499  .jim_handler = jim_dap_create,
500  .usage = "name '-chain-position' name",
501  .help = "Creates a new DAP instance",
502  },
503  {
504  .name = "names",
505  .mode = COMMAND_ANY,
506  .handler = handle_dap_names,
507  .usage = "",
508  .help = "Lists all registered DAP instances by name",
509  },
510  {
511  .name = "init",
512  .mode = COMMAND_ANY,
513  .handler = handle_dap_init,
514  .usage = "",
515  .help = "Initialize all registered DAP instances"
516  },
517  {
518  .name = "info",
519  .handler = handle_dap_info_command,
520  .mode = COMMAND_EXEC,
521  .help = "display ROM table for specified MEM-AP (default MEM-AP of current target) "
522  "or the ADIv6 root ROM table of current target's DAP",
523  .usage = "[ap_num | 'root']",
524  },
526 };
527 
528 static const struct command_registration dap_commands[] = {
529  {
530  .name = "dap",
531  .mode = COMMAND_CONFIG,
532  .help = "DAP commands",
533  .chain = dap_subcommand_handlers,
534  .usage = "",
535  },
537 };
538 
540 {
541  return register_commands(cmd_ctx, NULL, dap_commands);
542 }
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:677
bool transport_is_swd(void)
Returns true if the current debug session is using SWD as its transport.
Definition: adi_v5_swd.c:776
Holds the interface to ARM cores.
static struct arm * target_to_arm(const struct target *target)
Convert target handle to generic ARM target state handle.
Definition: arm.h:261
int dap_info_command(struct command_invocation *cmd, struct adiv5_ap *ap)
Definition: arm_adi_v5.c:2233
bool is_ap_num_valid(struct adiv5_dap *dap, uint64_t ap_num)
Definition: arm_adi_v5.c:1078
int adiv6_dap_read_baseptr(struct command_invocation *cmd, struct adiv5_dap *dap, uint64_t *baseptr)
Definition: arm_adi_v5.c:1266
struct adiv5_ap * dap_get_ap(struct adiv5_dap *dap, uint64_t ap_num)
Definition: arm_adi_v5.c:1189
int dap_put_ap(struct adiv5_ap *ap)
Definition: arm_adi_v5.c:1209
const struct command_registration dap_instance_commands[]
Definition: arm_adi_v5.c:2903
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:756
#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_create(struct jim_getopt_info *goi)
Definition: arm_dap.c:336
static int dap_init_all(void)
Definition: arm_dap.c:90
int dap_cleanup_all(void)
Definition: arm_dap.c:160
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:495
struct adiv5_dap * dap_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
Definition: arm_dap.c:70
static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap)
Definition: arm_dap.c:200
static const struct command_registration dap_commands[]
Definition: arm_dap.c:528
const struct swd_driver * adiv5_dap_swd_driver(struct adiv5_dap *self)
Definition: arm_dap.c:60
static LIST_HEAD(all_dap)
static void dap_instance_init(struct adiv5_dap *dap)
Definition: arm_dap.c:33
int dap_register_commands(struct command_context *cmd_ctx)
Definition: arm_dap.c:539
dap_cfg_param
Definition: arm_dap.c:181
@ CFG_IGNORE_SYSPWRUPACK
Definition: arm_dap.c:183
@ CFG_INSTANCE_ID
Definition: arm_dap.c:185
@ CFG_CHAIN_POSITION
Definition: arm_dap.c:182
@ 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:66
static int jim_dap_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: arm_dap.c:419
static int dap_check_config(struct adiv5_dap *dap)
Definition: arm_dap.c:290
const char * adiv5_dap_name(struct adiv5_dap *self)
Definition: arm_dap.c:54
struct adapter_driver * adapter_driver
Definition: adapter.c:26
COMMAND_HANDLER(handle_dap_names)
Definition: arm_dap.c:431
const char * name
Definition: armv4_5.c:76
struct command_context * current_command_context(Jim_Interp *interp)
Definition: command.c:157
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:443
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
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:315
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:402
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#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:442
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
Definition: command.h:146
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
#define ERROR_COMMAND_ARGUMENT_INVALID
Definition: command.h:404
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
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:1827
const char * jtag_tap_name(const struct jtag_tap *tap)
Definition: jtag/core.c:276
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:199
#define list_for_each_entry_safe(p, n, h, field)
Definition: list.h:155
#define list_for_each_entry(p, h, field)
Definition: list.h:151
static void INIT_LIST_HEAD(struct list_head *list)
Definition: list.h:53
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:164
static uint32_t lh(unsigned int rd, unsigned int base, uint16_t offset) __attribute__((unused))
Definition: opcodes.h:117
Represents a driver for a debugging interface.
Definition: interface.h:207
const struct swd_driver * swd_ops
Low-level SWD APIs.
Definition: interface.h:345
const struct dap_ops * dap_swd_ops
Definition: interface.h:351
const struct dap_ops * dap_jtag_ops
Definition: interface.h:348
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
const struct swd_driver * swd
Definition: arm_dap.c:30
struct adiv5_dap dap
Definition: arm_dap.c:28
struct list_head lh
Definition: arm_dap.c:27
char * name
Definition: arm_dap.c:29
Represents a generic ARM core, with standard application registers.
Definition: arm.h:175
struct adiv5_dap * dap
For targets conforming to ARM Debug Interface v5, this handle references the Debug Access Port (DAP) ...
Definition: arm.h:257
const char * name
Definition: command.h:235
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:249
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241
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:135
Jim_Interp * interp
Definition: jim-nvp.h:136
Jim_Obj *const * argv
Definition: jim-nvp.h:138
Name Value Pairs, aka: NVP.
Definition: jim-nvp.h:59
const char * name
Definition: jim-nvp.h:60
int value
Definition: jim-nvp.h:61
Definition: jtag.h:101
bool enabled
Is this TAP currently enabled?
Definition: jtag.h:109
Definition: list.h:40
Definition: target.h:116
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:458
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
Definition: target.h:794
#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
uint8_t cmd
Definition: vdebug.c:1