Skip to content
Snippets Groups Projects
Commit e98817c4 authored by David Brownell's avatar David Brownell
Browse files

JTAG: jtag_tap_init() bugfixes


Stop allocating three bytes per IR bit, and cope somewhat better
with IR lengths over 32 bits.

Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
parent 2a8aa3b7
No related branches found
No related tags found
No related merge requests found
...@@ -1204,20 +1204,29 @@ done: ...@@ -1204,20 +1204,29 @@ done:
void jtag_tap_init(jtag_tap_t *tap) void jtag_tap_init(jtag_tap_t *tap)
{ {
unsigned ir_len_bits;
unsigned ir_len_bytes;
assert(0 != tap->ir_length); assert(0 != tap->ir_length);
/// @todo fix, this allocates one byte per bit for all three fields! ir_len_bits = tap->ir_length;
tap->expected = malloc(tap->ir_length); ir_len_bytes = CEIL(ir_len_bits, 8);
tap->expected_mask = malloc(tap->ir_length);
tap->cur_instr = malloc(tap->ir_length);
/// @todo cope sanely with ir_length bigger than 32 bits tap->expected = calloc(1, ir_len_bytes);
buf_set_u32(tap->expected, 0, tap->ir_length, tap->ir_capture_value); tap->expected_mask = calloc(1, ir_len_bytes);
buf_set_u32(tap->expected_mask, 0, tap->ir_length, tap->ir_capture_mask); tap->cur_instr = malloc(ir_len_bytes);
buf_set_ones(tap->cur_instr, tap->ir_length);
/// @todo cope better with ir_length bigger than 32 bits
if (ir_len_bits > 32)
ir_len_bits = 32;
// place TAP in bypass mode buf_set_u32(tap->expected, 0, ir_len_bits, tap->ir_capture_value);
buf_set_u32(tap->expected_mask, 0, ir_len_bits, tap->ir_capture_mask);
// TAP will be in bypass mode after jtag_validate_ircapture()
tap->bypass = 1; tap->bypass = 1;
buf_set_ones(tap->cur_instr, tap->ir_length);
// register the reset callback for the TAP // register the reset callback for the TAP
jtag_register_event_callback(&jtag_reset_callback, tap); jtag_register_event_callback(&jtag_reset_callback, tap);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment