int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
-jtag_tap_t *jtag_AllTaps(void)
-{
- return jtag_all_taps;
+jtag_tap_t *jtag_AllTaps(void)
+{
+ return jtag_all_taps;
};
-int
+int
jtag_NumTotalTaps(void)
{
jtag_tap_t *t;
return n;
}
-jtag_tap_t *
-jtag_NextEnabledTap( jtag_tap_t *p )
-{
- if( p == NULL ){
- // start at the head of list
- p = jtag_AllTaps();
- } else {
- // start *after* this one
- p = p->next_tap;
- }
- while( p ){
- if( p->enabled ){
- break;
- } else {
- p = p->next_tap;
- }
- }
- return p;
-}
jtag_tap_t *jtag_TapByString( const char *s )
{
t = NULL;
} else {
t = jtag_TapByString( cp );
- }
+ }
if( t == NULL ){
Jim_SetResult_sprintf(interp,"Tap: %s is unknown", cp );
}
orig_n = n;
t = jtag_AllTaps();
-
+
while( t && (n > 0)) {
n--;
t = t->next_tap;
char *in_check_mask_char;
in_check_mask_char = buf_to_str(field->in_check_mask, (num_bits > 64) ? 64 : num_bits, 16);
LOG_WARNING("value captured during scan didn't pass the requested check:");
- LOG_WARNING("captured: 0x%s check_value: 0x%s check_mask: 0x%s",
+ LOG_WARNING("captured: 0x%s check_value: 0x%s check_mask: 0x%s",
captured_char, in_check_value_char, in_check_mask_char);
free(in_check_mask_char);
}
LOG_ERROR("JTAG: No taps enabled?");
return ERROR_JTAG_INIT_FAILED;
}
-
+
for (bit_count = 0; bit_count < (JTAG_MAX_CHAIN_SIZE * 32) - 31;)
{
u32 idcode = buf_get_u32(idcode_buffer, bit_count, 32);
}
} else {
#if 0
- LOG_INFO("JTAG TAP ID: 0x%08x - Unknown - please report (A) chipname and (B) idcode to the openocd project",
+ LOG_INFO("JTAG TAP ID: 0x%08x - Unknown - please report (A) chipname and (B) idcode to the openocd project",
tap->idcode);
#endif
}
if( tap == NULL ){
break;
}
-
+
if (buf_get_u32(ir_test, chain_pos, 2) != 0x1)
{
{ .name = NULL , .value = -1 },
};
-
+
pTap = malloc( sizeof(jtag_tap_t) );
memset( pTap, 0, sizeof(*pTap) );
if( !pTap ){
}
//
// we expect CHIP + TAP + OPTIONS
- //
+ //
if( goi->argc < 3 ){
Jim_SetResult_sprintf(goi->interp, "Missing CHIP TAP OPTIONS ....");
return JIM_ERR;
Jim_GetOpt_String( goi, &cp, NULL );
pTap->tapname = strdup(cp);
-
+
// name + dot + name + null
x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1;
cp = malloc( x );
sprintf( cp, "%s.%s", pTap->chip, pTap->tapname );
pTap->dotted_name = cp;
- LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
+ LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
pTap->chip, pTap->tapname, pTap->dotted_name, goi->argc);
-
+
// default is enabled
pTap->enabled = 1;
// clear them as we find them
reqbits = (NTREQ_IRLEN | NTREQ_IRCAPTURE | NTREQ_IRMASK);
-
+
while( goi->argc ){
e = Jim_GetOpt_Nvp( goi, opts, &n );
if( e != JIM_OK ){
}
if( (w < 0) || (w > 0xffff) ){
// wacky value
- Jim_SetResult_sprintf( goi->interp, "option: %s - wacky value: %d (0x%x)",
+ Jim_SetResult_sprintf( goi->interp, "option: %s - wacky value: %d (0x%x)",
n->name, (int)(w), (int)(w));
return JIM_ERR;
}
// Did we get all the options?
if( reqbits ){
- // no
+ // no
Jim_SetResult_sprintf( goi->interp,
- "newtap: %s missing required parameters",
+ "newtap: %s missing required parameters",
pTap->dotted_name);
// fixme: Tell user what is missing :-(
// no memory leaks pelase
pTap->ir_length,
pTap->ir_capture_value );
buf_set_u32( pTap->expected_mask,
- 0,
+ 0,
pTap->ir_length,
pTap->ir_capture_mask );
- buf_set_ones( pTap->cur_instr,
+ buf_set_ones( pTap->cur_instr,
pTap->ir_length );
pTap->bypass = 1;
jtag_register_event_callback(jtag_reset_callback, pTap );
-
+
ppTap = &(jtag_all_taps);
while( (*ppTap) != NULL ){
ppTap = &((*ppTap)->next_tap);
}
*ppTap = pTap;
- {
+ {
static int n_taps = 0;
pTap->abs_chain_position = n_taps++;
}
Jim_SetResultString( goi.interp, "Too many parameters",-1 );
return JIM_ERR;
}
-
- {
+
+ {
jtag_tap_t *t;
t = jtag_TapByJimObj( goi.interp, goi.argv[0] );
if( t == NULL ){
// argv[ 1] = ir capture
// argv[ 2] = ir mask
// argv[ 3] = not actually used by anything but in the docs
-
+
if( argc < 4 ){
command_print( cmd_ctx, "OLD DEPRECATED SYNTAX: Please use the NEW syntax");
return ERROR_OK;
command_print( cmd_ctx, "jtag newtap stm32 cortexm3 ....., thus creating the tap: \"stm32.cortexm3\"");
command_print( cmd_ctx, "jtag newtap stm32 boundry ....., and the tap: \"stm32.boundery\"");
command_print( cmd_ctx, "And then refer to the taps by the dotted name.");
-
+
newargs[0] = Jim_NewStringObj( interp, "jtag", -1 );
Jim_GetString( newargs[8], NULL ),
Jim_GetString( newargs[9], NULL ) );
-
+
e = jim_jtag_command( interp, 10, newargs );
if( e != JIM_OK ){
tap->abs_chain_position,
tap->dotted_name,
tap->enabled ? 'Y' : 'n',
- tap->idcode,
+ tap->idcode,
tap->expected_id,
- tap->ir_length,
- expected,
- expected_mask,
+ tap->ir_length,
+ expected,
+ expected_mask,
cur_instr);
tap = tap->next_tap;
}
int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
{
- int i, j;
+ int j;
int scan_size = 0;
- jtag_device_t *device;
-
- for (i=0; i < jtag_num_devices; i++)
+ jtag_tap_t *tap, *nextTap;
+ for(tap = jtag_NextEnabledTap(NULL); tap!= NULL; tap=nextTap)
{
- int pause=i==(jtag_num_devices-1);
+ nextTap=jtag_NextEnabledTap(tap);
+ int pause=(nextTap==NULL);
+
int found = 0;
- device = jtag_get_device(i);
- if (device==NULL)
- {
- return ERROR_FAIL;
- }
- scan_size = device->ir_length;
+ scan_size = tap->ir_length;
/* search the list */
for (j=0; j < num_fields; j++)
{
- if (i == fields[j].device)
+ if (tap == fields[j].tap)
{
found = 1;
if ((jtag_verify_capture_ir)&&(fields[j].in_handler==NULL))
{
- jtag_set_check_value(fields+j, device->expected, device->expected_mask, NULL);
+ jtag_set_check_value(fields+j, tap->expected, tap->expected_mask, NULL);
} else if (jtag_verify_capture_ir)
{
- fields[j].in_check_value = device->expected;
- fields[j].in_check_mask = device->expected_mask;
+ fields[j].in_check_value = tap->expected;
+ fields[j].in_check_mask = tap->expected_mask;
}
scanFields(1, fields+j, TAP_SI, pause);
/* update device information */
- buf_cpy(fields[j].out_value, device->cur_instr, scan_size);
+ buf_cpy(fields[j].out_value, tap->cur_instr, scan_size);
- device->bypass = 0;
+ tap->bypass = 0;
break;
}
}
tmp.num_bits = scan_size;
scanFields(1, &tmp, TAP_SI, pause);
/* update device information */
- buf_cpy(tmp.out_value, device->cur_instr, scan_size);
- device->bypass = 1;
+ buf_cpy(tmp.out_value, tap->cur_instr, scan_size);
+ tap->bypass = 1;
}
}
gotoEndState();
int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
{
- int i, j;
- for (i=0; i < jtag_num_devices; i++)
+
+ int j;
+ jtag_tap_t *tap, *nextTap;
+ for(tap = jtag_NextEnabledTap(NULL); tap!= NULL; tap=nextTap)
{
- int found = 0;
- int pause = (i==(jtag_num_devices-1));
+ nextTap=jtag_NextEnabledTap(tap);
+ int found=0;
+ int pause=(nextTap==NULL);
for (j=0; j < num_fields; j++)
{
- if (i == fields[j].device)
+ if (tap == fields[j].tap)
{
found = 1;
}
if (!found)
{
-#ifdef _DEBUG_JTAG_IO_
- /* if a device isn't listed, the BYPASS register should be selected */
- if (!jtag_get_device(i)->bypass)
- {
- LOG_ERROR("BUG: no scan data for a device not in BYPASS");
- exit(-1);
- }
-#endif
-
scan_field_t tmp;
/* program the scan field to 1 bit length, and ignore it's value */
tmp.num_bits = 1;
}
else
{
-#ifdef _DEBUG_JTAG_IO_
- /* if a device is listed, the BYPASS register must not be selected */
- if (jtag_get_device(i)->bypass)
- {
- LOG_WARNING("scan data for a device in BYPASS");
- }
-#endif
}
}
gotoEndState();
-void embeddedice_write_dcc(int chain_pos, int reg_addr, u8 *buffer, int little, int count)
+void embeddedice_write_dcc(jtag_tap_t *tap, int reg_addr, u8 *buffer, int little, int count)
{
// static int const reg_addr=0x5;
enum tap_state end_state=cmd_queue_end_state;
- if (jtag_num_devices==1)
+ if (jtag_NextEnabledTap(jtag_NextEnabledTap(NULL))==NULL)
{
/* better performance via code duplication */
if (little)
int i;
for (i = 0; i < count; i++)
{
- embeddedice_write_reg_inner(chain_pos, reg_addr, fast_target_buffer_get_u32(buffer, little));
+ embeddedice_write_reg_inner(tap, reg_addr, fast_target_buffer_get_u32(buffer, little));
buffer += 4;
}
}