- use correct SCAN_N check value (disabled by default)
[openocd.git] / src / target / arm_jtag.c
index c401d8f358c612a1911f8dffe500c2855f5efb7b..edc1bd8804f4ae98faef32b548c2661a3590536e 100644 (file)
@@ -17,7 +17,9 @@
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include "arm_jtag.h"
 
 
 #include <stdlib.h>
 
-int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr)
+#if 0
+#define _ARM_JTAG_SCAN_N_CHECK_
+#endif
+
+int arm_jtag_set_instr_error_handler(u8 *in_value, void *priv)
+{
+       ERROR("setting the new JTAG instruction failed, debugging is likely to be broken");
+       
+       return ERROR_OK;
+}
+
+int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr, error_handler_t *caller_error_handler)
 {
        jtag_device_t *device = jtag_get_device(jtag_info->chain_pos);
        
@@ -46,7 +59,21 @@ int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr)
                field.in_handler = NULL;
                field.in_handler_priv = NULL;
                
-               jtag_add_ir_scan(1, &field, -1);
+               
+               
+               if (caller_error_handler)
+               {
+                       jtag_set_check_value(&field, NULL, NULL, caller_error_handler);
+               }
+               else
+               {
+                       error_handler_t error_handler;
+                       error_handler.error_handler = arm_jtag_set_instr_error_handler;
+                       error_handler.error_handler_priv = NULL;
+                       jtag_set_check_value(&field, NULL, NULL, &error_handler);
+               }
+               jtag_add_ir_scan(1, &field, -1, NULL);
+               
                
                free(field.out_value);
        }
@@ -58,6 +85,9 @@ int arm_jtag_scann(arm_jtag_t *jtag_info, u32 new_scan_chain)
 {
        if(jtag_info->cur_scan_chain != new_scan_chain)
        {
+#ifdef _ARM_JTAG_SCAN_N_CHECK_
+               u8 scan_n_check_value = 1 << (jtag_info->scann_size - 1);
+#endif
                scan_field_t field;
                
                field.device = jtag_info->chain_pos;
@@ -65,15 +95,17 @@ int arm_jtag_scann(arm_jtag_t *jtag_info, u32 new_scan_chain)
                field.out_value = calloc(CEIL(field.num_bits, 8), 1);
                buf_set_u32(field.out_value, 0, field.num_bits, new_scan_chain);
                field.out_mask = NULL;
-               //field.in_value = &scan_n_capture;
                field.in_value = NULL;
-               field.in_check_value = NULL;
-               field.in_check_mask = NULL;
+#ifdef _ARM_JTAG_SCAN_N_CHECK_
+               jtag_set_check_value(&field, &scan_n_check_value, NULL, NULL, NULL);
+#else
                field.in_handler = NULL;
                field.in_handler_priv = NULL;
+#endif 
+               
                
-               arm_jtag_set_instr(jtag_info, jtag_info->scann_instr);
-               jtag_add_dr_scan(1, &field, -1);
+               arm_jtag_set_instr(jtag_info, jtag_info->scann_instr, NULL);
+               jtag_add_dr_scan(1, &field, -1, NULL);
                
                jtag_info->cur_scan_chain = new_scan_chain;
                
@@ -106,11 +138,91 @@ int arm_jtag_setup_connection(arm_jtag_t *jtag_info)
        return ERROR_OK;
 }
 
+/* read JTAG buffer into host-endian u32, flipping bit-order */
 int arm_jtag_buf_to_u32_flip(u8 *in_buf, void *priv)
 {
        u32 *dest = priv;
-       
-       *dest = flip_u32(buf_get_u32(in_buf, 0, 32), 32);
-       
+       *dest = flip_u32(le_to_h_u32(in_buf), 32);
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into little-endian u32, flipping bit-order */
+int arm_jtag_buf_to_le32_flip(u8 *in_buf, void *priv)
+{
+       h_u32_to_le(((u8*)priv), flip_u32(le_to_h_u32(in_buf), 32));
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into little-endian u16, flipping bit-order */
+int arm_jtag_buf_to_le16_flip(u8 *in_buf, void *priv)
+{
+       h_u16_to_le(((u8*)priv), flip_u32(le_to_h_u32(in_buf), 32) & 0xffff);
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into big-endian u32, flipping bit-order */
+int arm_jtag_buf_to_be32_flip(u8 *in_buf, void *priv)
+{
+       h_u32_to_be(((u8*)priv), flip_u32(le_to_h_u32(in_buf), 32));
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into big-endian u16, flipping bit-order */
+int arm_jtag_buf_to_be16_flip(u8 *in_buf, void *priv)
+{
+       h_u16_to_be(((u8*)priv), flip_u32(le_to_h_u32(in_buf), 32) & 0xffff);
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into u8, flipping bit-order */
+int arm_jtag_buf_to_8_flip(u8 *in_buf, void *priv)
+{
+       u8 *dest = priv;
+       *dest = flip_u32(le_to_h_u32(in_buf), 32) & 0xff;
+       return ERROR_OK;
+}
+
+/* not-flipping variants */
+/* read JTAG buffer into host-endian u32 */
+int arm_jtag_buf_to_u32(u8 *in_buf, void *priv)
+{
+       u32 *dest = priv;
+       *dest = le_to_h_u32(in_buf);
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into little-endian u32 */
+int arm_jtag_buf_to_le32(u8 *in_buf, void *priv)
+{
+       h_u32_to_le(((u8*)priv), le_to_h_u32(in_buf));
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into little-endian u16 */
+int arm_jtag_buf_to_le16(u8 *in_buf, void *priv)
+{
+       h_u16_to_le(((u8*)priv), le_to_h_u32(in_buf) & 0xffff);
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into big-endian u32 */
+int arm_jtag_buf_to_be32(u8 *in_buf, void *priv)
+{
+       h_u32_to_be(((u8*)priv), le_to_h_u32(in_buf));
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into big-endian u16 */
+int arm_jtag_buf_to_be16(u8 *in_buf, void *priv)
+{
+       h_u16_to_be(((u8*)priv), le_to_h_u32(in_buf) & 0xffff);
+       return ERROR_OK;
+}
+
+/* read JTAG buffer into u8 */
+int arm_jtag_buf_to_8(u8 *in_buf, void *priv)
+{
+       u8 *dest = priv;
+       *dest = le_to_h_u32(in_buf) & 0xff;
        return ERROR_OK;
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)