summaryrefslogtreecommitdiff
path: root/src/target/target.c
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-05 06:18:26 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-05 06:18:26 +0000
commit3a4896182036eb472a06f66be3710d5c228b6748 (patch)
treeaa1207bc7952af699ead708f5f669fed53a20a47 /src/target/target.c
parente4729b3b7a5cfa30c19da4be7babfc074616fac6 (diff)
downloadopenocd+libswd-3a4896182036eb472a06f66be3710d5c228b6748.tar.gz
openocd+libswd-3a4896182036eb472a06f66be3710d5c228b6748.tar.bz2
openocd+libswd-3a4896182036eb472a06f66be3710d5c228b6748.tar.xz
openocd+libswd-3a4896182036eb472a06f66be3710d5c228b6748.zip
moves handling of problems with resetting into the halted state
into the target implementation. Also target_process_reset() is now simpler and has error handling, e.g. if assert reset fails, then target_process_reset() will propagate that error. cmd_ctx was passed in to examine(), which is wrong - removed that. git-svn-id: svn://svn.berlios.de/openocd/trunk@887 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target/target.c')
-rw-r--r--src/target/target.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 02016e77..5bd16622 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -290,7 +290,7 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
*
* For the "reset halt/init" case we must only set up the registers here.
*/
- if ((retval = target_examine(cmd_ctx)) != ERROR_OK)
+ if ((retval = target_examine()) != ERROR_OK)
return retval;
keep_alive(); /* we might be running on a very slow JTAG clk */
@@ -303,14 +303,10 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
*/
target_free_all_working_areas_restore(target, 0);
target->reset_halt=((reset_mode==RESET_HALT)||(reset_mode==RESET_INIT));
- target->type->assert_reset(target);
+ if ((retval = target->type->assert_reset(target))!=ERROR_OK)
+ return retval;
target = target->next;
}
- if ((retval = jtag_execute_queue()) != ERROR_OK)
- {
- LOG_WARNING("JTAG communication failed asserting reset.");
- retval = ERROR_OK;
- }
/* request target halt if necessary, and schedule further action */
target = targets;
@@ -318,23 +314,24 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
{
if (reset_mode!=RESET_RUN)
{
- if ((jtag_reset_config & RESET_SRST_PULLS_TRST)==0)
- target_halt(target);
+ if ((retval = target_halt(target))!=ERROR_OK)
+ return retval;
}
target = target->next;
}
- if ((retval = jtag_execute_queue()) != ERROR_OK)
+ target = targets;
+ while (target)
{
- LOG_WARNING("JTAG communication failed while reset was asserted. Consider using srst_only for reset_config.");
- retval = ERROR_OK;
+ if ((retval = target->type->deassert_reset(target))!=ERROR_OK)
+ return retval;
+ target = target->next;
}
target = targets;
while (target)
{
- target->type->deassert_reset(target);
- /* We can fail to bring the target into the halted state */
+ /* We can fail to bring the target into the halted state, try after reset has been deasserted */
if (target->reset_halt)
{
/* wait up to 1 second for halt. */
@@ -342,25 +339,14 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
if (target->state != TARGET_HALTED)
{
LOG_WARNING("Failed to reset target into halted mode - issuing halt");
- target->type->halt(target);
+ if ((retval = target->type->halt(target))!=ERROR_OK)
+ return retval;
}
}
target = target->next;
}
- if ((retval = jtag_execute_queue()) != ERROR_OK)
- {
- LOG_WARNING("JTAG communication failed while deasserting reset.");
- retval = ERROR_OK;
- }
-
- if (jtag_reset_config & RESET_SRST_PULLS_TRST)
- {
- /* If TRST was asserted we need to set up registers again */
- if ((retval = target_examine(cmd_ctx)) != ERROR_OK)
- return retval;
- }
LOG_DEBUG("Waiting for halted stated as appropriate");
@@ -397,7 +383,7 @@ static int default_mmu(struct target_s *target, int *enabled)
return ERROR_OK;
}
-static int default_examine(struct command_context_s *cmd_ctx, struct target_s *target)
+static int default_examine(struct target_s *target)
{
target->type->examined = 1;
return ERROR_OK;
@@ -415,7 +401,7 @@ int target_examine(struct command_context_s *cmd_ctx)
target_t *target = targets;
while (target)
{
- if ((retval = target->type->examine(cmd_ctx, target))!=ERROR_OK)
+ if ((retval = target->type->examine(target))!=ERROR_OK)
return retval;
target = target->next;
}