Allow targets to run checks post reset. Used to check
that e.g. DCC downloads have been enabled.

Signed-off-by: Øyvind Harboe <oyvind.har...@zylin.com>
---
 src/target/target.c      |   14 ++++++++++++++
 src/target/target_type.h |    7 +++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/target/target.c b/src/target/target.c
index 7994aff..843edd5 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -477,6 +477,11 @@ int target_process_reset(struct command_context *cmd_ctx, 
enum target_reset_mode
        /* We want any events to be processed before the prompt */
        retval = target_call_timer_callbacks_now();
 
+       struct target *target;
+       for (target = all_targets; target; target = target->next) {
+               target->type->check_reset(target);
+       }
+
        return retval;
 }
 
@@ -499,6 +504,12 @@ static int default_examine(struct target *target)
        return ERROR_OK;
 }
 
+/* no check by default */
+static int default_check_reset(struct target *target)
+{
+       return ERROR_OK;
+}
+
 int target_examine_one(struct target *target)
 {
        return target->type->examine(target);
@@ -708,6 +719,9 @@ static int target_init_one(struct command_context *cmd_ctx,
        if (type->examine == NULL)
                type->examine = default_examine;
 
+       if (type->check_reset== NULL)
+               type->check_reset = default_check_reset;
+
        int retval = type->init_target(cmd_ctx, target);
        if (ERROR_OK != retval)
        {
diff --git a/src/target/target_type.h b/src/target/target_type.h
index 67041b3..70eb962 100644
--- a/src/target/target_type.h
+++ b/src/target/target_type.h
@@ -213,6 +213,13 @@ struct target_type
 
        int (*mmu)(struct target *target, int *enabled);
 
+       /* after reset is complete, the target can check if things are properly 
set up.
+        *
+        * This can be used to check if e.g. DCC memory writes have been 
enabled for
+        * arm7/9 targets, which they really should except in the most contrived
+        * circumstances.
+        */
+       int (*check_reset)(struct target *target);
 };
 
 #endif // TARGET_TYPE_H
-- 
1.6.3.3

_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to