update zy1000 to svn head jtag api

git-svn-id: svn://svn.berlios.de/openocd/trunk@1197 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
oharboe 2008-12-01 14:21:24 +00:00
parent b8db7aa18b
commit 1006986ab1
5 changed files with 82 additions and 99 deletions

View File

@ -989,13 +989,13 @@ zylinjtag_Jim_Command_format_jffs2(Jim_Interp *interp,
int argc, int argc,
Jim_Obj * const *argv) Jim_Obj * const *argv)
{ {
int del;
if (argc != 1) if (argc != 1)
{ {
return JIM_ERR; return JIM_ERR;
} }
format(); format();
for(;;);
} }

View File

@ -273,12 +273,12 @@ int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
jtag_tap_t *jtag_AllTaps(void) jtag_tap_t *jtag_AllTaps(void)
{ {
return jtag_all_taps; return jtag_all_taps;
}; };
int int
jtag_NumTotalTaps(void) jtag_NumTotalTaps(void)
{ {
jtag_tap_t *t; jtag_tap_t *t;
@ -310,25 +310,6 @@ jtag_NumEnabledTaps(void)
return n; 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 ) jtag_tap_t *jtag_TapByString( const char *s )
{ {
@ -369,7 +350,7 @@ jtag_TapByJimObj( Jim_Interp *interp, Jim_Obj *o )
t = NULL; t = NULL;
} else { } else {
t = jtag_TapByString( cp ); t = jtag_TapByString( cp );
} }
if( t == NULL ){ if( t == NULL ){
Jim_SetResult_sprintf(interp,"Tap: %s is unknown", cp ); Jim_SetResult_sprintf(interp,"Tap: %s is unknown", cp );
} }
@ -385,7 +366,7 @@ jtag_TapByAbsPosition( int n )
orig_n = n; orig_n = n;
t = jtag_AllTaps(); t = jtag_AllTaps();
while( t && (n > 0)) { while( t && (n > 0)) {
n--; n--;
t = t->next_tap; t = t->next_tap;
@ -1348,7 +1329,7 @@ int jtag_check_value(u8 *captured, void *priv, scan_field_t *field)
char *in_check_mask_char; char *in_check_mask_char;
in_check_mask_char = buf_to_str(field->in_check_mask, (num_bits > 64) ? 64 : num_bits, 16); 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("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); captured_char, in_check_value_char, in_check_mask_char);
free(in_check_mask_char); free(in_check_mask_char);
} }
@ -1499,7 +1480,7 @@ int jtag_examine_chain(void)
LOG_ERROR("JTAG: No taps enabled?"); LOG_ERROR("JTAG: No taps enabled?");
return ERROR_JTAG_INIT_FAILED; return ERROR_JTAG_INIT_FAILED;
} }
for (bit_count = 0; bit_count < (JTAG_MAX_CHAIN_SIZE * 32) - 31;) for (bit_count = 0; bit_count < (JTAG_MAX_CHAIN_SIZE * 32) - 31;)
{ {
u32 idcode = buf_get_u32(idcode_buffer, bit_count, 32); u32 idcode = buf_get_u32(idcode_buffer, bit_count, 32);
@ -1579,7 +1560,7 @@ int jtag_examine_chain(void)
} }
} else { } else {
#if 0 #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); tap->idcode);
#endif #endif
} }
@ -1642,7 +1623,7 @@ int jtag_validate_chain(void)
if( tap == NULL ){ if( tap == NULL ){
break; break;
} }
if (buf_get_u32(ir_test, chain_pos, 2) != 0x1) if (buf_get_u32(ir_test, chain_pos, 2) != 0x1)
{ {
@ -1697,7 +1678,7 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
{ .name = NULL , .value = -1 }, { .name = NULL , .value = -1 },
}; };
pTap = malloc( sizeof(jtag_tap_t) ); pTap = malloc( sizeof(jtag_tap_t) );
memset( pTap, 0, sizeof(*pTap) ); memset( pTap, 0, sizeof(*pTap) );
if( !pTap ){ if( !pTap ){
@ -1706,7 +1687,7 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
} }
// //
// we expect CHIP + TAP + OPTIONS // we expect CHIP + TAP + OPTIONS
// //
if( goi->argc < 3 ){ if( goi->argc < 3 ){
Jim_SetResult_sprintf(goi->interp, "Missing CHIP TAP OPTIONS ...."); Jim_SetResult_sprintf(goi->interp, "Missing CHIP TAP OPTIONS ....");
return JIM_ERR; return JIM_ERR;
@ -1716,17 +1697,17 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
Jim_GetOpt_String( goi, &cp, NULL ); Jim_GetOpt_String( goi, &cp, NULL );
pTap->tapname = strdup(cp); pTap->tapname = strdup(cp);
// name + dot + name + null // name + dot + name + null
x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1; x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1;
cp = malloc( x ); cp = malloc( x );
sprintf( cp, "%s.%s", pTap->chip, pTap->tapname ); sprintf( cp, "%s.%s", pTap->chip, pTap->tapname );
pTap->dotted_name = cp; 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); pTap->chip, pTap->tapname, pTap->dotted_name, goi->argc);
// default is enabled // default is enabled
pTap->enabled = 1; pTap->enabled = 1;
@ -1737,7 +1718,7 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
// clear them as we find them // clear them as we find them
reqbits = (NTREQ_IRLEN | NTREQ_IRCAPTURE | NTREQ_IRMASK); reqbits = (NTREQ_IRLEN | NTREQ_IRCAPTURE | NTREQ_IRMASK);
while( goi->argc ){ while( goi->argc ){
e = Jim_GetOpt_Nvp( goi, opts, &n ); e = Jim_GetOpt_Nvp( goi, opts, &n );
if( e != JIM_OK ){ if( e != JIM_OK ){
@ -1766,7 +1747,7 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
} }
if( (w < 0) || (w > 0xffff) ){ if( (w < 0) || (w > 0xffff) ){
// wacky value // 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)); n->name, (int)(w), (int)(w));
return JIM_ERR; return JIM_ERR;
} }
@ -1789,9 +1770,9 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
// Did we get all the options? // Did we get all the options?
if( reqbits ){ if( reqbits ){
// no // no
Jim_SetResult_sprintf( goi->interp, Jim_SetResult_sprintf( goi->interp,
"newtap: %s missing required parameters", "newtap: %s missing required parameters",
pTap->dotted_name); pTap->dotted_name);
// fixme: Tell user what is missing :-( // fixme: Tell user what is missing :-(
// no memory leaks pelase // no memory leaks pelase
@ -1811,23 +1792,23 @@ jim_newtap_cmd( Jim_GetOptInfo *goi )
pTap->ir_length, pTap->ir_length,
pTap->ir_capture_value ); pTap->ir_capture_value );
buf_set_u32( pTap->expected_mask, buf_set_u32( pTap->expected_mask,
0, 0,
pTap->ir_length, pTap->ir_length,
pTap->ir_capture_mask ); pTap->ir_capture_mask );
buf_set_ones( pTap->cur_instr, buf_set_ones( pTap->cur_instr,
pTap->ir_length ); pTap->ir_length );
pTap->bypass = 1; pTap->bypass = 1;
jtag_register_event_callback(jtag_reset_callback, pTap ); jtag_register_event_callback(jtag_reset_callback, pTap );
ppTap = &(jtag_all_taps); ppTap = &(jtag_all_taps);
while( (*ppTap) != NULL ){ while( (*ppTap) != NULL ){
ppTap = &((*ppTap)->next_tap); ppTap = &((*ppTap)->next_tap);
} }
*ppTap = pTap; *ppTap = pTap;
{ {
static int n_taps = 0; static int n_taps = 0;
pTap->abs_chain_position = n_taps++; pTap->abs_chain_position = n_taps++;
} }
@ -1913,8 +1894,8 @@ jim_jtag_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
Jim_SetResultString( goi.interp, "Too many parameters",-1 ); Jim_SetResultString( goi.interp, "Too many parameters",-1 );
return JIM_ERR; return JIM_ERR;
} }
{ {
jtag_tap_t *t; jtag_tap_t *t;
t = jtag_TapByJimObj( goi.interp, goi.argv[0] ); t = jtag_TapByJimObj( goi.interp, goi.argv[0] );
if( t == NULL ){ if( t == NULL ){
@ -2194,7 +2175,7 @@ int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, cha
// argv[ 1] = ir capture // argv[ 1] = ir capture
// argv[ 2] = ir mask // argv[ 2] = ir mask
// argv[ 3] = not actually used by anything but in the docs // argv[ 3] = not actually used by anything but in the docs
if( argc < 4 ){ if( argc < 4 ){
command_print( cmd_ctx, "OLD DEPRECATED SYNTAX: Please use the NEW syntax"); command_print( cmd_ctx, "OLD DEPRECATED SYNTAX: Please use the NEW syntax");
return ERROR_OK; return ERROR_OK;
@ -2208,7 +2189,7 @@ int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, cha
command_print( cmd_ctx, "jtag newtap stm32 cortexm3 ....., thus creating the tap: \"stm32.cortexm3\""); 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, "jtag newtap stm32 boundry ....., and the tap: \"stm32.boundery\"");
command_print( cmd_ctx, "And then refer to the taps by the dotted name."); command_print( cmd_ctx, "And then refer to the taps by the dotted name.");
newargs[0] = Jim_NewStringObj( interp, "jtag", -1 ); newargs[0] = Jim_NewStringObj( interp, "jtag", -1 );
@ -2237,7 +2218,7 @@ int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, cha
Jim_GetString( newargs[8], NULL ), Jim_GetString( newargs[8], NULL ),
Jim_GetString( newargs[9], NULL ) ); Jim_GetString( newargs[9], NULL ) );
e = jim_jtag_command( interp, 10, newargs ); e = jim_jtag_command( interp, 10, newargs );
if( e != JIM_OK ){ if( e != JIM_OK ){
@ -2265,11 +2246,11 @@ int handle_scan_chain_command(struct command_context_s *cmd_ctx, char *cmd, char
tap->abs_chain_position, tap->abs_chain_position,
tap->dotted_name, tap->dotted_name,
tap->enabled ? 'Y' : 'n', tap->enabled ? 'Y' : 'n',
tap->idcode, tap->idcode,
tap->expected_id, tap->expected_id,
tap->ir_length, tap->ir_length,
expected, expected,
expected_mask, expected_mask,
cur_instr); cur_instr);
tap = tap->next_tap; tap = tap->next_tap;
} }

View File

@ -186,7 +186,6 @@ struct jtag_tap_s
}; };
extern jtag_tap_t *jtag_AllTaps(void); extern jtag_tap_t *jtag_AllTaps(void);
extern jtag_tap_t *jtag_TapByPosition(int n); extern jtag_tap_t *jtag_TapByPosition(int n);
extern jtag_tap_t *jtag_NextEnabledTap( jtag_tap_t * );
extern jtag_tap_t *jtag_TapByPosition( int n ); extern jtag_tap_t *jtag_TapByPosition( int n );
extern jtag_tap_t *jtag_TapByString( const char *dotted_name ); extern jtag_tap_t *jtag_TapByString( const char *dotted_name );
extern jtag_tap_t *jtag_TapByJimObj( Jim_Interp *interp, Jim_Obj *obj ); extern jtag_tap_t *jtag_TapByJimObj( Jim_Interp *interp, Jim_Obj *obj );
@ -195,6 +194,27 @@ extern int jtag_NumEnabledTaps(void);
extern int jtag_NumTotalTaps(void); extern int jtag_NumTotalTaps(void);
static __inline__ 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;
}
enum reset_line_mode enum reset_line_mode

View File

@ -492,43 +492,39 @@ int interface_jtag_add_end_state(enum tap_state state)
int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state) 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; int scan_size = 0;
jtag_device_t *device; jtag_tap_t *tap, *nextTap;
for(tap = jtag_NextEnabledTap(NULL); tap!= NULL; tap=nextTap)
for (i=0; i < jtag_num_devices; i++)
{ {
int pause=i==(jtag_num_devices-1); nextTap=jtag_NextEnabledTap(tap);
int found = 0; int pause=(nextTap==NULL);
device = jtag_get_device(i);
if (device==NULL)
{
return ERROR_FAIL;
}
scan_size = device->ir_length; int found = 0;
scan_size = tap->ir_length;
/* search the list */ /* search the list */
for (j=0; j < num_fields; j++) for (j=0; j < num_fields; j++)
{ {
if (i == fields[j].device) if (tap == fields[j].tap)
{ {
found = 1; found = 1;
if ((jtag_verify_capture_ir)&&(fields[j].in_handler==NULL)) 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) } else if (jtag_verify_capture_ir)
{ {
fields[j].in_check_value = device->expected; fields[j].in_check_value = tap->expected;
fields[j].in_check_mask = device->expected_mask; fields[j].in_check_mask = tap->expected_mask;
} }
scanFields(1, fields+j, TAP_SI, pause); scanFields(1, fields+j, TAP_SI, pause);
/* update device information */ /* 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; break;
} }
} }
@ -544,8 +540,8 @@ int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_st
tmp.num_bits = scan_size; tmp.num_bits = scan_size;
scanFields(1, &tmp, TAP_SI, pause); scanFields(1, &tmp, TAP_SI, pause);
/* update device information */ /* update device information */
buf_cpy(tmp.out_value, device->cur_instr, scan_size); buf_cpy(tmp.out_value, tap->cur_instr, scan_size);
device->bypass = 1; tap->bypass = 1;
} }
} }
gotoEndState(); gotoEndState();
@ -569,15 +565,18 @@ int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum
int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state) 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; nextTap=jtag_NextEnabledTap(tap);
int pause = (i==(jtag_num_devices-1)); int found=0;
int pause=(nextTap==NULL);
for (j=0; j < num_fields; j++) for (j=0; j < num_fields; j++)
{ {
if (i == fields[j].device) if (tap == fields[j].tap)
{ {
found = 1; found = 1;
@ -586,15 +585,6 @@ int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_st
} }
if (!found) 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; scan_field_t tmp;
/* program the scan field to 1 bit length, and ignore it's value */ /* program the scan field to 1 bit length, and ignore it's value */
tmp.num_bits = 1; tmp.num_bits = 1;
@ -610,13 +600,6 @@ int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_st
} }
else 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(); gotoEndState();
@ -739,11 +722,11 @@ int interface_jtag_add_pathmove(int num_states, enum tap_state *path)
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; // static int const reg_addr=0x5;
enum tap_state end_state=cmd_queue_end_state; 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 */ /* better performance via code duplication */
if (little) if (little)
@ -771,7 +754,7 @@ void embeddedice_write_dcc(int chain_pos, int reg_addr, u8 *buffer, int little,
int i; int i;
for (i = 0; i < count; 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; buffer += 4;
} }
} }

View File

@ -27,8 +27,7 @@ if { [info exists ENDIAN] } {
if { [info exists CPUTAPID ] } { if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID set _CPUTAPID $CPUTAPID
} else { } else {
# sharp changed the number! set _CPUTAPID 0x1f0f0f0f
set _CPUTAPID 0x3f0f0f0f
} }
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID