Reset wip. Just adding hooks. This is just to reduce the size of the actual change...
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 11 Apr 2008 14:06:42 +0000 (14:06 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 11 Apr 2008 14:06:42 +0000 (14:06 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@565 b42882b7-edfa-0310-969c-e2dbd0fdcd60

12 files changed:
src/jtag/jtag.c
src/jtag/jtag.h
src/server/gdb_server.c
src/target/arm720t.c
src/target/arm7_9_common.c
src/target/arm920t.c
src/target/arm926ejs.c
src/target/armv4_5.c
src/target/armv7m.c
src/target/feroceon.c
src/target/target.c
src/target/target.h

index 8ebd92b109629d9b1a10b37ad2195cebf1a81b30..fa439ec5a026854b04232dd13ddeeae0be4b1056 100644 (file)
@@ -1482,6 +1482,9 @@ int jtag_register_commands(struct command_context_s *cmd_ctx)
 
 int jtag_interface_init(struct command_context_s *cmd_ctx)
 {
+       if (jtag)
+               return ERROR_OK;
+       
        if (!jtag_interface)
        {
                /* nothing was previously specified by "interface" command */
@@ -1511,11 +1514,12 @@ static int jtag_init_inner(struct command_context_s *cmd_ctx)
 {
        int validate_tries = 0;
        jtag_device_t *device;
+       int retval;
 
        LOG_DEBUG("-");
        
-       if (!jtag && jtag_interface_init(cmd_ctx) != ERROR_OK)
-               return ERROR_JTAG_INIT_FAILED;
+       if ((retval=jtag_interface_init(cmd_ctx)) != ERROR_OK)
+               return retval;
 
        device = jtag_devices;
        jtag_ir_scan_size = 0;
@@ -1528,7 +1532,8 @@ static int jtag_init_inner(struct command_context_s *cmd_ctx)
        }
        
        jtag_add_tlr();
-       jtag_execute_queue();
+       if ((retval=jtag_execute_queue())==ERROR_OK)
+               return retval;
 
        /* examine chain first, as this could discover the real chain layout */
        if (jtag_examine_chain() != ERROR_OK)
@@ -1930,7 +1935,7 @@ int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
-       if (!jtag && jtag_interface_init(cmd_ctx) != ERROR_OK)
+       if (jtag_interface_init(cmd_ctx) != ERROR_OK)
                return ERROR_JTAG_INIT_FAILED;
 
        jtag_add_reset(trst, srst);
index b7ce094d6aeec0f17d6e9ffa639fc70dfa408eed..27ffbf87f0f28165bfb8a6387c2dec7074ef775e 100644 (file)
@@ -241,6 +241,10 @@ enum reset_types
 
 extern enum reset_types jtag_reset_config;
 
+/* initialize interface upon startup. A successful no-op 
+ * upon subsequent invocations
+ */
+extern int jtag_interface_init(struct command_context_s *cmd_ctx);
 /* initialize JTAG chain using only a TLR reset. If init fails,
  * try reset + init.
  */
index 9a5b81a49360d19e188c7931460a734b79bd40af..3e4ba8248acda76c14e0b73a656aad33c6a9143a 100644 (file)
@@ -690,7 +690,7 @@ int gdb_new_connection(connection_t *connection)
         * instantaneous and thus avoiding annoying timeout problems during
         * connect. 
         */
-       gdb_service->target->type->halt(gdb_service->target);
+       target_halt(gdb_service->target);
        
        /* remove the initial ACK from the incoming buffer */
        if ((retval = gdb_get_char(connection, &initial_ack)) != ERROR_OK)
@@ -1231,7 +1231,7 @@ void gdb_step_continue_packet(connection_t *connection, target_t *target, char *
        if (packet[0] == 'c')
        {
                LOG_DEBUG("continue");
-               target->type->resume(target, current, address, 0, 0); /* resume at current address, don't handle breakpoints, not debugging */
+               target_resume(target, current, address, 0, 0); /* resume at current address, don't handle breakpoints, not debugging */
        }
        else if (packet[0] == 's')
        {
@@ -1755,7 +1755,7 @@ int gdb_detach(connection_t *connection, target_t *target)
        switch( detach_mode )
        {
                case GDB_DETACH_RESUME:
-                       target->type->resume(target, 1, 0, 1, 0);
+                       target_resume(target, 1, 0, 1, 0);
                        break;
 
                case GDB_DETACH_RESET:
@@ -1763,7 +1763,7 @@ int gdb_detach(connection_t *connection, target_t *target)
                        break;
 
                case GDB_DETACH_HALT:
-                       target->type->halt(target);
+                       target_halt(target);
                        break;
 
                case GDB_DETACH_NOTHING:
@@ -1904,7 +1904,7 @@ int gdb_input_inner(connection_t *connection)
                {
                        if (target->state == TARGET_RUNNING)
                        {
-                               target->type->halt(target);
+                               target_halt(target);
                                gdb_con->ctrl_c = 0;
                        }
                }
index 24885d2e5e73185b94a7f38e10d255eeed373f06..9645db855b48f3250f470b39e827d1a9f4f72501 100644 (file)
@@ -368,7 +368,7 @@ int arm720t_soft_reset_halt(struct target_s *target)
        int i;
        reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
        
-       target->type->halt(target);
+       target_halt(target);
        
        for (i=0; i<10; i++)
        {
index 106b95db1c599d9cf8de25eb03eab6a61ed501a7..14d0314149b9da5913b9d3cd15fe500accd1413f 100644 (file)
@@ -755,14 +755,6 @@ int arm7_9_assert_reset(target_t *target)
 
        if ((target->reset_mode == RESET_HALT) || (target->reset_mode == RESET_INIT))
        {
-               reg_t *dbg_ctrl = &arm7_9->eice_cache->reg_list[EICE_DBG_CTRL];
-               
-               /* program EmbeddedICE Debug Control Register to deassert DBGRQ
-                * i.e. resume.
-                */
-               buf_set_u32(dbg_ctrl->value, EICE_DBG_CONTROL_DBGRQ, 1, 0);     
-               embeddedice_store_reg(dbg_ctrl);
-
                /*
                 * Some targets do not support communication while SRST is asserted. We need to
                 * set up the reset vector catch here.
@@ -867,7 +859,7 @@ int arm7_9_soft_reset_halt(struct target_s *target)
        int i;
        int retval;
        
-       if ((retval=target->type->halt(target))!=ERROR_OK)
+       if ((retval=target_halt(target))!=ERROR_OK)
                return retval;
        
        for (i=0; i<10; i++)
@@ -2176,11 +2168,11 @@ int arm7_9_bulk_write_memory(target_t *target, u32 address, u32 count, u8 *buffe
                }
        }
        
-       target->type->halt(target);
+       target_halt(target);
        
        for (i=0; i<100; i++)
        {
-               target->type->poll(target);
+               target_poll(target);
                if (target->state == TARGET_HALTED)
                        break;
                usleep(1000); /* sleep 1ms */
index 93ddb4cafd4c1bd1541ee694cf2c0d96ad2e989e..2dff6b9428599c9590f96127287224a150ff5a3a 100644 (file)
@@ -624,7 +624,7 @@ int arm920t_soft_reset_halt(struct target_s *target)
        reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
        int i;
        
-       target->type->halt(target);
+       target_halt(target);
        
        for (i=0; i<10; i++)
        {
index 50abd4627f149e097ce92be92ec25e906c21a259..f46760e54e07b16c843b98fb32b765090e6805c7 100644 (file)
@@ -580,7 +580,7 @@ int arm926ejs_soft_reset_halt(struct target_s *target)
        reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
        int i;
        
-       target->type->halt(target);
+       target_halt(target);
        
        for (i=0; i<10; i++)
        {
index 0b6b34570a6f702461ddd241ea6ad949917accb1..07033bfbb8937c2974e46dce0cd61c18d2d8975d 100644 (file)
@@ -574,22 +574,22 @@ int armv4_5_run_algorithm(struct target_s *target, int num_mem_params, mem_param
                return ERROR_TARGET_FAILURE;
        }
        
-       target->type->resume(target, 0, entry_point, 1, 1);
-       target->type->poll(target);
+       target_resume(target, 0, entry_point, 1, 1);
+       target_poll(target);
        
        while (target->state != TARGET_HALTED)
        {
                usleep(10000);
-               target->type->poll(target);
+               target_poll(target);
                if ((timeout_ms -= 10) <= 0)
                {
                        LOG_ERROR("timeout waiting for algorithm to complete, trying to halt target");
-                       target->type->halt(target);
+                       target_halt(target);
                        timeout_ms = 1000;
                        while (target->state != TARGET_HALTED)
                        {
                                usleep(10000);
-                               target->type->poll(target);
+                               target_poll(target);
                                if ((timeout_ms -= 10) <= 0)
                                {
                                        LOG_ERROR("target didn't reenter debug state, exiting");
index 81b477a90787e15481c950b390e7e3f0ca72d737..eaf1eb9536f1baa30bc5c785d0271edd634d0ec4 100644 (file)
@@ -349,22 +349,22 @@ int armv7m_run_algorithm(struct target_s *target, int num_mem_params, mem_param_
        
        /* This code relies on the target specific  resume() and  poll()->debug_entry() 
        sequence to write register values to the processor and the read them back */
-       target->type->resume(target, 0, entry_point, 1, 1);
-       target->type->poll(target);
+       target_resume(target, 0, entry_point, 1, 1);
+       target_poll(target);
        
        while (target->state != TARGET_HALTED)
        {
                usleep(5000);
-               target->type->poll(target);
+               target_poll(target);
                if ((timeout_ms -= 5) <= 0)
                {
                        LOG_ERROR("timeout waiting for algorithm to complete, trying to halt target");
-                       target->type->halt(target);
+                       target_halt(target);
                        timeout_ms = 1000;
                        while (target->state != TARGET_HALTED)
                        {
                                usleep(10000);
-                               target->type->poll(target);
+                               target_poll(target);
                                if ((timeout_ms -= 10) <= 0)
                                {
                                        LOG_ERROR("target didn't reenter debug state, exiting");
index c6edc429d1db819bebb4b08e83e4303ebe635fc5..0cd632bd77fb3e65cf149d291931801793e1a2b8 100644 (file)
@@ -547,9 +547,9 @@ int feroceon_bulk_write_memory(target_t *target, u32 address, u32 count, u8 *buf
                buffer += 4;
        }
 
-       target->type->halt(target);
+       target_halt(target);
        while (target->state != TARGET_HALTED)
-               target->type->poll(target);
+               target_poll(target);
 
        /* restore target state */
        for (i = 0; i <= 5; i++)
index 28639a76026e8c64029c80a75c32d2447908f6f8..ee387dbda5844d38739209f10dc041bbf36d9922 100644 (file)
@@ -248,11 +248,45 @@ int target_run_and_halt_handler(void *priv)
 {
        target_t *target = priv;
        
-       target->type->halt(target);
+       target_halt(target);
        
        return ERROR_OK;
 }
 
+int target_poll(struct target_s *target)
+{
+       /* We can't poll until after examine */
+       if (!target->type->examined)
+       {
+               /* Fail silently lest we pollute the log */
+               return ERROR_FAIL;
+       }
+       return target->type->poll(target);
+}
+
+int target_halt(struct target_s *target)
+{
+       /* We can't poll until after examine */
+       if (!target->type->examined)
+       {
+               LOG_ERROR("Target not examined yet");
+               return ERROR_FAIL;
+       }
+       return target->type->halt(target);
+}
+
+int target_resume(struct target_s *target, int current, u32 address, int handle_breakpoints, int debug_execution)
+{
+       /* We can't poll until after examine */
+       if (!target->type->examined)
+       {
+               LOG_ERROR("Target not examined yet");
+               return ERROR_FAIL;
+       }
+       return target->type->resume(target, current, address, handle_breakpoints, debug_execution);
+}
+
+
 int target_process_reset(struct command_context_s *cmd_ctx)
 {
        int retval = ERROR_OK;
@@ -325,10 +359,10 @@ int target_process_reset(struct command_context_s *cmd_ctx)
                                target_register_event_callback(target_init_handler, cmd_ctx);
                                break;
                        case RESET_HALT:
-                               target->type->halt(target);
+                               target_halt(target);
                                break;
                        case RESET_INIT:
-                               target->type->halt(target);
+                               target_halt(target);
                                target_register_event_callback(target_init_handler, cmd_ctx);
                                break;
                        default:
@@ -371,7 +405,7 @@ int target_process_reset(struct command_context_s *cmd_ctx)
                while (target)
                {
                        LOG_DEBUG("Polling target");
-                       target->type->poll(target);
+                       target_poll(target);
                        if ((target->reset_mode == RESET_RUN_AND_INIT) || 
                                        (target->reset_mode == RESET_RUN_AND_HALT) ||
                                        (target->reset_mode == RESET_HALT) ||
@@ -1414,19 +1448,14 @@ int handle_working_area_command(struct command_context_s *cmd_ctx, char *cmd, ch
 /* process target state changes */
 int handle_target(void *priv)
 {
-       int retval;
        target_t *target = targets;
        
        while (target)
        {
-               /* only poll if target isn't already halted */
-               if (target->state != TARGET_HALTED)
+               if (target_continous_poll)
                {
-                       if (target_continous_poll)
-                               if ((retval = target->type->poll(target)) != ERROR_OK)
-                               {
-                                       LOG_ERROR("couldn't poll target(%d). It's due for a reset.", retval);
-                               }
+                       /* polling may fail silently until the target has been examined */
+                       target_poll(target);
                }
        
                target = target->next;
@@ -1565,7 +1594,7 @@ int handle_poll_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
 
        if (argc == 0)
        {
-               target->type->poll(target);
+               target_poll(target);
                target_arch_state(target);
        }
        else
@@ -1610,7 +1639,7 @@ int handle_wait_halt_command(struct command_context_s *cmd_ctx, char *cmd, char
 static void target_process_events(struct command_context_s *cmd_ctx)
 {
        target_t *target = get_current_target(cmd_ctx);
-       target->type->poll(target);
+       target_poll(target);
        target_call_timer_callbacks_now();
 }
 
@@ -1625,7 +1654,7 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
        target_t *target = get_current_target(cmd_ctx);
        for (;;)
        {
-               if ((retval=target->type->poll(target))!=ERROR_OK)
+               if ((retval=target_poll(target))!=ERROR_OK)
                        return retval;
                target_call_timer_callbacks_now();
                if (target->state == state)
@@ -1656,7 +1685,7 @@ int handle_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
 
        LOG_DEBUG("-");
 
-       if ((retval = target->type->halt(target)) != ERROR_OK)
+       if ((retval = target_halt(target)) != ERROR_OK)
        {
                return retval;
        }
@@ -1733,9 +1762,9 @@ int handle_resume_command(struct command_context_s *cmd_ctx, char *cmd, char **a
        target_t *target = get_current_target(cmd_ctx);
        
        if (argc == 0)
-               retval = target->type->resume(target, 1, 0, 1, 0); /* current pc, addr = 0, handle breakpoints, not debugging */
+               retval = target_resume(target, 1, 0, 1, 0); /* current pc, addr = 0, handle breakpoints, not debugging */
        else if (argc == 1)
-               retval = target->type->resume(target, 0, strtoul(args[0], NULL, 0), 1, 0); /* addr = args[0], handle breakpoints, not debugging */
+               retval = target_resume(target, 0, strtoul(args[0], NULL, 0), 1, 0); /* addr = args[0], handle breakpoints, not debugging */
        else
        {
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -2485,18 +2514,18 @@ int handle_profile_command(struct command_context_s *cmd_ctx, char *cmd, char **
        
        for (;;)
        {
-               target->type->poll(target);
+               target_poll(target);
                if (target->state == TARGET_HALTED)
                {
                        u32 t=*((u32 *)reg->value);
                        samples[numSamples++]=t;
-                       retval = target->type->resume(target, 1, 0, 0, 0); /* current pc, addr = 0, do not handle breakpoints, not debugging */
-                       target->type->poll(target);
+                       retval = target_resume(target, 1, 0, 0, 0); /* current pc, addr = 0, do not handle breakpoints, not debugging */
+                       target_poll(target);
                        usleep(10*1000); // sleep 10ms, i.e. <100 samples/second.
                } else if (target->state == TARGET_RUNNING)
                {
                        // We want to quickly sample the PC.
-                       target->type->halt(target);
+                       target_halt(target);
                } else
                {
                        command_print(cmd_ctx, "Target not halted or running");
@@ -2512,12 +2541,12 @@ int handle_profile_command(struct command_context_s *cmd_ctx, char *cmd, char **
                if ((numSamples>=maxSample) || ((now.tv_sec >= timeout.tv_sec) && (now.tv_usec >= timeout.tv_usec)))
                {
                        command_print(cmd_ctx, "Profiling completed. %d samples.", numSamples);
-                       target->type->poll(target);
+                       target_poll(target);
                        if (target->state == TARGET_HALTED)
                        {
-                               target->type->resume(target, 1, 0, 0, 0); /* current pc, addr = 0, do not handle breakpoints, not debugging */
+                               target_resume(target, 1, 0, 0, 0); /* current pc, addr = 0, do not handle breakpoints, not debugging */
                        }
-                       target->type->poll(target);
+                       target_poll(target);
                        writeGmon(samples, numSamples, args[1]);
                        command_print(cmd_ctx, "Wrote %s", args[1]);
                        break;
index 6480bc5b62342d7b789627b67a82586bc57cf425..8f53d8923f2b8cfef2d1670d2bb3cfc79df807b0 100644 (file)
@@ -256,6 +256,9 @@ extern int target_process_reset(struct command_context_s *cmd_ctx);
 
 extern int target_register_event_callback(int (*callback)(struct target_s *target, enum target_event event, void *priv), void *priv);
 extern int target_unregister_event_callback(int (*callback)(struct target_s *target, enum target_event event, void *priv), void *priv);
+extern int target_poll(target_t *target);
+extern int target_resume(target_t *target, int current, u32 address, int handle_breakpoints, int debug_execution);
+extern int target_halt(target_t *target);
 extern int target_call_event_callbacks(target_t *target, enum target_event event);
 
 /* The period is very approximate, the callback can happen much more often 

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)