-extern int jtag_init(struct command_context_s *cmd_ctx);
-/* reset, then initialize JTAG chain */
-extern int jtag_init_reset(struct command_context_s *cmd_ctx);
-extern int jtag_register_commands(struct command_context_s *cmd_ctx);
-
-/* JTAG interface, can be implemented with a software or hardware fifo
- *
- * TAP_SD and TAP_SI are illegal end states. TAP_SD/SI as end states
- * can be emulated by using a larger scan.
- *
- * Code that is relatively insensitive to the path(as long
- * as it is JTAG compliant) taken through state machine can use
- * endstate for jtag_add_xxx_scan(). Otherwise the pause state must be
- * specified as end state and a subsequent jtag_add_pathmove() must
- * be issued.
- *
- */
-extern void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
-extern int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
-extern void jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
-extern int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
-extern void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
-extern int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
-extern void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
-extern int interface_jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
-/* run a TAP_TLR reset. End state is TAP_TLR, regardless
- * of start state.
+extern int jtag_init(struct command_context_s* cmd_ctx);
+
+/// reset, then initialize JTAG chain
+extern int jtag_init_reset(struct command_context_s* cmd_ctx);
+extern int jtag_register_commands(struct command_context_s* cmd_ctx);
+
+/**
+ * @file
+ * The JTAG interface can be implemented with a software or hardware fifo.
+ *
+ * TAP_DRSHIFT and TAP_IRSHIFT are illegal end states; however,
+ * TAP_DRSHIFT/IRSHIFT can be emulated as end states, by using longer
+ * scans.
+ *
+ * Code that is relatively insensitive to the path taken through state
+ * machine (as long as it is JTAG compliant) can use @a endstate for
+ * jtag_add_xxx_scan(). Otherwise, the pause state must be specified as
+ * end state and a subsequent jtag_add_pathmove() must be issued.
+ */
+
+/**
+ * Generate an IR SCAN with a list of scan fields with one entry for
+ * each enabled TAP.
+ *
+ * If the input field list contains an instruction value for a TAP then
+ * that is used otherwise the TAP is set to bypass.
+ *
+ * TAPs for which no fields are passed are marked as bypassed for
+ * subsequent DR SCANs.
+ *
+ */
+extern void jtag_add_ir_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
+/**
+ * The same as jtag_add_ir_scan except no verification is performed out
+ * the output values.
+ */
+extern void jtag_add_ir_scan_noverify(int num_fields, const scan_field_t *fields, tap_state_t state);
+/**
+ * Duplicate the scan fields passed into the function into an IR SCAN
+ * command. This function assumes that the caller handles extra fields
+ * for bypassed TAPs.
+ */
+extern void jtag_add_plain_ir_scan(int num_fields, const scan_field_t* fields, tap_state_t endstate);
+
+
+/**
+ * Set in_value to point to 32 bits of memory to scan into. This
+ * function is a way to handle the case of synchronous and asynchronous
+ * JTAG queues.
+ *
+ * In the event of an asynchronous queue execution the queue buffer
+ * allocation method is used, for the synchronous case the temporary 32
+ * bits come from the input field itself.
+ */
+extern void jtag_alloc_in_value32(scan_field_t *field);
+
+/**
+ * Generate a DR SCAN using the fields passed to the function.
+ * For connected TAPs, the function checks in_fields and uses fields
+ * specified there. For bypassed TAPs, the function generates a dummy
+ * 1-bit field. The bypass status of TAPs is set by jtag_add_ir_scan().
+ */
+extern void jtag_add_dr_scan(int num_fields, const scan_field_t* fields, tap_state_t endstate);
+/// A version of jtag_add_dr_scan() that uses the check_value/mask fields
+extern void jtag_add_dr_scan_check(int num_fields, scan_field_t* fields, tap_state_t endstate);
+/**
+ * Duplicate the scan fields passed into the function into a DR SCAN
+ * command. Unlike jtag_add_dr_scan(), this function assumes that the
+ * caller handles extra fields for bypassed TAPs.
+ */
+extern void jtag_add_plain_dr_scan(int num_fields, const scan_field_t* fields, tap_state_t endstate);
+
+/**
+ * Defines the type of data passed to the jtag_callback_t interface.
+ * The underlying type must allow storing an @c int or pointer type.
+ */
+typedef intptr_t jtag_callback_data_t;
+
+/**
+ * Defines a simple JTAG callback that can allow conversions on data
+ * scanned in from an interface.
+ *
+ * This callback should only be used for conversion that cannot fail.
+ * For conversion types or checks that can fail, use the more complete
+ * variant: jtag_callback_t.
+ */
+typedef void (*jtag_callback1_t)(jtag_callback_data_t data0);
+
+/// A simpler version of jtag_add_callback4().
+extern void jtag_add_callback(jtag_callback1_t, jtag_callback_data_t data0);
+
+
+
+/**
+ * Defines the interface of the JTAG callback mechanism.
+ *
+ * @param in the pointer to the data clocked in
+ * @param data1 An integer big enough to use as an @c int or a pointer.
+ * @param data2 An integer big enough to use as an @c int or a pointer.
+ * @param data3 An integer big enough to use as an @c int or a pointer.
+ * @returns an error code
+ */
+typedef int (*jtag_callback_t)(jtag_callback_data_t data0, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3);
+
+
+/**
+ * This callback can be executed immediately the queue has been flushed.
+ *
+ * The JTAG queue can be executed synchronously or asynchronously.
+ * Typically for USB, the queue is executed asynchronously. For
+ * low-latency interfaces, the queue may be executed synchronously.
+ *
+ * The callback mechanism is very general and does not make many
+ * assumptions about what the callback does or what its arguments are.
+ * These callbacks are typically executed *after* the *entire* JTAG
+ * queue has been executed for e.g. USB interfaces, and they are
+ * guaranteeed to be invoked in the order that they were queued.
+ *
+ * If the execution of the queue fails before the callbacks, then --
+ * depending on driver implementation -- the callbacks may or may not be
+ * invoked. @todo Can we make this behavior consistent?
+ *
+ * The strange name is due to C's lack of overloading using function
+ * arguments.
+ *
+ * @param f The callback function to add.
+ * @param data0 Typically used to point to the data to operate on.
+ * Frequently this will be the data clocked in during a shift operation.
+ * @param data1 An integer big enough to use as an @c int or a pointer.
+ * @param data2 An integer big enough to use as an @c int or a pointer.
+ * @param data3 An integer big enough to use as an @c int or a pointer.
+ *
+ */
+extern void jtag_add_callback4(jtag_callback_t f, jtag_callback_data_t data0,
+ jtag_callback_data_t data1, jtag_callback_data_t data2,
+ jtag_callback_data_t data3);
+
+
+/**
+ * Run a TAP_RESET reset where the end state is TAP_RESET,
+ * regardless of the start state.