summaryrefslogtreecommitdiff
path: root/src/svf
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-24 00:47:49 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-24 00:47:49 +0000
commit8717ed04aaa465dcd6ae722b120b2cd4fdc4c8b4 (patch)
treeefc0916a344b6a57236a60d4f6756c85bb04df7c /src/svf
parent7e11f08a77f986f68625589088d4ffd971264ace (diff)
downloadopenocd_libswd-8717ed04aaa465dcd6ae722b120b2cd4fdc4c8b4.tar.gz
openocd_libswd-8717ed04aaa465dcd6ae722b120b2cd4fdc4c8b4.tar.bz2
openocd_libswd-8717ed04aaa465dcd6ae722b120b2cd4fdc4c8b4.tar.xz
openocd_libswd-8717ed04aaa465dcd6ae722b120b2cd4fdc4c8b4.zip
SimonQian <simonqian@SimonQian.com>:
Changes svf_check_tdo function (checks tdo output matches desired values): - call buf_cmp_mask function to do comparison instead of using a loop. - fixes a bug when data length is equal to sizeof(int). git-svn-id: svn://svn.berlios.de/openocd/trunk@1900 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/svf')
-rw-r--r--src/svf/svf.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/svf/svf.c b/src/svf/svf.c
index 3cad4c7e..0552c122 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -628,32 +628,35 @@ static int svf_copy_hexstring_to_binary(char *str, u8 **bin, int orig_bit_len, i
static int svf_check_tdo(void)
{
- int i, j, byte_len, index;
+ int i, len, index;
for (i = 0; i < svf_check_tdo_para_index; i++)
{
- if (svf_check_tdo_para[i].enabled)
+ index = svf_check_tdo_para[i].buffer_offset;
+ len = svf_check_tdo_para[i].bit_len;
+ if ((svf_check_tdo_para[i].enabled)
+ && buf_cmp_mask(&svf_tdi_buffer[index], &svf_tdo_buffer[index], &svf_mask_buffer[index], len))
{
- byte_len = (svf_check_tdo_para[i].bit_len + 7) >> 3;
- index = svf_check_tdo_para[i].buffer_offset;
- for (j = 0; j < byte_len; j++)
+ unsigned bitmask;
+ unsigned received, expected, tapmask;
+ if (svf_check_tdo_para[i].bit_len >= 32)
{
- if ((svf_tdi_buffer[index + j] & svf_mask_buffer[index + j]) != svf_tdo_buffer[index + j])
- {
- unsigned bitmask = (1 << svf_check_tdo_para[i].bit_len) - 1;
- unsigned received, expected, tapmask;
- memcpy(&received, svf_tdi_buffer + index, sizeof(unsigned));
- memcpy(&expected, svf_tdo_buffer + index, sizeof(unsigned));
- memcpy(&tapmask, svf_mask_buffer + index, sizeof(unsigned));
- LOG_ERROR("tdo check error at line %d, "
- "read = 0x%X, want = 0x%X, mask = 0x%X",
- svf_check_tdo_para[i].line_num,
- received & bitmask,
- expected & bitmask,
- tapmask & bitmask);
- return ERROR_FAIL;
- }
+ bitmask = 0xFFFFFFFF;
}
+ else
+ {
+ bitmask = (1 << svf_check_tdo_para[i].bit_len) - 1;
+ }
+ memcpy(&received, svf_tdi_buffer + index, sizeof(unsigned));
+ memcpy(&expected, svf_tdo_buffer + index, sizeof(unsigned));
+ memcpy(&tapmask, svf_mask_buffer + index, sizeof(unsigned));
+ LOG_ERROR("tdo check error at line %d",
+ svf_check_tdo_para[i].line_num);
+ LOG_ERROR("read = 0x%X, want = 0x%X, mask = 0x%X",
+ received & bitmask,
+ expected & bitmask,
+ tapmask & bitmask);
+ return ERROR_FAIL;
}
}
svf_check_tdo_para_index = 0;