aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-01-11 15:28:18 +0100
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-01-13 12:00:02 +0100
commitdc793455e9a04be556b0b25eb1513ecbb7be3f51 (patch)
treea09806f64def6c9b5cbe5f7ea6f244c0d3fd5932 /src
parent3e33393078105f25ebd591b5b76c7c1501ff41d5 (diff)
downloadriscv-openocd-dc793455e9a04be556b0b25eb1513ecbb7be3f51.zip
riscv-openocd-dc793455e9a04be556b0b25eb1513ecbb7be3f51.tar.gz
riscv-openocd-dc793455e9a04be556b0b25eb1513ecbb7be3f51.tar.bz2
target: add check_reset hook
Allow targets to run checks post reset. Used to check that e.g. DCC downloads have been enabled. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src')
-rw-r--r--src/target/target.c36
-rw-r--r--src/target/target.h4
-rw-r--r--src/target/target_type.h7
3 files changed, 46 insertions, 1 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 7994aff..c56265c 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)
{
@@ -4887,6 +4901,20 @@ int target_register_commands(struct command_context *cmd_ctx)
return register_commands(cmd_ctx, NULL, target_command_handlers);
}
+static bool target_reset_nag = true;
+
+bool get_target_reset_nag(void)
+{
+ return target_reset_nag;
+}
+
+COMMAND_HANDLER(handle_target_reset_nag)
+{
+ return CALL_COMMAND_HANDLER(handle_command_parse_bool,
+ &target_reset_nag, "Nag after each reset about options to improve "
+ "performance");
+}
+
static const struct command_registration target_exec_command_handlers[] = {
{
.name = "fast_load_image",
@@ -5088,6 +5116,14 @@ static const struct command_registration target_exec_command_handlers[] = {
"and write the 8/16/32 bit values",
.usage = "arrayname bitwidth address count",
},
+ {
+ .name = "reset_nag",
+ .handler = handle_target_reset_nag,
+ .mode = COMMAND_ANY,
+ .help = "Nag after each reset about options that could have been "
+ "enabled to improve performance. ",
+ .usage = "['enable'|'disable']",
+ },
COMMAND_REGISTRATION_DONE
};
int target_register_user_commands(struct command_context *cmd_ctx)
diff --git a/src/target/target.h b/src/target/target.h
index 4151c22..da91d46 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -2,7 +2,7 @@
* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
- * Copyright (C) 2007,2008,2009 Øyvind Harboe *
+ * Copyright (C) 2007-9 Øyvind Harboe *
* oyvind.harboe@zylin.com *
* *
* Copyright (C) 2008 by Spencer Oliver *
@@ -483,4 +483,6 @@ void target_all_handle_event(enum target_event e);
const char *target_strerror_safe(int err);
+extern bool get_target_reset_nag(void);
+
#endif /* TARGET_H */
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