]> git.sur5r.net Git - openocd/commitdiff
refactor to be able to remove more in_handler stuff
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 7 May 2009 20:53:32 +0000 (20:53 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 7 May 2009 20:53:32 +0000 (20:53 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1652 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/jtag.c
src/jtag/jtag.h

index e8680b23b3a0eb33a5a1a14b3dd1666a9571e49e..2432516a34898ad99f230c1ed97d7ad418963d5a 100644 (file)
@@ -1347,7 +1347,7 @@ static const char *jtag_tap_name(jtag_tap_t *tap)
        return (tap == NULL) ? "(unknown)" : tap->dotted_name;
 }
 
-int jtag_check_value(u8 *captured, void *priv, scan_field_t *field)
+int jtag_check_value_inner(u8 *captured, scan_field_t *field, u8 *in_check_value, u8 *in_check_mask)
 {
        int retval = ERROR_OK;
        int num_bits = field->num_bits;
@@ -1355,9 +1355,9 @@ int jtag_check_value(u8 *captured, void *priv, scan_field_t *field)
        int compare_failed = 0;
 
        if (field->in_check_mask)
-               compare_failed = buf_cmp_mask(captured, field->in_check_value, field->in_check_mask, num_bits);
+               compare_failed = buf_cmp_mask(captured, in_check_value, in_check_mask, num_bits);
        else
-               compare_failed = buf_cmp(captured, field->in_check_value, num_bits);
+               compare_failed = buf_cmp(captured, in_check_value, num_bits);
 
        if (compare_failed){
                /* An error handler could have caught the failing check
@@ -1369,12 +1369,12 @@ int jtag_check_value(u8 *captured, void *priv, scan_field_t *field)
                if (compare_failed)
                {
                        char *captured_char = buf_to_str(captured, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
-                       char *in_check_value_char = buf_to_str(field->in_check_value, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
+                       char *in_check_value_char = buf_to_str(in_check_value, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
 
-                       if (field->in_check_mask)
+                       if (in_check_mask)
                        {
                                char *in_check_mask_char;
-                               in_check_mask_char = buf_to_str(field->in_check_mask, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
+                               in_check_mask_char = buf_to_str(in_check_mask, (num_bits > DEBUG_JTAG_IOZ) ? DEBUG_JTAG_IOZ : num_bits, 16);
                                LOG_WARNING("value captured during scan didn't pass the requested check:");
                                LOG_WARNING("captured: 0x%s check_value: 0x%s check_mask: 0x%s",
                                                        captured_char, in_check_value_char, in_check_mask_char);
@@ -1395,6 +1395,11 @@ int jtag_check_value(u8 *captured, void *priv, scan_field_t *field)
        return retval;
 }
 
+int jtag_check_value(u8 *captured, void *priv, scan_field_t *field)
+{
+       return jtag_check_value_inner(captured, field, field->in_check_value, field->in_check_mask);
+}
+
 /*
   set up checking of this field using the in_handler. The values passed in must be valid until
   after jtag_execute() has completed.
@@ -1410,6 +1415,17 @@ void jtag_set_check_value(scan_field_t *field, u8 *value, u8 *mask, struct inval
        field->in_check_mask = mask;
 }
 
+void jtag_check_value_mask(scan_field_t *field, u8 *value, u8 *mask)
+{
+       jtag_execute_queue_noclear();
+       
+       int retval=jtag_check_value_inner(field->in_value, field, value, mask);
+       jtag_set_error(retval);
+       
+}
+
+
+
 enum scan_type jtag_scan_type(scan_command_t *cmd)
 {
        int i;
index f2c887f87a2c1e8963feee6bdf94d9ddfaf0a438..6e3df55d27c879e645b25c9858c9ac73a29c8cf3 100644 (file)
@@ -735,6 +735,9 @@ struct invalidstruct
 };
 
 extern void           jtag_set_check_value(scan_field_t* field, u8* value, u8* mask, struct invalidstruct *obsolete);
+/* execute jtag queue and check value and use mask if mask is != NULL. invokes
+ * jtag_set_error() with any error. */
+extern void jtag_check_value_mask(scan_field_t *field, u8 *value, u8 *mask);
 extern enum scan_type jtag_scan_type(scan_command_t* cmd);
 extern int            jtag_scan_size(scan_command_t* cmd);
 extern int            jtag_read_buffer(u8* buffer, scan_command_t* cmd);