OpenOCD
jtag/tcl.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2005 by Dominic Rath *
5  * Dominic.Rath@gmx.de *
6  * *
7  * Copyright (C) 2007-2010 Øyvind Harboe *
8  * oyvind.harboe@zylin.com *
9  * *
10  * Copyright (C) 2009 SoftPLC Corporation *
11  * http://softplc.com *
12  * dick@softplc.com *
13  * *
14  * Copyright (C) 2009 Zachary T Welch *
15  * zw@superlucidity.net *
16  ***************************************************************************/
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
22 #include "adapter.h"
23 #include "jtag.h"
24 #include "swd.h"
25 #include "minidriver.h"
26 #include "interface.h"
27 #include "interfaces.h"
28 #include "tcl.h"
29 
30 #ifdef HAVE_STRINGS_H
31 #include <strings.h>
32 #endif
33 
34 #include <helper/command.h>
35 #include <helper/nvp.h>
36 #include <helper/time_support.h>
37 #include "transport/transport.h"
38 
44 static const struct nvp nvp_jtag_tap_event[] = {
45  { .value = JTAG_TRST_ASSERTED, .name = "post-reset" },
46  { .value = JTAG_TAP_EVENT_SETUP, .name = "setup" },
47  { .value = JTAG_TAP_EVENT_ENABLE, .name = "tap-enable" },
48  { .value = JTAG_TAP_EVENT_DISABLE, .name = "tap-disable" },
49 
50  { .name = NULL, .value = -1 }
51 };
52 
53 struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
54 {
55  const char *cp = Jim_GetString(o, NULL);
56  struct jtag_tap *t = cp ? jtag_tap_by_string(cp) : NULL;
57  if (!cp)
58  cp = "(unknown)";
59  if (!t)
60  Jim_SetResultFormatted(interp, "Tap '%s' could not be found", cp);
61  return t;
62 }
63 
65 {
66  switch (state) {
67  case TAP_RESET:
68  case TAP_IDLE:
69  case TAP_DRPAUSE:
70  case TAP_IRPAUSE:
71  return true;
72  default:
73  return false;
74  }
75 }
76 
77 static COMMAND_HELPER(handle_jtag_command_drscan_fields, struct scan_field *fields)
78 {
79  unsigned int field_count = 0;
80  for (unsigned int i = 1; i < CMD_ARGC; i += 2) {
81  unsigned int bits;
83  fields[field_count].num_bits = bits;
84 
85  void *t = malloc(DIV_ROUND_UP(bits, 8));
86  if (!t) {
87  LOG_ERROR("Out of memory");
88  return ERROR_FAIL;
89  }
90 
91  fields[field_count].out_value = t;
92  int ret = CALL_COMMAND_HANDLER(command_parse_str_to_buf, CMD_ARGV[i + 1], t, bits);
93  if (ret != ERROR_OK)
94  return ret;
95  fields[field_count].in_value = t;
96  field_count++;
97  }
98 
99  return ERROR_OK;
100 }
101 
102 COMMAND_HANDLER(handle_jtag_command_drscan)
103 {
104  /*
105  * CMD_ARGV[0] = device
106  * CMD_ARGV[1] = num_bits
107  * CMD_ARGV[2] = hex string
108  * ... repeat num bits and hex string ...
109  *
110  * ... optionally:
111  * CMD_ARGV[CMD_ARGC-2] = "-endstate"
112  * CMD_ARGV[CMD_ARGC-1] = statename
113  */
114 
115  if (CMD_ARGC < 3 || (CMD_ARGC % 2) != 1)
117 
118  struct jtag_tap *tap = jtag_tap_by_string(CMD_ARGV[0]);
119  if (!tap) {
120  command_print(CMD, "Tap '%s' could not be found", CMD_ARGV[0]);
122  }
123 
124  if (tap->bypass) {
125  command_print(CMD, "Can't execute as the selected tap is in BYPASS");
126  return ERROR_FAIL;
127  }
128 
129  tap_state_t endstate = TAP_IDLE;
130  if (CMD_ARGC > 3 && !strcmp("-endstate", CMD_ARGV[CMD_ARGC - 2])) {
131  const char *state_name = CMD_ARGV[CMD_ARGC - 1];
132  endstate = tap_state_by_name(state_name);
133  if (endstate < 0) {
134  command_print(CMD, "endstate: %s invalid", state_name);
136  }
137 
138  if (!scan_is_safe(endstate))
139  LOG_WARNING("drscan with unsafe endstate \"%s\"", state_name);
140 
141  CMD_ARGC -= 2;
142  }
143 
144  unsigned int num_fields = (CMD_ARGC - 1) / 2;
145  struct scan_field *fields = calloc(num_fields, sizeof(struct scan_field));
146  if (!fields) {
147  LOG_ERROR("Out of memory");
148  return ERROR_FAIL;
149  }
150 
151  int retval = CALL_COMMAND_HANDLER(handle_jtag_command_drscan_fields, fields);
152  if (retval != ERROR_OK)
153  goto fail;
154 
155  jtag_add_dr_scan(tap, num_fields, fields, endstate);
156 
157  retval = jtag_execute_queue();
158  if (retval != ERROR_OK) {
159  command_print(CMD, "drscan: jtag execute failed");
160  goto fail;
161  }
162 
163  for (unsigned int i = 0; i < num_fields; i++) {
164  char *str = buf_to_hex_str(fields[i].in_value, fields[i].num_bits);
165  command_print(CMD, "%s", str);
166  free(str);
167  }
168 
169 fail:
170  for (unsigned int i = 0; i < num_fields; i++)
171  free(fields[i].in_value);
172  free(fields);
173 
174  return retval;
175 }
176 
177 COMMAND_HANDLER(handle_jtag_command_pathmove)
178 {
179  tap_state_t states[8];
180 
181  if (CMD_ARGC < 1 || CMD_ARGC > ARRAY_SIZE(states))
183 
184  for (unsigned int i = 0; i < CMD_ARGC; i++) {
185  states[i] = tap_state_by_name(CMD_ARGV[i]);
186  if (states[i] < 0) {
187  command_print(CMD, "endstate: %s invalid", CMD_ARGV[i]);
189  }
190  }
191 
192  int retval = jtag_add_statemove(states[0]);
193  if (retval == ERROR_OK)
194  retval = jtag_execute_queue();
195  if (retval != ERROR_OK) {
196  command_print(CMD, "pathmove: jtag execute failed");
197  return retval;
198  }
199 
200  jtag_add_pathmove(CMD_ARGC - 1, states + 1);
201  retval = jtag_execute_queue();
202  if (retval != ERROR_OK) {
203  command_print(CMD, "pathmove: failed");
204  return retval;
205  }
206 
207  return ERROR_OK;
208 }
209 
210 COMMAND_HANDLER(handle_jtag_flush_count)
211 {
212  if (CMD_ARGC != 0)
214 
215  const unsigned int count = jtag_get_flush_queue_count();
217 
218  return ERROR_OK;
219 }
220 
221 /* REVISIT Just what about these should "move" ... ?
222  * These registrations, into the main JTAG table?
223  *
224  * There's a minor compatibility issue, these all show up twice;
225  * that's not desirable:
226  * - jtag drscan ... NOT DOCUMENTED!
227  * - drscan ...
228  *
229  * The "irscan" command (for example) doesn't show twice.
230  */
231 static const struct command_registration jtag_command_handlers_to_move[] = {
232  {
233  .name = "drscan",
234  .mode = COMMAND_EXEC,
235  .handler = handle_jtag_command_drscan,
236  .help = "Execute Data Register (DR) scan for one TAP. "
237  "Other TAPs must be in BYPASS mode.",
238  .usage = "tap_name (num_bits value)+ ['-endstate' state_name]",
239  },
240  {
241  .name = "flush_count",
242  .mode = COMMAND_EXEC,
243  .handler = handle_jtag_flush_count,
244  .help = "Returns the number of times the JTAG queue "
245  "has been flushed.",
246  .usage = "",
247  },
248  {
249  .name = "pathmove",
250  .mode = COMMAND_EXEC,
251  .handler = handle_jtag_command_pathmove,
252  .usage = "start_state state1 [state2 [state3 ...]]",
253  .help = "Move JTAG state machine from current state "
254  "(start_state) to state1, then state2, state3, etc.",
255  },
257 };
258 
259 
263 };
264 
265 static struct nvp nvp_config_opts[] = {
266  { .name = "-event", .value = JCFG_EVENT },
267  { .name = "-idcode", .value = JCFG_IDCODE },
268 
269  { .name = NULL, .value = -1 }
270 };
271 
272 static int jtag_tap_set_event(struct command_context *cmd_ctx, struct jtag_tap *tap,
273  const struct nvp *event, Jim_Obj *body)
274 {
275  struct jtag_tap_event_action *jteap = tap->event_action;
276 
277  while (jteap) {
278  if (jteap->event == (enum jtag_event)event->value)
279  break;
280  jteap = jteap->next;
281  }
282 
283  if (!jteap) {
284  jteap = calloc(1, sizeof(*jteap));
285  if (!jteap) {
286  LOG_ERROR("Out of memory");
287  return ERROR_FAIL;
288  }
289 
290  /* add to head of event list */
291  jteap->next = tap->event_action;
292  tap->event_action = jteap;
293  } else {
294  Jim_DecrRefCount(cmd_ctx->interp, jteap->body);
295  }
296 
297  jteap->interp = cmd_ctx->interp;
298  jteap->event = (enum jtag_event)event->value;
299  jteap->body = Jim_DuplicateObj(cmd_ctx->interp, body);
300  Jim_IncrRefCount(jteap->body);
301 
302  return ERROR_OK;
303 }
304 
305 __COMMAND_HANDLER(handle_jtag_configure)
306 {
307  bool is_configure = !strcmp(CMD_NAME, "configure");
308 
309  if (CMD_ARGC < (is_configure ? 3 : 2))
311 
312  /* FIXME: rework jtag_tap_by_jim_obj */
313  struct jtag_tap *tap = jtag_tap_by_jim_obj(CMD_CTX->interp, CMD_JIMTCL_ARGV[0]);
314  if (!tap)
315  return ERROR_FAIL;
316 
317  for (unsigned int i = 1; i < CMD_ARGC; i++) {
318  const struct nvp *n = nvp_name2value(nvp_config_opts, CMD_ARGV[i]);
319  switch (n->value) {
320  case JCFG_EVENT:
321  if (i + (is_configure ? 2 : 1) >= CMD_ARGC) {
322  command_print(CMD, "wrong # args: should be \"-event <event-name>%s\"",
323  is_configure ? " <event-body>" : "");
325  }
326 
327  const struct nvp *event = nvp_name2value(nvp_jtag_tap_event, CMD_ARGV[i + 1]);
328  if (!event->name) {
331  }
332 
333  if (is_configure) {
334  int retval = jtag_tap_set_event(CMD_CTX, tap, event, CMD_JIMTCL_ARGV[i + 2]);
335  if (retval != ERROR_OK)
336  return retval;
337  } else {
338  struct jtag_tap_event_action *jteap = tap->event_action;
339  while (jteap) {
340  if (jteap->event == (enum jtag_event)event->value) {
341  command_print(CMD, "%s", Jim_GetString(jteap->body, NULL));
342  break;
343  }
344  jteap = jteap->next;
345  }
346  }
347 
348  i += is_configure ? 2 : 1;
349  break;
350  case JCFG_IDCODE:
351  if (is_configure) {
352  command_print(CMD, "not settable: %s", n->name);
354  }
355  command_print(CMD, "0x%08x", tap->idcode);
356  break;
357  default:
360  }
361  }
362  return ERROR_OK;
363 }
364 
365 #define NTAP_OPT_IRLEN 0
366 #define NTAP_OPT_IRMASK 1
367 #define NTAP_OPT_IRCAPTURE 2
368 #define NTAP_OPT_ENABLED 3
369 #define NTAP_OPT_DISABLED 4
370 #define NTAP_OPT_EXPECTED_ID 5
371 #define NTAP_OPT_VERSION 6
372 #define NTAP_OPT_BYPASS 7
373 #define NTAP_OPT_IRBYPASS 8
374 
375 static const struct nvp jtag_newtap_opts[] = {
376  { .name = "-irlen", .value = NTAP_OPT_IRLEN },
377  { .name = "-irmask", .value = NTAP_OPT_IRMASK },
378  { .name = "-ircapture", .value = NTAP_OPT_IRCAPTURE },
379  { .name = "-enable", .value = NTAP_OPT_ENABLED },
380  { .name = "-disable", .value = NTAP_OPT_DISABLED },
381  { .name = "-expected-id", .value = NTAP_OPT_EXPECTED_ID },
382  { .name = "-ignore-version", .value = NTAP_OPT_VERSION },
383  { .name = "-ignore-bypass", .value = NTAP_OPT_BYPASS },
384  { .name = "-ir-bypass", .value = NTAP_OPT_IRBYPASS },
385  { .name = NULL, .value = -1 },
386 };
387 
388 static COMMAND_HELPER(handle_jtag_newtap_args, struct jtag_tap *tap)
389 {
390  /* we expect CHIP + TAP + OPTIONS */
391  if (CMD_ARGC < 2)
393 
394  tap->chip = strdup(CMD_ARGV[0]);
395  tap->tapname = strdup(CMD_ARGV[1]);
396  tap->dotted_name = alloc_printf("%s.%s", CMD_ARGV[0], CMD_ARGV[1]);
397  if (!tap->chip || !tap->tapname || !tap->dotted_name) {
398  LOG_ERROR("Out of memory");
399  return ERROR_FAIL;
400  }
401  CMD_ARGC -= 2;
402  CMD_ARGV += 2;
403 
404  LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
405  tap->chip, tap->tapname, tap->dotted_name, CMD_ARGC);
406 
407  /*
408  * IEEE specifies that the two LSBs of an IR scan are 01, so make
409  * that the default. The "-ircapture" and "-irmask" options are only
410  * needed to cope with nonstandard TAPs, or to specify more bits.
411  */
412  tap->ir_capture_mask = 0x03;
413  tap->ir_capture_value = 0x01;
414 
415  while (CMD_ARGC) {
416  const struct nvp *n = nvp_name2value(jtag_newtap_opts, CMD_ARGV[0]);
417  CMD_ARGC--;
418  CMD_ARGV++;
419  switch (n->value) {
420  case NTAP_OPT_ENABLED:
421  tap->disabled_after_reset = false;
422  break;
423 
424  case NTAP_OPT_DISABLED:
425  tap->disabled_after_reset = true;
426  break;
427 
429  if (!CMD_ARGC)
431 
432  tap->expected_ids = realloc(tap->expected_ids,
433  (tap->expected_ids_cnt + 1) * sizeof(uint32_t));
434  if (!tap->expected_ids) {
435  LOG_ERROR("Out of memory");
436  return ERROR_FAIL;
437  }
438 
439  uint32_t id;
440  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], id);
441  CMD_ARGC--;
442  CMD_ARGV++;
443  tap->expected_ids[tap->expected_ids_cnt++] = id;
444 
445  break;
446 
447  case NTAP_OPT_IRLEN:
448  if (!CMD_ARGC)
450 
451  COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], tap->ir_length);
452  CMD_ARGC--;
453  CMD_ARGV++;
454  if (tap->ir_length > (8 * sizeof(tap->ir_capture_value)))
455  LOG_WARNING("%s: huge IR length %u", tap->dotted_name, tap->ir_length);
456  break;
457 
458  case NTAP_OPT_IRMASK:
459  if (!CMD_ARGC)
461 
463  CMD_ARGC--;
464  CMD_ARGV++;
465  if ((tap->ir_capture_mask & 3) != 3)
466  LOG_WARNING("%s: nonstandard IR mask", tap->dotted_name);
467  break;
468 
469  case NTAP_OPT_IRCAPTURE:
470  if (!CMD_ARGC)
472 
474  CMD_ARGC--;
475  CMD_ARGV++;
476  if ((tap->ir_capture_value & 3) != 1)
477  LOG_WARNING("%s: nonstandard IR value", tap->dotted_name);
478  break;
479 
480  case NTAP_OPT_VERSION:
481  tap->ignore_version = true;
482  break;
483 
484  case NTAP_OPT_BYPASS:
485  tap->ignore_bypass = true;
486  break;
487 
488  case NTAP_OPT_IRBYPASS:
489  if (!CMD_ARGC)
491 
493  CMD_ARGC--;
494  CMD_ARGV++;
495  break;
496 
497  default:
500  }
501  }
502 
503  /* default is enabled-after-reset */
504  tap->enabled = !tap->disabled_after_reset;
505 
506  if (transport_is_jtag() && tap->ir_length == 0) {
507  command_print(CMD, "newtap: %s missing IR length", tap->dotted_name);
509  }
510 
511  return ERROR_OK;
512 }
513 
514 __COMMAND_HANDLER(handle_jtag_newtap)
515 {
516  struct jtag_tap *tap = calloc(1, sizeof(struct jtag_tap));
517  if (!tap) {
518  LOG_ERROR("Out of memory");
519  return ERROR_FAIL;
520  }
521 
522  int retval = CALL_COMMAND_HANDLER(handle_jtag_newtap_args, tap);
523  if (retval != ERROR_OK) {
524  free(tap->chip);
525  free(tap->tapname);
526  free(tap->dotted_name);
527  free(tap->expected_ids);
528  free(tap);
529  return retval;
530  }
531 
532  jtag_tap_init(tap);
533  return ERROR_OK;
534 }
535 
536 static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
537 {
538  struct jtag_tap_event_action *jteap;
539  int retval;
540 
541  for (jteap = tap->event_action; jteap; jteap = jteap->next) {
542  if (jteap->event != e)
543  continue;
544 
545  const struct nvp *nvp = nvp_value2name(nvp_jtag_tap_event, e);
546  LOG_DEBUG("JTAG tap: %s event: %d (%s)\n\taction: %s",
547  tap->dotted_name, e, nvp->name,
548  Jim_GetString(jteap->body, NULL));
549 
550  retval = Jim_EvalObj(jteap->interp, jteap->body);
551  if (retval == JIM_RETURN)
552  retval = jteap->interp->returnCode;
553 
554  if (retval != JIM_OK) {
555  Jim_MakeErrorMessage(jteap->interp);
556  LOG_USER("%s", Jim_GetString(Jim_GetResult(jteap->interp), NULL));
557  continue;
558  }
559 
560  switch (e) {
563  /* NOTE: we currently assume the handlers
564  * can't fail. Right here is where we should
565  * really be verifying the scan chains ...
566  */
567  tap->enabled = (e == JTAG_TAP_EVENT_ENABLE);
568  LOG_INFO("JTAG tap: %s %s", tap->dotted_name,
569  tap->enabled ? "enabled" : "disabled");
570  break;
571  default:
572  break;
573  }
574  }
575 }
576 
577 COMMAND_HANDLER(handle_jtag_arp_init)
578 {
579  if (CMD_ARGC != 0)
581 
582  return jtag_init_inner(CMD_CTX);
583 }
584 
585 COMMAND_HANDLER(handle_jtag_arp_init_reset)
586 {
587  if (CMD_ARGC != 0)
589 
590  if (transport_is_jtag())
591  return jtag_init_reset(CMD_CTX);
592 
593  if (transport_is_swd())
594  return swd_init_reset(CMD_CTX);
595 
596  return ERROR_OK;
597 }
598 
599 static bool jtag_tap_enable(struct jtag_tap *t)
600 {
601  if (t->enabled)
602  return true;
604  if (!t->enabled)
605  return false;
606 
607  /* FIXME add JTAG sanity checks, w/o TLR
608  * - scan chain length grew by one (this)
609  * - IDs and IR lengths are as expected
610  */
612  return true;
613 }
614 static bool jtag_tap_disable(struct jtag_tap *t)
615 {
616  if (!t->enabled)
617  return true;
619  if (t->enabled)
620  return false;
621 
622  /* FIXME add JTAG sanity checks, w/o TLR
623  * - scan chain length shrank by one (this)
624  * - IDs and IR lengths are as expected
625  */
627  return true;
628 }
629 
630 __COMMAND_HANDLER(handle_jtag_tap_enabler)
631 {
632  if (CMD_ARGC != 1)
634 
635  struct jtag_tap *t = jtag_tap_by_string(CMD_ARGV[0]);
636  if (!t) {
637  command_print(CMD, "Tap '%s' could not be found", CMD_ARGV[0]);
639  }
640 
641  if (strcmp(CMD_NAME, "tapisenabled") == 0) {
642  /* do nothing, just return the value */
643  } else if (strcmp(CMD_NAME, "tapenable") == 0) {
644  if (!jtag_tap_enable(t)) {
645  command_print(CMD, "failed to enable tap %s", t->dotted_name);
646  return ERROR_FAIL;
647  }
648  } else if (strcmp(CMD_NAME, "tapdisable") == 0) {
649  if (!jtag_tap_disable(t)) {
650  command_print(CMD, "failed to disable tap %s", t->dotted_name);
651  return ERROR_FAIL;
652  }
653  } else {
654  command_print(CMD, "command '%s' unknown", CMD_NAME);
655  return ERROR_FAIL;
656  }
657 
658  command_print(CMD, "%d", t->enabled ? 1 : 0);
659  return ERROR_OK;
660 }
661 
662 COMMAND_HANDLER(handle_jtag_names)
663 {
664  if (CMD_ARGC != 0)
666 
667  for (struct jtag_tap *tap = jtag_all_taps(); tap; tap = tap->next_tap)
668  command_print(CMD, "%s", tap->dotted_name);
669 
670  return ERROR_OK;
671 }
672 
673 COMMAND_HANDLER(handle_jtag_init_command)
674 {
675  if (CMD_ARGC != 0)
677 
678  static bool jtag_initialized;
679  if (jtag_initialized) {
680  LOG_INFO("'jtag init' has already been called");
681  return ERROR_OK;
682  }
683  jtag_initialized = true;
684 
685  LOG_DEBUG("Initializing jtag devices...");
686  return jtag_init(CMD_CTX);
687 }
688 
689 static const struct command_registration jtag_subcommand_handlers[] = {
690  {
691  .name = "init",
692  .mode = COMMAND_ANY,
693  .handler = handle_jtag_init_command,
694  .help = "initialize jtag scan chain",
695  .usage = ""
696  },
697  {
698  .name = "arp_init",
699  .mode = COMMAND_ANY,
700  .handler = handle_jtag_arp_init,
701  .help = "Validates JTAG scan chain against the list of "
702  "declared TAPs using just the four standard JTAG "
703  "signals.",
704  .usage = "",
705  },
706  {
707  .name = "arp_init-reset",
708  .mode = COMMAND_ANY,
709  .handler = handle_jtag_arp_init_reset,
710  .help = "Uses TRST and SRST to try resetting everything on "
711  "the JTAG scan chain, then performs 'jtag arp_init'.",
712  .usage = "",
713  },
714  {
715  .name = "newtap",
716  .mode = COMMAND_CONFIG,
717  .handler = handle_jtag_newtap,
718  .help = "Create a new TAP instance named basename.tap_type, "
719  "and appends it to the scan chain.",
720  .usage = "basename tap_type '-irlen' count "
721  "['-enable'|'-disable'] "
722  "['-expected_id' number] "
723  "['-ignore-version'] "
724  "['-ignore-bypass'] "
725  "['-ircapture' number] "
726  "['-ir-bypass' number] "
727  "['-mask' number]",
728  },
729  {
730  .name = "tapisenabled",
731  .mode = COMMAND_EXEC,
732  .handler = handle_jtag_tap_enabler,
733  .help = "Returns a Tcl boolean (0/1) indicating whether "
734  "the TAP is enabled (1) or not (0).",
735  .usage = "tap_name",
736  },
737  {
738  .name = "tapenable",
739  .mode = COMMAND_EXEC,
740  .handler = handle_jtag_tap_enabler,
741  .help = "Try to enable the specified TAP using the "
742  "'tap-enable' TAP event.",
743  .usage = "tap_name",
744  },
745  {
746  .name = "tapdisable",
747  .mode = COMMAND_EXEC,
748  .handler = handle_jtag_tap_enabler,
749  .help = "Try to disable the specified TAP using the "
750  "'tap-disable' TAP event.",
751  .usage = "tap_name",
752  },
753  {
754  .name = "configure",
755  .mode = COMMAND_ANY,
756  .handler = handle_jtag_configure,
757  .help = "Provide a Tcl handler for the specified "
758  "TAP event.",
759  .usage = "tap_name '-event' event_name handler",
760  },
761  {
762  .name = "cget",
763  .mode = COMMAND_EXEC,
764  .handler = handle_jtag_configure,
765  .help = "Return any Tcl handler for the specified "
766  "TAP event or the value of the IDCODE found in hardware.",
767  .usage = "tap_name '-event' event_name | "
768  "tap_name '-idcode'",
769  },
770  {
771  .name = "names",
772  .mode = COMMAND_ANY,
773  .handler = handle_jtag_names,
774  .help = "Returns list of all JTAG tap names.",
775  .usage = "",
776  },
777  {
779  },
781 };
782 
784 {
785  struct jtag_tap *tap;
786 
787  for (tap = jtag_all_taps(); tap; tap = tap->next_tap)
788  jtag_tap_handle_event(tap, event);
789 }
790 
791 
792 COMMAND_HANDLER(handle_scan_chain_command)
793 {
794  struct jtag_tap *tap;
795  char expected_id[12];
796 
797  tap = jtag_all_taps();
799  " TapName Enabled IdCode Expected IrLen IrCap IrMask");
801  "-- ------------------- -------- ---------- ---------- ----- ----- ------");
802 
803  while (tap) {
804  uint32_t expected, expected_mask, ii;
805 
806  snprintf(expected_id, sizeof(expected_id), "0x%08" PRIx32,
807  (tap->expected_ids_cnt > 0) ? tap->expected_ids[0] : 0);
808  if (tap->ignore_version)
809  expected_id[2] = '*';
810 
811  expected = buf_get_u32(tap->expected, 0, tap->ir_length);
813 
815  "%2u %-18s %c 0x%08x %s %5u 0x%02x 0x%02x",
816  tap->abs_chain_position,
817  tap->dotted_name,
818  tap->enabled ? 'Y' : 'n',
819  (unsigned int)(tap->idcode),
820  expected_id,
821  tap->ir_length,
822  (unsigned int)(expected),
823  (unsigned int)(expected_mask));
824 
825  for (ii = 1; ii < tap->expected_ids_cnt; ii++) {
826  snprintf(expected_id, sizeof(expected_id), "0x%08" PRIx32, tap->expected_ids[ii]);
827  if (tap->ignore_version)
828  expected_id[2] = '*';
829 
831  " %s",
832  expected_id);
833  }
834 
835  tap = tap->next_tap;
836  }
837 
838  return ERROR_OK;
839 }
840 
841 COMMAND_HANDLER(handle_jtag_ntrst_delay_command)
842 {
843  if (CMD_ARGC > 1)
845  if (CMD_ARGC == 1) {
846  unsigned int delay;
847  COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay);
848 
849  jtag_set_ntrst_delay(delay);
850  }
851  command_print(CMD, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay());
852  return ERROR_OK;
853 }
854 
855 COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command)
856 {
857  if (CMD_ARGC > 1)
859  if (CMD_ARGC == 1) {
860  unsigned int delay;
861  COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay);
862 
864  }
865  command_print(CMD, "jtag_ntrst_assert_width: %u", jtag_get_ntrst_assert_width());
866  return ERROR_OK;
867 }
868 
869 COMMAND_HANDLER(handle_jtag_rclk_command)
870 {
871  if (CMD_ARGC > 1)
873 
874  int retval = ERROR_OK;
875  if (CMD_ARGC == 1) {
876  unsigned int khz = 0;
877  COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz);
878 
879  retval = adapter_config_rclk(khz);
880  if (retval != ERROR_OK)
881  return retval;
882  }
883 
884  int cur_khz = adapter_get_speed_khz();
885  retval = adapter_get_speed_readable(&cur_khz);
886  if (retval != ERROR_OK)
887  return retval;
888 
889  if (cur_khz)
890  command_print(CMD, "RCLK not supported - fallback to %d kHz", cur_khz);
891  else
892  command_print(CMD, "RCLK - adaptive");
893 
894  return retval;
895 }
896 
897 COMMAND_HANDLER(handle_runtest_command)
898 {
899  if (CMD_ARGC != 1)
901 
902  unsigned int num_clocks;
903  COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num_clocks);
904 
905  jtag_add_runtest(num_clocks, TAP_IDLE);
906  return jtag_execute_queue();
907 }
908 
909 /*
910  * For "irscan" or "drscan" commands, the "end" (really, "next") state
911  * should be stable ... and *NOT* a shift state, otherwise free-running
912  * jtag clocks could change the values latched by the update state.
913  * Not surprisingly, this is the same constraint as SVF; the "irscan"
914  * and "drscan" commands are a write-only subset of what SVF provides.
915  */
916 
917 COMMAND_HANDLER(handle_irscan_command)
918 {
919  int i;
920  struct scan_field *fields;
921  struct jtag_tap *tap = NULL;
922  tap_state_t endstate;
923 
924  if ((CMD_ARGC < 2) || (CMD_ARGC % 2))
926 
927  /* optional "-endstate" "statename" at the end of the arguments,
928  * so that e.g. IRPAUSE can let us load the data register before
929  * entering RUN/IDLE to execute the instruction we load here.
930  */
931  endstate = TAP_IDLE;
932 
933  if (CMD_ARGC >= 4) {
934  /* have at least one pair of numbers.
935  * is last pair the magic text? */
936  if (strcmp("-endstate", CMD_ARGV[CMD_ARGC - 2]) == 0) {
937  endstate = tap_state_by_name(CMD_ARGV[CMD_ARGC - 1]);
938  if (endstate == TAP_INVALID)
940  if (!scan_is_safe(endstate))
941  LOG_WARNING("unstable irscan endstate \"%s\"",
942  CMD_ARGV[CMD_ARGC - 1]);
943  CMD_ARGC -= 2;
944  }
945  }
946 
947  int num_fields = CMD_ARGC / 2;
948  if (num_fields > 1) {
949  /* we really should be looking at plain_ir_scan if we want
950  * anything more fancy.
951  */
952  LOG_ERROR("Specify a single value for tap");
954  }
955 
956  fields = calloc(num_fields, sizeof(*fields));
957 
958  int retval;
959  for (i = 0; i < num_fields; i++) {
960  tap = jtag_tap_by_string(CMD_ARGV[i*2]);
961  if (!tap) {
962  free(fields);
963  command_print(CMD, "Tap: %s unknown", CMD_ARGV[i*2]);
964 
965  return ERROR_FAIL;
966  }
967  uint64_t value;
968  retval = parse_u64(CMD_ARGV[i * 2 + 1], &value);
969  if (retval != ERROR_OK)
970  goto error_return;
971 
972  unsigned int field_size = tap->ir_length;
973  fields[i].num_bits = field_size;
974  uint8_t *v = calloc(1, DIV_ROUND_UP(field_size, 8));
975  if (!v) {
976  LOG_ERROR("Out of memory");
977  goto error_return;
978  }
979 
980  buf_set_u64(v, 0, field_size, value);
981  fields[i].out_value = v;
982  fields[i].in_value = NULL;
983  }
984 
985  /* did we have an endstate? */
986  jtag_add_ir_scan(tap, fields, endstate);
987 
988  retval = jtag_execute_queue();
989 
990 error_return:
991  for (i = 0; i < num_fields; i++)
992  free((void *)fields[i].out_value);
993 
994  free(fields);
995 
996  return retval;
997 }
998 
999 COMMAND_HANDLER(handle_verify_ircapture_command)
1000 {
1001  if (CMD_ARGC > 1)
1003 
1004  if (CMD_ARGC == 1) {
1005  bool enable;
1006  COMMAND_PARSE_ENABLE(CMD_ARGV[0], enable);
1008  }
1009 
1010  const char *status = jtag_will_verify_capture_ir() ? "enabled" : "disabled";
1011  command_print(CMD, "verify Capture-IR is %s", status);
1012 
1013  return ERROR_OK;
1014 }
1015 
1016 COMMAND_HANDLER(handle_verify_jtag_command)
1017 {
1018  if (CMD_ARGC > 1)
1020 
1021  if (CMD_ARGC == 1) {
1022  bool enable;
1023  COMMAND_PARSE_ENABLE(CMD_ARGV[0], enable);
1024  jtag_set_verify(enable);
1025  }
1026 
1027  const char *status = jtag_will_verify() ? "enabled" : "disabled";
1028  command_print(CMD, "verify jtag capture is %s", status);
1029 
1030  return ERROR_OK;
1031 }
1032 
1033 COMMAND_HANDLER(handle_tms_sequence_command)
1034 {
1035  if (CMD_ARGC > 1)
1037 
1038  if (CMD_ARGC == 1) {
1039  bool use_new_table;
1040  if (strcmp(CMD_ARGV[0], "short") == 0)
1041  use_new_table = true;
1042  else if (strcmp(CMD_ARGV[0], "long") == 0)
1043  use_new_table = false;
1044  else
1046 
1047  tap_use_new_tms_table(use_new_table);
1048  }
1049 
1050  command_print(CMD, "tms sequence is %s",
1051  tap_uses_new_tms_table() ? "short" : "long");
1052 
1053  return ERROR_OK;
1054 }
1055 
1056 COMMAND_HANDLER(handle_jtag_flush_queue_sleep)
1057 {
1058  if (CMD_ARGC != 1)
1060 
1061  int sleep_ms;
1063 
1065 
1066  return ERROR_OK;
1067 }
1068 
1069 COMMAND_HANDLER(handle_wait_srst_deassert)
1070 {
1071  if (CMD_ARGC != 1)
1073 
1074  int timeout_ms;
1075  COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], timeout_ms);
1076  if ((timeout_ms <= 0) || (timeout_ms > 100000)) {
1077  LOG_ERROR("Timeout must be an integer between 0 and 100000");
1078  return ERROR_FAIL;
1079  }
1080 
1081  LOG_USER("Waiting for srst assert + deassert for at most %dms", timeout_ms);
1082  int asserted_yet;
1083  int64_t then = timeval_ms();
1084  while (jtag_srst_asserted(&asserted_yet) == ERROR_OK) {
1085  if ((timeval_ms() - then) > timeout_ms) {
1086  LOG_ERROR("Timed out");
1087  return ERROR_FAIL;
1088  }
1089  if (asserted_yet)
1090  break;
1091  }
1092  while (jtag_srst_asserted(&asserted_yet) == ERROR_OK) {
1093  if ((timeval_ms() - then) > timeout_ms) {
1094  LOG_ERROR("Timed out");
1095  return ERROR_FAIL;
1096  }
1097  if (!asserted_yet)
1098  break;
1099  }
1100 
1101  return ERROR_OK;
1102 }
1103 
1104 static const struct command_registration jtag_command_handlers[] = {
1105 
1106  {
1107  .name = "jtag_flush_queue_sleep",
1108  .handler = handle_jtag_flush_queue_sleep,
1109  .mode = COMMAND_ANY,
1110  .help = "For debug purposes(simulate long delays of interface) "
1111  "to test performance or change in behavior. Default 0ms.",
1112  .usage = "[sleep in ms]",
1113  },
1114  {
1115  .name = "jtag_rclk",
1116  .handler = handle_jtag_rclk_command,
1117  .mode = COMMAND_ANY,
1118  .help = "With an argument, change to to use adaptive clocking "
1119  "if possible; else to use the fallback speed. "
1120  "With or without argument, display current setting.",
1121  .usage = "[fallback_speed_khz]",
1122  },
1123  {
1124  .name = "jtag_ntrst_delay",
1125  .handler = handle_jtag_ntrst_delay_command,
1126  .mode = COMMAND_ANY,
1127  .help = "delay after deasserting trst in ms",
1128  .usage = "[milliseconds]",
1129  },
1130  {
1131  .name = "jtag_ntrst_assert_width",
1132  .handler = handle_jtag_ntrst_assert_width_command,
1133  .mode = COMMAND_ANY,
1134  .help = "delay after asserting trst in ms",
1135  .usage = "[milliseconds]",
1136  },
1137  {
1138  .name = "scan_chain",
1139  .handler = handle_scan_chain_command,
1140  .mode = COMMAND_ANY,
1141  .help = "print current scan chain configuration",
1142  .usage = ""
1143  },
1144  {
1145  .name = "runtest",
1146  .handler = handle_runtest_command,
1147  .mode = COMMAND_EXEC,
1148  .help = "Move to Run-Test/Idle, and issue TCK for num_cycles.",
1149  .usage = "num_cycles"
1150  },
1151  {
1152  .name = "irscan",
1153  .handler = handle_irscan_command,
1154  .mode = COMMAND_EXEC,
1155  .help = "Execute Instruction Register (IR) scan. The "
1156  "specified opcodes are put into each TAP's IR, "
1157  "and other TAPs are put in BYPASS.",
1158  .usage = "[tap_name instruction]* ['-endstate' state_name]",
1159  },
1160  {
1161  .name = "verify_ircapture",
1162  .handler = handle_verify_ircapture_command,
1163  .mode = COMMAND_ANY,
1164  .help = "Display or assign flag controlling whether to "
1165  "verify values captured during Capture-IR.",
1166  .usage = "['enable'|'disable']",
1167  },
1168  {
1169  .name = "verify_jtag",
1170  .handler = handle_verify_jtag_command,
1171  .mode = COMMAND_ANY,
1172  .help = "Display or assign flag controlling whether to "
1173  "verify values captured during IR and DR scans.",
1174  .usage = "['enable'|'disable']",
1175  },
1176  {
1177  .name = "tms_sequence",
1178  .handler = handle_tms_sequence_command,
1179  .mode = COMMAND_ANY,
1180  .help = "Display or change what style TMS sequences to use "
1181  "for JTAG state transitions: short (default) or "
1182  "long. Only for working around JTAG bugs.",
1183  /* Specifically for working around DRIVER bugs... */
1184  .usage = "['short'|'long']",
1185  },
1186  {
1187  .name = "wait_srst_deassert",
1188  .handler = handle_wait_srst_deassert,
1189  .mode = COMMAND_ANY,
1190  .help = "Wait for an SRST deassert. "
1191  "Useful for cases where you need something to happen within ms "
1192  "of an srst deassert. Timeout in ms",
1193  .usage = "ms",
1194  },
1195  {
1196  .name = "jtag",
1197  .mode = COMMAND_ANY,
1198  .help = "perform jtag tap actions",
1199  .usage = "",
1200 
1201  .chain = jtag_subcommand_handlers,
1202  },
1203  {
1205  },
1207 };
1208 
1210 {
1211  return register_commands(cmd_ctx, NULL, jtag_command_handlers);
1212 }
int adapter_config_rclk(unsigned int fallback_speed_khz)
Attempt to enable RTCK/RCLK.
Definition: adapter.c:257
unsigned int adapter_get_speed_khz(void)
Retrieves the clock speed of the adapter in kHz.
Definition: adapter.c:207
int adapter_get_speed_readable(int *khz)
Given a speed setting, use the interface speed_div callback to adjust the setting.
Definition: adapter.c:283
bool transport_is_swd(void)
Returns true if the current debug session is using SWD as its transport.
Definition: adi_v5_swd.c:776
char * buf_to_hex_str(const void *_buf, unsigned int buf_len)
Definition: binarybuffer.c:178
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
Definition: binarybuffer.h:104
static void buf_set_u64(uint8_t *_buffer, unsigned int first, unsigned int num, uint64_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:65
void command_print_sameline(struct command_invocation *cmd, const char *format,...)
Definition: command.c:420
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:443
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
Definition: command.h:118
#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
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:402
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#define 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 COMMAND_PARSE_ENABLE(in, out)
parses an enable/disable command argument
Definition: command.h:533
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
Definition: command.h:442
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
Definition: command.h:146
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
#define ERROR_COMMAND_ARGUMENT_INVALID
Definition: command.h:404
static int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends,...
Definition: command.h:274
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
void tap_use_new_tms_table(bool use_new)
Allow switching between old and new TMS tables.
Definition: interface.c:447
bool tap_uses_new_tms_table(void)
Definition: interface.c:451
tap_state_t tap_state_by_name(const char *name)
Provides user-friendly name lookup of TAP states.
Definition: interface.c:355
Exports the list of JTAG interface drivers, along with routines for loading and unloading them dynami...
struct jtag_tap * jtag_tap_by_string(const char *s)
Definition: jtag/core.c:237
int jtag_init_inner(struct command_context *cmd_ctx)
Definition: jtag/core.c:1503
void jtag_add_runtest(unsigned int num_cycles, tap_state_t state)
Goes to TAP_IDLE (if we're not already there), cycle precisely num_cycles in the TAP_IDLE state,...
Definition: jtag/core.c:592
void jtag_add_pathmove(unsigned int num_states, const tap_state_t *path)
Application code must assume that interfaces will implement transitions between states with different...
Definition: jtag/core.c:517
unsigned int jtag_get_ntrst_assert_width(void)
Definition: jtag/core.c:1781
int jtag_init(struct command_context *cmd_ctx)
Initialize JTAG chain using only a RESET reset.
Definition: jtag/core.c:1664
int jtag_srst_asserted(int *srst_asserted)
Definition: jtag/core.c:1725
bool transport_is_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
Definition: jtag/core.c:1827
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
Definition: jtag/core.c:1037
void jtag_set_flush_queue_sleep(int ms)
Set ms to sleep after jtag_execute_queue() flushes queue.
Definition: jtag/core.c:118
struct jtag_tap * jtag_all_taps(void)
Definition: jtag/core.c:184
int jtag_add_statemove(tap_state_t goal_state)
jtag_add_statemove() moves from the current state to goal_state.
Definition: jtag/core.c:551
int swd_init_reset(struct command_context *cmd_ctx)
Definition: jtag/core.c:1583
int jtag_init_reset(struct command_context *cmd_ctx)
reset, then initialize JTAG chain
Definition: jtag/core.c:1600
bool jtag_will_verify(void)
Definition: jtag/core.c:1695
int jtag_call_event_callbacks(enum jtag_event event)
Definition: jtag/core.c:324
void jtag_set_ntrst_delay(unsigned int delay)
Definition: jtag/core.c:1760
void jtag_set_verify_capture_ir(bool enable)
Enable or disable verification of IR scan checking.
Definition: jtag/core.c:1700
unsigned int jtag_get_ntrst_delay(void)
Definition: jtag/core.c:1764
bool jtag_will_verify_capture_ir(void)
Definition: jtag/core.c:1705
unsigned int jtag_get_flush_queue_count(void)
Definition: jtag/core.c:1032
void jtag_add_ir_scan(struct jtag_tap *active, struct scan_field *in_fields, tap_state_t state)
Generate an IR SCAN with a list of scan fields with one entry for each enabled TAP.
Definition: jtag/core.c:374
void jtag_tap_init(struct jtag_tap *tap)
Definition: jtag/core.c:1447
void jtag_set_ntrst_assert_width(unsigned int delay)
Definition: jtag/core.c:1777
void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
Generate a DR SCAN using the fields passed to the function.
Definition: jtag/core.c:451
void jtag_set_verify(bool enable)
Enable or disable data scan verification checking.
Definition: jtag/core.c:1690
int jtag_register_commands(struct command_context *cmd_ctx)
Definition: jtag/tcl.c:1209
static const struct command_registration jtag_command_handlers_to_move[]
Definition: jtag/tcl.c:231
static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
Definition: jtag/tcl.c:536
#define NTAP_OPT_IRMASK
Definition: jtag/tcl.c:366
#define NTAP_OPT_DISABLED
Definition: jtag/tcl.c:369
static const struct nvp jtag_newtap_opts[]
Definition: jtag/tcl.c:375
#define NTAP_OPT_IRLEN
Definition: jtag/tcl.c:365
jtag_tap_cfg_param
Definition: jtag/tcl.c:260
@ JCFG_IDCODE
Definition: jtag/tcl.c:262
@ JCFG_EVENT
Definition: jtag/tcl.c:261
static COMMAND_HELPER(handle_jtag_command_drscan_fields, struct scan_field *fields)
Definition: jtag/tcl.c:77
#define NTAP_OPT_BYPASS
Definition: jtag/tcl.c:372
static bool jtag_tap_disable(struct jtag_tap *t)
Definition: jtag/tcl.c:614
static int jtag_tap_set_event(struct command_context *cmd_ctx, struct jtag_tap *tap, const struct nvp *event, Jim_Obj *body)
Definition: jtag/tcl.c:272
#define NTAP_OPT_ENABLED
Definition: jtag/tcl.c:368
__COMMAND_HANDLER(handle_jtag_configure)
Definition: jtag/tcl.c:305
#define NTAP_OPT_EXPECTED_ID
Definition: jtag/tcl.c:370
#define NTAP_OPT_IRCAPTURE
Definition: jtag/tcl.c:367
static struct nvp nvp_config_opts[]
Definition: jtag/tcl.c:265
static const struct nvp nvp_jtag_tap_event[]
Definition: jtag/tcl.c:44
static bool scan_is_safe(tap_state_t state)
Definition: jtag/tcl.c:64
#define NTAP_OPT_IRBYPASS
Definition: jtag/tcl.c:373
#define NTAP_OPT_VERSION
Definition: jtag/tcl.c:371
COMMAND_HANDLER(handle_jtag_command_drscan)
Definition: jtag/tcl.c:102
static const struct command_registration jtag_subcommand_handlers[]
Definition: jtag/tcl.c:689
static bool jtag_tap_enable(struct jtag_tap *t)
Definition: jtag/tcl.c:599
static const struct command_registration jtag_command_handlers[]
Definition: jtag/tcl.c:1104
void jtag_notify_event(enum jtag_event event)
Report Tcl event to all TAPs.
Definition: jtag/tcl.c:783
struct jtag_tap * jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
Definition: jtag/tcl.c:53
The JTAG interface can be implemented with a software or hardware fifo.
@ TAP_RESET
Definition: jtag.h:56
@ TAP_DRPAUSE
Definition: jtag.h:44
@ TAP_IDLE
Definition: jtag.h:53
@ TAP_IRPAUSE
Definition: jtag.h:52
@ TAP_INVALID
Definition: jtag.h:38
jtag_event
Definition: jtag.h:180
@ JTAG_TAP_EVENT_ENABLE
Definition: jtag.h:183
@ JTAG_TAP_EVENT_SETUP
Definition: jtag.h:182
@ JTAG_TRST_ASSERTED
Definition: jtag.h:181
@ JTAG_TAP_EVENT_DISABLE
Definition: jtag.h:184
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
char * alloc_printf(const char *format,...)
Definition: log.c:364
#define LOG_USER(expr ...)
Definition: log.h:135
#define LOG_WARNING(expr ...)
Definition: log.h:129
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_INFO(expr ...)
Definition: log.h:126
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:164
void nvp_unknown_command_print(struct command_invocation *cmd, const struct nvp *nvp, const char *param_name, const char *param_value)
Definition: nvp.c:49
const struct nvp * nvp_name2value(const struct nvp *p, const char *name)
Definition: nvp.c:29
const struct nvp * nvp_value2name(const struct nvp *p, int value)
Definition: nvp.c:39
uint8_t bits[QN908X_FLASH_MAX_BLOCKS *QN908X_FLASH_PAGES_PER_BLOCK/8]
Definition: qn908x.c:0
char id[RTT_CB_MAX_ID_LENGTH]
Control block identifier.
Definition: rtt/rtt.c:32
Jim_Interp * interp
Definition: command.h:53
const char * name
Definition: command.h:235
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
Definition: command.h:249
struct jtag_tap_event_action * next
Definition: jtag.h:195
enum jtag_event event
The event for which this action will be triggered.
Definition: jtag.h:189
Jim_Obj * body
Contains a script to 'eval' when the event is triggered.
Definition: jtag.h:193
Jim_Interp * interp
The interpreter to use for evaluating the body.
Definition: jtag.h:191
Definition: jtag.h:101
uint32_t ir_capture_value
Definition: jtag.h:111
bool bypass
Bypass register selected.
Definition: jtag.h:134
uint8_t * expected_mask
Capture-IR expected mask.
Definition: jtag.h:114
char * chip
Definition: jtag.h:102
bool ignore_version
Flag saying whether to ignore version field in expected_ids[].
Definition: jtag.h:126
bool disabled_after_reset
Is this TAP disabled after JTAG reset?
Definition: jtag.h:107
struct jtag_tap_event_action * event_action
Definition: jtag.h:139
unsigned int ir_length
size of instruction register
Definition: jtag.h:110
uint8_t * expected
Capture-IR expected value.
Definition: jtag.h:112
uint32_t ir_capture_mask
Definition: jtag.h:113
uint8_t expected_ids_cnt
Number of expected identification codes.
Definition: jtag.h:123
unsigned int abs_chain_position
Definition: jtag.h:105
char * tapname
Definition: jtag.h:103
bool ignore_bypass
Flag saying whether to ignore the bypass bit in the code.
Definition: jtag.h:129
bool enabled
Is this TAP currently enabled?
Definition: jtag.h:109
uint64_t ir_bypass_value
Bypass instruction value.
Definition: jtag.h:137
uint32_t * expected_ids
Array of expected identification codes.
Definition: jtag.h:121
struct jtag_tap * next_tap
Definition: jtag.h:141
uint32_t idcode
device identification code
Definition: jtag.h:115
char * dotted_name
Definition: jtag.h:104
Name Value Pairs, aka: NVP.
Definition: nvp.h:61
int value
Definition: nvp.h:63
const char * name
Definition: nvp.h:62
This structure defines a single scan field in the scan.
Definition: jtag.h:87
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
Definition: jtag.h:93
const uint8_t * out_value
A pointer to value to be scanned into the device.
Definition: jtag.h:91
unsigned int num_bits
The number of bits this field specifies.
Definition: jtag.h:89
int64_t timeval_ms(void)
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
Definition: types.h:57
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
Definition: types.h:79
#define NULL
Definition: usb.h:16
uint8_t status[4]
Definition: vdebug.c:17
uint8_t state[4]
Definition: vdebug.c:21
uint8_t count[4]
Definition: vdebug.c:22
#define sleep_ms(ms)