diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-04-11 14:06:42 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-04-11 14:06:42 +0000 |
commit | c4a2fdbc39dd31170e61e7fe0be332826825acbd (patch) | |
tree | e2c5b5221f3f882bee7386e24e0fed2fed9a5822 /src/target | |
parent | 0d7d64b5e9a463f63deb19f00efa14e6e5b1c34e (diff) | |
download | openocd+libswd-c4a2fdbc39dd31170e61e7fe0be332826825acbd.tar.gz openocd+libswd-c4a2fdbc39dd31170e61e7fe0be332826825acbd.tar.bz2 openocd+libswd-c4a2fdbc39dd31170e61e7fe0be332826825acbd.tar.xz openocd+libswd-c4a2fdbc39dd31170e61e7fe0be332826825acbd.zip |
Reset wip. Just adding hooks. This is just to reduce the size of the actual change, no change in behaviour.
git-svn-id: svn://svn.berlios.de/openocd/trunk@565 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/arm720t.c | 2 | ||||
-rw-r--r-- | src/target/arm7_9_common.c | 14 | ||||
-rw-r--r-- | src/target/arm920t.c | 2 | ||||
-rw-r--r-- | src/target/arm926ejs.c | 2 | ||||
-rw-r--r-- | src/target/armv4_5.c | 10 | ||||
-rw-r--r-- | src/target/armv7m.c | 10 | ||||
-rw-r--r-- | src/target/feroceon.c | 4 | ||||
-rw-r--r-- | src/target/target.c | 79 | ||||
-rw-r--r-- | src/target/target.h | 3 |
9 files changed, 75 insertions, 51 deletions
diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 24885d2e..9645db85 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -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++) { diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 106b95db..14d03141 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -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 */ diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 93ddb4ca..2dff6b94 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -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++) { diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 50abd462..f46760e5 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -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++) { diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 0b6b3457..07033bfb 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -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"); diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 81b477a9..eaf1eb95 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -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"); diff --git a/src/target/feroceon.c b/src/target/feroceon.c index c6edc429..0cd632bd 100644 --- a/src/target/feroceon.c +++ b/src/target/feroceon.c @@ -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++) diff --git a/src/target/target.c b/src/target/target.c index 28639a76..ee387dbd 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -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; diff --git a/src/target/target.h b/src/target/target.h index 6480bc5b..8f53d892 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -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 |