wip
[openocd.git] / src / target / arm9tdmi.c
index dcb35dabb88d93a3acc12e41f88ed9e73309eb4d..89842d504613bf45f2ba1b053e2a5d2a3e39eafd 100644 (file)
@@ -2,6 +2,12 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2008 by Spencer Oliver                                  *
+ *   spen@spen-soft.co.uk                                                  *
+ *                                                                         *
+ *   Copyright (C) 2008 by Hongtao Zheng                                   *
+ *   hontor@126.com                                                        *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -105,6 +111,7 @@ arm9tdmi_vector_t arm9tdmi_vectors[] =
 
 int arm9tdmi_examine_debug_reason(target_t *target)
 {
+       int retval = ERROR_OK;
        /* get pointers to arch-specific information */
        armv4_5_common_t *armv4_5 = target->arch_info;
        arm7_9_common_t *arm7_9 = armv4_5->arch_info;
@@ -150,11 +157,17 @@ int arm9tdmi_examine_debug_reason(target_t *target)
                fields[2].in_handler = NULL;
                fields[2].in_handler_priv = NULL;
                
-               arm_jtag_scann(&arm7_9->jtag_info, 0x1);
+               if((retval = arm_jtag_scann(&arm7_9->jtag_info, 0x1)) != ERROR_OK)
+               {
+                       return retval;
+               }
                arm_jtag_set_instr(&arm7_9->jtag_info, arm7_9->jtag_info.intest_instr, NULL);
 
                jtag_add_dr_scan(3, fields, TAP_PD);
-               jtag_execute_queue();
+               if((retval = jtag_execute_queue()) != ERROR_OK)
+               {
+                       return retval;
+               }
                
                fields[0].in_value = NULL;
                fields[0].out_value = databus;
@@ -180,6 +193,7 @@ int arm9tdmi_examine_debug_reason(target_t *target)
 /* put an instruction in the ARM9TDMI pipeline or write the data bus, and optionally read data */
 int arm9tdmi_clock_out(arm_jtag_t *jtag_info, u32 instr, u32 out, u32 *in, int sysspeed)
 {
+       int retval = ERROR_OK;
        scan_field_t fields[3];
        u8 out_buf[4];
        u8 instr_buf[4];
@@ -194,7 +208,10 @@ int arm9tdmi_clock_out(arm_jtag_t *jtag_info, u32 instr, u32 out, u32 *in, int s
                buf_set_u32(&sysspeed_buf, 2, 1, 1);
        
        jtag_add_end_state(TAP_PD);
-       arm_jtag_scann(jtag_info, 0x1);
+       if((retval = arm_jtag_scann(jtag_info, 0x1)) != ERROR_OK)
+       {
+               return retval;
+       }
        
        arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL);
                
@@ -242,7 +259,10 @@ int arm9tdmi_clock_out(arm_jtag_t *jtag_info, u32 instr, u32 out, u32 *in, int s
        
 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
        {
-               jtag_execute_queue();
+               if((retval = jtag_execute_queue()) != ERROR_OK)
+               {
+                       return retval;
+               }
                
                if (in)
                {
@@ -259,10 +279,14 @@ int arm9tdmi_clock_out(arm_jtag_t *jtag_info, u32 instr, u32 out, u32 *in, int s
 /* just read data (instruction and data-out = don't care) */
 int arm9tdmi_clock_data_in(arm_jtag_t *jtag_info, u32 *in)
 {
+       int retval = ERROR_OK;;
        scan_field_t fields[3];
 
        jtag_add_end_state(TAP_PD);
-       arm_jtag_scann(jtag_info, 0x1);
+       if((retval = arm_jtag_scann(jtag_info, 0x1)) != ERROR_OK)
+       {
+               return retval;
+       }
        
        arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL);
                
@@ -302,8 +326,11 @@ int arm9tdmi_clock_data_in(arm_jtag_t *jtag_info, u32 *in)
        
 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
        {
-               jtag_execute_queue();
-                       
+               if((retval = jtag_execute_queue()) != ERROR_OK)
+               {
+                       return retval;
+               }
+               
                if (in)
                {
                        LOG_DEBUG("in: 0x%8.8x", *in);
@@ -324,10 +351,14 @@ int arm9tdmi_clock_data_in(arm_jtag_t *jtag_info, u32 *in)
  */
 int arm9tdmi_clock_data_in_endianness(arm_jtag_t *jtag_info, void *in, int size, int be)
 {
+       int retval = ERROR_OK;
        scan_field_t fields[3];
        
        jtag_add_end_state(TAP_PD);
-       arm_jtag_scann(jtag_info, 0x1);
+       if((retval = arm_jtag_scann(jtag_info, 0x1)) != ERROR_OK)
+       {
+               return retval;
+       }
        
        arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL);
                
@@ -378,8 +409,11 @@ int arm9tdmi_clock_data_in_endianness(arm_jtag_t *jtag_info, void *in, int size,
        
 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
        {
-               jtag_execute_queue();
-                       
+               if((retval = jtag_execute_queue()) != ERROR_OK)
+               {
+                       return retval;
+               }
+               
                if (in)
                {
                        LOG_DEBUG("in: 0x%8.8x", *(u32*)in);
@@ -396,6 +430,7 @@ int arm9tdmi_clock_data_in_endianness(arm_jtag_t *jtag_info, void *in, int size,
 
 void arm9tdmi_change_to_arm(target_t *target, u32 *r0, u32 *pc)
 {
+       int retval = ERROR_OK;
        /* get pointers to arch-specific information */
        armv4_5_common_t *armv4_5 = target->arch_info;
        arm7_9_common_t *arm7_9 = armv4_5->arch_info;
@@ -436,7 +471,10 @@ void arm9tdmi_change_to_arm(target_t *target, u32 *r0, u32 *pc)
        /* NOP fetched, BX in Execute (1) */
        arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
        
-       jtag_execute_queue();
+       if((retval = jtag_execute_queue()) != ERROR_OK)
+       {
+               return;
+       }
        
        /* fix program counter:
         * MOV r0, r15 was the 5th instruction (+8)
@@ -806,7 +844,7 @@ void arm9tdmi_branch_resume_thumb(target_t *target)
 
 }
 
-void arm9tdmi_enable_single_step(target_t *target)
+void arm9tdmi_enable_single_step(target_t *target, u32 next_pc)
 {
        /* get pointers to arch-specific information */
        armv4_5_common_t *armv4_5 = target->arch_info;
@@ -819,7 +857,7 @@ void arm9tdmi_enable_single_step(target_t *target)
        }
        else
        {
-               arm7_9_enable_eice_step(target);
+               arm7_9_enable_eice_step(target, next_pc);
        }
 }
 
@@ -1032,7 +1070,7 @@ int arm9tdmi_register_commands(struct command_context_s *cmd_ctx)
        register_command(cmd_ctx, arm9tdmi_cmd, "vector_catch", handle_arm9tdmi_catch_vectors_command, COMMAND_EXEC, "catch arm920t vectors ['all'|'none'|'<vec1 vec2 ...>']");
        
        
-       return ERROR_OK;
+       return retval;
 
 }
 
@@ -1116,12 +1154,3 @@ int handle_arm9tdmi_catch_vectors_command(struct command_context_s *cmd_ctx, cha
 
        return ERROR_OK;
 }
-
-
-
-/*
- * Local Variables: ***
- * c-basic-offset: 4 ***
- * tab-width: 4 ***
- * End: ***
- */

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)