u8 *in;
jtag_callback_data_t data1;
jtag_callback_data_t data2;
-
+ jtag_callback_data_t data3;
};
jtag_error=retval;
}
+
+int jtag_check_value_inner(u8 *captured, u8 *in_check_value, u8 *in_check_mask, int num_bits);
+
+static int jtag_check_value_mask_callback(u8 *in, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
+{
+ return jtag_check_value_inner(in, (u8 *)data1, (u8 *)data2, (int)data3);
+}
+
+void jtag_add_dr_scan_check(int num_fields, scan_field_t *fields, tap_state_t state)
+{
+ for (int i=0; i<num_fields; i++)
+ {
+ fields[i].allocated=0;
+ fields[i].modified=0;
+ if ((fields[i].check_value!=NULL)&&(fields[i].in_value==NULL))
+ {
+ fields[i].modified=1;
+ /* we need storage space... */
+#ifdef HAVE_JTAG_MINIDRIVER_H
+ if (fields[i].num_bits<=32)
+ {
+ /* This is enough space and we're executing this synchronously */
+ fields[i].in_value=(u8 *)&fields[i].intmp;
+ } else
+ {
+ fields[i].in_value=(u8 *)malloc(CEIL(fields[i].num_bits, 8));
+ fields[i].allocated=1;
+ }
+#else
+ fields[i].in_value=(u8 *)cmd_queue_alloc(CEIL(fields[i].num_bits, 8));
+#endif
+ }
+ }
+
+ jtag_add_dr_scan(num_fields, fields, state);
+
+ for (int i=0; i<num_fields; i++)
+ {
+ if ((fields[i].check_value!=NULL)&&(fields[i].in_value!=NULL))
+ {
+ /* this is synchronous for a minidriver */
+ jtag_add_callback4(jtag_check_value_mask_callback, fields[i].in_value, fields[i].check_value, fields[i].check_mask, (jtag_callback_data_t)fields[i].num_bits);
+ }
+ if (fields[i].allocated)
+ {
+ free(fields[i].in_value);
+ }
+ if (fields[i].modified)
+ {
+ fields[i].in_value=NULL;
+ }
+ }
+
+
+}
+
void jtag_add_dr_scan_now(int num_fields, scan_field_t *fields, tap_state_t state)
{
jtag_add_dr_scan(num_fields, fields, state);
return (tap == NULL) ? "(unknown)" : tap->dotted_name;
}
-int jtag_check_value_inner(u8 *captured, scan_field_t *field, u8 *in_check_value, u8 *in_check_mask)
+int jtag_check_value_inner(u8 *captured, u8 *in_check_value, u8 *in_check_mask, int num_bits)
{
int retval = ERROR_OK;
- int num_bits = field->num_bits;
int compare_failed = 0;
* only report a problem when there wasn't a handler, or if the handler
* acknowledged the error
*/
+ /*
LOG_WARNING("TAP %s:",
jtag_tap_name(field->tap));
+ */
if (compare_failed)
{
char *captured_char = buf_to_str(captured, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
jtag_execute_queue_noclear();
- int retval=jtag_check_value_inner(field->in_value, field, value, mask);
+ int retval=jtag_check_value_inner(field->in_value, value, mask, field->num_bits);
jtag_set_error(retval);
}
#ifndef HAVE_JTAG_MINIDRIVER_H
/* add callback to end of queue */
-void jtag_add_callback3(jtag_callback_t callback, u8 *in, jtag_callback_data_t data1, jtag_callback_data_t data2)
+void jtag_add_callback4(jtag_callback_t callback, u8 *in, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
{
struct jtag_callback_entry *entry=cmd_queue_alloc(sizeof(struct jtag_callback_entry));
entry->in=in;
entry->data1=data1;
entry->data2=data2;
+ entry->data3=data3;
if (jtag_callback_queue_head==NULL)
{
}
-static int jtag_convert_to_callback3(u8 *in, jtag_callback_data_t data1, jtag_callback_data_t data2)
+static int jtag_convert_to_callback4(u8 *in, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3)
{
((jtag_callback1_t)data1)(in);
return ERROR_OK;
void jtag_add_callback(jtag_callback1_t callback, u8 *in)
{
- jtag_add_callback3(jtag_convert_to_callback3, in, (jtag_callback_data_t)callback, 0);
+ jtag_add_callback4(jtag_convert_to_callback4, in, (jtag_callback_data_t)callback, 0, 0);
}
#endif
struct jtag_callback_entry *entry;
for (entry=jtag_callback_queue_head; entry!=NULL; entry=entry->next)
{
- retval=entry->callback(entry->in, entry->data1, entry->data2);
+ retval=entry->callback(entry->in, entry->data1, entry->data2, entry->data3);
if (retval!=ERROR_OK)
break;
}
int num_bits; /* number of bits this field specifies (up to 32) */
u8* out_value; /* value to be scanned into the device */
u8* in_value; /* pointer to a 32-bit memory location to take data scanned out */
+
+ u8* check_value; /* Used together with jtag_add_dr_scan_check() to check data clocked
+ in */
+ u8* check_mask; /* mask to go with check_value */
+
+ /* internal work space */
+ int allocated; /* in_value has been allocated for the queue */
+ int modified; /* did we modify the in_value? */
+ u32 intmp; /* temporary storage for checking synchronously */
} scan_field_t;
enum scan_type {
extern void jtag_add_ir_scan_noverify(int num_fields, scan_field_t *fields, tap_state_t state);
extern int interface_jtag_add_ir_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
extern void jtag_add_dr_scan(int num_fields, scan_field_t* fields, tap_state_t endstate);
+
+/* This version of jtag_add_dr_scan() uses the check_value/mask fields */
+extern void jtag_add_dr_scan_check(int num_fields, scan_field_t* fields, tap_state_t endstate);
/* same as jtag_add_dr_scan but the scan is executed immediately. sets jtag_error if there
* was a failure.
*/
typedef void (*jtag_callback1_t)(u8 *in);
#ifndef HAVE_JTAG_MINIDRIVER_H
-/* A simpler version of jtag_add_callback3 */
+/* A simpler version of jtag_add_callback4 */
extern void jtag_add_callback(jtag_callback1_t, u8 *in);
#else
/* implemented by minidriver */
* The callback is invoked with three arguments. The first argument is
* the pointer to the data clocked in.
*/
-typedef int (*jtag_callback_t)(u8 *in, jtag_callback_data_t data1, jtag_callback_data_t data2);
+typedef int (*jtag_callback_t)(u8 *in, 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. Note that
* callbacks may or may not be invoked depending on driver implementation.
*/
#ifndef HAVE_JTAG_MINIDRIVER_H
-extern void jtag_add_callback3(jtag_callback_t, u8 *in, jtag_callback_data_t data1, jtag_callback_data_t data2);
+extern void jtag_add_callback4(jtag_callback_t, u8 *in, jtag_callback_data_t data1, jtag_callback_data_t data2, jtag_callback_data_t data3);
#else
/* implemented by minidriver */
#endif
extern void arm_endianness(u8 *tmp, void *in, int size, int be, int flip);
-static int arm9endianness(u8 *in, jtag_callback_data_t size, jtag_callback_data_t be)
+static int arm9endianness(u8 *in, jtag_callback_data_t size, jtag_callback_data_t be, jtag_callback_data_t dummy)
{
arm_endianness(in, in, (int)size, (int)be, 0);
return ERROR_OK;
jtag_add_dr_scan(3, fields, TAP_INVALID);
- jtag_add_callback3(arm9endianness, in, (jtag_callback_data_t)size, (jtag_callback_data_t)be);
+ jtag_add_callback4(arm9endianness, in, (jtag_callback_data_t)size, (jtag_callback_data_t)be, 0);
jtag_add_runtest(0, TAP_INVALID);