* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
+ * Copyright (C) 2007,2008 Øyvind Harboe *
+ * oyvind.harboe@zylin.com *
+ * *
+ * Copyright (C) 2008 Peter Hettkamp *
+ * peter.hettkamp@htp-tel.de *
+ * *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
if ((state != TAP_TLR) && (state == cmd_queue_cur_state))
return;
+ if(state==TAP_TLR)
+ {
+ jtag_add_tlr();
+ return;
+ }
for (i=0; i<7; i++)
{
int j = (move >> i) & 1;
int runtest_requires_tck = 0;
- int device = -1; /* use -1 to indicate a "plain" xsvf file which accounts for additional devices in the scan chain, otherwise the device that should be affected */
+ jtag_tap_t *tap = NULL;
+ /* use NULL to indicate a "plain" xsvf file which accounts for
+ additional devices in the scan chain, otherwise the device
+ that should be affected */
if (argc < 2)
{
if (strcmp(args[0], "plain") != 0)
{
- device = strtoul(args[0], NULL, 0);
+ tap = jtag_TapByString( args[0] );
+ if( !tap ){
+ command_print( cmd_ctx, "Tap: %s unknown", args[0] );
+ return ERROR_OK;
+ }
}
if ((xsvf_fd = open(args[1], O_RDONLY)) < 0)
else
{
scan_field_t field;
- field.device = device;
+ field.tap = tap;
field.num_bits = c;
field.out_value = ir_buf;
field.out_mask = NULL;
field.in_check_mask = NULL;
field.in_handler = NULL;
field.in_handler_priv = NULL;
- if (device == -1)
+ if (tap == NULL)
jtag_add_plain_ir_scan(1, &field, TAP_PI);
else
jtag_add_ir_scan(1, &field, TAP_PI);
else
{
scan_field_t field;
- field.device = device;
+ field.tap = tap;
field.num_bits = xsdrsize;
field.out_value = dr_out_buf;
field.out_mask = NULL;
field.in_value = NULL;
jtag_set_check_value(&field, dr_in_buf, dr_in_mask, NULL);
- if (device == -1)
+ if (tap == NULL)
jtag_add_plain_dr_scan(1, &field, TAP_PD);
else
jtag_add_dr_scan(1, &field, TAP_PD);
else
{
scan_field_t field;
- field.device = device;
+ field.tap = tap;
field.num_bits = xsdrsize;
field.out_value = dr_out_buf;
field.out_mask = NULL;
field.in_value = NULL;
jtag_set_check_value(&field, dr_in_buf, dr_in_mask, NULL);
- if (device == -1)
+ if (tap == NULL)
jtag_add_plain_dr_scan(1, &field, TAP_PD);
else
jtag_add_dr_scan(1, &field, TAP_PD);
do_abort = 1;
else
{
- jtag_add_pathmove(path_len, path);
+ int i,lasti;
+ /* here the trick is that jtag_add_pathmove() must end in a stable
+ state, so we must only invoke jtag_add_tlr() when we absolutely
+ have to
+ */
+ for(i=0,lasti=0;i<path_len;i++)
+ {
+ if(path[i]==TAP_TLR)
+ {
+ if(i>lasti)
+ {
+ jtag_add_pathmove(i-lasti,path+lasti);
+ }
+ lasti=i+1;
+ jtag_add_tlr();
+ }
+ }
+ if(i>=lasti)
+ {
+ jtag_add_pathmove(i-lasti, path+lasti);
+ }
}
free(path);
}
else
{
scan_field_t field;
- field.device = device;
+ field.tap = tap;
field.num_bits = us;
field.out_value = ir_buf;
field.out_mask = NULL;
field.in_check_mask = NULL;
field.in_handler = NULL;
field.in_handler_priv = NULL;
- if (device == -1)
+ if (tap == NULL)
jtag_add_plain_ir_scan(1, &field, xsvf_to_tap[xendir]);
else
jtag_add_ir_scan(1, &field, xsvf_to_tap[xendir]);