|
|
|
@ -31,6 +31,18 @@
|
|
|
|
|
|
|
|
|
|
#include "cmd.h"
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cmd_bit_print_params( char *params[], unsigned int parameters, char *command )
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
strcpy(command, params[0]);
|
|
|
|
|
for (i=1; i<parameters; i++) {
|
|
|
|
|
strcat(command, " ");
|
|
|
|
|
strcat(command, params[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
cmd_bit_run( char *params[] )
|
|
|
|
|
{
|
|
|
|
@ -40,13 +52,20 @@ cmd_bit_run( char *params[] )
|
|
|
|
|
int type;
|
|
|
|
|
int safe;
|
|
|
|
|
unsigned int control;
|
|
|
|
|
unsigned int parameters = cmd_params( params );
|
|
|
|
|
char command[1024];
|
|
|
|
|
|
|
|
|
|
if ((cmd_params( params ) != 5) && (cmd_params( params ) != 8))
|
|
|
|
|
return -1;
|
|
|
|
|
cmd_bit_print_params(params, parameters, command);
|
|
|
|
|
|
|
|
|
|
if ((parameters != 5) && (parameters != 8)) {
|
|
|
|
|
printf( _("%s: invalid number of parameters (%d) for command '%s'\n"), "bit", parameters, command );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!cmd_test_cable())
|
|
|
|
|
if (!cmd_test_cable()) {
|
|
|
|
|
printf( _("%s: cable test failed for command '%s'\n"), "bit", command);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!chain->parts) {
|
|
|
|
|
printf( _("Run \"detect\" first.\n") );
|
|
|
|
@ -61,26 +80,30 @@ cmd_bit_run( char *params[] )
|
|
|
|
|
part = chain->parts->parts[chain->active_part];
|
|
|
|
|
bsr = part_find_data_register( part, "BSR" );
|
|
|
|
|
if (bsr == NULL) {
|
|
|
|
|
printf( _("missing Boundary Scan Register (BSR)\n") );
|
|
|
|
|
printf( _("%s: missing Boundary Scan Register (BSR) for command '%s'\n"), "bit", command );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* bit number */
|
|
|
|
|
if (cmd_get_number( params[1], &bit ))
|
|
|
|
|
if (cmd_get_number( params[1], &bit )) {
|
|
|
|
|
printf( _("%s: unable to get boundary bit number for command '%s'\n"), "bit", command );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bit >= bsr->in->len) {
|
|
|
|
|
printf( _("invalid boundary bit number\n") );
|
|
|
|
|
printf( _("%s: invalid boundary bit number for command '%s'\n"), "bit", command );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if (part->bsbits[bit] != NULL) {
|
|
|
|
|
printf( _("duplicate bit declaration\n") );
|
|
|
|
|
printf( _("%s: duplicate bit declaration for command '%s'\n"), "bit", command );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* bit type */
|
|
|
|
|
if (strlen( params[2] ) != 1)
|
|
|
|
|
if (strlen( params[2] ) != 1) {
|
|
|
|
|
printf( _("%s: invalid bit type length for command '%s'\n"), "bit", command );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
switch (params[2][0]) {
|
|
|
|
|
case 'I':
|
|
|
|
|
case 'i':
|
|
|
|
@ -103,20 +126,23 @@ cmd_bit_run( char *params[] )
|
|
|
|
|
type = BSBIT_INTERNAL;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf( _("%s: invalid bit type for command '%s'\n"), "bit", command );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* default (safe) value */
|
|
|
|
|
if (strlen( params[3] ) != 1)
|
|
|
|
|
if (strlen( params[3] ) != 1) {
|
|
|
|
|
printf( _("%s: invalid default value length for command '%s'\n"), "bit", command );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
safe = (params[3][0] == '1') ? 1 : 0;
|
|
|
|
|
bsr->in->data[bit] = safe;
|
|
|
|
|
|
|
|
|
|
/* allocate bsbit */
|
|
|
|
|
part->bsbits[bit] = bsbit_alloc( bit, params[4], type, part_find_signal( part, params[4] ), safe );
|
|
|
|
|
part->bsbits[bit] = bsbit_alloc( bit, params[4], type, part->signals, safe );
|
|
|
|
|
if (part->bsbits[bit] == NULL) {
|
|
|
|
|
printf( _("out of memory\n") );
|
|
|
|
|
printf( _("%s: out of memory for command '%s'\n"), "bit", command );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -125,22 +151,27 @@ cmd_bit_run( char *params[] )
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
/* control bit number */
|
|
|
|
|
if (cmd_get_number( params[5], &control ))
|
|
|
|
|
if (cmd_get_number( params[5], &control )) {
|
|
|
|
|
printf( _("%s: unable to get control bit number for command '%s'\n"), "bit", command );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (control >= bsr->in->len) {
|
|
|
|
|
printf( _("invalid control bit number\n") );
|
|
|
|
|
printf( _("%s: invalid control bit number for command '%s'\n"), "bit", command );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
part->bsbits[bit]->control = control;
|
|
|
|
|
|
|
|
|
|
/* control value */
|
|
|
|
|
if (strlen( params[6] ) != 1)
|
|
|
|
|
if (strlen( params[6] ) != 1) {
|
|
|
|
|
printf( _("%s: invalid control value length for command '%s'\n"), "bit", command );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
part->bsbits[bit]->control_value = (params[6][0] == '1') ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
/* control state */
|
|
|
|
|
if (strcasecmp(params[7], "Z"))
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
part->bsbits[bit]->control_state = BSBIT_STATE_Z;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|