Hi all,

The attached patch adds a literate macro for the calculation of the
number of bytes required to store a TAP scan chain given its bit count. 

This macro ensures this calculation will be done correctly in all
locations that it is required, though this patch simply changes the line
of code in the J-Link driver that originated the macro.  Would someone
like to chase down all of the other references and submit another patch?

While other parts of the tree are likely to find a use for it, but it
will be required for the next patch.  Please apply.

Cheers,

Zach

Index: src/jtag/jlink.c
===================================================================
--- src/jtag/jlink.c	(revision 1522)
+++ src/jtag/jlink.c	(working copy)
@@ -672,7 +676,7 @@
 		return ERROR_OK;
 
 	// number of full bytes (plus one if some would be left over)
-	byte_length = tap_length / 8 + !!(tap_length % 8);
+	byte_length = TAP_SCAN_BYTES(tap_length);
 
 	usb_out_buffer[0] = EMU_CMD_HW_JTAG3;
 	usb_out_buffer[1] = 0;
Index: src/jtag/jtag.h
===================================================================
--- src/jtag/jtag.h	(revision 1522)
+++ src/jtag/jtag.h	(working copy)
@@ -217,6 +230,9 @@
 struct scan_field_s;
 typedef int (*in_handler_t)(u8* in_value, void* priv, struct scan_field_s* field);
 
+/// @brief calculates number of bytes required to hold @a n TAP scan bits
+#define TAP_SCAN_BYTES(n)		(((n) / 8) + !!((n) % 8))
+
 typedef struct scan_field_s
 {
 	jtag_tap_t* tap;                /* tap pointer this instruction refers to */
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to