Hi all,

This patch unwinds the logic in jlink_tap_append_{step,scan}.

Cheers,

Zach
Index: src/jtag/jlink.c
===================================================================
--- src/jtag/jlink.c	(revision 1497)
+++ src/jtag/jlink.c	(working copy)
@@ -593,40 +589,32 @@
 	last_tms = tms;
 	int index = tap_length / 8;
 
-	if (index < JLINK_TAP_BUFFER_SIZE)
+	if (index >= JLINK_TAP_BUFFER_SIZE)
 	{
-		int bit_index = tap_length % 8;
-		u8 bit = 1 << bit_index;
+		LOG_ERROR("jlink_tap_append_step: overflow");
+		exit(-1);
+	}
 
-		if (tms)
-		{
-			tms_buffer[index] |= bit;
-		}
-		else
-		{
-			tms_buffer[index] &= ~bit;
-		}
+	int bit_index = tap_length % 8;
+	u8 bit = 1 << bit_index;
 
-		if (tdi)
-		{
-			tdi_buffer[index] |= bit;
-		}
-		else
-		{
-			tdi_buffer[index] &= ~bit;
-		}
+	if (tms)
+		tms_buffer[index] |= bit;
+	else
+		tms_buffer[index] &= ~bit;
 
-		tap_length++;
-	}
+	if (tdi)
+		tdi_buffer[index] |= bit;
 	else
-	{
-		LOG_ERROR("jlink_tap_append_step, overflow");
-	}
+		tdi_buffer[index] &= ~bit;
+
+	tap_length++;
 }
 
 static void jlink_tap_append_scan(int length, u8 *buffer, scan_command_t *command)
 {
-	pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length];
+	pending_scan_result_t *pending_scan_result =
+		&pending_scan_results_buffer[pending_scan_results_length];
 	int i;
 
 	pending_scan_result->first = tap_length;
@@ -636,7 +624,9 @@
 
 	for (i = 0; i < length; i++)
 	{
-		jlink_tap_append_step((i < length-1 ? 0 : 1), (buffer[i/8] >> (i%8)) & 1);
+		int tms = i < length - 1 ? 0 : 1;
+		int tdi = buffer[i / 8] & (1 << (i % 8));
+		jlink_tap_append_step(tms, tdi);
 	}
 	pending_scan_results_length++;
 }
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to