diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2009-10-25 13:07:57 -0700 |
---|---|---|
committer | David Brownell <dbrownell@users.sourceforge.net> | 2009-10-25 13:07:57 -0700 |
commit | e98817c4636f45b45db4332d2a5fbf36676f2f39 (patch) | |
tree | 0100031d66dd8abe1b6faa21e5f73b91e9c2a6f1 /src | |
parent | 2a8aa3b7efb590cabd7ee930dbb68fd64e028099 (diff) | |
download | openocd+libswd-e98817c4636f45b45db4332d2a5fbf36676f2f39.tar.gz openocd+libswd-e98817c4636f45b45db4332d2a5fbf36676f2f39.tar.bz2 openocd+libswd-e98817c4636f45b45db4332d2a5fbf36676f2f39.tar.xz openocd+libswd-e98817c4636f45b45db4332d2a5fbf36676f2f39.zip |
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: David Brownell <dbrownell@users.sourceforge.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/jtag/core.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/jtag/core.c b/src/jtag/core.c index 7c85839b..08cfe436 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1204,20 +1204,29 @@ done: void jtag_tap_init(jtag_tap_t *tap) { + unsigned ir_len_bits; + unsigned ir_len_bytes; + assert(0 != tap->ir_length); - /// @todo fix, this allocates one byte per bit for all three fields! - tap->expected = malloc(tap->ir_length); - tap->expected_mask = malloc(tap->ir_length); - tap->cur_instr = malloc(tap->ir_length); + ir_len_bits = tap->ir_length; + ir_len_bytes = CEIL(ir_len_bits, 8); - /// @todo cope sanely with ir_length bigger than 32 bits - buf_set_u32(tap->expected, 0, tap->ir_length, tap->ir_capture_value); - buf_set_u32(tap->expected_mask, 0, tap->ir_length, tap->ir_capture_mask); - buf_set_ones(tap->cur_instr, tap->ir_length); + tap->expected = calloc(1, ir_len_bytes); + tap->expected_mask = calloc(1, ir_len_bytes); + tap->cur_instr = malloc(ir_len_bytes); + + /// @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; + buf_set_ones(tap->cur_instr, tap->ir_length); + // register the reset callback for the TAP jtag_register_event_callback(&jtag_reset_callback, tap); |