1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * Copyright (C) 2007,2008 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
8 * Copyright (C) 2009 SoftPLC Corporation *
12 * Copyright (C) 2009 Zachary T Welch *
13 * zw@superlucidity.net *
15 * This program is free software; you can redistribute it and/or modify *
16 * it under the terms of the GNU General Public License as published by *
17 * the Free Software Foundation; either version 2 of the License, or *
18 * (at your option) any later version. *
20 * This program is distributed in the hope that it will be useful, *
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
23 * GNU General Public License for more details. *
25 * You should have received a copy of the GNU General Public License *
26 * along with this program; if not, write to the *
27 * Free Software Foundation, Inc., *
28 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
29 ***************************************************************************/
35 #include "minidriver.h"
36 #include "interface.h"
37 #include "interfaces.h"
43 static const Jim_Nvp nvp_jtag_tap_event
[] = {
44 { .value
= JTAG_TRST_ASSERTED
, .name
= "post-reset" },
45 { .value
= JTAG_TAP_EVENT_SETUP
, .name
= "setup" },
46 { .value
= JTAG_TAP_EVENT_ENABLE
, .name
= "tap-enable" },
47 { .value
= JTAG_TAP_EVENT_DISABLE
, .name
= "tap-disable" },
49 { .name
= NULL
, .value
= -1 }
52 extern struct jtag_interface
*jtag_interface
;
54 struct jtag_tap
*jtag_tap_by_jim_obj(Jim_Interp
*interp
, Jim_Obj
*o
)
56 const char *cp
= Jim_GetString(o
, NULL
);
57 struct jtag_tap
*t
= cp
? jtag_tap_by_string(cp
) : NULL
;
61 Jim_SetResult_sprintf(interp
, "Tap '%s' could not be found", cp
);
65 static bool scan_is_safe(tap_state_t state
)
79 static int Jim_Command_drscan(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *args
)
82 struct scan_field
*fields
;
91 * args[3] = hex string
92 * ... repeat num bits and hex string ...
95 * args[N-2] = "-endstate"
96 * args[N-1] = statename
98 if ((argc
< 4) || ((argc
% 2) != 0))
100 Jim_WrongNumArgs(interp
, 1, args
, "wrong arguments");
106 script_debug(interp
, "drscan", argc
, args
);
108 /* validate arguments as numbers */
110 for (i
= 2; i
< argc
; i
+= 2)
115 e
= Jim_GetLong(interp
, args
[i
], &bits
);
116 /* If valid - try next arg */
121 /* Not valid.. are we at the end? */
122 if (((i
+ 2) != argc
)) {
123 /* nope, then error */
127 /* it could be: "-endstate FOO"
128 * e.g. DRPAUSE so we can issue more instructions
129 * before entering RUN/IDLE and executing them.
132 /* get arg as a string. */
133 cp
= Jim_GetString(args
[i
], NULL
);
134 /* is it the magic? */
135 if (0 == strcmp("-endstate", cp
)) {
136 /* is the statename valid? */
137 cp
= Jim_GetString(args
[i
+ 1], NULL
);
139 /* see if it is a valid state name */
140 endstate
= tap_state_by_name(cp
);
142 /* update the error message */
143 Jim_SetResult_sprintf(interp
,"endstate: %s invalid", cp
);
145 if (!scan_is_safe(endstate
))
146 LOG_WARNING("drscan with unsafe "
147 "endstate \"%s\"", cp
);
149 /* valid - so clear the error */
151 /* and remove the last 2 args */
156 /* Still an error? */
158 return e
; /* too bad */
160 } /* validate args */
162 tap
= jtag_tap_by_jim_obj(interp
, args
[1]);
167 num_fields
= (argc
-2)/2;
168 fields
= malloc(sizeof(struct scan_field
) * num_fields
);
169 for (i
= 2; i
< argc
; i
+= 2)
175 Jim_GetLong(interp
, args
[i
], &bits
);
176 str
= Jim_GetString(args
[i
+ 1], &len
);
178 fields
[field_count
].num_bits
= bits
;
179 fields
[field_count
].out_value
= malloc(DIV_ROUND_UP(bits
, 8));
180 str_to_buf(str
, len
, fields
[field_count
].out_value
, bits
, 0);
181 fields
[field_count
].in_value
= fields
[field_count
].out_value
;
185 jtag_add_dr_scan(tap
, num_fields
, fields
, endstate
);
187 retval
= jtag_execute_queue();
188 if (retval
!= ERROR_OK
)
190 Jim_SetResultString(interp
, "drscan: jtag execute failed",-1);
195 Jim_Obj
*list
= Jim_NewListObj(interp
, NULL
, 0);
196 for (i
= 2; i
< argc
; i
+= 2)
201 Jim_GetLong(interp
, args
[i
], &bits
);
202 str
= buf_to_str(fields
[field_count
].in_value
, bits
, 16);
203 free(fields
[field_count
].out_value
);
205 Jim_ListAppendElement(interp
, list
, Jim_NewStringObj(interp
, str
, strlen(str
)));
210 Jim_SetResult(interp
, list
);
218 static int Jim_Command_pathmove(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *args
)
220 tap_state_t states
[8];
222 if ((argc
< 2) || ((size_t)argc
> (ARRAY_SIZE(states
) + 1)))
224 Jim_WrongNumArgs(interp
, 1, args
, "wrong arguments");
228 script_debug(interp
, "pathmove", argc
, args
);
231 for (i
= 0; i
< argc
-1; i
++)
234 cp
= Jim_GetString(args
[i
+ 1], NULL
);
235 states
[i
] = tap_state_by_name(cp
);
238 /* update the error message */
239 Jim_SetResult_sprintf(interp
,"endstate: %s invalid", cp
);
244 if ((jtag_add_statemove(states
[0]) != ERROR_OK
) || (jtag_execute_queue()!= ERROR_OK
))
246 Jim_SetResultString(interp
, "pathmove: jtag execute failed",-1);
250 jtag_add_pathmove(argc
-2, states
+ 1);
252 if (jtag_execute_queue()!= ERROR_OK
)
254 Jim_SetResultString(interp
, "pathmove: failed",-1);
262 static int Jim_Command_flush_count(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *args
)
264 script_debug(interp
, "flush_count", argc
, args
);
266 Jim_SetResult(interp
, Jim_NewIntObj(interp
, jtag_get_flush_queue_count()));
271 /* REVISIT Just what about these should "move" ... ?
272 * These registrations, into the main JTAG table?
274 * There's a minor compatibility issue, these all show up twice;
275 * that's not desirable:
276 * - jtag drscan ... NOT DOCUMENTED!
279 * The "irscan" command (for example) doesn't show twice.
281 static const struct command_registration jtag_command_handlers_to_move
[] = {
284 .mode
= COMMAND_EXEC
,
285 .jim_handler
= Jim_Command_drscan
,
286 .help
= "Execute Data Register (DR) scan for one TAP. "
287 "Other TAPs must be in BYPASS mode.",
288 .usage
= "tap_name [num_bits value]* ['-endstate' state_name]",
291 .name
= "flush_count",
292 .mode
= COMMAND_EXEC
,
293 .jim_handler
= Jim_Command_flush_count
,
294 .help
= "Returns the number of times the JTAG queue "
299 .mode
= COMMAND_EXEC
,
300 .jim_handler
= Jim_Command_pathmove
,
301 .usage
= "start_state state1 [state2 [state3 ...]]",
302 .help
= "Move JTAG state machine from current state "
303 "(start_state) to state1, then state2, state3, etc.",
305 COMMAND_REGISTRATION_DONE
309 enum jtag_tap_cfg_param
{
313 static Jim_Nvp nvp_config_opts
[] = {
314 { .name
= "-event", .value
= JCFG_EVENT
},
316 { .name
= NULL
, .value
= -1 }
319 static int jtag_tap_configure_event(Jim_GetOptInfo
*goi
, struct jtag_tap
* tap
)
323 Jim_WrongNumArgs(goi
->interp
, goi
->argc
, goi
->argv
, "-event <event-name> ...");
328 int e
= Jim_GetOpt_Nvp(goi
, nvp_jtag_tap_event
, &n
);
331 Jim_GetOpt_NvpUnknown(goi
, nvp_jtag_tap_event
, 1);
335 if (goi
->isconfigure
) {
336 if (goi
->argc
!= 1) {
337 Jim_WrongNumArgs(goi
->interp
, goi
->argc
, goi
->argv
, "-event <event-name> <event-body>");
341 if (goi
->argc
!= 0) {
342 Jim_WrongNumArgs(goi
->interp
, goi
->argc
, goi
->argv
, "-event <event-name>");
347 struct jtag_tap_event_action
*jteap
= tap
->event_action
;
348 /* replace existing event body */
352 if (jteap
->event
== (enum jtag_event
)n
->value
)
360 Jim_SetEmptyResult(goi
->interp
);
362 if (goi
->isconfigure
)
365 jteap
= calloc(1, sizeof(*jteap
));
366 else if (NULL
!= jteap
->body
)
367 Jim_DecrRefCount(goi
->interp
, jteap
->body
);
369 jteap
->interp
= goi
->interp
;
370 jteap
->event
= n
->value
;
373 Jim_GetOpt_Obj(goi
, &o
);
374 jteap
->body
= Jim_DuplicateObj(goi
->interp
, o
);
375 Jim_IncrRefCount(jteap
->body
);
379 /* add to head of event list */
380 jteap
->next
= tap
->event_action
;
381 tap
->event_action
= jteap
;
386 jteap
->interp
= goi
->interp
;
387 Jim_SetResult(goi
->interp
,
388 Jim_DuplicateObj(goi
->interp
, jteap
->body
));
393 static int jtag_tap_configure_cmd(Jim_GetOptInfo
*goi
, struct jtag_tap
* tap
)
395 /* parse config or cget options */
396 while (goi
->argc
> 0)
398 Jim_SetEmptyResult (goi
->interp
);
401 int e
= Jim_GetOpt_Nvp(goi
, nvp_config_opts
, &n
);
404 Jim_GetOpt_NvpUnknown(goi
, nvp_config_opts
, 0);
411 e
= jtag_tap_configure_event(goi
, tap
);
416 Jim_SetResult_sprintf(goi
->interp
, "unknown event: %s", n
->name
);
424 static int is_bad_irval(int ir_length
, jim_wide w
)
434 static int jim_newtap_expected_id(Jim_Nvp
*n
, Jim_GetOptInfo
*goi
,
435 struct jtag_tap
*pTap
)
438 int e
= Jim_GetOpt_Wide(goi
, &w
);
440 Jim_SetResult_sprintf(goi
->interp
, "option: %s bad parameter", n
->name
);
444 unsigned expected_len
= sizeof(uint32_t) * pTap
->expected_ids_cnt
;
445 uint32_t *new_expected_ids
= malloc(expected_len
+ sizeof(uint32_t));
446 if (new_expected_ids
== NULL
)
448 Jim_SetResult_sprintf(goi
->interp
, "no memory");
452 memcpy(new_expected_ids
, pTap
->expected_ids
, expected_len
);
454 new_expected_ids
[pTap
->expected_ids_cnt
] = w
;
456 free(pTap
->expected_ids
);
457 pTap
->expected_ids
= new_expected_ids
;
458 pTap
->expected_ids_cnt
++;
463 #define NTAP_OPT_IRLEN 0
464 #define NTAP_OPT_IRMASK 1
465 #define NTAP_OPT_IRCAPTURE 2
466 #define NTAP_OPT_ENABLED 3
467 #define NTAP_OPT_DISABLED 4
468 #define NTAP_OPT_EXPECTED_ID 5
469 #define NTAP_OPT_VERSION 6
471 static int jim_newtap_ir_param(Jim_Nvp
*n
, Jim_GetOptInfo
*goi
,
472 struct jtag_tap
*pTap
)
475 int e
= Jim_GetOpt_Wide(goi
, &w
);
478 Jim_SetResult_sprintf(goi
->interp
,
479 "option: %s bad parameter", n
->name
);
480 free((void *)pTap
->dotted_name
);
485 if (w
> (jim_wide
) (8 * sizeof(pTap
->ir_capture_value
)))
487 LOG_WARNING("%s: huge IR length %d",
488 pTap
->dotted_name
, (int) w
);
492 case NTAP_OPT_IRMASK
:
493 if (is_bad_irval(pTap
->ir_length
, w
))
495 LOG_ERROR("%s: IR mask %x too big",
501 LOG_WARNING("%s: nonstandard IR mask", pTap
->dotted_name
);
502 pTap
->ir_capture_mask
= w
;
504 case NTAP_OPT_IRCAPTURE
:
505 if (is_bad_irval(pTap
->ir_length
, w
))
507 LOG_ERROR("%s: IR capture %x too big",
508 pTap
->dotted_name
, (int) w
);
512 LOG_WARNING("%s: nonstandard IR value",
514 pTap
->ir_capture_value
= w
;
522 static int jim_newtap_cmd(Jim_GetOptInfo
*goi
)
524 struct jtag_tap
*pTap
;
529 const Jim_Nvp opts
[] = {
530 { .name
= "-irlen" , .value
= NTAP_OPT_IRLEN
},
531 { .name
= "-irmask" , .value
= NTAP_OPT_IRMASK
},
532 { .name
= "-ircapture" , .value
= NTAP_OPT_IRCAPTURE
},
533 { .name
= "-enable" , .value
= NTAP_OPT_ENABLED
},
534 { .name
= "-disable" , .value
= NTAP_OPT_DISABLED
},
535 { .name
= "-expected-id" , .value
= NTAP_OPT_EXPECTED_ID
},
536 { .name
= "-ignore-version" , .value
= NTAP_OPT_VERSION
},
537 { .name
= NULL
, .value
= -1 },
540 pTap
= calloc(1, sizeof(struct jtag_tap
));
542 Jim_SetResult_sprintf(goi
->interp
, "no memory");
547 * we expect CHIP + TAP + OPTIONS
550 Jim_SetResult_sprintf(goi
->interp
, "Missing CHIP TAP OPTIONS ....");
554 Jim_GetOpt_String(goi
, &cp
, NULL
);
555 pTap
->chip
= strdup(cp
);
557 Jim_GetOpt_String(goi
, &cp
, NULL
);
558 pTap
->tapname
= strdup(cp
);
560 /* name + dot + name + null */
561 x
= strlen(pTap
->chip
) + 1 + strlen(pTap
->tapname
) + 1;
563 sprintf(cp
, "%s.%s", pTap
->chip
, pTap
->tapname
);
564 pTap
->dotted_name
= cp
;
566 LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
567 pTap
->chip
, pTap
->tapname
, pTap
->dotted_name
, goi
->argc
);
569 /* IEEE specifies that the two LSBs of an IR scan are 01, so make
570 * that the default. The "-irlen" and "-irmask" options are only
571 * needed to cope with nonstandard TAPs, or to specify more bits.
573 pTap
->ir_capture_mask
= 0x03;
574 pTap
->ir_capture_value
= 0x01;
577 e
= Jim_GetOpt_Nvp(goi
, opts
, &n
);
579 Jim_GetOpt_NvpUnknown(goi
, opts
, 0);
580 free((void *)pTap
->dotted_name
);
584 LOG_DEBUG("Processing option: %s", n
->name
);
586 case NTAP_OPT_ENABLED
:
587 pTap
->disabled_after_reset
= false;
589 case NTAP_OPT_DISABLED
:
590 pTap
->disabled_after_reset
= true;
592 case NTAP_OPT_EXPECTED_ID
:
593 e
= jim_newtap_expected_id(n
, goi
, pTap
);
596 free((void *)pTap
->dotted_name
);
602 case NTAP_OPT_IRMASK
:
603 case NTAP_OPT_IRCAPTURE
:
604 e
= jim_newtap_ir_param(n
, goi
, pTap
);
607 free((void *)pTap
->dotted_name
);
612 case NTAP_OPT_VERSION
:
613 pTap
->ignore_version
= true;
615 } /* switch (n->value) */
616 } /* while (goi->argc) */
618 /* default is enabled-after-reset */
619 pTap
->enabled
= !pTap
->disabled_after_reset
;
621 /* Did all the required option bits get cleared? */
622 if (pTap
->ir_length
!= 0)
628 Jim_SetResult_sprintf(goi
->interp
,
629 "newtap: %s missing IR length",
635 static void jtag_tap_handle_event(struct jtag_tap
*tap
, enum jtag_event e
)
637 struct jtag_tap_event_action
* jteap
;
639 for (jteap
= tap
->event_action
; jteap
!= NULL
; jteap
= jteap
->next
)
641 if (jteap
->event
!= e
)
644 Jim_Nvp
*nvp
= Jim_Nvp_value2name_simple(nvp_jtag_tap_event
, e
);
645 LOG_DEBUG("JTAG tap: %s event: %d (%s)\n\taction: %s",
646 tap
->dotted_name
, e
, nvp
->name
,
647 Jim_GetString(jteap
->body
, NULL
));
649 if (Jim_EvalObj(jteap
->interp
, jteap
->body
) != JIM_OK
)
651 Jim_PrintErrorMessage(jteap
->interp
);
657 case JTAG_TAP_EVENT_ENABLE
:
658 case JTAG_TAP_EVENT_DISABLE
:
659 /* NOTE: we currently assume the handlers
660 * can't fail. Right here is where we should
661 * really be verifying the scan chains ...
663 tap
->enabled
= (e
== JTAG_TAP_EVENT_ENABLE
);
664 LOG_INFO("JTAG tap: %s %s", tap
->dotted_name
,
665 tap
->enabled
? "enabled" : "disabled");
674 jim_jtag_interface(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
677 Jim_GetOpt_Setup(&goi
, interp
, argc
-1, argv
+ 1);
679 /* return the name of the interface */
680 /* TCL code might need to know the exact type... */
681 /* FUTURE: we allow this as a means to "set" the interface. */
683 Jim_WrongNumArgs(goi
.interp
, 1, goi
.argv
-1, "(no params)");
686 const char *name
= jtag_interface
? jtag_interface
->name
: NULL
;
687 Jim_SetResultString(goi
.interp
, name
? : "undefined", -1);
691 static int jim_jtag_arp_init(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
694 Jim_GetOpt_Setup(&goi
, interp
, argc
-1, argv
+ 1);
696 Jim_WrongNumArgs(goi
.interp
, 1, goi
.argv
-1, "(no params)");
699 struct command_context
*context
= Jim_GetAssocData(interp
, "context");
700 int e
= jtag_init_inner(context
);
702 Jim_SetResult_sprintf(goi
.interp
, "error: %d", e
);
708 static int jim_jtag_arp_init_reset(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
711 Jim_GetOpt_Setup(&goi
, interp
, argc
-1, argv
+ 1);
713 Jim_WrongNumArgs(goi
.interp
, 1, goi
.argv
-1, "(no params)");
716 struct command_context
*context
= Jim_GetAssocData(interp
, "context");
717 int e
= jtag_init_reset(context
);
719 Jim_SetResult_sprintf(goi
.interp
, "error: %d", e
);
725 static int jim_jtag_newtap(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
728 Jim_GetOpt_Setup(&goi
, interp
, argc
-1, argv
+ 1);
729 return jim_newtap_cmd(&goi
);
732 static bool jtag_tap_enable(struct jtag_tap
*t
)
736 jtag_tap_handle_event(t
, JTAG_TAP_EVENT_ENABLE
);
740 /* FIXME add JTAG sanity checks, w/o TLR
741 * - scan chain length grew by one (this)
742 * - IDs and IR lengths are as expected
744 jtag_call_event_callbacks(JTAG_TAP_EVENT_ENABLE
);
747 static bool jtag_tap_disable(struct jtag_tap
*t
)
751 jtag_tap_handle_event(t
, JTAG_TAP_EVENT_DISABLE
);
755 /* FIXME add JTAG sanity checks, w/o TLR
756 * - scan chain length shrank by one (this)
757 * - IDs and IR lengths are as expected
759 jtag_call_event_callbacks(JTAG_TAP_EVENT_DISABLE
);
763 static int jim_jtag_tap_enabler(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
765 const char *cmd_name
= Jim_GetString(argv
[0], NULL
);
767 Jim_GetOpt_Setup(&goi
, interp
, argc
-1, argv
+ 1);
769 Jim_SetResult_sprintf(goi
.interp
, "usage: %s <name>", cmd_name
);
775 t
= jtag_tap_by_jim_obj(goi
.interp
, goi
.argv
[0]);
779 if (strcasecmp(cmd_name
, "tapisenabled") == 0) {
780 // do nothing, just return the value
781 } else if (strcasecmp(cmd_name
, "tapenable") == 0) {
782 if (!jtag_tap_enable(t
))
783 LOG_WARNING("failed to disable tap");
784 } else if (strcasecmp(cmd_name
, "tapdisable") == 0) {
785 if (!jtag_tap_disable(t
))
786 LOG_WARNING("failed to disable tap");
788 LOG_ERROR("command '%s' unknown", cmd_name
);
792 Jim_SetResult(goi
.interp
, Jim_NewIntObj(goi
.interp
, e
));
796 static int jim_jtag_configure(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
798 const char *cmd_name
= Jim_GetString(argv
[0], NULL
);
800 Jim_GetOpt_Setup(&goi
, interp
, argc
-1, argv
+ 1);
801 goi
.isconfigure
= !strcmp(cmd_name
, "configure");
802 if (goi
.argc
< 2 + goi
.isconfigure
) {
803 Jim_WrongNumArgs(goi
.interp
, 0, NULL
,
804 "<tap_name> <attribute> ...");
811 Jim_GetOpt_Obj(&goi
, &o
);
812 t
= jtag_tap_by_jim_obj(goi
.interp
, o
);
817 return jtag_tap_configure_cmd(&goi
, t
);
820 static int jim_jtag_names(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
823 Jim_GetOpt_Setup(&goi
, interp
, argc
-1, argv
+ 1);
825 Jim_WrongNumArgs(goi
.interp
, 1, goi
.argv
, "Too many parameters");
828 Jim_SetResult(goi
.interp
, Jim_NewListObj(goi
.interp
, NULL
, 0));
829 struct jtag_tap
*tap
;
831 for (tap
= jtag_all_taps(); tap
; tap
= tap
->next_tap
) {
832 Jim_ListAppendElement(goi
.interp
,
833 Jim_GetResult(goi
.interp
),
834 Jim_NewStringObj(goi
.interp
,
835 tap
->dotted_name
, -1));
840 COMMAND_HANDLER(handle_jtag_init_command
)
843 return ERROR_COMMAND_SYNTAX_ERROR
;
845 static bool jtag_initialized
= false;
846 if (jtag_initialized
)
848 LOG_INFO("'jtag init' has already been called");
851 jtag_initialized
= true;
853 LOG_DEBUG("Initializing jtag devices...");
854 return jtag_init(CMD_CTX
);
857 static const struct command_registration jtag_subcommand_handlers
[] = {
861 .handler
= handle_jtag_init_command
,
862 .help
= "initialize jtag scan chain",
867 .jim_handler
= jim_jtag_interface
,
868 .help
= "Returns the name of the currently selected interface.",
873 .jim_handler
= jim_jtag_arp_init
,
874 .help
= "Validates JTAG scan chain against the list of "
875 "declared TAPs using just the four standard JTAG "
879 .name
= "arp_init-reset",
881 .jim_handler
= jim_jtag_arp_init_reset
,
882 .help
= "Uses TRST and SRST to try resetting everything on "
883 "the JTAG scan chain, then performs 'jtag arp_init'."
887 .mode
= COMMAND_CONFIG
,
888 .jim_handler
= jim_jtag_newtap
,
889 .help
= "Create a new TAP instance named basename.tap_type, "
890 "and appends it to the scan chain.",
891 .usage
= "basename tap_type '-irlen' count "
892 "['-enable'|'-disable'] "
893 "['-expected_id' number] "
894 "['-ignore-version'] "
895 "['-ircapture' number] "
899 .name
= "tapisenabled",
900 .mode
= COMMAND_EXEC
,
901 .jim_handler
= jim_jtag_tap_enabler
,
902 .help
= "Returns a Tcl boolean (0/1) indicating whether "
903 "the TAP is enabled (1) or not (0).",
908 .mode
= COMMAND_EXEC
,
909 .jim_handler
= jim_jtag_tap_enabler
,
910 .help
= "Try to enable the specified TAP using the "
911 "'tap-enable' TAP event.",
915 .name
= "tapdisable",
916 .mode
= COMMAND_EXEC
,
917 .jim_handler
= jim_jtag_tap_enabler
,
918 .help
= "Try to disable the specified TAP using the "
919 "'tap-disable' TAP event.",
924 .mode
= COMMAND_EXEC
,
925 .jim_handler
= jim_jtag_configure
,
926 .help
= "Provide a Tcl handler for the specified "
928 .usage
= "tap_name '-event' event_name handler",
932 .mode
= COMMAND_EXEC
,
933 .jim_handler
= jim_jtag_configure
,
934 .help
= "Return any Tcl handler for the specified "
936 .usage
= "tap_name '-event' event_name",
941 .jim_handler
= jim_jtag_names
,
942 .help
= "Returns list of all JTAG tap names.",
945 .chain
= jtag_command_handlers_to_move
,
947 COMMAND_REGISTRATION_DONE
950 void jtag_notify_event(enum jtag_event event
)
952 struct jtag_tap
*tap
;
954 for (tap
= jtag_all_taps(); tap
; tap
= tap
->next_tap
)
955 jtag_tap_handle_event(tap
, event
);
959 static int default_khz(int khz
, int *jtag_speed
)
961 LOG_ERROR("Translation from khz to jtag_speed not implemented");
965 static int default_speed_div(int speed
, int *khz
)
967 LOG_ERROR("Translation from jtag_speed to khz not implemented");
971 static int default_power_dropout(int *dropout
)
973 *dropout
= 0; /* by default we can't detect power dropout */
977 static int default_srst_asserted(int *srst_asserted
)
979 *srst_asserted
= 0; /* by default we can't detect srst asserted */
983 COMMAND_HANDLER(handle_interface_list_command
)
985 if (strcmp(CMD_NAME
, "interface_list") == 0 && CMD_ARGC
> 0)
986 return ERROR_COMMAND_SYNTAX_ERROR
;
988 command_print(CMD_CTX
, "The following debug interfaces are available:");
989 for (unsigned i
= 0; NULL
!= jtag_interfaces
[i
]; i
++)
991 const char *name
= jtag_interfaces
[i
]->name
;
992 command_print(CMD_CTX
, "%u: %s", i
+ 1, name
);
998 COMMAND_HANDLER(handle_interface_command
)
1000 /* check whether the interface is already configured */
1003 LOG_WARNING("Interface already configured, ignoring");
1007 /* interface name is a mandatory argument */
1008 if (CMD_ARGC
!= 1 || CMD_ARGV
[0][0] == '\0')
1009 return ERROR_COMMAND_SYNTAX_ERROR
;
1011 for (unsigned i
= 0; NULL
!= jtag_interfaces
[i
]; i
++)
1013 if (strcmp(CMD_ARGV
[0], jtag_interfaces
[i
]->name
) != 0)
1016 if (NULL
!= jtag_interfaces
[i
]->commands
)
1018 int retval
= register_commands(CMD_CTX
, NULL
,
1019 jtag_interfaces
[i
]->commands
);
1020 if (ERROR_OK
!= retval
)
1024 jtag_interface
= jtag_interfaces
[i
];
1026 if (jtag_interface
->khz
== NULL
)
1027 jtag_interface
->khz
= default_khz
;
1028 if (jtag_interface
->speed_div
== NULL
)
1029 jtag_interface
->speed_div
= default_speed_div
;
1030 if (jtag_interface
->power_dropout
== NULL
)
1031 jtag_interface
->power_dropout
= default_power_dropout
;
1032 if (jtag_interface
->srst_asserted
== NULL
)
1033 jtag_interface
->srst_asserted
= default_srst_asserted
;
1038 /* no valid interface was found (i.e. the configuration option,
1039 * didn't match one of the compiled-in interfaces
1041 LOG_ERROR("The specified debug interface was not found (%s)", CMD_ARGV
[0]);
1042 CALL_COMMAND_HANDLER(handle_interface_list_command
);
1043 return ERROR_JTAG_INVALID_INTERFACE
;
1046 COMMAND_HANDLER(handle_scan_chain_command
)
1048 struct jtag_tap
*tap
;
1049 char expected_id
[12];
1051 tap
= jtag_all_taps();
1052 command_print(CMD_CTX
,
1053 " TapName Enabled IdCode Expected IrLen IrCap IrMask");
1054 command_print(CMD_CTX
,
1055 "-- ------------------- -------- ---------- ---------- ----- ----- ------");
1058 uint32_t expected
, expected_mask
, ii
;
1060 snprintf(expected_id
, sizeof expected_id
, "0x%08x",
1061 (unsigned)((tap
->expected_ids_cnt
> 0)
1062 ? tap
->expected_ids
[0]
1064 if (tap
->ignore_version
)
1065 expected_id
[2] = '*';
1067 expected
= buf_get_u32(tap
->expected
, 0, tap
->ir_length
);
1068 expected_mask
= buf_get_u32(tap
->expected_mask
, 0, tap
->ir_length
);
1070 command_print(CMD_CTX
,
1071 "%2d %-18s %c 0x%08x %s %5d 0x%02x 0x%02x",
1072 tap
->abs_chain_position
,
1074 tap
->enabled
? 'Y' : 'n',
1075 (unsigned int)(tap
->idcode
),
1077 (unsigned int)(tap
->ir_length
),
1078 (unsigned int)(expected
),
1079 (unsigned int)(expected_mask
));
1081 for (ii
= 1; ii
< tap
->expected_ids_cnt
; ii
++) {
1082 snprintf(expected_id
, sizeof expected_id
, "0x%08x",
1083 (unsigned) tap
->expected_ids
[1]);
1084 if (tap
->ignore_version
)
1085 expected_id
[2] = '*';
1087 command_print(CMD_CTX
,
1092 tap
= tap
->next_tap
;
1098 COMMAND_HANDLER(handle_reset_config_command
)
1103 /* Original versions cared about the order of these tokens:
1104 * reset_config signals [combination [trst_type [srst_type]]]
1105 * They also clobbered the previous configuration even on error.
1107 * Here we don't care about the order, and only change values
1108 * which have been explicitly specified.
1110 for (; CMD_ARGC
; CMD_ARGC
--, CMD_ARGV
++) {
1115 m
= RESET_SRST_NO_GATING
;
1116 if (strcmp(*CMD_ARGV
, "srst_gates_jtag") == 0)
1117 /* default: don't use JTAG while SRST asserted */;
1118 else if (strcmp(*CMD_ARGV
, "srst_nogate") == 0)
1119 tmp
= RESET_SRST_NO_GATING
;
1123 LOG_ERROR("extra reset_config %s spec (%s)",
1124 "gating", *CMD_ARGV
);
1125 return ERROR_INVALID_ARGUMENTS
;
1131 m
= RESET_HAS_TRST
| RESET_HAS_SRST
;
1132 if (strcmp(*CMD_ARGV
, "none") == 0)
1134 else if (strcmp(*CMD_ARGV
, "trst_only") == 0)
1135 tmp
= RESET_HAS_TRST
;
1136 else if (strcmp(*CMD_ARGV
, "srst_only") == 0)
1137 tmp
= RESET_HAS_SRST
;
1138 else if (strcmp(*CMD_ARGV
, "trst_and_srst") == 0)
1139 tmp
= RESET_HAS_TRST
| RESET_HAS_SRST
;
1143 LOG_ERROR("extra reset_config %s spec (%s)",
1144 "signal", *CMD_ARGV
);
1145 return ERROR_INVALID_ARGUMENTS
;
1150 /* combination (options for broken wiring) */
1151 m
= RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
;
1152 if (strcmp(*CMD_ARGV
, "separate") == 0)
1153 /* separate reset lines - default */;
1154 else if (strcmp(*CMD_ARGV
, "srst_pulls_trst") == 0)
1155 tmp
|= RESET_SRST_PULLS_TRST
;
1156 else if (strcmp(*CMD_ARGV
, "trst_pulls_srst") == 0)
1157 tmp
|= RESET_TRST_PULLS_SRST
;
1158 else if (strcmp(*CMD_ARGV
, "combined") == 0)
1159 tmp
|= RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
;
1163 LOG_ERROR("extra reset_config %s spec (%s)",
1164 "combination", *CMD_ARGV
);
1165 return ERROR_INVALID_ARGUMENTS
;
1170 /* trst_type (NOP without HAS_TRST) */
1171 m
= RESET_TRST_OPEN_DRAIN
;
1172 if (strcmp(*CMD_ARGV
, "trst_open_drain") == 0)
1173 tmp
|= RESET_TRST_OPEN_DRAIN
;
1174 else if (strcmp(*CMD_ARGV
, "trst_push_pull") == 0)
1175 /* push/pull from adapter - default */;
1179 LOG_ERROR("extra reset_config %s spec (%s)",
1180 "trst_type", *CMD_ARGV
);
1181 return ERROR_INVALID_ARGUMENTS
;
1186 /* srst_type (NOP without HAS_SRST) */
1187 m
|= RESET_SRST_PUSH_PULL
;
1188 if (strcmp(*CMD_ARGV
, "srst_push_pull") == 0)
1189 tmp
|= RESET_SRST_PUSH_PULL
;
1190 else if (strcmp(*CMD_ARGV
, "srst_open_drain") == 0)
1191 /* open drain from adapter - default */;
1195 LOG_ERROR("extra reset_config %s spec (%s)",
1196 "srst_type", *CMD_ARGV
);
1197 return ERROR_INVALID_ARGUMENTS
;
1202 /* caller provided nonsense; fail */
1203 LOG_ERROR("unknown reset_config flag (%s)", *CMD_ARGV
);
1204 return ERROR_INVALID_ARGUMENTS
;
1207 /* Remember the bits which were specified (mask)
1208 * and their new values (new_cfg).
1214 /* clear previous values of those bits, save new values */
1216 int old_cfg
= jtag_get_reset_config();
1220 jtag_set_reset_config(new_cfg
);
1222 new_cfg
= jtag_get_reset_config();
1226 * Display the (now-)current reset mode
1230 /* minimal JTAG has neither SRST nor TRST (so that's the default) */
1231 switch (new_cfg
& (RESET_HAS_TRST
| RESET_HAS_SRST
)) {
1232 case RESET_HAS_SRST
:
1233 modes
[0] = "srst_only";
1235 case RESET_HAS_TRST
:
1236 modes
[0] = "trst_only";
1238 case RESET_TRST_AND_SRST
:
1239 modes
[0] = "trst_and_srst";
1246 /* normally SRST and TRST are decoupled; but bugs happen ... */
1247 switch (new_cfg
& (RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
)) {
1248 case RESET_SRST_PULLS_TRST
:
1249 modes
[1] = "srst_pulls_trst";
1251 case RESET_TRST_PULLS_SRST
:
1252 modes
[1] = "trst_pulls_srst";
1254 case RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
:
1255 modes
[1] = "combined";
1258 modes
[1] = "separate";
1262 /* TRST-less connectors include Altera, Xilinx, and minimal JTAG */
1263 if (new_cfg
& RESET_HAS_TRST
) {
1264 if (new_cfg
& RESET_TRST_OPEN_DRAIN
)
1265 modes
[3] = " trst_open_drain";
1267 modes
[3] = " trst_push_pull";
1271 /* SRST-less connectors include TI-14, Xilinx, and minimal JTAG */
1272 if (new_cfg
& RESET_HAS_SRST
) {
1273 if (new_cfg
& RESET_SRST_NO_GATING
)
1274 modes
[2] = " srst_nogate";
1276 modes
[2] = " srst_gates_jtag";
1278 if (new_cfg
& RESET_SRST_PUSH_PULL
)
1279 modes
[4] = " srst_push_pull";
1281 modes
[4] = " srst_open_drain";
1287 command_print(CMD_CTX
, "%s %s%s%s%s",
1289 modes
[2], modes
[3], modes
[4]);
1294 COMMAND_HANDLER(handle_adapter_nsrst_delay_command
)
1297 return ERROR_COMMAND_SYNTAX_ERROR
;
1301 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], delay
);
1303 jtag_set_nsrst_delay(delay
);
1305 command_print(CMD_CTX
, "adapter_nsrst_delay: %u", jtag_get_nsrst_delay());
1309 COMMAND_HANDLER(handle_jtag_ntrst_delay_command
)
1312 return ERROR_COMMAND_SYNTAX_ERROR
;
1316 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], delay
);
1318 jtag_set_ntrst_delay(delay
);
1320 command_print(CMD_CTX
, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay());
1324 COMMAND_HANDLER(handle_adapter_nsrst_assert_width_command
)
1327 return ERROR_COMMAND_SYNTAX_ERROR
;
1331 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], delay
);
1333 jtag_set_nsrst_assert_width(delay
);
1335 command_print(CMD_CTX
, "adapter_nsrst_assert_width: %u", jtag_get_nsrst_assert_width());
1339 COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command
)
1342 return ERROR_COMMAND_SYNTAX_ERROR
;
1346 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], delay
);
1348 jtag_set_ntrst_assert_width(delay
);
1350 command_print(CMD_CTX
, "jtag_ntrst_assert_width: %u", jtag_get_ntrst_assert_width());
1354 COMMAND_HANDLER(handle_adapter_khz_command
)
1357 return ERROR_COMMAND_SYNTAX_ERROR
;
1359 int retval
= ERROR_OK
;
1363 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], khz
);
1365 retval
= jtag_config_khz(khz
);
1366 if (ERROR_OK
!= retval
)
1370 int cur_speed
= jtag_get_speed_khz();
1371 retval
= jtag_get_speed_readable(&cur_speed
);
1372 if (ERROR_OK
!= retval
)
1376 command_print(CMD_CTX
, "%d kHz", cur_speed
);
1378 command_print(CMD_CTX
, "RCLK - adaptive");
1383 COMMAND_HANDLER(handle_jtag_rclk_command
)
1386 return ERROR_COMMAND_SYNTAX_ERROR
;
1388 int retval
= ERROR_OK
;
1392 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], khz
);
1394 retval
= jtag_config_rclk(khz
);
1395 if (ERROR_OK
!= retval
)
1399 int cur_khz
= jtag_get_speed_khz();
1400 retval
= jtag_get_speed_readable(&cur_khz
);
1401 if (ERROR_OK
!= retval
)
1405 command_print(CMD_CTX
, "RCLK not supported - fallback to %d kHz", cur_khz
);
1407 command_print(CMD_CTX
, "RCLK - adaptive");
1412 COMMAND_HANDLER(handle_jtag_reset_command
)
1415 return ERROR_COMMAND_SYNTAX_ERROR
;
1418 if (CMD_ARGV
[0][0] == '1')
1420 else if (CMD_ARGV
[0][0] == '0')
1423 return ERROR_COMMAND_SYNTAX_ERROR
;
1426 if (CMD_ARGV
[1][0] == '1')
1428 else if (CMD_ARGV
[1][0] == '0')
1431 return ERROR_COMMAND_SYNTAX_ERROR
;
1433 if (adapter_init(CMD_CTX
) != ERROR_OK
)
1434 return ERROR_JTAG_INIT_FAILED
;
1436 jtag_add_reset(trst
, srst
);
1437 return jtag_execute_queue();
1440 COMMAND_HANDLER(handle_runtest_command
)
1443 return ERROR_COMMAND_SYNTAX_ERROR
;
1445 unsigned num_clocks
;
1446 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], num_clocks
);
1448 jtag_add_runtest(num_clocks
, TAP_IDLE
);
1449 return jtag_execute_queue();
1453 * For "irscan" or "drscan" commands, the "end" (really, "next") state
1454 * should be stable ... and *NOT* a shift state, otherwise free-running
1455 * jtag clocks could change the values latched by the update state.
1456 * Not surprisingly, this is the same constraint as SVF; the "irscan"
1457 * and "drscan" commands are a write-only subset of what SVF provides.
1460 COMMAND_HANDLER(handle_irscan_command
)
1463 struct scan_field
*fields
;
1464 struct jtag_tap
*tap
= NULL
;
1465 tap_state_t endstate
;
1467 if ((CMD_ARGC
< 2) || (CMD_ARGC
% 2))
1469 return ERROR_COMMAND_SYNTAX_ERROR
;
1472 /* optional "-endstate" "statename" at the end of the arguments,
1473 * so that e.g. IRPAUSE can let us load the data register before
1474 * entering RUN/IDLE to execute the instruction we load here.
1476 endstate
= TAP_IDLE
;
1478 if (CMD_ARGC
>= 4) {
1479 /* have at least one pair of numbers. */
1480 /* is last pair the magic text? */
1481 if (strcmp("-endstate", CMD_ARGV
[CMD_ARGC
- 2]) == 0) {
1482 endstate
= tap_state_by_name(CMD_ARGV
[CMD_ARGC
- 1]);
1483 if (endstate
== TAP_INVALID
)
1484 return ERROR_COMMAND_SYNTAX_ERROR
;
1485 if (!scan_is_safe(endstate
))
1486 LOG_WARNING("unstable irscan endstate \"%s\"",
1487 CMD_ARGV
[CMD_ARGC
- 1]);
1492 int num_fields
= CMD_ARGC
/ 2;
1495 /* we really should be looking at plain_ir_scan if we want
1496 * anything more fancy.
1498 LOG_ERROR("Specify a single value for tap");
1499 return ERROR_COMMAND_SYNTAX_ERROR
;
1502 size_t fields_len
= sizeof(struct scan_field
) * num_fields
;
1503 fields
= malloc(fields_len
);
1504 memset(fields
, 0, fields_len
);
1507 for (i
= 0; i
< num_fields
; i
++)
1509 tap
= jtag_tap_by_string(CMD_ARGV
[i
*2]);
1513 for (j
= 0; j
< i
; j
++)
1514 free(fields
[j
].out_value
);
1516 command_print(CMD_CTX
, "Tap: %s unknown", CMD_ARGV
[i
*2]);
1520 int field_size
= tap
->ir_length
;
1521 fields
[i
].num_bits
= field_size
;
1522 fields
[i
].out_value
= malloc(DIV_ROUND_UP(field_size
, 8));
1525 retval
= parse_u32(CMD_ARGV
[i
* 2 + 1], &value
);
1526 if (ERROR_OK
!= retval
)
1528 buf_set_u32(fields
[i
].out_value
, 0, field_size
, value
);
1529 fields
[i
].in_value
= NULL
;
1532 /* did we have an endstate? */
1533 jtag_add_ir_scan(tap
, fields
, endstate
);
1535 retval
= jtag_execute_queue();
1538 for (i
= 0; i
< num_fields
; i
++)
1540 if (NULL
!= fields
[i
].out_value
)
1541 free(fields
[i
].out_value
);
1550 COMMAND_HANDLER(handle_verify_ircapture_command
)
1553 return ERROR_COMMAND_SYNTAX_ERROR
;
1558 COMMAND_PARSE_ENABLE(CMD_ARGV
[0], enable
);
1559 jtag_set_verify_capture_ir(enable
);
1562 const char *status
= jtag_will_verify_capture_ir() ? "enabled": "disabled";
1563 command_print(CMD_CTX
, "verify Capture-IR is %s", status
);
1568 COMMAND_HANDLER(handle_verify_jtag_command
)
1571 return ERROR_COMMAND_SYNTAX_ERROR
;
1576 COMMAND_PARSE_ENABLE(CMD_ARGV
[0], enable
);
1577 jtag_set_verify(enable
);
1580 const char *status
= jtag_will_verify() ? "enabled": "disabled";
1581 command_print(CMD_CTX
, "verify jtag capture is %s", status
);
1586 COMMAND_HANDLER(handle_tms_sequence_command
)
1589 return ERROR_COMMAND_SYNTAX_ERROR
;
1594 if (strcmp(CMD_ARGV
[0], "short") == 0)
1595 use_new_table
= true;
1596 else if (strcmp(CMD_ARGV
[0], "long") == 0)
1597 use_new_table
= false;
1599 return ERROR_COMMAND_SYNTAX_ERROR
;
1601 tap_use_new_tms_table(use_new_table
);
1604 command_print(CMD_CTX
, "tms sequence is %s",
1605 tap_uses_new_tms_table() ? "short": "long");
1610 static const struct command_registration interface_command_handlers
[] = {
1612 .name
= "adapter_khz",
1613 .handler
= handle_adapter_khz_command
,
1614 .mode
= COMMAND_ANY
,
1615 .help
= "With an argument, change to the specified maximum "
1616 "jtag speed. For JTAG, 0 KHz signifies adaptive "
1618 "With or without argument, display current setting.",
1622 .name
= "adapter_nsrst_assert_width",
1623 .handler
= handle_adapter_nsrst_assert_width_command
,
1624 .mode
= COMMAND_ANY
,
1625 .help
= "delay after asserting SRST in ms",
1626 .usage
= "[milliseconds]",
1629 .name
= "adapter_nsrst_delay",
1630 .handler
= handle_adapter_nsrst_delay_command
,
1631 .mode
= COMMAND_ANY
,
1632 .help
= "delay after deasserting SRST in ms",
1633 .usage
= "[milliseconds]",
1636 .name
= "interface",
1637 .handler
= handle_interface_command
,
1638 .mode
= COMMAND_CONFIG
,
1639 .help
= "Select a debug adapter interface (driver)",
1640 .usage
= "driver_name",
1643 .name
= "interface_list",
1644 .handler
= handle_interface_list_command
,
1645 .mode
= COMMAND_ANY
,
1646 .help
= "List all built-in debug adapter interfaces (drivers)",
1648 COMMAND_REGISTRATION_DONE
1652 * Register the commands which deal with arbitrary debug adapter drivers.
1654 * @todo Remove internal assumptions that all debug adapters use JTAG for
1655 * transport. Various types and data structures are not named generically.
1657 int interface_register_commands(struct command_context
*ctx
)
1659 return register_commands(ctx
, NULL
, interface_command_handlers
);
1662 static const struct command_registration jtag_command_handlers
[] = {
1664 .name
= "jtag_rclk",
1665 .handler
= handle_jtag_rclk_command
,
1666 .mode
= COMMAND_ANY
,
1667 .help
= "With an argument, change to to use adaptive clocking "
1668 "if possible; else to use the fallback speed. "
1669 "With or without argument, display current setting.",
1670 .usage
= "[fallback_speed_khz]",
1673 .name
= "reset_config",
1674 .handler
= handle_reset_config_command
,
1675 .mode
= COMMAND_ANY
,
1676 .help
= "configure JTAG reset behavior",
1677 .usage
= "[none|trst_only|srst_only|trst_and_srst] "
1678 "[srst_pulls_trst|trst_pulls_srst|combined|separate] "
1679 "[srst_gates_jtag|srst_nogate] "
1680 "[trst_push_pull|trst_open_drain] "
1681 "[srst_push_pull|srst_open_drain]",
1684 .name
= "jtag_ntrst_delay",
1685 .handler
= handle_jtag_ntrst_delay_command
,
1686 .mode
= COMMAND_ANY
,
1687 .help
= "delay after deasserting trst in ms",
1688 .usage
= "[milliseconds]",
1691 .name
= "jtag_ntrst_assert_width",
1692 .handler
= handle_jtag_ntrst_assert_width_command
,
1693 .mode
= COMMAND_ANY
,
1694 .help
= "delay after asserting trst in ms",
1695 .usage
= "[milliseconds]",
1698 .name
= "scan_chain",
1699 .handler
= handle_scan_chain_command
,
1700 .mode
= COMMAND_ANY
,
1701 .help
= "print current scan chain configuration",
1704 .name
= "jtag_reset",
1705 .handler
= handle_jtag_reset_command
,
1706 .mode
= COMMAND_EXEC
,
1707 .help
= "Set reset line values. Value '1' is active, "
1708 "value '0' is inactive.",
1709 .usage
= "trst_active srst_active",
1713 .handler
= handle_runtest_command
,
1714 .mode
= COMMAND_EXEC
,
1715 .help
= "Move to Run-Test/Idle, and issue TCK for num_cycles.",
1716 .usage
= "num_cycles"
1720 .handler
= handle_irscan_command
,
1721 .mode
= COMMAND_EXEC
,
1722 .help
= "Execute Instruction Register (DR) scan. The "
1723 "specified opcodes are put into each TAP's IR, "
1724 "and other TAPs are put in BYPASS.",
1725 .usage
= "[tap_name instruction]* ['-endstate' state_name]",
1728 .name
= "verify_ircapture",
1729 .handler
= handle_verify_ircapture_command
,
1730 .mode
= COMMAND_ANY
,
1731 .help
= "Display or assign flag controlling whether to "
1732 "verify values captured during Capture-IR.",
1733 .usage
= "['enable'|'disable']",
1736 .name
= "verify_jtag",
1737 .handler
= handle_verify_jtag_command
,
1738 .mode
= COMMAND_ANY
,
1739 .help
= "Display or assign flag controlling whether to "
1740 "verify values captured during IR and DR scans.",
1741 .usage
= "['enable'|'disable']",
1744 .name
= "tms_sequence",
1745 .handler
= handle_tms_sequence_command
,
1746 .mode
= COMMAND_ANY
,
1747 .help
= "Display or change what style TMS sequences to use "
1748 "for JTAG state transitions: short (default) or "
1749 "long. Only for working around JTAG bugs.",
1750 /* Specifically for working around DRIVER bugs... */
1751 .usage
= "['short'|'long']",
1755 .mode
= COMMAND_ANY
,
1756 .help
= "perform jtag tap actions",
1758 .chain
= jtag_subcommand_handlers
,
1761 .chain
= jtag_command_handlers_to_move
,
1763 COMMAND_REGISTRATION_DONE
1766 int jtag_register_commands(struct command_context
*cmd_ctx
)
1768 return register_commands(cmd_ctx
, NULL
, jtag_command_handlers
);