OpenOCD
arm_tpiu_swo.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
11 /*
12  * Relevant specifications from ARM include:
13  *
14  * CoreSight(tm) Components Technical Reference Manual ARM DDI 0314H
15  * CoreSight(tm) TPIU-Lite Technical Reference Manual ARM DDI 0317A
16  * Cortex(tm)-M3 Technical Reference Manual ARM DDI 0337G
17  * Cortex(tm)-M4 Technical Reference Manual ARM DDI 0439B
18  * CoreSight(tm) SoC-400 Technical Reference Manual ARM DDI 0480F
19  */
20 
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24 
25 #include <stdlib.h>
26 #include <jim.h>
27 
28 #include <helper/bits.h>
29 #include <helper/command.h>
30 #include <helper/jim-nvp.h>
31 #include <helper/list.h>
32 #include <helper/log.h>
33 #include <helper/types.h>
34 #include <jtag/interface.h>
35 #include <server/server.h>
36 #include <target/arm_adi_v5.h>
37 #include <target/target.h>
38 #include <transport/transport.h>
39 #include "arm_tpiu_swo.h"
40 
41 /* START_DEPRECATED_TPIU */
42 #include <target/cortex_m.h>
43 #define MSG "DEPRECATED \'tpiu config\' command: "
44 /* END_DEPRECATED_TPIU */
45 
46 #define TCP_SERVICE_NAME "tpiu_swo_trace"
47 
48 /* default for Cortex-M3 and Cortex-M4 specific TPIU */
49 #define TPIU_SWO_DEFAULT_BASE 0xE0040000
50 
51 #define TPIU_SSPSR_OFFSET 0x000
52 #define TPIU_CSPSR_OFFSET 0x004
53 #define TPIU_ACPR_OFFSET 0x010
54 #define TPIU_SPPR_OFFSET 0x0F0
55 #define TPIU_FFSR_OFFSET 0x300
56 #define TPIU_FFCR_OFFSET 0x304
57 #define TPIU_FSCR_OFFSET 0x308
58 #define TPIU_DEVID_OFFSET 0xfc8
59 
60 #define TPIU_ACPR_MAX_PRESCALER 0x1fff
61 #define TPIU_SPPR_PROTOCOL_SYNC (TPIU_PIN_PROTOCOL_SYNC)
62 #define TPIU_SPPR_PROTOCOL_MANCHESTER (TPIU_PIN_PROTOCOL_ASYNC_MANCHESTER)
63 #define TPIU_SPPR_PROTOCOL_UART (TPIU_PIN_PROTOCOL_ASYNC_UART)
64 #define TPIU_DEVID_NOSUPPORT_SYNC BIT(9)
65 #define TPIU_DEVID_SUPPORT_MANCHESTER BIT(10)
66 #define TPIU_DEVID_SUPPORT_UART BIT(11)
67 
73 };
74 
75 static const struct jim_nvp nvp_arm_tpiu_swo_event[] = {
76  { .value = TPIU_SWO_EVENT_PRE_ENABLE, .name = "pre-enable" },
77  { .value = TPIU_SWO_EVENT_POST_ENABLE, .name = "post-enable" },
78  { .value = TPIU_SWO_EVENT_PRE_DISABLE, .name = "pre-disable" },
79  { .value = TPIU_SWO_EVENT_POST_DISABLE, .name = "post-disable" },
80 };
81 
84  Jim_Interp *interp;
85  Jim_Obj *body;
87 };
88 
90  struct list_head lh;
91  struct adiv5_mem_ap_spot spot;
92  struct adiv5_ap *ap;
93  char *name;
95  /* record enable before init */
97  bool enabled;
98  bool en_capture;
101  uint32_t port_width;
102  FILE *file;
104  unsigned int pin_protocol;
108  unsigned int traceclkin_freq;
110  unsigned int swo_pin_freq;
114  struct list_head connections;
115  /* START_DEPRECATED_TPIU */
117  /* END_DEPRECATED_TPIU */
118 };
119 
121  struct list_head lh;
123 };
124 
127 };
128 
129 static OOCD_LIST_HEAD(all_tpiu_swo);
130 
131 #define ARM_TPIU_SWO_TRACE_BUF_SIZE 4096
132 
133 static int arm_tpiu_swo_poll_trace(void *priv)
134 {
135  struct arm_tpiu_swo_object *obj = priv;
136  uint8_t buf[ARM_TPIU_SWO_TRACE_BUF_SIZE];
137  size_t size = sizeof(buf);
138  struct arm_tpiu_swo_connection *c;
139 
140  int retval = adapter_poll_trace(buf, &size);
141  if (retval != ERROR_OK || !size)
142  return retval;
143 
144  target_call_trace_callbacks(/*target*/NULL, size, buf);
145 
146  if (obj->file) {
147  if (fwrite(buf, 1, size, obj->file) == size) {
148  fflush(obj->file);
149  } else {
150  LOG_ERROR("Error writing to the SWO trace destination file");
151  return ERROR_FAIL;
152  }
153  }
154 
155  if (obj->out_filename[0] == ':')
157  if (connection_write(c->connection, buf, size) != (int)size)
158  LOG_ERROR("Error writing to connection"); /* FIXME: which connection? */
159 
160  return ERROR_OK;
161 }
162 
164 {
165  for (struct arm_tpiu_swo_event_action *ea = obj->event_action; ea; ea = ea->next) {
166  if (ea->event != event)
167  continue;
168 
169  LOG_DEBUG("TPIU/SWO: %s event: %s (%d) action : %s",
170  obj->name,
172  event,
173  Jim_GetString(ea->body, NULL));
174 
175  /* prevent event execution to change current target */
176  struct command_context *cmd_ctx = current_command_context(ea->interp);
177  struct target *saved_target = cmd_ctx->current_target;
178  int retval = Jim_EvalObj(ea->interp, ea->body);
179  cmd_ctx->current_target = saved_target;
180 
181  if (retval == JIM_RETURN)
182  retval = ea->interp->returnCode;
183  if (retval == JIM_OK || retval == ERROR_COMMAND_CLOSE_CONNECTION)
184  return ERROR_OK;
185 
186  Jim_MakeErrorMessage(ea->interp);
187  LOG_USER("Error executing event %s on TPIU/SWO %s:\n%s",
189  obj->name,
190  Jim_GetString(Jim_GetResult(ea->interp), NULL));
191  /* clean both error code and stacktrace before return */
192  Jim_Eval(ea->interp, "error \"\" \"\"");
193  return ERROR_FAIL;
194  }
195 
196  return ERROR_OK;
197 }
198 
200 {
201  if (obj->file) {
202  fclose(obj->file);
203  obj->file = NULL;
204  }
205  if (obj->out_filename[0] == ':')
207 }
208 
210 {
211  struct arm_tpiu_swo_object *obj, *tmp;
212 
213  list_for_each_entry_safe(obj, tmp, &all_tpiu_swo, lh) {
214  if (obj->enabled)
216 
218 
219  if (obj->en_capture) {
221 
222  int retval = adapter_config_trace(false, 0, 0, NULL, 0, NULL);
223  if (retval != ERROR_OK)
224  LOG_ERROR("Failed to stop adapter's trace");
225  }
226 
227  if (obj->enabled)
229 
230  struct arm_tpiu_swo_event_action *ea = obj->event_action;
231  while (ea) {
232  struct arm_tpiu_swo_event_action *next = ea->next;
233  Jim_DecrRefCount(ea->interp, ea->body);
234  free(ea);
235  ea = next;
236  }
237 
238  if (obj->ap)
239  dap_put_ap(obj->ap);
240 
241  free(obj->name);
242  free(obj->out_filename);
243  free(obj);
244  }
245 
246  return ERROR_OK;
247 }
248 
250 {
252  struct arm_tpiu_swo_object *obj = priv->obj;
253  struct arm_tpiu_swo_connection *c = malloc(sizeof(*c));
254  if (!c) {
255  LOG_ERROR("Out of memory");
256  return ERROR_FAIL;
257  }
258  c->connection = connection;
259  list_add(&c->lh, &obj->connections);
260  return ERROR_OK;
261 }
262 
264 {
265  /* read a dummy buffer to check if the connection is still active */
266  long dummy;
267  int bytes_read = connection_read(connection, &dummy, sizeof(dummy));
268 
269  if (bytes_read == 0) {
271  } else if (bytes_read == -1) {
272  LOG_ERROR("error during read: %s", strerror(errno));
274  }
275 
276  return ERROR_OK;
277 }
278 
280 {
282  struct arm_tpiu_swo_object *obj = priv->obj;
283  struct arm_tpiu_swo_connection *c, *tmp;
284 
285  list_for_each_entry_safe(c, tmp, &obj->connections, lh)
286  if (c->connection == connection) {
287  list_del(&c->lh);
288  free(c);
289  return ERROR_OK;
290  }
291  LOG_ERROR("Failed to find connection to close!");
292  return ERROR_FAIL;
293 }
294 
295 COMMAND_HANDLER(handle_arm_tpiu_swo_event_list)
296 {
297  struct arm_tpiu_swo_object *obj = CMD_DATA;
298 
299  command_print(CMD, "Event actions for TPIU/SWO %s\n", obj->name);
300  command_print(CMD, "%-25s | Body", "Event");
301  command_print(CMD, "------------------------- | "
302  "----------------------------------------");
303 
304  for (struct arm_tpiu_swo_event_action *ea = obj->event_action; ea; ea = ea->next) {
305  struct jim_nvp *opt = jim_nvp_value2name_simple(nvp_arm_tpiu_swo_event, ea->event);
306  command_print(CMD, "%-25s | %s",
307  opt->name, Jim_GetString(ea->body, NULL));
308  }
309  command_print(CMD, "***END***");
310  return ERROR_OK;
311 }
312 
321 };
322 
323 static const struct jim_nvp nvp_arm_tpiu_swo_config_opts[] = {
324  { .name = "-port-width", .value = CFG_PORT_WIDTH },
325  { .name = "-protocol", .value = CFG_PROTOCOL },
326  { .name = "-formatter", .value = CFG_FORMATTER },
327  { .name = "-traceclk", .value = CFG_TRACECLKIN },
328  { .name = "-pin-freq", .value = CFG_BITRATE },
329  { .name = "-output", .value = CFG_OUTFILE },
330  { .name = "-event", .value = CFG_EVENT },
331  /* handled by mem_ap_spot, added for jim_getopt_nvp_unknown() */
332  { .name = "-dap", .value = -1 },
333  { .name = "-ap-num", .value = -1 },
334  { .name = "-baseaddr", .value = -1 },
335  { .name = NULL, .value = -1 },
336 };
337 
338 static const struct jim_nvp nvp_arm_tpiu_swo_protocol_opts[] = {
339  { .name = "sync", .value = TPIU_SPPR_PROTOCOL_SYNC },
340  { .name = "uart", .value = TPIU_SPPR_PROTOCOL_UART },
341  { .name = "manchester", .value = TPIU_SPPR_PROTOCOL_MANCHESTER },
342  { .name = NULL, .value = -1 },
343 };
344 
345 static const struct jim_nvp nvp_arm_tpiu_swo_bool_opts[] = {
346  { .name = "on", .value = 1 },
347  { .name = "yes", .value = 1 },
348  { .name = "1", .value = 1 },
349  { .name = "true", .value = 1 },
350  { .name = "off", .value = 0 },
351  { .name = "no", .value = 0 },
352  { .name = "0", .value = 0 },
353  { .name = "false", .value = 0 },
354  { .name = NULL, .value = -1 },
355 };
356 
357 static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_swo_object *obj)
358 {
359  assert(obj);
360 
361  if (goi->is_configure && obj->enabled) {
362  Jim_SetResultFormatted(goi->interp, "Cannot configure TPIU/SWO; %s is enabled!", obj->name);
363  return JIM_ERR;
364  }
365 
366  /* parse config or cget options ... */
367  while (goi->argc > 0) {
368  Jim_SetEmptyResult(goi->interp);
369 
370  int e = adiv5_jim_mem_ap_spot_configure(&obj->spot, goi);
371  if (e == JIM_OK)
372  continue;
373  if (e == JIM_ERR)
374  return e;
375 
376  struct jim_nvp *n;
378  if (e != JIM_OK) {
380  return e;
381  }
382 
383  switch (n->value) {
384  case CFG_PORT_WIDTH:
385  if (goi->is_configure) {
386  jim_wide port_width;
387  e = jim_getopt_wide(goi, &port_width);
388  if (e != JIM_OK)
389  return e;
390  if (port_width < 1 || port_width > 32) {
391  Jim_SetResultString(goi->interp, "Invalid port width!", -1);
392  return JIM_ERR;
393  }
394  obj->port_width = (uint32_t)port_width;
395  } else {
396  if (goi->argc)
397  goto err_no_params;
398  Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, obj->port_width));
399  }
400  break;
401  case CFG_PROTOCOL:
402  if (goi->is_configure) {
403  struct jim_nvp *p;
405  if (e != JIM_OK)
406  return e;
407  obj->pin_protocol = p->value;
408  } else {
409  if (goi->argc)
410  goto err_no_params;
411  struct jim_nvp *p;
413  if (e != JIM_OK) {
414  Jim_SetResultString(goi->interp, "protocol error", -1);
415  return JIM_ERR;
416  }
417  Jim_SetResult(goi->interp, Jim_NewStringObj(goi->interp, p->name, -1));
418  }
419  break;
420  case CFG_FORMATTER:
421  if (goi->is_configure) {
422  struct jim_nvp *p;
424  if (e != JIM_OK)
425  return e;
426  obj->en_formatter = p->value;
427  } else {
428  if (goi->argc)
429  goto err_no_params;
430  struct jim_nvp *p;
432  if (e != JIM_OK) {
433  Jim_SetResultString(goi->interp, "formatter error", -1);
434  return JIM_ERR;
435  }
436  Jim_SetResult(goi->interp, Jim_NewStringObj(goi->interp, p->name, -1));
437  }
438  break;
439  case CFG_TRACECLKIN:
440  if (goi->is_configure) {
441  jim_wide clk;
442  e = jim_getopt_wide(goi, &clk);
443  if (e != JIM_OK)
444  return e;
445  obj->traceclkin_freq = clk;
446  } else {
447  if (goi->argc)
448  goto err_no_params;
449  Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, obj->traceclkin_freq));
450  }
451  break;
452  case CFG_BITRATE:
453  if (goi->is_configure) {
454  jim_wide clk;
455  e = jim_getopt_wide(goi, &clk);
456  if (e != JIM_OK)
457  return e;
458  obj->swo_pin_freq = clk;
459  } else {
460  if (goi->argc)
461  goto err_no_params;
462  Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, obj->swo_pin_freq));
463  }
464  break;
465  case CFG_OUTFILE:
466  if (goi->is_configure) {
467  const char *s;
468  e = jim_getopt_string(goi, &s, NULL);
469  if (e != JIM_OK)
470  return e;
471  if (s[0] == ':') {
472  char *end;
473  long port = strtol(s + 1, &end, 0);
474  if (port <= 0 || port > UINT16_MAX || *end != '\0') {
475  Jim_SetResultFormatted(goi->interp, "Invalid TCP port \'%s\'", s + 1);
476  return JIM_ERR;
477  }
478  }
479  char *out_filename = strdup(s);
480  if (!out_filename) {
481  LOG_ERROR("Out of memory");
482  return JIM_ERR;
483  }
484  free(obj->out_filename);
485  obj->out_filename = out_filename;
486  } else {
487  if (goi->argc)
488  goto err_no_params;
489  if (obj->out_filename)
490  Jim_SetResult(goi->interp, Jim_NewStringObj(goi->interp, obj->out_filename, -1));
491  }
492  break;
493  case CFG_EVENT:
494  if (goi->is_configure) {
495  if (goi->argc < 2) {
496  Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ?EVENT-BODY?");
497  return JIM_ERR;
498  }
499  } else {
500  if (goi->argc != 1) {
501  Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name?");
502  return JIM_ERR;
503  }
504  }
505 
506  {
507  struct jim_nvp *p;
508  Jim_Obj *o;
509  struct arm_tpiu_swo_event_action *ea = obj->event_action;
510 
512  if (e != JIM_OK) {
514  return e;
515  }
516 
517  while (ea) {
518  /* replace existing? */
519  if (ea->event == (enum arm_tpiu_swo_event)p->value)
520  break;
521  ea = ea->next;
522  }
523 
524  if (goi->is_configure) {
525  if (!ea) {
526  ea = calloc(1, sizeof(*ea));
527  if (!ea) {
528  LOG_ERROR("Out of memory");
529  return JIM_ERR;
530  }
531  ea->next = obj->event_action;
532  obj->event_action = ea;
533  }
534  if (ea->body)
535  Jim_DecrRefCount(ea->interp, ea->body);
536  ea->event = p->value;
537  ea->interp = goi->interp;
538  jim_getopt_obj(goi, &o);
539  ea->body = Jim_DuplicateObj(goi->interp, o);
540  Jim_IncrRefCount(ea->body);
541  } else {
542  if (ea)
543  Jim_SetResult(goi->interp, Jim_DuplicateObj(goi->interp, ea->body));
544  }
545  }
546  break;
547  }
548  }
549 
550  return JIM_OK;
551 
552 err_no_params:
553  Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS");
554  return JIM_ERR;
555 }
556 
557 COMMAND_HANDLER(handle_arm_tpiu_swo_configure)
558 {
559  struct arm_tpiu_swo_object *obj = CMD_DATA;
560 
561  if (!CMD_ARGC)
563 
564  struct jim_getopt_info goi;
566  goi.is_configure = !strcmp(CMD_NAME, "configure");
567 
568  int e = arm_tpiu_swo_configure(&goi, obj);
569 
570  int reslen;
571  const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
572  if (reslen > 0)
573  command_print(CMD, "%s", result);
574 
575  if (e != JIM_OK)
576  return ERROR_FAIL;
577 
578  return ERROR_OK;
579 }
580 
581 static int wrap_write_u32(struct target *target, struct adiv5_ap *tpiu_ap,
582  target_addr_t address, uint32_t value)
583 {
584  if (transport_is_hla())
585  return target_write_u32(target, address, value);
586  else
587  return mem_ap_write_atomic_u32(tpiu_ap, address, value);
588 }
589 
590 static int wrap_read_u32(struct target *target, struct adiv5_ap *tpiu_ap,
591  target_addr_t address, uint32_t *value)
592 {
593  if (transport_is_hla())
594  return target_read_u32(target, address, value);
595  else
596  return mem_ap_read_atomic_u32(tpiu_ap, address, value);
597 }
598 
599 static const struct service_driver arm_tpiu_swo_service_driver = {
600  .name = "tpiu_swo_trace",
601  .new_connection_during_keep_alive_handler = NULL,
602  .new_connection_handler = arm_tpiu_swo_service_new_connection,
603  .input_handler = arm_tpiu_swo_service_input,
604  .connection_closed_handler = arm_tpiu_swo_service_connection_closed,
605  .keep_client_alive_handler = NULL,
606 };
607 
608 COMMAND_HANDLER(handle_arm_tpiu_swo_enable)
609 {
610  struct arm_tpiu_swo_object *obj = CMD_DATA;
611  uint32_t value;
612  int retval;
613 
614  if (CMD_ARGC != 0)
616 
617  if (CMD_CTX->mode == COMMAND_CONFIG) {
618  LOG_DEBUG("%s: enable deferred", obj->name);
619  obj->deferred_enable = true;
620  return ERROR_OK;
621  }
622 
623  if (obj->enabled)
624  return ERROR_OK;
625 
626  if (transport_is_hla() && obj->spot.ap_num != 0) {
628  "Invalid access port 0x%" PRIx64 ". Only AP#0 allowed with hla transport",
629  obj->spot.ap_num);
630  return ERROR_FAIL;
631  }
632 
633  if (!obj->traceclkin_freq) {
634  command_print(CMD, "Trace clock-in frequency not set");
635  return ERROR_FAIL;
636  }
637 
638  const bool output_external = !strcmp(obj->out_filename, "external");
639 
641  if (!obj->swo_pin_freq) {
642  if (output_external) {
643  command_print(CMD, "SWO pin frequency required when using external capturing");
644  return ERROR_FAIL;
645  }
646 
647  LOG_DEBUG("SWO pin frequency not set, will be autodetected by the adapter");
648  }
649  }
650 
652 
653  /* START_DEPRECATED_TPIU */
654  if (obj->recheck_ap_cur_target) {
655  if (strcmp(target_type_name(target), "cortex_m") &&
656  strcmp(target_type_name(target), "hla_target")) {
657  LOG_ERROR(MSG "Current target is not a Cortex-M nor a HLA");
658  return ERROR_FAIL;
659  }
660  if (!target_was_examined(target)) {
661  LOG_ERROR(MSG "Current target not examined yet");
662  return ERROR_FAIL;
663  }
664  struct cortex_m_common *cm = target_to_cm(target);
665  obj->recheck_ap_cur_target = false;
666  obj->spot.ap_num = cm->armv7m.debug_ap->ap_num;
667  if (obj->spot.ap_num == 0)
668  LOG_INFO(MSG "Confirmed TPIU %s is on AP 0", obj->name);
669  else
670  LOG_INFO(MSG "Target %s is on AP#0x%" PRIx64 ". Revised command is "
671  "\'tpiu create %s -dap %s -ap-num 0x%" PRIx64 "\'",
672  target_name(target), obj->spot.ap_num,
673  obj->name, adiv5_dap_name(obj->spot.dap), obj->spot.ap_num);
674  }
675  /* END_DEPRECATED_TPIU */
676 
677  if (!obj->ap) {
678  obj->ap = dap_get_ap(obj->spot.dap, obj->spot.ap_num);
679  if (!obj->ap) {
680  command_print(CMD, "Cannot get AP");
681  return ERROR_FAIL;
682  }
683  }
684 
685  /* trigger the event before any attempt to R/W in the TPIU/SWO */
687  if (retval != ERROR_OK)
688  return retval;
689 
690  retval = wrap_read_u32(target, obj->ap, obj->spot.base + TPIU_DEVID_OFFSET, &value);
691  if (retval != ERROR_OK) {
692  command_print(CMD, "Unable to read %s", obj->name);
693  return retval;
694  }
695  switch (obj->pin_protocol) {
697  value = !(value & TPIU_DEVID_NOSUPPORT_SYNC);
698  break;
700  value &= TPIU_DEVID_SUPPORT_UART;
701  break;
704  break;
705  default:
706  value = 0;
707  }
708  if (!value) {
710  command_print(CMD, "%s does not support protocol %s", obj->name, p->name);
711  return ERROR_FAIL;
712  }
713 
715  retval = wrap_read_u32(target, obj->ap, obj->spot.base + TPIU_SSPSR_OFFSET, &value);
716  if (retval != ERROR_OK) {
717  command_print(CMD, "Cannot read TPIU register SSPSR");
718  return retval;
719  }
720  if (!(value & BIT(obj->port_width - 1))) {
721  command_print(CMD, "TPIU does not support port-width of %d bits", obj->port_width);
722  return ERROR_FAIL;
723  }
724  }
725 
726  uint16_t prescaler = 1; /* dummy value */
727  unsigned int swo_pin_freq = obj->swo_pin_freq; /* could be replaced */
728 
729  if (!output_external) {
730  if (obj->out_filename[0] == ':') {
731  struct arm_tpiu_swo_priv_connection *priv = malloc(sizeof(*priv));
732  if (!priv) {
733  LOG_ERROR("Out of memory");
734  return ERROR_FAIL;
735  }
736  priv->obj = obj;
737  LOG_INFO("starting trace server for %s on %s", obj->name, &obj->out_filename[1]);
740  if (retval != ERROR_OK) {
741  command_print(CMD, "Can't configure trace TCP port %s", &obj->out_filename[1]);
742  return retval;
743  }
744  } else if (strcmp(obj->out_filename, "-")) {
745  obj->file = fopen(obj->out_filename, "ab");
746  if (!obj->file) {
747  command_print(CMD, "Can't open trace destination file \"%s\"", obj->out_filename);
748  return ERROR_FAIL;
749  }
750  }
751 
753  &swo_pin_freq, obj->traceclkin_freq, &prescaler);
754  if (retval != ERROR_OK) {
755  command_print(CMD, "Failed to start adapter's trace");
757  return retval;
758  }
759 
761  if (!swo_pin_freq) {
762  if (obj->swo_pin_freq)
763  command_print(CMD, "Adapter rejected SWO pin frequency %d Hz", obj->swo_pin_freq);
764  else
766  "Adapter does not support auto-detection of SWO pin frequency nor a default value");
767 
769  return ERROR_FAIL;
770  }
771 
772  if (obj->swo_pin_freq != swo_pin_freq)
773  LOG_INFO("SWO pin data rate adjusted by adapter to %d Hz", swo_pin_freq);
774  obj->swo_pin_freq = swo_pin_freq;
775 
778 
779  obj->en_capture = true;
781  prescaler = (obj->traceclkin_freq + obj->swo_pin_freq / 2) / obj->swo_pin_freq;
782  if (prescaler > TPIU_ACPR_MAX_PRESCALER)
783  prescaler = TPIU_ACPR_MAX_PRESCALER;
784  swo_pin_freq = obj->traceclkin_freq / prescaler;
785 
786  if (obj->swo_pin_freq != swo_pin_freq)
787  LOG_INFO("SWO pin data rate adjusted to %d Hz", swo_pin_freq);
788  obj->swo_pin_freq = swo_pin_freq;
789  }
790 
792  if (retval != ERROR_OK)
793  goto error_exit;
794 
795  retval = wrap_write_u32(target, obj->ap, obj->spot.base + TPIU_ACPR_OFFSET, prescaler - 1);
796  if (retval != ERROR_OK)
797  goto error_exit;
798 
800  if (retval != ERROR_OK)
801  goto error_exit;
802 
803  retval = wrap_read_u32(target, obj->ap, obj->spot.base + TPIU_FFCR_OFFSET, &value);
804  if (retval != ERROR_OK)
805  goto error_exit;
806  if (obj->en_formatter)
807  value |= BIT(1);
808  else
809  value &= ~BIT(1);
810  retval = wrap_write_u32(target, obj->ap, obj->spot.base + TPIU_FFCR_OFFSET, value);
811  if (retval != ERROR_OK)
812  goto error_exit;
813 
815  if (retval != ERROR_OK)
816  goto error_exit;
817 
818  /* START_DEPRECATED_TPIU */
820  /* END_DEPRECATED_TPIU */
821 
822  obj->enabled = true;
823  return ERROR_OK;
824 
825 error_exit:
826  command_print(CMD, "Error!");
827 
828  if (obj->en_capture) {
829  obj->en_capture = false;
830 
832 
834 
835  int retval1 = adapter_config_trace(false, 0, 0, NULL, 0, NULL);
836  if (retval1 != ERROR_OK)
837  command_print(CMD, "Failed to stop adapter's trace");
838  }
839  return retval;
840 }
841 
842 COMMAND_HANDLER(handle_arm_tpiu_swo_disable)
843 {
844  struct arm_tpiu_swo_object *obj = CMD_DATA;
845 
846  if (CMD_ARGC != 0)
848 
849  if (!obj->enabled)
850  return ERROR_OK;
851  obj->enabled = false;
852 
854 
855  if (obj->en_capture) {
856  obj->en_capture = false;
857 
859 
861 
862  int retval = adapter_config_trace(false, 0, 0, NULL, 0, NULL);
863  if (retval != ERROR_OK) {
864  command_print(CMD, "Failed to stop adapter's trace");
865  return retval;
866  }
867  }
868 
870 
871  /* START_DEPRECATED_TPIU */
874  /* END_DEPRECATED_TPIU */
875 
876  return ERROR_OK;
877 }
878 
880  {
881  .name = "configure",
882  .mode = COMMAND_ANY,
883  .handler = handle_arm_tpiu_swo_configure,
884  .help = "configure a new TPIU/SWO for use",
885  .usage = "[attribute value ...]",
886  },
887  {
888  .name = "cget",
889  .mode = COMMAND_ANY,
890  .handler = handle_arm_tpiu_swo_configure,
891  .help = "returns the specified TPIU/SWO attribute",
892  .usage = "attribute",
893  },
894  {
895  .name = "eventlist",
896  .mode = COMMAND_ANY,
897  .handler = handle_arm_tpiu_swo_event_list,
898  .help = "displays a table of events defined for this TPIU/SWO",
899  .usage = "",
900  },
901  {
902  .name = "enable",
903  .mode = COMMAND_ANY,
904  .handler = handle_arm_tpiu_swo_enable,
905  .usage = "",
906  .help = "Enables the TPIU/SWO output",
907  },
908  {
909  .name = "disable",
910  .mode = COMMAND_EXEC,
911  .handler = handle_arm_tpiu_swo_disable,
912  .usage = "",
913  .help = "Disables the TPIU/SWO output",
914  },
916 };
917 
918 COMMAND_HANDLER(handle_arm_tpiu_swo_create)
919 {
920  int retval = ERROR_FAIL;
921 
922  if (!CMD_ARGC)
924 
925  /* does this command exist? */
926  Jim_Cmd *jimcmd = Jim_GetCommand(CMD_CTX->interp, CMD_JIMTCL_ARGV[0], JIM_NONE);
927  if (jimcmd) {
928  command_print(CMD, "cannot create TPIU object because a command with name '%s' already exists",
929  CMD_ARGV[0]);
930  return ERROR_FAIL;
931  }
932 
933  struct arm_tpiu_swo_object *obj = calloc(1, sizeof(struct arm_tpiu_swo_object));
934  if (!obj) {
935  LOG_ERROR("Out of memory");
936  return ERROR_FAIL;
937  }
941  obj->port_width = 1;
942  obj->out_filename = strdup("external");
943  if (!obj->out_filename) {
944  LOG_ERROR("Out of memory");
945  goto err_exit;
946  }
947 
948  obj->name = strdup(CMD_ARGV[0]);
949  if (!obj->name) {
950  LOG_ERROR("Out of memory");
951  goto err_exit;
952  }
953 
954  /* Do the rest as "configure" options */
955  struct jim_getopt_info goi;
956  jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - 1, CMD_JIMTCL_ARGV + 1);
957  goi.is_configure = 1;
958  int e = arm_tpiu_swo_configure(&goi, obj);
959 
960  int reslen;
961  const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
962  if (reslen > 0)
963  command_print(CMD, "%s", result);
964 
965  if (e != JIM_OK)
966  goto err_exit;
967 
968  if (!obj->spot.dap || obj->spot.ap_num == DP_APSEL_INVALID) {
969  command_print(CMD, "-dap and -ap-num required when creating TPIU");
970  goto err_exit;
971  }
972 
973  /* now - create the new tpiu/swo name command */
974  const struct command_registration obj_commands[] = {
975  {
976  .name = obj->name,
977  .mode = COMMAND_ANY,
978  .help = "tpiu/swo instance command group",
979  .usage = "",
981  },
983  };
984  retval = register_commands_with_data(CMD_CTX, NULL, obj_commands, obj);
985  if (retval != ERROR_OK)
986  goto err_exit;
987 
988  list_add_tail(&obj->lh, &all_tpiu_swo);
989 
990  return ERROR_OK;
991 
992 err_exit:
993  free(obj->name);
994  free(obj->out_filename);
995  free(obj);
996  return retval;
997 }
998 
999 COMMAND_HANDLER(handle_arm_tpiu_swo_names)
1000 {
1001  struct arm_tpiu_swo_object *obj;
1002 
1003  if (CMD_ARGC != 0)
1005 
1006  list_for_each_entry(obj, &all_tpiu_swo, lh)
1007  command_print(CMD, "%s", obj->name);
1008 
1009  return ERROR_OK;
1010 }
1011 
1012 COMMAND_HANDLER(handle_arm_tpiu_swo_init)
1013 {
1014  struct arm_tpiu_swo_object *obj;
1015  int retval = ERROR_OK;
1016 
1017  if (CMD_ARGC != 0)
1019 
1020  list_for_each_entry(obj, &all_tpiu_swo, lh) {
1021  if (!obj->deferred_enable)
1022  continue;
1023  LOG_DEBUG("%s: running enable during init", obj->name);
1024  int retval2 = command_run_linef(CMD_CTX, "%s enable", obj->name);
1025  if (retval2 != ERROR_OK)
1026  retval = retval2;
1027  }
1028  return retval;
1029 }
1030 
1031 /* START_DEPRECATED_TPIU */
1032 /* DEPRECATED: emulation of old command 'tpiu config' */
1033 COMMAND_HANDLER(handle_tpiu_deprecated_config_command)
1034 {
1036  struct arm_tpiu_swo_object *obj = NULL;
1037  int retval;
1038 
1039  if (strcmp(target_type_name(target), "cortex_m") &&
1040  strcmp(target_type_name(target), "hla_target")) {
1041  LOG_ERROR(MSG "Current target is not a Cortex-M nor a HLA");
1042  return ERROR_FAIL;
1043  }
1044 
1045  if (!list_empty(&all_tpiu_swo)) {
1046  obj = list_first_entry(&all_tpiu_swo, typeof(*obj), lh);
1047  LOG_INFO(MSG "Using %s", obj->name);
1048  } else {
1049  struct cortex_m_common *cm = target_to_cm(target);
1051  struct adiv5_dap *dap = pc->dap;
1052  uint64_t ap_num = pc->ap_num;
1053  bool set_recheck_ap_cur_target = false;
1054 
1055  LOG_INFO(MSG "Adding a TPIU \'%s.tpiu\' in the configuration", target_name(target));
1056 
1057  if (ap_num == DP_APSEL_INVALID && transport_is_hla())
1058  ap_num = 0; /* HLA should only support AP 0 */
1059 
1060  if (ap_num == DP_APSEL_INVALID && target_was_examined(target))
1061  ap_num = cm->armv7m.debug_ap->ap_num;
1062 
1063  if (ap_num == DP_APSEL_INVALID) {
1064  LOG_INFO(MSG "Target %s uses AP autodetection. Adding TPIU on AP 0; can be revised later",
1065  target_name(target));
1066  ap_num = 0;
1067  set_recheck_ap_cur_target = true;
1068  }
1069 
1070  LOG_INFO(MSG "Running: \'tpiu create %s.tpiu -dap %s -ap-num 0x%" PRIx64 "\'",
1071  target_name(target), adiv5_dap_name(dap), ap_num);
1072 
1073  retval = command_run_linef(CMD_CTX, "tpiu create %s.tpiu -dap %s -ap-num 0x%" PRIx64,
1074  target_name(target), adiv5_dap_name(dap), ap_num);
1075  if (retval != ERROR_OK)
1076  return retval;
1077 
1078  obj = list_first_entry(&all_tpiu_swo, typeof(*obj), lh);
1079  if (set_recheck_ap_cur_target)
1080  obj->recheck_ap_cur_target = true;
1081  }
1082 
1083  unsigned int cmd_idx = 0;
1084  if (cmd_idx == CMD_ARGC)
1086 
1087  if (!strcmp(CMD_ARGV[cmd_idx], "disable")) {
1088  if (CMD_ARGC != cmd_idx + 1)
1090  LOG_INFO(MSG "Running: \'%s disable\'", obj->name);
1091  return command_run_linef(CMD_CTX, "%s disable", obj->name);
1092  }
1093 
1094  const char *output = NULL;
1095  const char *protocol;
1096  const char *formatter = NULL;
1097  const char *port_width = NULL;
1098  const char *trace_clk;
1099  const char *pin_clk = NULL;
1100  if (!strcmp(CMD_ARGV[cmd_idx], "internal")) {
1101  cmd_idx++;
1102  if (cmd_idx == CMD_ARGC)
1104  output = CMD_ARGV[cmd_idx];
1105  } else if (strcmp(CMD_ARGV[cmd_idx], "external"))
1107  cmd_idx++;
1108  if (cmd_idx == CMD_ARGC)
1110  if (!strcmp(CMD_ARGV[cmd_idx], "sync")) {
1111  protocol = CMD_ARGV[cmd_idx];
1112  cmd_idx++;
1113  if (cmd_idx == CMD_ARGC)
1115  port_width = CMD_ARGV[cmd_idx];
1116  } else {
1117  if (strcmp(CMD_ARGV[cmd_idx], "manchester") && strcmp(CMD_ARGV[cmd_idx], "uart"))
1119  protocol = CMD_ARGV[cmd_idx];
1120  cmd_idx++;
1121  if (cmd_idx == CMD_ARGC)
1123  formatter = CMD_ARGV[cmd_idx];
1124  }
1125  cmd_idx++;
1126  if (cmd_idx == CMD_ARGC)
1128  trace_clk = CMD_ARGV[cmd_idx];
1129  cmd_idx++;
1130  if (cmd_idx != CMD_ARGC) {
1131  pin_clk = CMD_ARGV[cmd_idx];
1132  cmd_idx++;
1133  }
1134  if (cmd_idx != CMD_ARGC)
1136 
1137  LOG_INFO(MSG "Running: \'%s configure -protocol %s -traceclk %s" "%s%s" "%s%s" "%s%s" "%s%s\'",
1138  obj->name, protocol, trace_clk,
1139  pin_clk ? " -pin-freq " : "", pin_clk ? pin_clk : "",
1140  output ? " -output " : "", output ? output : "",
1141  formatter ? " -formatter " : "", formatter ? formatter : "",
1142  port_width ? " -port-width " : "", port_width ? port_width : "");
1143 
1144  retval = command_run_linef(CMD_CTX,
1145  "%s configure -protocol %s -traceclk %s" "%s%s" "%s%s" "%s%s" "%s%s",
1146  obj->name, protocol, trace_clk,
1147  pin_clk ? " -pin-freq " : "", pin_clk ? pin_clk : "",
1148  output ? " -output " : "", output ? output : "",
1149  formatter ? " -formatter " : "", formatter ? formatter : "",
1150  port_width ? " -port-width " : "", port_width ? port_width : "");
1151  if (retval != ERROR_OK)
1152  return retval;
1153 
1154  LOG_INFO(MSG "Running: \'%s enable\'", obj->name);
1155  retval = command_run_linef(CMD_CTX, "%s enable", obj->name);
1156  if (retval != ERROR_OK)
1157  return retval;
1158 
1159  return ERROR_OK;
1160 }
1161 
1163  {
1164  .name = "config",
1165  .handler = handle_tpiu_deprecated_config_command,
1166  .mode = COMMAND_ANY,
1167  .help = "Configure TPIU features, DEPRECATED, use \'tpiu create\'",
1168  .usage = "(disable | "
1169  "((external | internal (<filename> | <:port> | -)) "
1170  "(sync <port width> | ((manchester | uart) <formatter enable>)) "
1171  "<TRACECLKIN freq> [<trace freq>]))",
1172  },
1174 };
1175 
1177  {
1178  .name = "tpiu",
1180  .usage = "",
1181  .help = "tpiu command group",
1182  },
1184 };
1185 /* END_DEPRECATED_TPIU */
1186 
1188  {
1189  .name = "create",
1190  .mode = COMMAND_ANY,
1191  .handler = handle_arm_tpiu_swo_create,
1192  .usage = "name [-dap dap] [-ap-num num] [-baseaddr baseaddr]",
1193  .help = "Creates a new TPIU or SWO object",
1194  },
1195  {
1196  .name = "names",
1197  .mode = COMMAND_ANY,
1198  .handler = handle_arm_tpiu_swo_names,
1199  .usage = "",
1200  .help = "Lists all registered TPIU and SWO objects by name",
1201  },
1202  {
1203  .name = "init",
1204  .mode = COMMAND_EXEC,
1205  .handler = handle_arm_tpiu_swo_init,
1206  .usage = "",
1207  .help = "Initialize TPIU and SWO",
1208  },
1210 };
1211 
1212 static const struct command_registration arm_tpiu_swo_command_handlers[] = {
1213  {
1214  .name = "tpiu",
1216  .usage = "",
1217  .help = "tpiu command group",
1218  },
1219  {
1220  .name = "swo",
1222  .usage = "",
1223  .help = "swo command group",
1224  },
1226 };
1227 
1229 {
1231 }
int adiv5_mem_ap_spot_init(struct adiv5_mem_ap_spot *p)
Definition: arm_adi_v5.c:2503
int mem_ap_read_atomic_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t *value)
Synchronous read of a word from memory or a system register.
Definition: arm_adi_v5.c:266
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
int adiv5_jim_mem_ap_spot_configure(struct adiv5_mem_ap_spot *cfg, struct jim_getopt_info *goi)
Definition: arm_adi_v5.c:2497
int mem_ap_write_atomic_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t value)
Synchronous write of a word to memory or a system register.
Definition: arm_adi_v5.c:318
This defines formats and data structures used to talk to ADIv5 entities.
#define DP_APSEL_INVALID
Definition: arm_adi_v5.h:110
const char * adiv5_dap_name(struct adiv5_dap *self)
Definition: arm_dap.c:54
static const struct jim_nvp nvp_arm_tpiu_swo_bool_opts[]
Definition: arm_tpiu_swo.c:345
#define ARM_TPIU_SWO_TRACE_BUF_SIZE
Definition: arm_tpiu_swo.c:131
#define MSG
Definition: arm_tpiu_swo.c:43
static const struct command_registration arm_tpiu_deprecated_subcommand_handlers[]
#define TPIU_SWO_DEFAULT_BASE
Definition: arm_tpiu_swo.c:49
#define TPIU_SPPR_PROTOCOL_MANCHESTER
Definition: arm_tpiu_swo.c:62
arm_tpiu_swo_event
Definition: arm_tpiu_swo.c:68
@ TPIU_SWO_EVENT_PRE_DISABLE
Definition: arm_tpiu_swo.c:71
@ TPIU_SWO_EVENT_PRE_ENABLE
Definition: arm_tpiu_swo.c:69
@ TPIU_SWO_EVENT_POST_ENABLE
Definition: arm_tpiu_swo.c:70
@ TPIU_SWO_EVENT_POST_DISABLE
Definition: arm_tpiu_swo.c:72
static const struct jim_nvp nvp_arm_tpiu_swo_config_opts[]
Definition: arm_tpiu_swo.c:323
#define TPIU_DEVID_OFFSET
Definition: arm_tpiu_swo.c:58
#define TPIU_CSPSR_OFFSET
Definition: arm_tpiu_swo.c:52
static const struct service_driver arm_tpiu_swo_service_driver
Definition: arm_tpiu_swo.c:599
const struct command_registration arm_tpiu_deprecated_command_handlers[]
static const struct command_registration arm_tpiu_swo_subcommand_handlers[]
static void arm_tpiu_swo_close_output(struct arm_tpiu_swo_object *obj)
Definition: arm_tpiu_swo.c:199
int arm_tpiu_swo_register_commands(struct command_context *cmd_ctx)
static const struct jim_nvp nvp_arm_tpiu_swo_protocol_opts[]
Definition: arm_tpiu_swo.c:338
static int arm_tpiu_swo_service_connection_closed(struct connection *connection)
Definition: arm_tpiu_swo.c:279
arm_tpiu_swo_cfg_param
Definition: arm_tpiu_swo.c:313
@ CFG_PROTOCOL
Definition: arm_tpiu_swo.c:315
@ CFG_TRACECLKIN
Definition: arm_tpiu_swo.c:317
@ CFG_FORMATTER
Definition: arm_tpiu_swo.c:316
@ CFG_PORT_WIDTH
Definition: arm_tpiu_swo.c:314
@ CFG_OUTFILE
Definition: arm_tpiu_swo.c:319
@ CFG_EVENT
Definition: arm_tpiu_swo.c:320
@ CFG_BITRATE
Definition: arm_tpiu_swo.c:318
#define TPIU_SPPR_OFFSET
Definition: arm_tpiu_swo.c:54
static int arm_tpiu_swo_handle_event(struct arm_tpiu_swo_object *obj, enum arm_tpiu_swo_event event)
Definition: arm_tpiu_swo.c:163
static int arm_tpiu_swo_service_input(struct connection *connection)
Definition: arm_tpiu_swo.c:263
#define TPIU_SPPR_PROTOCOL_SYNC
Definition: arm_tpiu_swo.c:61
#define TPIU_FFCR_OFFSET
Definition: arm_tpiu_swo.c:56
static const struct command_registration arm_tpiu_swo_instance_command_handlers[]
Definition: arm_tpiu_swo.c:879
static int arm_tpiu_swo_service_new_connection(struct connection *connection)
Definition: arm_tpiu_swo.c:249
#define TPIU_ACPR_MAX_PRESCALER
Definition: arm_tpiu_swo.c:60
#define TPIU_DEVID_SUPPORT_UART
Definition: arm_tpiu_swo.c:66
#define TPIU_SPPR_PROTOCOL_UART
Definition: arm_tpiu_swo.c:63
static const struct jim_nvp nvp_arm_tpiu_swo_event[]
Definition: arm_tpiu_swo.c:75
#define TCP_SERVICE_NAME
Definition: arm_tpiu_swo.c:46
#define TPIU_DEVID_SUPPORT_MANCHESTER
Definition: arm_tpiu_swo.c:65
static int wrap_write_u32(struct target *target, struct adiv5_ap *tpiu_ap, target_addr_t address, uint32_t value)
Definition: arm_tpiu_swo.c:581
static const struct command_registration arm_tpiu_swo_command_handlers[]
#define TPIU_SSPSR_OFFSET
Definition: arm_tpiu_swo.c:51
#define TPIU_DEVID_NOSUPPORT_SYNC
Definition: arm_tpiu_swo.c:64
int arm_tpiu_swo_cleanup_all(void)
Definition: arm_tpiu_swo.c:209
static int wrap_read_u32(struct target *target, struct adiv5_ap *tpiu_ap, target_addr_t address, uint32_t *value)
Definition: arm_tpiu_swo.c:590
static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_swo_object *obj)
Definition: arm_tpiu_swo.c:357
static OOCD_LIST_HEAD(all_tpiu_swo)
COMMAND_HANDLER(handle_arm_tpiu_swo_event_list)
Definition: arm_tpiu_swo.c:295
#define TPIU_ACPR_OFFSET
Definition: arm_tpiu_swo.c:53
static int arm_tpiu_swo_poll_trace(void *priv)
Definition: arm_tpiu_swo.c:133
const char * name
Definition: armv4_5.c:76
struct command_context * current_command_context(Jim_Interp *interp)
Definition: command.c:90
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:375
int command_run_linef(struct command_context *context, const char *format,...)
Definition: command.c:542
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#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 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:313
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:400
#define CMD_DATA
Use this macro to access the invoked command handler's data pointer, rather than accessing the variab...
Definition: command.h:176
#define ERROR_COMMAND_CLOSE_CONNECTION
Definition: command.h:399
#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 CMD_JIMTCL_ARGV
Use this macro to access the jimtcl arguments for the command being handled, rather than accessing th...
Definition: command.h:161
#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:251
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:272
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
static struct cortex_m_common * target_to_cm(struct target *target)
Definition: cortex_m.h:287
uint32_t size
Size of dw_spi_transaction::buffer.
Definition: dw-spi-helper.h:4
uint32_t address
Starting address. Sector aligned.
Definition: dw-spi-helper.h:0
static struct esp_usb_jtag * priv
Definition: esp_usb_jtag.c:219
static uint16_t output
Definition: ftdi.c:119
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_string(struct jim_getopt_info *goi, const char **puthere, int *len)
Remove argv[0] as string.
Definition: jim-nvp.c:188
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
struct jim_nvp * jim_nvp_value2name_simple(const struct jim_nvp *p, int value)
Definition: jim-nvp.c:124
int jim_nvp_value2name(Jim_Interp *interp, const struct jim_nvp *_p, int value, struct jim_nvp **result)
Definition: jim-nvp.c:134
int adapter_config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol, uint32_t port_size, unsigned int *trace_freq, unsigned int traceclkin_freq, uint16_t *prescaler)
Definition: jtag/core.c:1929
int adapter_poll_trace(uint8_t *buf, size_t *size)
Definition: jtag/core.c:1944
static void list_add(struct list_head *new, struct list_head *head)
Definition: list.h:197
#define list_first_entry(ptr, type, member)
Definition: list.h:131
static void list_add_tail(struct list_head *new, struct list_head *head)
Definition: list.h:203
static int list_empty(const struct list_head *head)
Definition: list.h:61
#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 list_del(struct list_head *entry)
Definition: list.h:88
static void INIT_LIST_HEAD(struct list_head *list)
Definition: list.h:54
#define LOG_USER(expr ...)
Definition: log.h:136
#define ERROR_FAIL
Definition: log.h:174
#define LOG_ERROR(expr ...)
Definition: log.h:133
#define LOG_INFO(expr ...)
Definition: log.h:127
#define LOG_DEBUG(expr ...)
Definition: log.h:110
#define ERROR_OK
Definition: log.h:168
static uint32_t lh(unsigned int rd, unsigned int base, uint16_t offset) __attribute__((unused))
Definition: opcodes.h:117
int connection_write(struct connection *connection, const void *data, int len)
Definition: server.c:732
int connection_read(struct connection *connection, void *data, int len)
Definition: server.c:744
int remove_service(const char *name, const char *port)
Definition: server.c:355
int add_service(const struct service_driver *driver, const char *port, int max_connections, void *priv)
Definition: server.c:198
#define CONNECTION_LIMIT_UNLIMITED
Definition: server.h:34
#define ERROR_SERVER_REMOTE_CLOSED
Definition: server.h:119
#define BIT(nr)
Definition: stm32l4x.h:18
This represents an ARM Debug Interface (v5) Access Port (AP).
Definition: arm_adi_v5.h:250
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
This represents an ARM Debug Interface (v5) Debug Access Port (DAP).
Definition: arm_adi_v5.h:348
struct adiv5_dap * dap
Definition: arm_adi_v5.h:803
struct adiv5_dap * dap
Definition: arm_adi_v5.h:787
struct list_head lh
Definition: arm_tpiu_swo.c:121
struct connection * connection
Definition: arm_tpiu_swo.c:122
struct arm_tpiu_swo_event_action * next
Definition: arm_tpiu_swo.c:86
enum arm_tpiu_swo_event event
Definition: arm_tpiu_swo.c:83
uint32_t port_width
Handle to output trace data in INTERNAL capture mode.
Definition: arm_tpiu_swo.c:101
struct arm_tpiu_swo_event_action * event_action
Definition: arm_tpiu_swo.c:94
struct list_head lh
Definition: arm_tpiu_swo.c:90
struct adiv5_ap * ap
Definition: arm_tpiu_swo.c:92
bool en_formatter
Enable formatter.
Definition: arm_tpiu_swo.c:106
unsigned int traceclkin_freq
frequency of TRACECLKIN (usually matches HCLK)
Definition: arm_tpiu_swo.c:108
unsigned int swo_pin_freq
SWO pin frequency.
Definition: arm_tpiu_swo.c:110
struct adiv5_mem_ap_spot spot
Definition: arm_tpiu_swo.c:91
struct list_head connections
track TCP connections
Definition: arm_tpiu_swo.c:114
unsigned int pin_protocol
output mode
Definition: arm_tpiu_swo.c:104
char * out_filename
where to dump the captured output trace data
Definition: arm_tpiu_swo.c:112
struct arm_tpiu_swo_object * obj
Definition: arm_tpiu_swo.c:126
struct adiv5_ap * debug_ap
Definition: armv7m.h:234
struct target * current_target
Definition: command.h:55
const char * name
Definition: command.h:234
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:239
struct service * service
Definition: server.h:41
struct armv7m_common armv7m
Definition: cortex_m.h:224
A TCL -ish GetOpt like code.
Definition: jim-nvp.h:136
Jim_Interp * interp
Definition: jim-nvp.h:137
bool is_configure
Definition: jim-nvp.h:140
Jim_Obj *const * argv
Definition: jim-nvp.h:139
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: list.h:41
const char * name
the name of the server
Definition: server.h:49
void * priv
Definition: server.h:81
Definition: target.h:116
void * private_config
Definition: target.h:165
int target_unregister_timer_callback(int(*callback)(void *priv), void *priv)
Definition: target.c:1757
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2649
int target_register_timer_callback(int(*callback)(void *priv), unsigned int time_ms, enum target_timer_type type, void *priv)
The period is very approximate, the callback can happen much more often or much more rarely than spec...
Definition: target.c:1667
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
Definition: target.c:2558
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:466
void target_handle_event(struct target *target, enum target_event e)
Definition: target.c:4667
const char * target_type_name(const struct target *target)
Get the target type name.
Definition: target.c:745
int target_call_trace_callbacks(struct target *target, size_t len, uint8_t *data)
Definition: target.c:1811
static bool target_was_examined(const struct target *target)
Definition: target.h:429
@ TARGET_TIMER_TYPE_PERIODIC
Definition: target.h:320
@ TARGET_EVENT_TRACE_CONFIG
Definition: target.h:286
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
Definition: target.h:233
uint64_t target_addr_t
Definition: types.h:335
#define NULL
Definition: usb.h:16
uint8_t dummy[96]
Definition: vdebug.c:23