diff --git a/jtag/src/cmd/bit.c b/jtag/src/cmd/bit.c index 6cff8ffc..3a5be906 100644 --- a/jtag/src/cmd/bit.c +++ b/jtag/src/cmd/bit.c @@ -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; iparts) { 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;