Uwe Hermann <uwe@hermann-uwe.de> oocdlink file
[openocd.git] / src / target / arm11.c
index f93e716a078cd5a02d15a8512f49c1b08d6aac77..39a6817de0599e10f793c49745a2662a89004346 100644 (file)
@@ -393,7 +393,7 @@ static void arm11_on_enter_debug_state(arm11_common_t * arm11)
        arm11_setup_field(arm11,  1, NULL, NULL,        chain5_fields + 1);
        arm11_setup_field(arm11,  1, NULL, NULL,        chain5_fields + 2);
 
-       arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, TAP_PD);
+       arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, TAP_DRPAUSE);
        }
        else
        {
@@ -627,7 +627,7 @@ void arm11_leave_debug_state(arm11_common_t * arm11)
        arm11_setup_field(arm11,  1, &Ready,    NULL, chain5_fields + 1);
        arm11_setup_field(arm11,  1, &Valid,    NULL, chain5_fields + 2);
 
-       arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, TAP_PD);
+       arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, TAP_DRPAUSE);
        }
 
        arm11_record_register_history(arm11);
@@ -709,6 +709,8 @@ int arm11_target_request_data(struct target_s *target, u32 size, u8 *buffer)
 /* target execution control */
 int arm11_halt(struct target_s *target)
 {
+       int retval = ERROR_OK;
+
        FNC_INFO;
 
        arm11_common_t * arm11 = target->arch_info;
@@ -733,9 +735,12 @@ int arm11_halt(struct target_s *target)
        return ERROR_OK;
        }
 
-       arm11_add_IR(arm11, ARM11_HALT, TAP_RTI);
+       arm11_add_IR(arm11, ARM11_HALT, TAP_IDLE);
 
-       jtag_execute_queue();
+       if((retval = jtag_execute_queue()) != ERROR_OK)
+       {
+               return retval;
+       }
 
        u32 dscr;
 
@@ -754,14 +759,19 @@ int arm11_halt(struct target_s *target)
        target->state           = TARGET_HALTED;
        target->debug_reason    = arm11_get_DSCR_debug_reason(dscr);
 
-       target_call_event_callbacks(target,
-       old_state == TARGET_DEBUG_RUNNING ? TARGET_EVENT_DEBUG_HALTED : TARGET_EVENT_HALTED);
+       if((retval = target_call_event_callbacks(target,
+                       old_state == TARGET_DEBUG_RUNNING ? TARGET_EVENT_DEBUG_HALTED : TARGET_EVENT_HALTED)) != ERROR_OK)
+       {
+               return retval;
+       }
 
        return ERROR_OK;
 }
 
 int arm11_resume(struct target_s *target, int current, u32 address, int handle_breakpoints, int debug_execution)
 {
+       int retval = ERROR_OK;
+
        FNC_INFO;
 
 //       LOG_DEBUG("current %d  address %08x  handle_breakpoints %d  debug_execution %d",
@@ -831,9 +841,12 @@ int arm11_resume(struct target_s *target, int current, u32 address, int handle_b
 
        arm11_leave_debug_state(arm11);
 
-       arm11_add_IR(arm11, ARM11_RESTART, TAP_RTI);
+       arm11_add_IR(arm11, ARM11_RESTART, TAP_IDLE);
 
-       jtag_execute_queue();
+       if((retval = jtag_execute_queue()) != ERROR_OK)
+       {
+               return retval;
+       }
 
        while (1)
        {
@@ -847,15 +860,21 @@ int arm11_resume(struct target_s *target, int current, u32 address, int handle_b
 
        if (!debug_execution)
        {
-       target->state           = TARGET_RUNNING;
-       target->debug_reason    = DBG_REASON_NOTHALTED;
-       target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
+               target->state           = TARGET_RUNNING;
+               target->debug_reason    = DBG_REASON_NOTHALTED;
+               if((retval = target_call_event_callbacks(target, TARGET_EVENT_RESUMED)) != ERROR_OK)
+               {
+                       return retval;
+               }
        }
        else
        {
-       target->state           = TARGET_DEBUG_RUNNING;
-       target->debug_reason    = DBG_REASON_NOTHALTED;
-       target_call_event_callbacks(target, TARGET_EVENT_DEBUG_RESUMED);
+               target->state           = TARGET_DEBUG_RUNNING;
+               target->debug_reason    = DBG_REASON_NOTHALTED;
+               if((retval = target_call_event_callbacks(target, TARGET_EVENT_RESUMED)) != ERROR_OK)
+               {
+                       return retval;
+               }
        }
 
        return ERROR_OK;
@@ -863,6 +882,8 @@ int arm11_resume(struct target_s *target, int current, u32 address, int handle_b
 
 int arm11_step(struct target_s *target, int current, u32 address, int handle_breakpoints)
 {
+       int retval = ERROR_OK;
+
        FNC_INFO;
 
        LOG_DEBUG("target->state: %s",
@@ -935,9 +956,12 @@ int arm11_step(struct target_s *target, int current, u32 address, int handle_bre
 
        arm11_leave_debug_state(arm11);
 
-       arm11_add_IR(arm11, ARM11_RESTART, TAP_RTI);
+       arm11_add_IR(arm11, ARM11_RESTART, TAP_IDLE);
 
-       jtag_execute_queue();
+       if((retval = jtag_execute_queue()) != ERROR_OK)
+       {
+               return retval;
+       }
 
        /** \todo TODO: add a timeout */
 
@@ -964,7 +988,10 @@ int arm11_step(struct target_s *target, int current, u32 address, int handle_bre
 //       target->state         = TARGET_HALTED;
        target->debug_reason    = DBG_REASON_SINGLESTEP;
 
-       target_call_event_callbacks(target, TARGET_EVENT_HALTED);
+       if((retval = target_call_event_callbacks(target, TARGET_EVENT_HALTED)) != ERROR_OK)
+       {
+               return retval;
+       }
 
        return ERROR_OK;
 }
@@ -1411,9 +1438,17 @@ int arm11_run_algorithm(struct target_s *target, int num_mem_params, mem_param_t
                goto restore;
        }
 
-       target_resume(target, 0, entry_point, 1, 0);  // no debug, otherwise breakpoint is not set
+       // no debug, otherwise breakpoint is not set
+       if((retval = target_resume(target, 0, entry_point, 1, 0)) != ERROR_OK)
+       {
+               return retval;
+       }
+
+       if((retval = target_wait_state(target, TARGET_HALTED, timeout_ms)) != ERROR_OK)
+       {
+               return retval;
+       }
 
-       target_wait_state(target, TARGET_HALTED, timeout_ms);
        if (target->state != TARGET_HALTED)
        {
                if ((retval=target_halt(target))!=ERROR_OK)
@@ -1483,6 +1518,7 @@ restore:
 
 int arm11_target_create(struct target_s *target, Jim_Interp *interp)
 {
+       int retval = ERROR_OK;
        FNC_INFO;
 
        NEW(arm11_common_t, arm11, 1);
@@ -1490,16 +1526,20 @@ int arm11_target_create(struct target_s *target, Jim_Interp *interp)
        arm11->target = target;
 
        /* prepare JTAG information for the new target */
-       arm11->jtag_info.chain_pos      = target->chain_position;
+       arm11->jtag_info.tap    = target->tap;
        arm11->jtag_info.scann_size     = 5;
 
-       arm_jtag_setup_connection(&arm11->jtag_info);
+       if((retval = arm_jtag_setup_connection(&arm11->jtag_info)) != ERROR_OK)
+       {
+               return retval;
+       }
 
-       jtag_device_t *device = jtag_get_device(target->chain_position);
+       if (target->tap==NULL)
+               return ERROR_FAIL;
 
-       if (device->ir_length != 5)
+       if (target->tap->ir_length != 5)
        {
-               LOG_ERROR("'target arm11' expects 'jtag_device 5 0x01 0x1F 0x1E'");
+               LOG_ERROR("'target arm11' expects IR LENGTH = 5");
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
@@ -1511,7 +1551,8 @@ int arm11_target_create(struct target_s *target, Jim_Interp *interp)
 int arm11_init_target(struct command_context_s *cmd_ctx, struct target_s *target)
 {
        /* Initialize anything we can set up without talking to the target */
-       return ERROR_OK;
+       return arm11_build_reg_cache(target);
+
 }
 
 /* talk to the target and set things up */
@@ -1530,7 +1571,7 @@ int arm11_examine(struct target_s *target)
 
        arm11_setup_field(arm11, 32, NULL, &arm11->device_id, &idcode_field);
 
-       arm11_add_dr_scan_vc(1, &idcode_field, TAP_PD);
+       arm11_add_dr_scan_vc(1, &idcode_field, TAP_DRPAUSE);
 
        /* check DIDR */
 
@@ -1543,7 +1584,7 @@ int arm11_examine(struct target_s *target)
        arm11_setup_field(arm11, 32, NULL,      &arm11->didr,           chain0_fields + 0);
        arm11_setup_field(arm11,  8, NULL,      &arm11->implementor,    chain0_fields + 1);
 
-       arm11_add_dr_scan_vc(asizeof(chain0_fields), chain0_fields, TAP_RTI);
+       arm11_add_dr_scan_vc(asizeof(chain0_fields), chain0_fields, TAP_IDLE);
 
        if ((retval=jtag_execute_queue())!=ERROR_OK)
                return retval;
@@ -1583,8 +1624,6 @@ int arm11_examine(struct target_s *target)
        arm11->implementor,
        arm11->didr);
 
-       arm11_build_reg_cache(target);
-
        /* as a side-effect this reads DSCR and thus
         * clears the ARM11_DSCR_STICKY_PRECISE_DATA_ABORT / Sticky Precise Data Abort Flag
         * as suggested by the spec.
@@ -1643,7 +1682,7 @@ int arm11_set_reg(reg_t *reg, u8 *buf)
        return ERROR_OK;
 }
 
-void arm11_build_reg_cache(target_t *target)
+int arm11_build_reg_cache(target_t *target)
 {
        arm11_common_t *arm11 = target->arch_info;
 
@@ -1701,6 +1740,7 @@ void arm11_build_reg_cache(target_t *target)
        rs->def_index           = i;
        rs->target              = target;
        }
+       return ERROR_OK;
 }
 
 int arm11_handle_bool(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, bool * var, char * name)
@@ -1790,22 +1830,22 @@ const char arm11_mcr_syntax[] = "Syntax: mcr <jtag_target> <coprocessor> <opcode
 
 arm11_common_t * arm11_find_target(const char * arg)
 {
-       size_t jtag_target              = strtoul(arg, NULL, 0);
-
-       {target_t * t;
-       for (t = all_targets; t; t = t->next)
-       {
-               if (strcmp(t->type->name,"arm11"))
-               continue;
-
-       arm11_common_t * arm11 = t->arch_info;
+       jtag_tap_t *tap;
+       target_t * t;
 
-       if (arm11->jtag_info.chain_pos != jtag_target)
-               continue;
-
-       return arm11;
-       }}
+       tap = jtag_TapByString( arg );
+       if( !tap ){
+               return NULL;
+       }
 
+       for (t = all_targets; t; t = t->next){
+               if( t->tap == tap ){
+                       if( 0 == strcmp(t->type->name,"arm11")){
+                               arm11_common_t * arm11 = t->arch_info;
+                               return arm11;
+                       }
+               }
+       }
        return 0;
 }
 

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)