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 
187 };
188 
189 static const struct jim_nvp nvp_config_opts[] = {
190  { .name = "-chain-position", .value = CFG_CHAIN_POSITION },
191  { .name = "-ignore-syspwrupack", .value = CFG_IGNORE_SYSPWRUPACK },
192  { .name = "-dp-id", .value = CFG_DP_ID },
193  { .name = "-instance-id", .value = CFG_INSTANCE_ID },
194  { .name = "-adiv6", .value = CFG_ADIV6 },
195  { .name = "-adiv5", .value = CFG_ADIV5 },
196  { .name = NULL, .value = -1 }
197 };
198 
199 static int dap_configure(struct jim_getopt_info *goi, struct arm_dap_object *dap)
200 {
201  struct jim_nvp *n;
202  int e;
203 
204  /* parse config ... */
205  while (goi->argc > 0) {
206  Jim_SetEmptyResult(goi->interp);
207 
208  e = jim_getopt_nvp(goi, nvp_config_opts, &n);
209  if (e != JIM_OK) {
211  return e;
212  }
213  switch (n->value) {
214  case CFG_CHAIN_POSITION: {
215  Jim_Obj *o_t;
216  e = jim_getopt_obj(goi, &o_t);
217  if (e != JIM_OK)
218  return e;
219 
220  struct jtag_tap *tap;
221  tap = jtag_tap_by_jim_obj(goi->interp, o_t);
222  if (!tap) {
223  Jim_SetResultString(goi->interp, "-chain-position is invalid", -1);
224  return JIM_ERR;
225  }
226  dap->dap.tap = tap;
227  /* loop for more */
228  break;
229  }
231  dap->dap.ignore_syspwrupack = true;
232  break;
233  case CFG_DP_ID: {
234  jim_wide w;
235  e = jim_getopt_wide(goi, &w);
236  if (e != JIM_OK) {
237  Jim_SetResultFormatted(goi->interp,
238  "create %s: bad parameter %s",
239  dap->name, n->name);
240  return JIM_ERR;
241  }
242  if (w < 0 || w > DP_TARGETSEL_DPID_MASK) {
243  Jim_SetResultFormatted(goi->interp,
244  "create %s: %s out of range",
245  dap->name, n->name);
246  return JIM_ERR;
247  }
248  dap->dap.multidrop_targetsel =
250  | (w & DP_TARGETSEL_DPID_MASK);
251  dap->dap.multidrop_dp_id_valid = true;
252  break;
253  }
254  case CFG_INSTANCE_ID: {
255  jim_wide w;
256  e = jim_getopt_wide(goi, &w);
257  if (e != JIM_OK) {
258  Jim_SetResultFormatted(goi->interp,
259  "create %s: bad parameter %s",
260  dap->name, n->name);
261  return JIM_ERR;
262  }
263  if (w < 0 || w > 15) {
264  Jim_SetResultFormatted(goi->interp,
265  "create %s: %s out of range",
266  dap->name, n->name);
267  return JIM_ERR;
268  }
269  dap->dap.multidrop_targetsel =
272  dap->dap.multidrop_instance_id_valid = true;
273  break;
274  }
275  case CFG_ADIV6:
276  dap->dap.adi_version = 6;
277  break;
278  case CFG_ADIV5:
279  dap->dap.adi_version = 5;
280  break;
281  default:
282  break;
283  }
284  }
285 
286  return JIM_OK;
287 }
288 
289 static int dap_check_config(struct adiv5_dap *dap)
290 {
292  return ERROR_OK;
293 
294  struct arm_dap_object *obj;
295  bool new_multidrop = dap_is_multidrop(dap);
296  bool had_multidrop = new_multidrop;
297  uint32_t targetsel = dap->multidrop_targetsel;
298  unsigned int non_multidrop_count = had_multidrop ? 0 : 1;
299 
300  list_for_each_entry(obj, &all_dap, lh) {
301  struct adiv5_dap *dap_it = &obj->dap;
302 
303  if (transport_is_swd()) {
304  if (dap_is_multidrop(dap_it)) {
305  had_multidrop = true;
306  if (new_multidrop && dap_it->multidrop_targetsel == targetsel) {
307  uint32_t dp_id = targetsel & DP_TARGETSEL_DPID_MASK;
308  uint32_t instance_id = targetsel >> DP_TARGETSEL_INSTANCEID_SHIFT;
309  LOG_ERROR("%s and %s have the same multidrop selectors -dp-id 0x%08"
310  PRIx32 " and -instance-id 0x%" PRIx32,
311  obj->name, adiv5_dap_name(dap),
312  dp_id, instance_id);
313  return ERROR_FAIL;
314  }
315  } else {
316  non_multidrop_count++;
317  }
318  } else if (transport_is_dapdirect_swd()) {
319  non_multidrop_count++;
320  }
321  }
322 
323  if (non_multidrop_count > 1) {
324  LOG_ERROR("Two or more SWD non multidrop DAPs are not supported");
325  return ERROR_FAIL;
326  }
327  if (had_multidrop && non_multidrop_count) {
328  LOG_ERROR("Mixing of SWD multidrop DAPs and non multidrop DAPs is not supported");
329  return ERROR_FAIL;
330  }
331 
332  return ERROR_OK;
333 }
334 
335 COMMAND_HANDLER(handle_dap_create)
336 {
337  if (CMD_ARGC < 3)
339 
340  int retval = ERROR_COMMAND_ARGUMENT_INVALID;
341 
342  /* check if the dap name clashes with an existing command name */
343  Jim_Cmd *jimcmd = Jim_GetCommand(CMD_CTX->interp, CMD_JIMTCL_ARGV[0], JIM_NONE);
344  if (jimcmd) {
345  command_print(CMD, "Command/dap: %s Exists", CMD_ARGV[0]);
346  return ERROR_FAIL;
347  }
348 
349  /* Create it */
350  struct arm_dap_object *dap = calloc(1, sizeof(struct arm_dap_object));
351  if (!dap) {
352  LOG_ERROR("Out of memory");
353  return ERROR_FAIL;
354  }
355 
356  dap_instance_init(&dap->dap);
357 
358  dap->name = strdup(CMD_ARGV[0]);
359  if (!dap->name) {
360  LOG_ERROR("Out of memory");
361  free(dap);
362  return ERROR_FAIL;
363  }
364 
365  struct jim_getopt_info goi;
366  jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - 1, CMD_JIMTCL_ARGV + 1);
367  int e = dap_configure(&goi, dap);
368  if (e != JIM_OK) {
369  int reslen;
370  const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
371  if (reslen > 0)
372  command_print(CMD, "%s", result);
373  goto err;
374  }
375 
376  if (!dap->dap.tap) {
377  command_print(CMD, "-chain-position required when creating DAP");
378  goto err;
379  }
380 
381  retval = dap_check_config(&dap->dap);
382  if (retval != ERROR_OK)
383  goto err;
384 
385  struct command_registration dap_create_commands[] = {
386  {
387  .name = CMD_ARGV[0],
388  .mode = COMMAND_ANY,
389  .help = "dap instance command group",
390  .usage = "",
391  .chain = dap_instance_commands,
392  },
394  };
395 
396  /* don't expose the instance commands when using hla */
397  if (transport_is_hla())
398  dap_create_commands[0].chain = NULL;
399 
400  retval = register_commands_with_data(CMD_CTX, NULL, dap_create_commands, dap);
401  if (retval != ERROR_OK)
402  goto err;
403 
404  list_add_tail(&dap->lh, &all_dap);
405 
406  return ERROR_OK;
407 
408 err:
409  free(dap->name);
410  free(dap);
411  return retval;
412 }
413 
414 static struct adiv5_dap *target_to_dap(const struct target *target)
415 {
417 
418  if (!target->has_dap || !target->dap_configured || !pc)
419  return NULL;
420 
421  return pc->dap;
422 }
423 
424 COMMAND_HANDLER(handle_dap_names)
425 {
426  if (CMD_ARGC != 0)
428 
429  struct arm_dap_object *obj;
430  list_for_each_entry(obj, &all_dap, lh)
431  command_print(CMD, "%s", obj->name);
432 
433  return ERROR_OK;
434 }
435 
436 COMMAND_HANDLER(handle_dap_init)
437 {
438  return dap_init_all();
439 }
440 
441 COMMAND_HANDLER(handle_dap_info_command)
442 {
444  struct adiv5_dap *dap = target_to_dap(target);
445  uint64_t apsel;
446 
447  if (!dap) {
448  command_print(CMD, "target %s has no DAP", target_name(target));
450  }
451 
452  switch (CMD_ARGC) {
453  case 0:
454  apsel = dap->apsel;
455  break;
456  case 1:
457  if (!strcmp(CMD_ARGV[0], "root")) {
458  if (!is_adiv6(dap)) {
459  command_print(CMD, "Option \"root\" not allowed with ADIv5 DAP");
461  }
462  int retval = adiv6_dap_read_baseptr(CMD, dap, &apsel);
463  if (retval != ERROR_OK) {
464  command_print(CMD, "Failed reading DAP baseptr");
465  return retval;
466  }
467  break;
468  }
470  if (!is_ap_num_valid(dap, apsel))
472  break;
473  default:
475  }
476 
477  struct adiv5_ap *ap = dap_get_ap(dap, apsel);
478  if (!ap) {
479  command_print(CMD, "Cannot get AP");
480  return ERROR_FAIL;
481  }
482  int retval = dap_info_command(CMD, ap);
483  dap_put_ap(ap);
484  return retval;
485 }
486 
487 static const struct command_registration dap_subcommand_handlers[] = {
488  {
489  .name = "create",
490  .mode = COMMAND_ANY,
491  .handler = handle_dap_create,
492  .usage = "name '-chain-position' name",
493  .help = "Creates a new DAP instance",
494  },
495  {
496  .name = "names",
497  .mode = COMMAND_ANY,
498  .handler = handle_dap_names,
499  .usage = "",
500  .help = "Lists all registered DAP instances by name",
501  },
502  {
503  .name = "init",
504  .mode = COMMAND_ANY,
505  .handler = handle_dap_init,
506  .usage = "",
507  .help = "Initialize all registered DAP instances"
508  },
509  {
510  .name = "info",
511  .handler = handle_dap_info_command,
512  .mode = COMMAND_EXEC,
513  .help = "display ROM table for specified MEM-AP (default MEM-AP of current target) "
514  "or the ADIv6 root ROM table of current target's DAP",
515  .usage = "[ap_num | 'root']",
516  },
518 };
519 
520 static const struct command_registration dap_commands[] = {
521  {
522  .name = "dap",
523  .mode = COMMAND_CONFIG,
524  .help = "DAP commands",
525  .chain = dap_subcommand_handlers,
526  .usage = "",
527  },
529 };
530 
532 {
533  return register_commands(cmd_ctx, NULL, dap_commands);
534 }
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:675
bool transport_is_swd(void)
Returns true if the current debug session is using SWD as its transport.
Definition: adi_v5_swd.c:772
Holds the interface to ARM cores.
int dap_info_command(struct command_invocation *cmd, struct adiv5_ap *ap)
Definition: arm_adi_v5.c:2266
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:2938
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:189
static const struct command_registration dap_subcommand_handlers[]
Definition: arm_dap.c:487
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:199
static const struct command_registration dap_commands[]
Definition: arm_dap.c:520
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:531
dap_cfg_param
Definition: arm_dap.c:180
@ CFG_IGNORE_SYSPWRUPACK
Definition: arm_dap.c:182
@ CFG_INSTANCE_ID
Definition: arm_dap.c:184
@ CFG_CHAIN_POSITION
Definition: arm_dap.c:181
@ CFG_DP_ID
Definition: arm_dap.c:183
@ CFG_ADIV6
Definition: arm_dap.c:185
@ CFG_ADIV5
Definition: arm_dap.c:186
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:335
static int dap_check_config(struct adiv5_dap *dap)
Definition: arm_dap.c:289
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:414
const char * name
Definition: armv4_5.c:76
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:1838
const char * jtag_tap_name(const struct jtag_tap *tap)
Definition: jtag/core.c:280
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 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:208
const struct swd_driver * swd_ops
Low-level SWD APIs.
Definition: interface.h:354
const struct dap_ops * dap_swd_ops
Definition: interface.h:360
const struct dap_ops * dap_jtag_ops
Definition: interface.h:357
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:168
bool dap_configured
Definition: target.h:182
bool has_dap
Definition: target.h:181
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:467
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
Definition: target.h:236
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
Definition: target.h:799
#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