aboutsummaryrefslogtreecommitdiff
path: root/src/target.c
diff options
context:
space:
mode:
authorGareth McMullin2012-06-24 21:37:10 +1200
committerGareth McMullin2012-06-24 21:41:32 +1200
commit03fdd23e9cd72c4793fc9107da8b0a08a5793a4f (patch)
tree471cdc739875887952044c05274ffdc47701a3bf /src/target.c
parenta16123997b77a5d3a137fcd80e6bf4134b7a4a23 (diff)
Added mechanism for target driver to add new monitor commands.
Diffstat (limited to 'src/target.c')
-rw-r--r--src/target.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/target.c b/src/target.c
index 1c70340..4f2917f 100644
--- a/src/target.c
+++ b/src/target.c
@@ -38,11 +38,32 @@ target *target_new(unsigned size)
void target_list_free(void)
{
+ struct target_command_s *tc;
+
while(target_list) {
target *t = target_list->next;
+ while (target_list->commands) {
+ tc = target_list->commands->next;
+ free(target_list->commands);
+ target_list->commands = tc;
+ }
free(target_list);
target_list = t;
}
last_target = cur_target = NULL;
}
+void target_add_commands(target *t, const struct command_s *cmds, const char *name)
+{
+ struct target_command_s *tc;
+ if (t->commands) {
+ for (tc = t->commands; tc->next; tc = tc->next);
+ tc = tc->next = malloc(sizeof(*tc));
+ } else {
+ t->commands = tc = malloc(sizeof(*tc));
+ }
+ tc->specific_name = name;
+ tc->cmds = cmds;
+ tc->next = NULL;
+}
+