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  free(priv);
743  return retval;
744  }
745  } else if (strcmp(obj->out_filename, "-")) {
746  obj->file = fopen(obj->out_filename, "ab");
747  if (!obj->file) {
748  command_print(CMD, "Can't open trace destination file \"%s\"", obj->out_filename);
749  return ERROR_FAIL;
750  }
751  }
752 
754  &swo_pin_freq, obj->traceclkin_freq, &prescaler);
755  if (retval != ERROR_OK) {
756  command_print(CMD, "Failed to start adapter's trace");
758  return retval;
759  }
760 
762  if (!swo_pin_freq) {
763  if (obj->swo_pin_freq)
764  command_print(CMD, "Adapter rejected SWO pin frequency %d Hz", obj->swo_pin_freq);
765  else
767  "Adapter does not support auto-detection of SWO pin frequency nor a default value");
768 
770  return ERROR_FAIL;
771  }
772 
773  if (obj->swo_pin_freq != swo_pin_freq)
774  LOG_INFO("SWO pin data rate adjusted by adapter to %d Hz", swo_pin_freq);
775  obj->swo_pin_freq = swo_pin_freq;
776 
779 
780  obj->en_capture = true;
782  prescaler = (obj->traceclkin_freq + obj->swo_pin_freq / 2) / obj->swo_pin_freq;
783  if (prescaler > TPIU_ACPR_MAX_PRESCALER)
784  prescaler = TPIU_ACPR_MAX_PRESCALER;
785  swo_pin_freq = obj->traceclkin_freq / prescaler;
786 
787  if (obj->swo_pin_freq != swo_pin_freq)
788  LOG_INFO("SWO pin data rate adjusted to %d Hz", swo_pin_freq);
789  obj->swo_pin_freq = swo_pin_freq;
790  }
791 
793  if (retval != ERROR_OK)
794  goto error_exit;
795 
796  retval = wrap_write_u32(target, obj->ap, obj->spot.base + TPIU_ACPR_OFFSET, prescaler - 1);
797  if (retval != ERROR_OK)
798  goto error_exit;
799 
801  if (retval != ERROR_OK)
802  goto error_exit;
803 
804  retval = wrap_read_u32(target, obj->ap, obj->spot.base + TPIU_FFCR_OFFSET, &value);
805  if (retval != ERROR_OK)
806  goto error_exit;
807  if (obj->en_formatter)
808  value |= BIT(1);
809  else
810  value &= ~BIT(1);
811  retval = wrap_write_u32(target, obj->ap, obj->spot.base + TPIU_FFCR_OFFSET, value);
812  if (retval != ERROR_OK)
813  goto error_exit;
814 
816  if (retval != ERROR_OK)
817  goto error_exit;
818 
819  /* START_DEPRECATED_TPIU */
821  /* END_DEPRECATED_TPIU */
822 
823  obj->enabled = true;
824  return ERROR_OK;
825 
826 error_exit:
827  command_print(CMD, "Error!");
828 
829  if (obj->en_capture) {
830  obj->en_capture = false;
831 
833 
835 
836  int retval1 = adapter_config_trace(false, 0, 0, NULL, 0, NULL);
837  if (retval1 != ERROR_OK)
838  command_print(CMD, "Failed to stop adapter's trace");
839  }
840  return retval;
841 }
842 
843 COMMAND_HANDLER(handle_arm_tpiu_swo_disable)
844 {
845  struct arm_tpiu_swo_object *obj = CMD_DATA;
846 
847  if (CMD_ARGC != 0)
849 
850  if (!obj->enabled)
851  return ERROR_OK;
852  obj->enabled = false;
853 
855 
856  if (obj->en_capture) {
857  obj->en_capture = false;
858 
860 
862 
863  int retval = adapter_config_trace(false, 0, 0, NULL, 0, NULL);
864  if (retval != ERROR_OK) {
865  command_print(CMD, "Failed to stop adapter's trace");
866  return retval;
867  }
868  }
869 
871 
872  /* START_DEPRECATED_TPIU */
875  /* END_DEPRECATED_TPIU */
876 
877  return ERROR_OK;
878 }
879 
881  {
882  .name = "configure",
883  .mode = COMMAND_ANY,
884  .handler = handle_arm_tpiu_swo_configure,
885  .help = "configure a new TPIU/SWO for use",
886  .usage = "[attribute value ...]",
887  },
888  {
889  .name = "cget",
890  .mode = COMMAND_ANY,
891  .handler = handle_arm_tpiu_swo_configure,
892  .help = "returns the specified TPIU/SWO attribute",
893  .usage = "attribute",
894  },
895  {
896  .name = "eventlist",
897  .mode = COMMAND_ANY,
898  .handler = handle_arm_tpiu_swo_event_list,
899  .help = "displays a table of events defined for this TPIU/SWO",
900  .usage = "",
901  },
902  {
903  .name = "enable",
904  .mode = COMMAND_ANY,
905  .handler = handle_arm_tpiu_swo_enable,
906  .usage = "",
907  .help = "Enables the TPIU/SWO output",
908  },
909  {
910  .name = "disable",
911  .mode = COMMAND_EXEC,
912  .handler = handle_arm_tpiu_swo_disable,
913  .usage = "",
914  .help = "Disables the TPIU/SWO output",
915  },
917 };
918 
919 COMMAND_HANDLER(handle_arm_tpiu_swo_create)
920 {
921  int retval = ERROR_FAIL;
922 
923  if (!CMD_ARGC)
925 
926  /* does this command exist? */
927  Jim_Cmd *jimcmd = Jim_GetCommand(CMD_CTX->interp, CMD_JIMTCL_ARGV[0], JIM_NONE);
928  if (jimcmd) {
929  command_print(CMD, "cannot create TPIU object because a command with name '%s' already exists",
930  CMD_ARGV[0]);
931  return ERROR_FAIL;
932  }
933 
934  struct arm_tpiu_swo_object *obj = calloc(1, sizeof(struct arm_tpiu_swo_object));
935  if (!obj) {
936  LOG_ERROR("Out of memory");
937  return ERROR_FAIL;
938  }
942  obj->port_width = 1;
943  obj->out_filename = strdup("external");
944  if (!obj->out_filename) {
945  LOG_ERROR("Out of memory");
946  goto err_exit;
947  }
948 
949  obj->name = strdup(CMD_ARGV[0]);
950  if (!obj->name) {
951  LOG_ERROR("Out of memory");
952  goto err_exit;
953  }
954 
955  /* Do the rest as "configure" options */
956  struct jim_getopt_info goi;
957  jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - 1, CMD_JIMTCL_ARGV + 1);
958  goi.is_configure = 1;
959  int e = arm_tpiu_swo_configure(&goi, obj);
960 
961  int reslen;
962  const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
963  if (reslen > 0)
964  command_print(CMD, "%s", result);
965 
966  if (e != JIM_OK)
967  goto err_exit;
968 
969  if (!obj->spot.dap || obj->spot.ap_num == DP_APSEL_INVALID) {
970  command_print(CMD, "-dap and -ap-num required when creating TPIU");
971  goto err_exit;
972  }
973 
974  /* now - create the new tpiu/swo name command */
975  const struct command_registration obj_commands[] = {
976  {
977  .name = obj->name,
978  .mode = COMMAND_ANY,
979  .help = "tpiu/swo instance command group",
980  .usage = "",
982  },
984  };
985  retval = register_commands_with_data(CMD_CTX, NULL, obj_commands, obj);
986  if (retval != ERROR_OK)
987  goto err_exit;
988 
989  list_add_tail(&obj->lh, &all_tpiu_swo);
990 
991  return ERROR_OK;
992 
993 err_exit:
994  free(obj->name);
995  free(obj->out_filename);
996  free(obj);
997  return retval;
998 }
999 
1000 COMMAND_HANDLER(handle_arm_tpiu_swo_names)
1001 {
1002  struct arm_tpiu_swo_object *obj;
1003 
1004  if (CMD_ARGC != 0)
1006 
1007  list_for_each_entry(obj, &all_tpiu_swo, lh)
1008  command_print(CMD, "%s", obj->name);
1009 
1010  return ERROR_OK;
1011 }
1012 
1013 COMMAND_HANDLER(handle_arm_tpiu_swo_init)
1014 {
1015  struct arm_tpiu_swo_object *obj;
1016  int retval = ERROR_OK;
1017 
1018  if (CMD_ARGC != 0)
1020 
1021  list_for_each_entry(obj, &all_tpiu_swo, lh) {
1022  if (!obj->deferred_enable)
1023  continue;
1024  LOG_DEBUG("%s: running enable during init", obj->name);
1025  int retval2 = command_run_linef(CMD_CTX, "%s enable", obj->name);
1026  if (retval2 != ERROR_OK)
1027  retval = retval2;
1028  }
1029  return retval;
1030 }
1031 
1032 /* START_DEPRECATED_TPIU */
1033 /* DEPRECATED: emulation of old command 'tpiu config' */
1034 COMMAND_HANDLER(handle_tpiu_deprecated_config_command)
1035 {
1037  struct arm_tpiu_swo_object *obj = NULL;
1038  int retval;
1039 
1040  if (strcmp(target_type_name(target), "cortex_m") &&
1041  strcmp(target_type_name(target), "hla_target")) {
1042  LOG_ERROR(MSG "Current target is not a Cortex-M nor a HLA");
1043  return ERROR_FAIL;
1044  }
1045 
1046  if (!list_empty(&all_tpiu_swo)) {
1047  obj = list_first_entry(&all_tpiu_swo, typeof(*obj), lh);
1048  LOG_INFO(MSG "Using %s", obj->name);
1049  } else {
1050  struct cortex_m_common *cm = target_to_cm(target);
1052  struct adiv5_dap *dap = pc->dap;
1053  uint64_t ap_num = pc->ap_num;
1054  bool set_recheck_ap_cur_target = false;
1055 
1056  LOG_INFO(MSG "Adding a TPIU \'%s.tpiu\' in the configuration", target_name(target));
1057 
1058  if (ap_num == DP_APSEL_INVALID && transport_is_hla())
1059  ap_num = 0; /* HLA should only support AP 0 */
1060 
1061  if (ap_num == DP_APSEL_INVALID && target_was_examined(target))
1062  ap_num = cm->armv7m.debug_ap->ap_num;
1063 
1064  if (ap_num == DP_APSEL_INVALID) {
1065  LOG_INFO(MSG "Target %s uses AP autodetection. Adding TPIU on AP 0; can be revised later",
1066  target_name(target));
1067  ap_num = 0;
1068  set_recheck_ap_cur_target = true;
1069  }
1070 
1071  LOG_INFO(MSG "Running: \'tpiu create %s.tpiu -dap %s -ap-num 0x%" PRIx64 "\'",
1072  target_name(target), adiv5_dap_name(dap), ap_num);
1073 
1074  retval = command_run_linef(CMD_CTX, "tpiu create %s.tpiu -dap %s -ap-num 0x%" PRIx64,
1075  target_name(target), adiv5_dap_name(dap), ap_num);
1076  if (retval != ERROR_OK)
1077  return retval;
1078 
1079  obj = list_first_entry(&all_tpiu_swo, typeof(*obj), lh);
1080  if (set_recheck_ap_cur_target)
1081  obj->recheck_ap_cur_target = true;
1082  }
1083 
1084  unsigned int cmd_idx = 0;
1085  if (cmd_idx == CMD_ARGC)
1087 
1088  if (!strcmp(CMD_ARGV[cmd_idx], "disable")) {
1089  if (CMD_ARGC != cmd_idx + 1)
1091  LOG_INFO(MSG "Running: \'%s disable\'", obj->name);
1092  return command_run_linef(CMD_CTX, "%s disable", obj->name);
1093  }
1094 
1095  const char *output = NULL;
1096  const char *protocol;
1097  const char *formatter = NULL;
1098  const char *port_width = NULL;
1099  const char *trace_clk;
1100  const char *pin_clk = NULL;
1101  if (!strcmp(CMD_ARGV[cmd_idx], "internal")) {
1102  cmd_idx++;
1103  if (cmd_idx == CMD_ARGC)
1105  output = CMD_ARGV[cmd_idx];
1106  } else if (strcmp(CMD_ARGV[cmd_idx], "external"))
1108  cmd_idx++;
1109  if (cmd_idx == CMD_ARGC)
1111  if (!strcmp(CMD_ARGV[cmd_idx], "sync")) {
1112  protocol = CMD_ARGV[cmd_idx];
1113  cmd_idx++;
1114  if (cmd_idx == CMD_ARGC)
1116  port_width = CMD_ARGV[cmd_idx];
1117  } else {
1118  if (strcmp(CMD_ARGV[cmd_idx], "manchester") && strcmp(CMD_ARGV[cmd_idx], "uart"))
1120  protocol = CMD_ARGV[cmd_idx];
1121  cmd_idx++;
1122  if (cmd_idx == CMD_ARGC)
1124  formatter = CMD_ARGV[cmd_idx];
1125  }
1126  cmd_idx++;
1127  if (cmd_idx == CMD_ARGC)
1129  trace_clk = CMD_ARGV[cmd_idx];
1130  cmd_idx++;
1131  if (cmd_idx != CMD_ARGC) {
1132  pin_clk = CMD_ARGV[cmd_idx];
1133  cmd_idx++;
1134  }
1135  if (cmd_idx != CMD_ARGC)
1137 
1138  LOG_INFO(MSG "Running: \'%s configure -protocol %s -traceclk %s" "%s%s" "%s%s" "%s%s" "%s%s\'",
1139  obj->name, protocol, trace_clk,
1140  pin_clk ? " -pin-freq " : "", pin_clk ? pin_clk : "",
1141  output ? " -output " : "", output ? output : "",
1142  formatter ? " -formatter " : "", formatter ? formatter : "",
1143  port_width ? " -port-width " : "", port_width ? port_width : "");
1144 
1145  retval = command_run_linef(CMD_CTX,
1146  "%s configure -protocol %s -traceclk %s" "%s%s" "%s%s" "%s%s" "%s%s",
1147  obj->name, protocol, trace_clk,
1148  pin_clk ? " -pin-freq " : "", pin_clk ? pin_clk : "",
1149  output ? " -output " : "", output ? output : "",
1150  formatter ? " -formatter " : "", formatter ? formatter : "",
1151  port_width ? " -port-width " : "", port_width ? port_width : "");
1152  if (retval != ERROR_OK)
1153  return retval;
1154 
1155  LOG_INFO(MSG "Running: \'%s enable\'", obj->name);
1156  retval = command_run_linef(CMD_CTX, "%s enable", obj->name);
1157  if (retval != ERROR_OK)
1158  return retval;
1159 
1160  return ERROR_OK;
1161 }
1162 
1164  {
1165  .name = "config",
1166  .handler = handle_tpiu_deprecated_config_command,
1167  .mode = COMMAND_ANY,
1168  .help = "Configure TPIU features, DEPRECATED, use \'tpiu create\'",
1169  .usage = "(disable | "
1170  "((external | internal (<filename> | <:port> | -)) "
1171  "(sync <port width> | ((manchester | uart) <formatter enable>)) "
1172  "<TRACECLKIN freq> [<trace freq>]))",
1173  },
1175 };
1176 
1178  {
1179  .name = "tpiu",
1181  .usage = "",
1182  .help = "tpiu command group",
1183  },
1185 };
1186 /* END_DEPRECATED_TPIU */
1187 
1189  {
1190  .name = "create",
1191  .mode = COMMAND_ANY,
1192  .handler = handle_arm_tpiu_swo_create,
1193  .usage = "name [-dap dap] [-ap-num num] [-baseaddr baseaddr]",
1194  .help = "Creates a new TPIU or SWO object",
1195  },
1196  {
1197  .name = "names",
1198  .mode = COMMAND_ANY,
1199  .handler = handle_arm_tpiu_swo_names,
1200  .usage = "",
1201  .help = "Lists all registered TPIU and SWO objects by name",
1202  },
1203  {
1204  .name = "init",
1205  .mode = COMMAND_EXEC,
1206  .handler = handle_arm_tpiu_swo_init,
1207  .usage = "",
1208  .help = "Initialize TPIU and SWO",
1209  },
1211 };
1212 
1213 static const struct command_registration arm_tpiu_swo_command_handlers[] = {
1214  {
1215  .name = "tpiu",
1217  .usage = "",
1218  .help = "tpiu command group",
1219  },
1220  {
1221  .name = "swo",
1223  .usage = "",
1224  .help = "swo command group",
1225  },
1227 };
1228 
1230 {
1232 }
int adiv5_mem_ap_spot_init(struct adiv5_mem_ap_spot *p)
Definition: arm_adi_v5.c:2511
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:274
struct adiv5_ap * dap_get_ap(struct adiv5_dap *dap, uint64_t ap_num)
Definition: arm_adi_v5.c:1197
int dap_put_ap(struct adiv5_ap *ap)
Definition: arm_adi_v5.c:1217
int adiv5_jim_mem_ap_spot_configure(struct adiv5_mem_ap_spot *cfg, struct jim_getopt_info *goi)
Definition: arm_adi_v5.c:2505
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:326
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:880
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:86
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:389
int command_run_linef(struct command_context *context, const char *format,...)
Definition: command.c:553
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:146
#define CMD_NAME
Use this macro to access the name of the command being handled, rather than accessing the variable di...
Definition: command.h:171
#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_DATA
Use this macro to access the invoked command handler's data pointer, rather than accessing the variab...
Definition: command.h:181
#define ERROR_COMMAND_CLOSE_CONNECTION
Definition: command.h:404
#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 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
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
static struct cortex_m_common * target_to_cm(struct target *target)
Definition: cortex_m.h:346
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:162
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:143
#define ERROR_FAIL
Definition: log.h:181
#define LOG_ERROR(expr ...)
Definition: log.h:140
#define LOG_INFO(expr ...)
Definition: log.h:134
#define LOG_DEBUG(expr ...)
Definition: log.h:117
#define ERROR_OK
Definition: log.h:175
static uint32_t lh(unsigned int rd, unsigned int base, int16_t offset) __attribute__((unused))
Definition: opcodes.h:172
int connection_write(struct connection *connection, const void *data, int len)
Definition: server.c:742
int connection_read(struct connection *connection, void *data, int len)
Definition: server.c:754
int remove_service(const char *name, const char *port)
Definition: server.c:376
int add_service(const struct service_driver *driver, const char *port, int max_connections, void *priv)
Definition: server.c:206
#define CONNECTION_LIMIT_UNLIMITED
Definition: server.h:34
#define ERROR_SERVER_REMOTE_CLOSED
Definition: server.h:121
#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:239
struct target * current_target
Definition: command.h:55
const char * name
Definition: command.h:239
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:244
struct service * service
Definition: server.h:41
struct armv7m_common armv7m
Definition: cortex_m.h:274
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:83
Definition: target.h:119
void * private_config
Definition: target.h:168
int target_unregister_timer_callback(int(*callback)(void *priv), void *priv)
Definition: target.c:1766
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2624
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:1676
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
Definition: target.c:2550
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:467
void target_handle_event(struct target *target, enum target_event e)
Definition: target.c:4610
const char * target_type_name(const struct target *target)
Get the target type name.
Definition: target.c:746
int target_call_trace_callbacks(struct target *target, size_t len, uint8_t *data)
Definition: target.c:1820
static bool target_was_examined(const struct target *target)
Definition: target.h:432
@ TARGET_TIMER_TYPE_PERIODIC
Definition: target.h:323
@ TARGET_EVENT_TRACE_CONFIG
Definition: target.h:289
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
Definition: target.h:236
uint64_t target_addr_t
Definition: types.h:279
#define NULL
Definition: usb.h:16
uint8_t dummy[96]
Definition: vdebug.c:23