summaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
Diffstat (limited to 'src/target')
-rw-r--r--src/target/arm11.c23
-rw-r--r--src/target/arm11.h2
-rw-r--r--src/target/arm720t.c35
-rw-r--r--src/target/arm7tdmi.c37
-rw-r--r--src/target/arm920t.c37
-rw-r--r--src/target/arm926ejs.c35
-rw-r--r--src/target/arm926ejs.h2
-rw-r--r--src/target/arm966e.c35
-rw-r--r--src/target/arm9tdmi.c38
-rw-r--r--src/target/arm9tdmi.h2
-rw-r--r--src/target/cortex_m3.c35
-rw-r--r--src/target/cortex_m3.h2
-rw-r--r--src/target/feroceon.c35
-rw-r--r--src/target/mips32.c2
-rw-r--r--src/target/mips32.h2
-rw-r--r--src/target/mips_m4k.c33
-rw-r--r--src/target/target.c1352
-rw-r--r--src/target/target.h39
-rw-r--r--src/target/target/aduc702x.cfg4
-rw-r--r--src/target/target/at91eb40a.cfg5
-rw-r--r--src/target/target/at91r40008.cfg2
-rw-r--r--src/target/target/at91sam9260.cfg2
-rw-r--r--src/target/target/eir-sam7se512.cfg2
-rw-r--r--src/target/target/hammer.cfg2
-rw-r--r--src/target/target/lpc2148.cfg3
-rw-r--r--src/target/target/omap5912.cfg3
-rw-r--r--src/target/target/pxa255.cfg4
-rw-r--r--src/target/target/sam7x256.cfg4
-rw-r--r--src/target/target/str710.cfg13
-rw-r--r--src/target/target/str730.cfg13
-rw-r--r--src/target/target/str750.cfg13
-rw-r--r--src/target/target/str912.cfg31
-rw-r--r--src/target/target/wi-9c.cfg2
-rw-r--r--src/target/target/xba_revA3.cfg2
-rw-r--r--src/target/target/zy1000.cfg2
-rw-r--r--src/target/xscale.c33
36 files changed, 1411 insertions, 475 deletions
diff --git a/src/target/arm11.c b/src/target/arm11.c
index 56a397d3..108194e5 100644
--- a/src/target/arm11.c
+++ b/src/target/arm11.c
@@ -92,7 +92,7 @@ target_type_t arm11_target =
ARM11_HANDLER(run_algorithm),
ARM11_HANDLER(register_commands),
- ARM11_HANDLER(target_command),
+ ARM11_HANDLER(target_create),
ARM11_HANDLER(init_target),
ARM11_HANDLER(examine),
ARM11_HANDLER(quit),
@@ -1351,28 +1351,21 @@ int arm11_run_algorithm(struct target_s *target, int num_mem_params, mem_param_t
return ERROR_OK;
}
-int arm11_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int arm11_target_create(struct target_s *target, Jim_Interp *interp)
{
FNC_INFO;
- if (argc < 4)
- {
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
-
- int chain_pos = strtoul(args[3], NULL, 0);
-
NEW(arm11_common_t, arm11, 1);
arm11->target = target;
/* prepare JTAG information for the new target */
- arm11->jtag_info.chain_pos = chain_pos;
+ arm11->jtag_info.chain_pos = target->chain_position;
arm11->jtag_info.scann_size = 5;
arm_jtag_setup_connection(&arm11->jtag_info);
- jtag_device_t *device = jtag_get_device(chain_pos);
+ jtag_device_t *device = jtag_get_device(target->chain_position);
if (device->ir_length != 5)
{
@@ -1810,3 +1803,11 @@ int arm11_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
+
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/arm11.h b/src/target/arm11.h
index ccc9c09f..dfc8c8d4 100644
--- a/src/target/arm11.h
+++ b/src/target/arm11.h
@@ -222,7 +222,7 @@ int arm11_remove_watchpoint(struct target_s *target, watchpoint_t *watchpoint);
int arm11_run_algorithm(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info);
int arm11_register_commands(struct command_context_s *cmd_ctx);
-int arm11_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int arm11_target_create(struct target_s *target, Jim_Interp *interp);
int arm11_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm11_quit(void);
diff --git a/src/target/arm720t.c b/src/target/arm720t.c
index fab553cf..e910af3e 100644
--- a/src/target/arm720t.c
+++ b/src/target/arm720t.c
@@ -42,7 +42,7 @@ int arm720t_handle_md_phys_command(struct command_context_s *cmd_ctx, char *cmd,
int arm720t_handle_mw_phys_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
/* forward declarations */
-int arm720t_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int arm720t_target_create(struct target_s *target,Jim_Interp *interp);
int arm720t_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm720t_quit(void);
int arm720t_arch_state(struct target_s *target);
@@ -81,7 +81,7 @@ target_type_t arm720t_target =
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm720t_register_commands,
- .target_command = arm720t_target_command,
+ .target_create = arm720t_target_create,
.init_target = arm720t_init_target,
.examine = arm7tdmi_examine,
.quit = arm720t_quit
@@ -436,7 +436,7 @@ int arm720t_quit(void)
return ERROR_OK;
}
-int arm720t_init_arch_info(target_t *target, arm720t_common_t *arm720t, int chain_pos, char *variant)
+int arm720t_init_arch_info(target_t *target, arm720t_common_t *arm720t, int chain_pos, const char *variant)
{
arm7tdmi_common_t *arm7tdmi = &arm720t->arm7tdmi_common;
arm7_9_common_t *arm7_9 = &arm7tdmi->arm7_9_common;
@@ -461,27 +461,11 @@ int arm720t_init_arch_info(target_t *target, arm720t_common_t *arm720t, int chai
return ERROR_OK;
}
-int arm720t_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int arm720t_target_create(struct target_s *target, Jim_Interp *interp)
{
- int chain_pos;
- char *variant = NULL;
- arm720t_common_t *arm720t = malloc(sizeof(arm720t_common_t));
- memset(arm720t, 0, sizeof(*arm720t));
+ arm720t_common_t *arm720t = calloc(1,sizeof(arm720t_common_t));
- if (argc < 4)
- {
- LOG_ERROR("'target arm720t' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- if (argc >= 5)
- variant = args[4];
-
- LOG_DEBUG("chain_pos: %i, variant: %s", chain_pos, variant);
-
- arm720t_init_arch_info(target, arm720t, chain_pos, variant);
+ arm720t_init_arch_info(target, arm720t, target->chain_position, target->variant);
return ERROR_OK;
}
@@ -644,3 +628,10 @@ int arm720t_handle_mw_phys_command(command_context_t *cmd_ctx, char *cmd, char *
return armv4_5_mmu_handle_mw_phys_command(cmd_ctx, cmd, args, argc, target, &arm720t->armv4_5_mmu);
}
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c
index f3e9fd5f..56198d1c 100644
--- a/src/target/arm7tdmi.c
+++ b/src/target/arm7tdmi.c
@@ -44,8 +44,8 @@
int arm7tdmi_register_commands(struct command_context_s *cmd_ctx);
/* forward declarations */
-int arm7tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
-int arm7tdmi_target_create(Jim_Interp *interp, struct target_s *target);
+
+int arm7tdmi_target_create(struct target_s *target,Jim_Interp *interp);
int arm7tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm7tdmi_quit(void);
@@ -85,9 +85,8 @@ target_type_t arm7tdmi_target =
.add_watchpoint = arm7_9_add_watchpoint,
.remove_watchpoint = arm7_9_remove_watchpoint,
- .register_commands = arm7tdmi_register_commands,
- .target_command = arm7tdmi_target_command,
- // .target_create = arm7tdmi_target_create,
+ .register_commands = arm7tdmi_register_commands,
+ .target_create = arm7tdmi_target_create,
.init_target = arm7tdmi_init_target,
.examine = arm7tdmi_examine,
.quit = arm7tdmi_quit
@@ -829,32 +828,9 @@ int arm7tdmi_init_arch_info(target_t *target, arm7tdmi_common_t *arm7tdmi, int c
return ERROR_OK;
}
-/* target arm7tdmi <endianess> <startup_mode> <chain_pos> <variant> */
-int arm7tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
-{
- int chain_pos;
- char *variant = NULL;
- arm7tdmi_common_t *arm7tdmi = malloc(sizeof(arm7tdmi_common_t));
- memset(arm7tdmi, 0, sizeof(*arm7tdmi));
- if (argc < 4)
- {
- LOG_ERROR("'target arm7tdmi' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- if (argc >= 5)
- variant = args[4];
-
- arm7tdmi_init_arch_info(target, arm7tdmi, chain_pos, variant);
-
- return ERROR_OK;
-}
-int arm7tdmi_target_create(Jim_Interp *interp,
- struct target_s *target)
+int arm7tdmi_target_create( struct target_s *target, Jim_Interp *interp )
{
arm7tdmi_common_t *arm7tdmi;
@@ -866,7 +842,6 @@ int arm7tdmi_target_create(Jim_Interp *interp,
}
-
int arm7tdmi_register_commands(struct command_context_s *cmd_ctx)
{
int retval;
@@ -878,6 +853,8 @@ int arm7tdmi_register_commands(struct command_context_s *cmd_ctx)
}
+
+
/*
* Local Variables: ***
* c-basic-offset: 4 ***
diff --git a/src/target/arm920t.c b/src/target/arm920t.c
index 29228d8c..67ffb387 100644
--- a/src/target/arm920t.c
+++ b/src/target/arm920t.c
@@ -47,7 +47,7 @@ int arm920t_handle_read_cache_command(struct command_context_s *cmd_ctx, char *c
int arm920t_handle_read_mmu_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
/* forward declarations */
-int arm920t_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int arm920t_target_create(struct target_s *target, Jim_Interp *interp);
int arm920t_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm920t_quit(void);
int arm920t_arch_state(struct target_s *target);
@@ -90,7 +90,7 @@ target_type_t arm920t_target =
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm920t_register_commands,
- .target_command = arm920t_target_command,
+ .target_create = arm920t_target_create,
.init_target = arm920t_init_target,
.examine = arm9tdmi_examine,
.quit = arm920t_quit
@@ -699,7 +699,7 @@ int arm920t_quit(void)
return ERROR_OK;
}
-int arm920t_init_arch_info(target_t *target, arm920t_common_t *arm920t, int chain_pos, char *variant)
+int arm920t_init_arch_info(target_t *target, arm920t_common_t *arm920t, int chain_pos, const char *variant)
{
arm9tdmi_common_t *arm9tdmi = &arm920t->arm9tdmi_common;
arm7_9_common_t *arm7_9 = &arm9tdmi->arm7_9_common;
@@ -735,27 +735,11 @@ int arm920t_init_arch_info(target_t *target, arm920t_common_t *arm920t, int chai
return ERROR_OK;
}
-int arm920t_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int arm920t_target_create(struct target_s *target, Jim_Interp *interp)
{
- int chain_pos;
- char *variant = NULL;
- arm920t_common_t *arm920t = malloc(sizeof(arm920t_common_t));
- memset(arm920t, 0, sizeof(*arm920t));
+ arm920t_common_t *arm920t = calloc(1,sizeof(arm920t_common_t));
- if (argc < 4)
- {
- LOG_ERROR("'target arm920t' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- if (argc >= 5)
- variant = args[4];
-
- LOG_DEBUG("chain_pos: %i, variant: %s", chain_pos, variant);
-
- arm920t_init_arch_info(target, arm920t, chain_pos, variant);
+ arm920t_init_arch_info(target, arm920t, target->chain_position, target->variant);
return ERROR_OK;
}
@@ -1516,3 +1500,12 @@ int arm920t_handle_mw_phys_command(command_context_t *cmd_ctx, char *cmd, char *
return armv4_5_mmu_handle_mw_phys_command(cmd_ctx, cmd, args, argc, target, &arm920t->armv4_5_mmu);
}
+
+
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c
index 51a66653..c25a677d 100644
--- a/src/target/arm926ejs.c
+++ b/src/target/arm926ejs.c
@@ -47,7 +47,7 @@ int arm926ejs_handle_read_cache_command(struct command_context_s *cmd_ctx, char
int arm926ejs_handle_read_mmu_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
/* forward declarations */
-int arm926ejs_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int arm926ejs_target_create(struct target_s *target, Jim_Interp *interp);
int arm926ejs_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm926ejs_quit(void);
int arm926ejs_arch_state(struct target_s *target);
@@ -90,7 +90,7 @@ target_type_t arm926ejs_target =
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm926ejs_register_commands,
- .target_command = arm926ejs_target_command,
+ .target_create = arm926ejs_target_create,
.init_target = arm926ejs_init_target,
.examine = arm9tdmi_examine,
.quit = arm926ejs_quit,
@@ -680,7 +680,7 @@ int arm926ejs_quit(void)
return ERROR_OK;
}
-int arm926ejs_init_arch_info(target_t *target, arm926ejs_common_t *arm926ejs, int chain_pos, char *variant)
+int arm926ejs_init_arch_info(target_t *target, arm926ejs_common_t *arm926ejs, int chain_pos, const char *variant)
{
arm9tdmi_common_t *arm9tdmi = &arm926ejs->arm9tdmi_common;
arm7_9_common_t *arm7_9 = &arm9tdmi->arm7_9_common;
@@ -717,27 +717,11 @@ int arm926ejs_init_arch_info(target_t *target, arm926ejs_common_t *arm926ejs, in
return ERROR_OK;
}
-int arm926ejs_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int arm926ejs_target_create(struct target_s *target, Jim_Interp *interp)
{
- int chain_pos;
- char *variant = NULL;
- arm926ejs_common_t *arm926ejs = malloc(sizeof(arm926ejs_common_t));
- memset(arm926ejs, 0, sizeof(*arm926ejs));
+ arm926ejs_common_t *arm926ejs = calloc(1,sizeof(arm926ejs_common_t));
- if (argc < 4)
- {
- LOG_ERROR("'target arm926ejs' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- if (argc >= 5)
- variant = args[4];
-
- LOG_DEBUG("chain_pos: %i, variant: %s", chain_pos, variant);
-
- arm926ejs_init_arch_info(target, arm926ejs, chain_pos, variant);
+ arm926ejs_init_arch_info(target, arm926ejs, target->chain_position, target->variant);
return ERROR_OK;
}
@@ -963,3 +947,10 @@ static int arm926ejs_mmu(struct target_s *target, int *enabled)
*enabled = arm926ejs->armv4_5_mmu.mmu_enabled;
return ERROR_OK;
}
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/arm926ejs.h b/src/target/arm926ejs.h
index 178fc229..f40120c0 100644
--- a/src/target/arm926ejs.h
+++ b/src/target/arm926ejs.h
@@ -43,7 +43,7 @@ typedef struct arm926ejs_common_s
u32 d_far;
} arm926ejs_common_t;
-extern int arm926ejs_init_arch_info(target_t *target, arm926ejs_common_t *arm926ejs, int chain_pos, char *variant);
+extern int arm926ejs_init_arch_info(target_t *target, arm926ejs_common_t *arm926ejs, int chain_pos, const char *variant);
extern int arm926ejs_register_commands(struct command_context_s *cmd_ctx);
extern int arm926ejs_arch_state(struct target_s *target);
extern int arm926ejs_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
diff --git a/src/target/arm966e.c b/src/target/arm966e.c
index f6e3fde5..60682af8 100644
--- a/src/target/arm966e.c
+++ b/src/target/arm966e.c
@@ -43,7 +43,7 @@
int arm966e_register_commands(struct command_context_s *cmd_ctx);
/* forward declarations */
-int arm966e_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int arm966e_target_create(struct target_s *target, Jim_Interp *interp);
int arm966e_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm966e_quit(void);
@@ -80,7 +80,7 @@ target_type_t arm966e_target =
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm966e_register_commands,
- .target_command = arm966e_target_command,
+ .target_create = arm966e_target_create,
.init_target = arm966e_init_target,
.examine = arm9tdmi_examine,
.quit = arm966e_quit,
@@ -99,7 +99,7 @@ int arm966e_quit(void)
return ERROR_OK;
}
-int arm966e_init_arch_info(target_t *target, arm966e_common_t *arm966e, int chain_pos, char *variant)
+int arm966e_init_arch_info(target_t *target, arm966e_common_t *arm966e, int chain_pos, const char *variant)
{
arm9tdmi_common_t *arm9tdmi = &arm966e->arm9tdmi_common;
arm7_9_common_t *arm7_9 = &arm9tdmi->arm7_9_common;
@@ -118,27 +118,11 @@ int arm966e_init_arch_info(target_t *target, arm966e_common_t *arm966e, int chai
return ERROR_OK;
}
-int arm966e_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int arm966e_target_create( struct target_s *target, Jim_Interp *interp )
{
- int chain_pos;
- char *variant = NULL;
- arm966e_common_t *arm966e = malloc(sizeof(arm966e_common_t));
- memset(arm966e, 0, sizeof(*arm966e));
+ arm966e_common_t *arm966e = calloc(1,sizeof(arm966e_common_t));
- if (argc < 4)
- {
- LOG_ERROR("'target arm966e' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- if (argc >= 5)
- variant = args[4];
-
- LOG_DEBUG("chain_pos: %i, variant: %s", chain_pos, variant);
-
- arm966e_init_arch_info(target, arm966e, chain_pos, variant);
+ arm966e_init_arch_info(target, arm966e, target->chain_position, target->variant);
return ERROR_OK;
}
@@ -361,3 +345,10 @@ int arm966e_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c
index 0c242fad..dcb35dab 100644
--- a/src/target/arm9tdmi.c
+++ b/src/target/arm9tdmi.c
@@ -46,7 +46,8 @@ int arm9tdmi_register_commands(struct command_context_s *cmd_ctx);
int handle_arm9tdmi_catch_vectors_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
/* forward declarations */
-int arm9tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int arm9tdmi_target_create( struct target_s *target, Jim_Interp *interp );
+
int arm9tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm9tdmi_quit(void);
@@ -83,7 +84,7 @@ target_type_t arm9tdmi_target =
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm9tdmi_register_commands,
- .target_command = arm9tdmi_target_command,
+ .target_create = arm9tdmi_target_create,
.init_target = arm9tdmi_init_target,
.examine = arm9tdmi_examine,
.quit = arm9tdmi_quit
@@ -902,7 +903,7 @@ int arm9tdmi_quit(void)
return ERROR_OK;
}
-int arm9tdmi_init_arch_info(target_t *target, arm9tdmi_common_t *arm9tdmi, int chain_pos, char *variant)
+int arm9tdmi_init_arch_info(target_t *target, arm9tdmi_common_t *arm9tdmi, int chain_pos, const char *variant)
{
armv4_5_common_t *armv4_5;
arm7_9_common_t *arm7_9;
@@ -1007,26 +1008,12 @@ int arm9tdmi_get_arch_pointers(target_t *target, armv4_5_common_t **armv4_5_p, a
}
-/* target arm9tdmi <endianess> <startup_mode> <chain_pos> <variant>*/
-int arm9tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+
+int arm9tdmi_target_create(struct target_s *target, Jim_Interp *interp)
{
- int chain_pos;
- char *variant = NULL;
- arm9tdmi_common_t *arm9tdmi = malloc(sizeof(arm9tdmi_common_t));
- memset(arm9tdmi, 0, sizeof(*arm9tdmi));
+ arm9tdmi_common_t *arm9tdmi = calloc(1,sizeof(arm9tdmi_common_t));
- if (argc < 4)
- {
- LOG_ERROR("'target arm9tdmi' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- if (argc >= 5)
- variant = args[4];
-
- arm9tdmi_init_arch_info(target, arm9tdmi, chain_pos, variant);
+ arm9tdmi_init_arch_info(target, arm9tdmi, target->chain_position, target->variant);
return ERROR_OK;
}
@@ -1129,3 +1116,12 @@ int handle_arm9tdmi_catch_vectors_command(struct command_context_s *cmd_ctx, cha
return ERROR_OK;
}
+
+
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/arm9tdmi.h b/src/target/arm9tdmi.h
index 249a9287..18297b62 100644
--- a/src/target/arm9tdmi.h
+++ b/src/target/arm9tdmi.h
@@ -57,7 +57,7 @@ enum arm9tdmi_vector
extern int arm9tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm9tdmi_examine(struct target_s *target);
-extern int arm9tdmi_init_arch_info(target_t *target, arm9tdmi_common_t *arm9tdmi, int chain_pos, char *variant);
+extern int arm9tdmi_init_arch_info(target_t *target, arm9tdmi_common_t *arm9tdmi, int chain_pos, const char *variant);
extern int arm9tdmi_register_commands(struct command_context_s *cmd_ctx);
extern int arm9tdmi_clock_out(arm_jtag_t *jtag_info, u32 instr, u32 out, u32 *in, int sysspeed);
diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c
index dd9c6992..e034189a 100644
--- a/src/target/cortex_m3.c
+++ b/src/target/cortex_m3.c
@@ -45,7 +45,7 @@ int cortex_m3_register_commands(struct command_context_s *cmd_ctx);
/* forward declarations */
void cortex_m3_enable_breakpoints(struct target_s *target);
void cortex_m3_enable_watchpoints(struct target_s *target);
-int cortex_m3_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int cortex_m3_target_create(struct target_s *target, Jim_Interp *interp);
int cortex_m3_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int cortex_m3_quit(void);
int cortex_m3_load_core_reg_u32(target_t *target, enum armv7m_regtype type, u32 num, u32 *value);
@@ -91,7 +91,7 @@ target_type_t cortexm3_target =
.remove_watchpoint = cortex_m3_remove_watchpoint,
.register_commands = cortex_m3_register_commands,
- .target_command = cortex_m3_target_command,
+ .target_create = cortex_m3_target_create,
.init_target = cortex_m3_init_target,
.examine = cortex_m3_examine,
.quit = cortex_m3_quit
@@ -1463,7 +1463,7 @@ int cortex_m3_handle_target_request(void *priv)
return ERROR_OK;
}
-int cortex_m3_init_arch_info(target_t *target, cortex_m3_common_t *cortex_m3, int chain_pos, char *variant)
+int cortex_m3_init_arch_info(target_t *target, cortex_m3_common_t *cortex_m3, int chain_pos, const char *variant)
{
armv7m_common_t *armv7m;
armv7m = &cortex_m3->armv7m;
@@ -1510,26 +1510,11 @@ int cortex_m3_init_arch_info(target_t *target, cortex_m3_common_t *cortex_m3, in
return ERROR_OK;
}
-/* target cortex_m3 <endianess> <startup_mode> <chain_pos> <variant>*/
-int cortex_m3_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int cortex_m3_target_create(struct target_s *target, Jim_Interp *interp)
{
- int chain_pos;
- char *variant = NULL;
- cortex_m3_common_t *cortex_m3 = malloc(sizeof(cortex_m3_common_t));
- memset(cortex_m3, 0, sizeof(*cortex_m3));
-
- if (argc < 4)
- {
- LOG_ERROR("'target cortex_m3' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
+ cortex_m3_common_t *cortex_m3 = calloc(1,sizeof(cortex_m3_common_t));
- if (argc >= 5)
- variant = args[4];
-
- cortex_m3_init_arch_info(target, cortex_m3, chain_pos, variant);
+ cortex_m3_init_arch_info(target, cortex_m3, target->chain_position, target->variant);
return ERROR_OK;
}
@@ -1542,3 +1527,11 @@ int cortex_m3_register_commands(struct command_context_s *cmd_ctx)
return retval;
}
+
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/cortex_m3.h b/src/target/cortex_m3.h
index 0d4678e8..fec0a9ed 100644
--- a/src/target/cortex_m3.h
+++ b/src/target/cortex_m3.h
@@ -186,6 +186,6 @@ int cortex_m3_add_watchpoint(struct target_s *target, watchpoint_t *watchpoint);
int cortex_m3_remove_watchpoint(struct target_s *target, watchpoint_t *watchpoint);
extern int cortex_m3_register_commands(struct command_context_s *cmd_ctx);
-extern int cortex_m3_init_arch_info(target_t *target, cortex_m3_common_t *cortex_m3, int chain_pos, char *variant);
+extern int cortex_m3_init_arch_info(target_t *target, cortex_m3_common_t *cortex_m3, int chain_pos, const char *variant);
#endif /* CORTEX_M3_H */
diff --git a/src/target/feroceon.c b/src/target/feroceon.c
index e4874620..a5bdc2e1 100644
--- a/src/target/feroceon.c
+++ b/src/target/feroceon.c
@@ -55,7 +55,7 @@
#include <string.h>
int feroceon_examine(struct target_s *target);
-int feroceon_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int feroceon_target_create(struct target_s *target, Jim_Interp *interp);
int feroceon_bulk_write_memory(target_t *target, u32 address, u32 count, u8 *buffer);
int feroceon_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int feroceon_quit(void);
@@ -106,7 +106,7 @@ target_type_t feroceon_target =
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm926ejs_register_commands,
- .target_command = feroceon_target_command,
+ .target_create = feroceon_target_create,
.init_target = feroceon_init_target,
.examine = feroceon_examine,
.quit = feroceon_quit
@@ -646,29 +646,13 @@ int feroceon_quit(void)
return ERROR_OK;
}
-int feroceon_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int feroceon_target_create(struct target_s *target, Jim_Interp *interp)
{
- int chain_pos;
- char *variant = NULL;
armv4_5_common_t *armv4_5;
arm7_9_common_t *arm7_9;
- arm926ejs_common_t *arm926ejs = malloc(sizeof(arm926ejs_common_t));
- memset(arm926ejs, 0, sizeof(*arm926ejs));
-
- if (argc < 4)
- {
- LOG_ERROR("'target arm926ejs' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- if (argc >= 5)
- variant = args[4];
-
- LOG_DEBUG("chain_pos: %i, variant: %s", chain_pos, variant);
-
- arm926ejs_init_arch_info(target, arm926ejs, chain_pos, variant);
+ arm926ejs_common_t *arm926ejs = calloc(1,sizeof(arm926ejs_common_t));
+
+ arm926ejs_init_arch_info(target, arm926ejs, target->chain_position, target->variant);
armv4_5 = target->arch_info;
arm7_9 = armv4_5->arch_info;
@@ -741,3 +725,10 @@ int feroceon_examine(struct target_s *target)
return ERROR_OK;
}
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/mips32.c b/src/target/mips32.c
index 5870ae69..96e509c3 100644
--- a/src/target/mips32.c
+++ b/src/target/mips32.c
@@ -314,7 +314,7 @@ reg_cache_t *mips32_build_reg_cache(target_t *target)
return cache;
}
-int mips32_init_arch_info(target_t *target, mips32_common_t *mips32, int chain_pos, char *variant)
+int mips32_init_arch_info(target_t *target, mips32_common_t *mips32, int chain_pos, const char *variant)
{
target->arch_info = mips32;
mips32->common_magic = MIPS32_COMMON_MAGIC;
diff --git a/src/target/mips32.h b/src/target/mips32.h
index aeed1a60..a7a98b5c 100644
--- a/src/target/mips32.h
+++ b/src/target/mips32.h
@@ -99,7 +99,7 @@ typedef struct mips32_core_reg_s
#define MIPS32_DRET 0x4200001F
extern int mips32_arch_state(struct target_s *target);
-extern int mips32_init_arch_info(target_t *target, mips32_common_t *mips32, int chain_pos, char *variant);
+extern int mips32_init_arch_info(target_t *target, mips32_common_t *mips32, int chain_pos, const char *variant);
extern int mips32_restore_context(target_t *target);
extern int mips32_save_context(target_t *target);
extern reg_cache_t *mips32_build_reg_cache(target_t *target);
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index 599b2159..6f8c1e93 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -44,7 +44,7 @@ int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 co
int mips_m4k_register_commands(struct command_context_s *cmd_ctx);
int mips_m4k_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int mips_m4k_quit(void);
-int mips_m4k_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int mips_m4k_target_create(struct target_s *target, Jim_Interp *interp);
int mips_m4k_examine(struct target_s *target);
int mips_m4k_assert_reset(target_t *target);
@@ -83,7 +83,7 @@ target_type_t mips_m4k_target =
.remove_watchpoint = mips_m4k_remove_watchpoint,
.register_commands = mips_m4k_register_commands,
- .target_command = mips_m4k_target_command,
+ .target_create = mips_m4k_target_create,
.init_target = mips_m4k_init_target,
.examine = mips_m4k_examine,
.quit = mips_m4k_quit
@@ -578,7 +578,7 @@ int mips_m4k_quit(void)
return ERROR_OK;
}
-int mips_m4k_init_arch_info(target_t *target, mips_m4k_common_t *mips_m4k, int chain_pos, char *variant)
+int mips_m4k_init_arch_info(target_t *target, mips_m4k_common_t *mips_m4k, int chain_pos, const char *variant)
{
mips32_common_t *mips32 = &mips_m4k->mips32_common;
@@ -600,24 +600,11 @@ int mips_m4k_init_arch_info(target_t *target, mips_m4k_common_t *mips_m4k, int c
return ERROR_OK;
}
-int mips_m4k_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int mips_m4k_target_create(struct target_s *target, Jim_Interp *interp)
{
- int chain_pos;
- char *variant = NULL;
- mips_m4k_common_t *mips_m4k = malloc(sizeof(mips_m4k_common_t));
+ mips_m4k_common_t *mips_m4k = calloc(1,sizeof(mips_m4k_common_t));
- if (argc < 4)
- {
- LOG_ERROR("'target mips4k' requires at least one additional argument");
- exit(-1);
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- if (argc >= 5)
- variant = args[4];
-
- mips_m4k_init_arch_info(target, mips_m4k, chain_pos, variant);
+ mips_m4k_init_arch_info(target, mips_m4k, target->chain_position, target->variant);
return ERROR_OK;
}
@@ -652,3 +639,11 @@ int mips_m4k_bulk_write_memory(target_t *target, u32 address, u32 count, u8 *buf
{
return mips_m4k_write_memory(target, address, 4, count, buffer);
}
+
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
diff --git a/src/target/target.c b/src/target/target.c
index f79156ad..08a0505f 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -52,7 +52,7 @@
int cli_target_callback_event_handler(struct target_s *target, enum target_event event, void *priv);
-int handle_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+
int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_working_area_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
@@ -78,7 +78,7 @@ int handle_virt2phys_command(command_context_t *cmd_ctx, char *cmd, char **args,
int handle_profile_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
static int jim_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
static int jim_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
-
+static int jim_target( Jim_Interp *interp, int argc, Jim_Obj *const *argv);
static int target_array2mem(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv);
static int target_mem2array(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv);
@@ -128,31 +128,78 @@ const Jim_Nvp nvp_assert[] = {
{ .name = NULL, .value = -1 }
};
+const Jim_Nvp nvp_error_target[] = {
+ { .value = ERROR_TARGET_INVALID, .name = "err-invalid" },
+ { .value = ERROR_TARGET_INIT_FAILED, .name = "err-init-failed" },
+ { .value = ERROR_TARGET_TIMEOUT, .name = "err-timeout" },
+ { .value = ERROR_TARGET_NOT_HALTED, .name = "err-not-halted" },
+ { .value = ERROR_TARGET_FAILURE, .name = "err-failure" },
+ { .value = ERROR_TARGET_UNALIGNED_ACCESS , .name = "err-unaligned-access" },
+ { .value = ERROR_TARGET_DATA_ABORT , .name = "err-data-abort" },
+ { .value = ERROR_TARGET_RESOURCE_NOT_AVAILABLE , .name = "err-resource-not-available" },
+ { .value = ERROR_TARGET_TRANSLATION_FAULT , .name = "err-translation-fault" },
+ { .value = ERROR_TARGET_NOT_RUNNING, .name = "err-not-running" },
+ { .value = ERROR_TARGET_NOT_EXAMINED, .name = "err-not-examined" },
+ { .value = -1, .name = NULL }
+};
+
+const char *target_strerror_safe( int err )
+{
+ const Jim_Nvp *n;
+
+ n = Jim_Nvp_value2name_simple( nvp_error_target, err );
+ if( n->name == NULL ){
+ return "unknown";
+ } else {
+ return n->name;
+ }
+}
+
const Jim_Nvp nvp_target_event[] = {
+ { .value = TARGET_EVENT_OLD_pre_reset , .name = "old-pre_reset" },
+ { .value = TARGET_EVENT_OLD_gdb_program_config , .name = "old-gdb_program_config" },
+ { .value = TARGET_EVENT_OLD_post_reset , .name = "old-post_reset" },
+ { .value = TARGET_EVENT_OLD_pre_resume , .name = "old-pre_resume" },
+
+
{ .value = TARGET_EVENT_HALTED, .name = "halted" },
{ .value = TARGET_EVENT_RESUMED, .name = "resumed" },
{ .value = TARGET_EVENT_RESUME_START, .name = "resume-start" },
{ .value = TARGET_EVENT_RESUME_END, .name = "resume-end" },
/* historical name */
- { .value = TARGET_EVENT_RESET_START , .name = "pre_reset" },
+
{ .value = TARGET_EVENT_RESET_START, .name = "reset-start" },
- /* historical name */
- { .value = TARGET_EVENT_RESET , .name = "reset" },
+
+ { .value = TARGET_EVENT_RESET_ASSERT_PRE, .name = "reset-assert-pre" },
+ { .value = TARGET_EVENT_RESET_ASSERT_POST, .name = "reset-assert-post" },
+ { .value = TARGET_EVENT_RESET_DEASSERT_PRE, .name = "reset-deassert-pre" },
+ { .value = TARGET_EVENT_RESET_DEASSERT_POST, .name = "reset-deassert-post" },
+ { .value = TARGET_EVENT_RESET_HALT_PRE, .name = "reset-halt-pre" },
+ { .value = TARGET_EVENT_RESET_HALT_POST, .name = "reset-halt-post" },
+ { .value = TARGET_EVENT_RESET_WAIT_PRE, .name = "reset-wait-pre" },
+ { .value = TARGET_EVENT_RESET_WAIT_POST, .name = "reset-wait-post" },
{ .value = TARGET_EVENT_RESET_INIT , .name = "reset-init" },
{ .value = TARGET_EVENT_RESET_END, .name = "reset-end" },
+
+
+
+
+ { .value = TARGET_EVENT_EXAMINE_START, .name = "examine-start" },
+ { .value = TARGET_EVENT_EXAMINE_START, .name = "examine-end" },
+
+
{ .value = TARGET_EVENT_DEBUG_HALTED, .name = "debug-halted" },
{ .value = TARGET_EVENT_DEBUG_RESUMED, .name = "debug-resumed" },
{ .value = TARGET_EVENT_GDB_ATTACH, .name = "gdb-attach" },
{ .value = TARGET_EVENT_GDB_DETACH, .name = "gdb-detach" },
+
{ .value = TARGET_EVENT_GDB_FLASH_WRITE_START, .name = "gdb-flash-write-start" },
{ .value = TARGET_EVENT_GDB_FLASH_WRITE_END , .name = "gdb-flash-write-end" },
- { .value = TARGET_EVENT_GDB_FLASH_ERASE_START , .name = "gdb_program_config" },
-
{ .value = TARGET_EVENT_GDB_FLASH_ERASE_START, .name = "gdb-flash-erase-start" },
{ .value = TARGET_EVENT_GDB_FLASH_ERASE_END , .name = "gdb-flash-erase-end" },
@@ -193,6 +240,30 @@ const Jim_Nvp nvp_target_endian[] = {
{ .name = NULL, .value = -1 },
};
+const Jim_Nvp nvp_reset_modes[] = {
+ { .name = "unknown", .value = RESET_UNKNOWN },
+ { .name = "run" , .value = RESET_RUN },
+ { .name = "halt" , .value = RESET_HALT },
+ { .name = "init" , .value = RESET_INIT },
+ { .name = NULL , .value = -1 },
+};
+
+static int
+max_target_number( void )
+{
+ target_t *t;
+ int x;
+
+ x = -1;
+ t = all_targets;
+ while( t ){
+ if( x < t->target_number ){
+ x = (t->target_number)+1;
+ }
+ t = t->next;
+ }
+ return x;
+}
/* determine the number of the new target */
static int
@@ -340,17 +411,15 @@ int target_resume(struct target_s *target, int current, u32 address, int handle_
return retval;
}
+// Next patch - this turns into TCL...
int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mode reset_mode)
{
int retval = ERROR_OK;
target_t *target;
target = all_targets;
- while (target)
- {
- target_invoke_script(cmd_ctx, target, "pre_reset");
- target = target->next;
- }
+
+ target_all_handle_event( TARGET_EVENT_OLD_pre_reset );
if ((retval = jtag_init_reset(cmd_ctx)) != ERROR_OK)
return retval;
@@ -423,8 +492,9 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
/* Wait for reset to complete, maximum 5 seconds. */
if (((retval=target_wait_state(target, TARGET_HALTED, 5000)))==ERROR_OK)
{
- if (reset_mode == RESET_INIT)
- target_invoke_script(cmd_ctx, target, "post_reset");
+ if (reset_mode == RESET_INIT){
+ target_handle_event( target, TARGET_EVENT_OLD_post_reset );
+ }
}
target = target->next;
@@ -688,8 +758,11 @@ int target_call_event_callbacks(target_t *target, enum target_event event)
target_event_callback_t *callback = target_event_callbacks;
target_event_callback_t *next_callback;
- LOG_DEBUG("target event %i", event);
+ LOG_DEBUG("target event %i (%s)",
+ event,
+ Jim_Nvp_value2name_simple( nvp_target_event, event )->name );
+ target_handle_event( target, event );
while (callback)
{
@@ -903,12 +976,13 @@ int target_free_all_working_areas(struct target_s *target)
int target_register_commands(struct command_context_s *cmd_ctx)
{
- register_command(cmd_ctx, NULL, "target", handle_target_command, COMMAND_CONFIG, "target <cpu> [reset_init default - DEPRECATED] <chainpos> <endianness> <variant> [cpu type specifc args]");
+
register_command(cmd_ctx, NULL, "targets", handle_targets_command, COMMAND_EXEC, NULL);
register_command(cmd_ctx, NULL, "working_area", handle_working_area_command, COMMAND_ANY, "working_area <target#> <address> <size> <'backup'|'nobackup'> [virtual address]");
register_command(cmd_ctx, NULL, "virt2phys", handle_virt2phys_command, COMMAND_ANY, "virt2phys <virtual address>");
register_command(cmd_ctx, NULL, "profile", handle_profile_command, COMMAND_EXEC, "PRELIMINARY! - profile <seconds> <gmon.out>");
+ register_jim(cmd_ctx, "target", jim_target, "configure target" );
/* script procedures */
@@ -1343,16 +1417,17 @@ int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, char **
}
DumpTargets:
- command_print(cmd_ctx, " CmdName Type Endian State ");
- command_print(cmd_ctx, "-- ---------- ---------- ---------- ----------");
+ command_print(cmd_ctx, " CmdName Type Endian ChainPos State ");
+ command_print(cmd_ctx, "-- ---------- ---------- ---------- -------- ----------");
while (target)
{
/* XX: abcdefghij abcdefghij abcdefghij abcdefghij */
- command_print(cmd_ctx, "%2d: %-10s %-10s %-10s %s",
+ command_print(cmd_ctx, "%2d: %-10s %-10s %-10s %8d %s",
target->target_number,
- "", // future: target->cmd_name
+ target->cmd_name,
target->type->name,
Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness )->name,
+ target->chain_position,
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name );
target = target->next;
}
@@ -1360,143 +1435,7 @@ int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, char **
return ERROR_OK;
}
-int handle_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- int i;
- int found = 0;
-
- if (argc < 3)
- {
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
-
- /* search for the specified target */
- if (args[0] && (args[0][0] != 0))
- {
- for (i = 0; target_types[i]; i++)
- {
- if (strcmp(args[0], target_types[i]->name) == 0)
- {
- target_t **last_target_p = &all_targets;
- /* register target specific commands */
- if (target_types[i]->register_commands(cmd_ctx) != ERROR_OK)
- {
- LOG_ERROR("couldn't register '%s' commands", args[0]);
- exit(-1);
- }
-
- if (*last_target_p)
- {
- while ((*last_target_p)->next)
- last_target_p = &((*last_target_p)->next);
- last_target_p = &((*last_target_p)->next);
- }
-
- // get target number *before* adding new target to the list */
- int n = new_target_number();
- // calloc will init the memory to zero for us
- *last_target_p = calloc(1,sizeof(target_t));
- // save target number.
- (*last_target_p)->cmd_name = NULL;
- (*last_target_p)->target_number = n;
-
- /* allocate memory for each unique target type */
- (*last_target_p)->type = (target_type_t*)malloc(sizeof(target_type_t));
- *((*last_target_p)->type) = *target_types[i];
-
- if (strcmp(args[1], "big") == 0)
- (*last_target_p)->endianness = TARGET_BIG_ENDIAN;
- else if (strcmp(args[1], "little") == 0)
- (*last_target_p)->endianness = TARGET_LITTLE_ENDIAN;
- else
- {
- LOG_ERROR("endianness must be either 'little' or 'big', not '%s'", args[1]);
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
-
- if (strcmp(args[2], "reset_halt") == 0)
- {
- LOG_WARNING("reset_mode argument is obsolete.");
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
- else if (strcmp(args[2], "reset_run") == 0)
- {
- LOG_WARNING("reset_mode argument is obsolete.");
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
- else if (strcmp(args[2], "reset_init") == 0)
- {
- LOG_WARNING("reset_mode argument is obsolete.");
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
- else if (strcmp(args[2], "run_and_halt") == 0)
- {
- LOG_WARNING("reset_mode argument is obsolete.");
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
- else if (strcmp(args[2], "run_and_init") == 0)
- {
- LOG_WARNING("reset_mode argument is obsolete.");
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
- else
- {
- /* Kludge! we want to make this reset arg optional while remaining compatible! */
- args--;
- argc++;
- }
-
- (*last_target_p)->working_area = 0x0;
- (*last_target_p)->working_area_size = 0x0;
- (*last_target_p)->working_areas = NULL;
- (*last_target_p)->backup_working_area = 0;
-
- (*last_target_p)->state = TARGET_UNKNOWN;
- (*last_target_p)->debug_reason = DBG_REASON_UNDEFINED;
- (*last_target_p)->reg_cache = NULL;
- (*last_target_p)->breakpoints = NULL;
- (*last_target_p)->watchpoints = NULL;
- (*last_target_p)->next = NULL;
- (*last_target_p)->arch_info = NULL;
-
- /* initialize trace information */
- (*last_target_p)->trace_info = malloc(sizeof(trace_t));
- (*last_target_p)->trace_info->num_trace_points = 0;
- (*last_target_p)->trace_info->trace_points_size = 0;
- (*last_target_p)->trace_info->trace_points = NULL;
- (*last_target_p)->trace_info->trace_history_size = 0;
- (*last_target_p)->trace_info->trace_history = NULL;
- (*last_target_p)->trace_info->trace_history_pos = 0;
- (*last_target_p)->trace_info->trace_history_overflowed = 0;
-
- (*last_target_p)->dbgmsg = NULL;
- (*last_target_p)->dbg_msg_enabled = 0;
-
- (*last_target_p)->type->target_command(cmd_ctx, cmd, args, argc, *last_target_p);
-
- found = 1;
- break;
- }
- }
- }
-
- /* no matching target found */
- if (!found)
- {
- LOG_ERROR("target '%s' not found", args[0]);
- return ERROR_COMMAND_SYNTAX_ERROR;
- }
-
- return ERROR_OK;
-}
-
-int target_invoke_script(struct command_context_s *cmd_ctx, target_t *target, char *name)
-{
- return command_run_linef(cmd_ctx, " if {[catch {info body target_%d_%s} t]==0} {target_%d_%s}",
- get_num_by_target(target), name,
- get_num_by_target(target), name);
-}
int handle_working_area_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
@@ -1794,20 +1733,16 @@ int handle_soft_reset_halt_command(struct command_context_s *cmd_ctx, char *cmd,
int handle_reset_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
+ const Jim_Nvp *n;
enum target_reset_mode reset_mode = RESET_RUN;
if (argc >= 1)
{
- if (strcmp("run", args[0]) == 0)
- reset_mode = RESET_RUN;
- else if (strcmp("halt", args[0]) == 0)
- reset_mode = RESET_HALT;
- else if (strcmp("init", args[0]) == 0)
- reset_mode = RESET_INIT;
- else
- {
+ n = Jim_Nvp_name2value_simple( nvp_reset_modes, args[0] );
+ if( (n->name == NULL) || (n->value == RESET_UNKNOWN) ){
return ERROR_COMMAND_SYNTAX_ERROR;
}
+ reset_mode = n->value;
}
/* reset *all* targets */
@@ -1819,7 +1754,7 @@ int handle_resume_command(struct command_context_s *cmd_ctx, char *cmd, char **a
int retval;
target_t *target = get_current_target(cmd_ctx);
- target_invoke_script(cmd_ctx, target, "pre_resume");
+ target_handle_event( target, TARGET_EVENT_OLD_pre_resume );
if (argc == 0)
retval = target_resume(target, 1, 0, 1, 0); /* current pc, addr = 0, handle breakpoints, not debugging */
@@ -1827,7 +1762,7 @@ int handle_resume_command(struct command_context_s *cmd_ctx, char *cmd, char **a
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;
+ retval = ERROR_COMMAND_SYNTAX_ERROR;
}
return retval;
@@ -3014,6 +2949,1091 @@ static int target_array2mem(Jim_Interp *interp, target_t *target, int argc, Jim_
return JIM_OK;
}
+void
+target_all_handle_event( enum target_event e )
+{
+ target_t *target;
+
+
+ LOG_DEBUG( "**all*targets: event: %d, %s",
+ e,
+ Jim_Nvp_value2name_simple( nvp_target_event, e )->name );
+
+ target = all_targets;
+ while (target){
+ target_handle_event( target, e );
+ target = target->next;
+ }
+}
+
+void
+target_handle_event( target_t *target, enum target_event e )
+{
+ target_event_action_t *teap;
+ int done;
+
+ teap = target->event_action;
+
+ done = 0;
+ while( teap ){
+ if( teap->event == e ){
+ done = 1;
+ LOG_DEBUG( "target: (%d) %s (%s) event: %d (%s) action: %s\n",
+ target->target_number,
+ target->cmd_name,
+ target->type->name,
+ e,
+ Jim_Nvp_value2name_simple( nvp_target_event, e )->name,
+ Jim_GetString( teap->body, NULL ) );
+ Jim_EvalObj( interp, teap->body );
+ }
+ teap = teap->next;
+ }
+ if( !done ){
+ LOG_DEBUG( "event: %d %s - no action",
+ e,
+ Jim_Nvp_value2name_simple( nvp_target_event, e )->name );
+ }
+}
+
+enum target_cfg_param {
+ TCFG_TYPE,
+ TCFG_EVENT,
+ TCFG_RESET,
+ TCFG_WORK_AREA_VIRT,
+ TCFG_WORK_AREA_PHYS,
+ TCFG_WORK_AREA_SIZE,
+ TCFG_WORK_AREA_BACKUP,
+ TCFG_ENDIAN,
+ TCFG_VARIANT,
+ TCFG_CHAIN_POSITION,
+};
+
+
+static Jim_Nvp nvp_config_opts[] = {
+ { .name = "-type", .value = TCFG_TYPE },
+ { .name = "-event", .value = TCFG_EVENT },
+ { .name = "-reset", .value = TCFG_RESET },
+ { .name = "-work-area-virt", .value = TCFG_WORK_AREA_VIRT },
+ { .name = "-work-area-phys", .value = TCFG_WORK_AREA_PHYS },
+ { .name = "-work-area-size", .value = TCFG_WORK_AREA_SIZE },
+ { .name = "-work-area-backup", .value = TCFG_WORK_AREA_BACKUP },
+ { .name = "-endian" , .value = TCFG_ENDIAN },
+ { .name = "-variant", .value = TCFG_VARIANT },
+ { .name = "-chain-position", .value = TCFG_CHAIN_POSITION },
+
+ { .name = NULL, .value = -1 }
+};
+
+
+static int
+target_configure( Jim_GetOptInfo *goi,
+ target_t *target )
+{
+ Jim_Nvp *n;
+ Jim_Obj *o;
+ jim_wide w;
+ char *cp;
+ int e;
+
+
+ /* parse config or cget options ... */
+ while( goi->argc ){
+ Jim_SetEmptyResult( goi->interp );
+ //Jim_GetOpt_Debug( goi );
+
+ if( target->type->target_jim_configure ){
+ /* target defines a configure function */
+ /* target gets first dibs on parameters */
+ e = (*(target->type->target_jim_configure))( target, goi );
+ if( e == JIM_OK ){
+ /* more? */
+ continue;
+ }
+ if( e == JIM_ERR ){
+ /* An error */
+ return e;
+ }
+ /* otherwise we 'continue' below */
+ }
+ e = Jim_GetOpt_Nvp( goi, nvp_config_opts, &n );
+ if( e != JIM_OK ){
+ Jim_GetOpt_NvpUnknown( goi, nvp_config_opts, 0 );
+ return e;
+ }
+ switch( n->value ){
+ case TCFG_TYPE:
+ /* not setable */
+ if( goi->isconfigure ){
+ Jim_SetResult_sprintf( goi->interp, "not setable: %s", n->name );
+ return JIM_ERR;
+ } else {
+ no_params:
+ if( goi->argc != 0 ){
+ Jim_WrongNumArgs( goi->interp, goi->argc, goi->argv, "NO PARAMS");
+ return JIM_ERR;
+ }
+ }
+ Jim_SetResultString( goi->interp, target->type->name, -1 );
+ /* loop for more */
+ break;
+ case TCFG_EVENT:
+ if( goi->argc == 0 ){
+ Jim_WrongNumArgs( goi->interp, goi->argc, goi->argv, "-event ?event-name? ...");
+ return JIM_ERR;
+ }
+
+ e = Jim_GetOpt_Nvp( goi, nvp_target_event, &n );
+ if( e != JIM_OK ){
+ Jim_GetOpt_NvpUnknown( goi, nvp_target_event, 1 );
+ return e;
+ }
+
+ if( goi->isconfigure ){
+ if( goi->argc == 0 ){
+ Jim_WrongNumArgs( goi->interp, goi->argc, goi->argv, "-event ?event-name? ?EVENT-BODY?");
+ return JIM_ERR;
+ }
+ } else {
+ if( goi->argc != 0 ){
+ Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name?");
+ return JIM_ERR;
+ }
+ }
+
+
+ {
+ target_event_action_t *teap;
+
+ teap = target->event_action;
+ /* replace existing? */
+ while( teap ){
+ if( teap->event == n->value ){
+ break;
+ }
+ teap = teap->next;
+ }
+
+ if( goi->isconfigure ){
+ if( teap == NULL ){
+ /* create new */
+ teap = calloc( 1, sizeof(*teap) );
+ }
+ teap->event = n->value;
+ Jim_GetOpt_Obj( goi, &o );
+ if( teap->body ){
+ Jim_DecrRefCount( interp, teap->body );
+ }
+ teap->body = Jim_DuplicateObj( goi->interp, o );
+ /*
+ * FIXME:
+ * Tcl/TK - "tk events" have a nice feature.
+ * See the "BIND" command.
+ * We should support that here.
+ * You can specify %X and %Y in the event code.
+ * The idea is: %T - target name.
+ * The idea is: %N - target number
+ * The idea is: %E - event name.
+ */
+ Jim_IncrRefCount( teap->body );
+
+ /* add to head of event list */
+ teap->next = target->event_action;
+ target->event_action = teap;
+ Jim_SetEmptyResult(goi->interp);
+ } else {
+ /* get */
+ if( teap == NULL ){
+ Jim_SetEmptyResult( goi->interp );
+ } else {
+ Jim_SetResult( goi->interp, Jim_DuplicateObj( goi->interp, teap->body ) );
+ }
+ }
+ }
+ /* loop for more */
+ break;
+
+ case TCFG_RESET:
+ if( goi->isconfigure ){
+ e = Jim_GetOpt_Nvp( goi, nvp_reset_modes, &n );
+ if( e != JIM_OK ){
+ Jim_GetOpt_NvpUnknown( goi, nvp_reset_modes, 1 );
+ return e;
+ }
+ if( n->value == RESET_UNKNOWN ){
+ Jim_SetResultString( interp, "'unknown' is not a valid selection",-1);
+ return JIM_ERR;
+ }
+ target->reset_mode = n->value;
+ } else {
+ if( goi->argc != 0 ){
+ goto no_params;
+ }
+ }
+ n = Jim_Nvp_value2name_simple( nvp_reset_modes, target->reset_mode );
+ if( n->name == NULL ){
+ target->reset_mode = RESET_HALT;
+ n = Jim_Nvp_value2name_simple( nvp_reset_modes, target->reset_mode );
+ }
+ Jim_SetResultString( goi->interp, n->name, -1 );
+ /* loop for more */
+ break;
+
+ case TCFG_WORK_AREA_VIRT:
+ if( goi->isconfigure ){
+ target_free_all_working_areas(target);
+ e = Jim_GetOpt_Wide( goi, &w );
+ if( e != JIM_OK ){
+ return e;
+ }
+ target->working_area_virt = w;
+ } else {
+ if( goi->argc != 0 ){
+ goto no_params;
+ }
+ }
+ Jim_SetResult( interp, Jim_NewIntObj( goi->interp, target->working_area_virt ) );
+ /* loop for more */
+ break;
+
+ case TCFG_WORK_AREA_PHYS:
+ if( goi->isconfigure ){
+ target_free_all_working_areas(target);
+ e = Jim_GetOpt_Wide( goi, &w );
+ if( e != JIM_OK ){
+ return e;
+ }
+ target->working_area_phys = w;
+ } else {
+ if( goi->argc != 0 ){
+ goto no_params;
+ }
+ }
+ Jim_SetResult( interp, Jim_NewIntObj( goi->interp, target->working_area_phys ) );
+ /* loop for more */
+ break;
+
+ case TCFG_WORK_AREA_SIZE:
+ if( goi->isconfigure ){
+ target_free_all_working_areas(target);
+ e = Jim_GetOpt_Wide( goi, &w );
+ if( e != JIM_OK ){
+ return e;
+ }
+ target->working_area_size = w;
+ } else {
+ if( goi->argc != 0 ){
+ goto no_params;
+ }
+ }
+ Jim_SetResult( interp, Jim_NewIntObj( goi->interp, target->working_area_size ) );
+ /* loop for more */
+ break;
+
+ case TCFG_WORK_AREA_BACKUP:
+ if( goi->isconfigure ){
+ target_free_all_working_areas(target);
+ e = Jim_GetOpt_Wide( goi, &w );
+ if( e != JIM_OK ){
+ return e;
+ }
+ /* make this exactly 1 or 0 */
+ target->backup_working_area = (!!w);
+ } else {
+ if( goi->argc != 0 ){
+ goto no_params;
+ }
+ }
+ Jim_SetResult( interp, Jim_NewIntObj( goi->interp, target->working_area_size ) );
+ /* loop for more e*/
+ break;
+
+ case TCFG_ENDIAN:
+ if( goi->isconfigure ){
+ e = Jim_GetOpt_Nvp( goi, nvp_target_endian, &n );
+ if( e != JIM_OK ){
+ Jim_GetOpt_NvpUnknown( goi, nvp_target_endian, 1 );
+ return e;
+ }
+ target->endianness = n->value;
+ } else {
+ if( goi->argc != 0 ){
+ goto no_params;
+ }
+ }
+ n = Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness );
+ if( n->name == NULL ){
+ target->endianness = TARGET_LITTLE_ENDIAN;
+ n = Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness );
+ }
+ Jim_SetResultString( goi->interp, n->name, -1 );
+ /* loop for more */
+ break;
+
+ case TCFG_VARIANT:
+ if( goi->isconfigure ){
+ if( goi->argc < 1 ){
+ Jim_SetResult_sprintf( goi->interp,
+ "%s ?STRING?",
+ n->name );
+ return JIM_ERR;
+ }
+ if( target->variant ){
+ free((void *)(target->variant));
+ }
+ e = Jim_GetOpt_String( goi, &cp, NULL );
+ target->variant = strdup(cp);
+ } else {
+ if( goi->argc != 0 ){
+ goto no_params;
+ }
+ }
+ Jim_SetResultString( goi->interp, target->variant,-1 );
+ /* loop for more */
+ break;
+ case TCFG_CHAIN_POSITION:
+ if( goi->isconfigure ){
+ target_free_all_working_areas(target);
+ e = Jim_GetOpt_Wide( goi, &w );
+ if( e != JIM_OK ){
+ return e;
+ }
+ /* make this exactly 1 or 0 */
+ target->chain_position = w;
+ } else {
+ if( goi->argc != 0 ){
+ goto no_params;
+ }
+ }
+ Jim_SetResult( interp, Jim_NewIntObj( goi->interp, target->chain_position ) );
+ /* loop for more e*/
+ break;
+ }
+ }
+ /* done - we return */
+ return JIM_OK;
+}
+
+
+/** this is the 'tcl' handler for the target specific command */
+static int
+tcl_target_func( Jim_Interp *interp,
+ int argc,
+ Jim_Obj *const *argv )
+{
+ Jim_GetOptInfo goi;
+ jim_wide a,b,c;
+ int x,y,z;
+ u8 target_buf[32];
+ Jim_Nvp *n;
+ target_t *target;
+ struct command_context_s *cmd_ctx;
+ int e;
+
+
+ enum {
+ TS_CMD_CONFIGURE,
+ TS_CMD_CGET,
+
+ TS_CMD_MWW, TS_CMD_MWH, TS_CMD_MWB,
+ TS_CMD_MDW, TS_CMD_MDH, TS_CMD_MDB,
+ TS_CMD_MRW, TS_CMD_MRH, TS_CMD_MRB,
+ TS_CMD_MEM2ARRAY, TS_CMD_ARRAY2MEM,
+ TS_CMD_EXAMINE,
+ TS_CMD_POLL,
+ TS_CMD_RESET,
+ TS_CMD_HALT,
+ TS_CMD_WAITSTATE,
+ TS_CMD_EVENTLIST,
+ TS_CMD_CURSTATE,
+ };
+
+ static const Jim_Nvp target_options[] = {
+ { .name = "configure", .value = TS_CMD_CONFIGURE },
+ { .name = "cget", .value = TS_CMD_CGET },
+ { .name = "mww", .value = TS_CMD_MWW },
+ { .name = "mwh", .value = TS_CMD_MWH },
+ { .name = "mwb", .value = TS_CMD_MWB },
+ { .name = "mdw", .value = TS_CMD_MDW },
+ { .name = "mdh", .value = TS_CMD_MDH },
+ { .name = "mdb", .value = TS_CMD_MDB },
+ { .name = "mem2array", .value = TS_CMD_MEM2ARRAY },
+ { .name = "array2mem", .value = TS_CMD_ARRAY2MEM },
+ { .name = "eventlist", .value = TS_CMD_EVENTLIST },
+ { .name = "curstate", .value = TS_CMD_CURSTATE },
+
+ { .name = "arp_examine", .value = TS_CMD_EXAMINE },
+ { .name = "arp_poll", .value = TS_CMD_POLL },
+ { .name = "arp_reset", .value = TS_CMD_RESET },
+ { .name = "arp_halt", .value = TS_CMD_HALT },
+ { .name = "arp_waitstate", .value = TS_CMD_WAITSTATE },
+
+ { .name = NULL, .value = -1 },
+ };
+
+
+ /* go past the "command" */
+ Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 );
+
+ target = Jim_CmdPrivData( goi.interp );
+ cmd_ctx = Jim_GetAssocData(goi.interp, "context");
+
+ /* commands here are in an NVP table */
+ e = Jim_GetOpt_Nvp( &goi, target_options, &n );
+ if( e != JIM_OK ){
+ Jim_GetOpt_NvpUnknown( &goi, target_options, 0 );
+ return e;
+ }
+ // Assume blank result
+ Jim_SetEmptyResult( goi.interp );
+
+ switch( n->value ){
+ case TS_CMD_CONFIGURE:
+ if( goi.argc < 2 ){
+ Jim_WrongNumArgs( goi.interp, goi.argc, goi.argv, "missing: -option VALUE ...");
+ return JIM_ERR;
+ }
+ goi.isconfigure = 1;
+ return target_configure( &goi, target );
+ case TS_CMD_CGET:
+ // some things take params
+ if( goi.argc < 1 ){
+ Jim_WrongNumArgs( goi.interp, 0, goi.argv, "missing: ?-option?");
+ return JIM_ERR;
+ }
+ goi.isconfigure = 0;
+ return target_configure( &goi, target );
+ break;
+ case TS_CMD_MWW:
+ case TS_CMD_MWH:
+ case TS_CMD_MWB:
+ /* argv[0] = cmd
+ * argv[1] = address
+ * argv[2] = data
+ * argv[3] = optional count.
+ */
+
+ if( (goi.argc == 3) || (goi.argc == 4) ){
+ /* all is well */
+ } else {
+ mwx_error:
+ Jim_SetResult_sprintf( goi.interp, "expected: %s ADDR DATA [COUNT]", n->name );
+ return JIM_ERR;
+ }
+
+ e = Jim_GetOpt_Wide( &goi, &a );
+ if( e != JIM_OK ){
+ goto mwx_error;
+ }
+
+ e = Jim_GetOpt_Wide( &goi, &b );
+ if( e != JIM_OK ){
+ goto mwx_error;
+ }
+ if( goi.argc ){
+ e = Jim_GetOpt_Wide( &goi, &c );
+ if( e != JIM_OK ){
+ goto mwx_error;
+ }
+ } else {
+ c = 1;
+ }
+
+ switch( n->value ){
+ case TS_CMD_MWW:
+ target_buffer_set_u32( target, target_buf, b );
+ b = 4;
+ break;
+ case TS_CMD_MWH:
+ target_buffer_set_u16( target, target_buf, b );
+ b = 2;
+ break;
+ case TS_CMD_MWB:
+ target_buffer_set_u8( target, target_buf, b );
+ b = 1;
+ break;
+ }
+ for( x = 0 ; x < c ; x++ ){
+ e = target->type->write_memory( target, a, b, 1, target_buf );
+ if( e != ERROR_OK ){
+ Jim_SetResult_sprintf( interp, "Error writing @ 0x%08x: %d\n", (int)(a), e );
+ return JIM_ERR;
+ }
+ /* b = width */
+ a = a + b;
+ }
+ return JIM_OK;
+ break;
+
+ /* display */
+ case TS_CMD_MDW:
+ case TS_CMD_MDH:
+ case TS_CMD_MDB:
+ /* argv[0] = command
+ * argv[1] = address
+ * argv[2] = optional count
+ */
+ if( (goi.argc == 2) || (goi.argc == 3) ){
+ Jim_SetResult_sprintf( goi.interp, "expected: %s ADDR [COUNT]", n->name );
+ return JIM_ERR;
+ }
+ e = Jim_GetOpt_Wide( &goi, &a );
+ if( e != JIM_OK ){
+ return JIM_ERR;
+ }
+ if( goi.argc ){
+ e = Jim_GetOpt_Wide( &goi, &c );
+ if( e != JIM_OK ){
+ return JIM_ERR;
+ }
+ } else {
+ c = 1;
+ }
+ b = 1; /* shut up gcc */
+ switch( n->value ){
+ case TS_CMD_MDW:
+ b = 4;
+ break;
+ case TS_CMD_MDH:
+ b = 2;
+ break;
+ case TS_CMD_MDB:
+ b = 1;
+ break;
+ }
+
+ /* convert to "bytes" */
+ c = c * b;
+ /* count is now in 'BYTES' */
+ while( c > 0 ){
+ y = c;
+ if( y > 16 ){
+ y = 16;
+ }
+ e = target->type->read_memory( target, a, b, y / b, target_buf );
+ if( e != ERROR_OK ){
+ Jim_SetResult_sprintf( interp, "error reading target @ 0x%08lx", (int)(a) );
+ return JIM_ERR;
+ }
+
+ Jim_fprintf( interp, interp->cookie_stdout, "0x%08x ", (int)(a) );
+ switch( b ){
+ case 4:
+ for( x = 0 ; (x < 16) && (x < y) ; x += 4 ){
+ z = target_buffer_get_u32( target, &(target_buf[ x * 4 ]) );
+ Jim_fprintf( interp, interp->cookie_stdout, "%08x ", (int)(z) );
+ }
+ for( ; (x < 16) ; x += 4 ){
+ Jim_fprintf( interp, interp->cookie_stdout, " " );
+ }
+ break;
+ case 2:
+ for( x = 0 ; (x < 16) && (x < y) ; x += 2 ){
+ z = target_buffer_get_u16( target, &(target_buf[ x * 2 ]) );
+ Jim_fprintf( interp, interp->cookie_stdout, "%04x ", (int)(z) );
+ }
+ for( ; (x < 16) ; x += 2 ){
+ Jim_fprintf( interp, interp->cookie_stdout, " " );
+ }
+ break;
+ case 1:
+ default:
+ for( x = 0 ; (x < 16) && (x < y) ; x += 1 ){
+ z = target_buffer_get_u8( target, &(target_buf[ x * 4 ]) );
+ Jim_fprintf( interp, interp->cookie_stdout, "%02x ", (int)(z) );
+ }
+ for( ; (x < 16) ; x += 1 ){
+ Jim_fprintf( interp, interp->cookie_stdout, " " );
+ }
+ break;
+ }
+ /* ascii-ify the bytes */
+ for( x = 0 ; x < y ; x++ ){
+ if( (target_buf[x] >= 0x20) &&
+ (target_buf[x] <= 0x7e) ){
+ /* good */
+ } else {
+ /* smack it */
+ target_buf[x] = '.';
+ }
+ }
+ /* space pad */
+ while( x < 16 ){
+ target_buf[x] = ' ';
+ x++;
+ }
+ /* terminate */
+ target_buf[16] = 0;
+ /* print - with a newline */
+ Jim_fprintf( interp, interp->cookie_stdout, "%s\n", target_buf );
+ /* NEXT... */
+ c -= 16;
+ a += 16;
+ }
+ return JIM_OK;
+ case TS_CMD_MEM2ARRAY:
+ return target_mem2array( goi.interp, target, goi.argc, goi.argv );
+ break;
+ case TS_CMD_ARRAY2MEM:
+ return target_array2mem( goi.interp, target, goi.argc, goi.argv );
+ break;
+ case TS_CMD_EXAMINE:
+ if( goi.argc ){
+ Jim_WrongNumArgs( goi.interp, 0, argv, "[no parameters]");
+ return JIM_ERR;
+ }
+ e = target->type->examine( target );
+ if( e != ERROR_OK ){
+ Jim_SetResult_sprintf( interp, "examine-fails: %d", e );
+ return JIM_ERR;
+ }
+ return JIM_OK;
+ case TS_CMD_POLL:
+ if( goi.argc ){
+ Jim_WrongNumArgs( goi.interp, 0, argv, "[no parameters]");
+ return JIM_ERR;
+ }
+ if( !(target->type->examined) ){
+ e = ERROR_TARGET_NOT_EXAMINED;
+ } else {
+ e = target->type->poll( target );
+ }
+ if( e != ERROR_OK ){
+ Jim_SetResult_sprintf( interp, "poll-fails: %d", e );
+ return JIM_ERR;
+ } else {
+ return JIM_OK;
+ }
+ break;
+ case TS_CMD_RESET:
+ if( goi.argc != 1 ){
+ Jim_WrongNumArgs( interp, 1, argv, "reset t|f|assert|deassert");
+ return JIM_ERR;
+ }
+ e = Jim_GetOpt_Nvp( &goi, nvp_assert, &n );
+ if( e != JIM_OK ){
+ Jim_GetOpt_NvpUnknown( &goi, nvp_assert, 1 );
+ return e;
+ }
+ // When this happens - all workareas are invalid.
+ target_free_all_working_areas_restore(target, 0);
+
+ // do the assert
+ if( n->value == NVP_ASSERT ){
+ target->type->assert_reset( target );
+ } else {
+ target->type->deassert_reset( target );
+ }
+ return JIM_OK;
+ case TS_CMD_HALT:
+ if( goi.argc ){
+ Jim_WrongNumArgs( goi.interp, 0, argv, "halt [no parameters]");
+ return JIM_ERR;
+ }
+ target->type->halt( target );
+ return JIM_OK;
+ case TS_CMD_WAITSTATE:
+ // params: <name> statename timeoutmsecs
+ if( goi.argc != 2 ){
+ Jim_SetResult_sprintf( goi.interp, "%s STATENAME TIMEOUTMSECS", n->name );
+ return JIM_ERR;
+ }
+ e = Jim_GetOpt_Nvp( &goi, nvp_target_state, &n );
+ if( e != JIM_OK ){
+ Jim_GetOpt_NvpUnknown( &goi, nvp_target_state,1 );
+ return e;
+ }
+ e = Jim_GetOpt_Wide( &goi, &a );
+ if( e != JIM_OK ){
+ return e;
+ }
+ e = target_wait_state( target, n->value, a );
+ if( e == ERROR_OK ){
+ Jim_SetResult_sprintf( goi.interp,
+ "target: %s wait %s fails %d",
+ target->cmd_name,
+ n->name,
+ target_strerror_safe(e) );
+ return JIM_ERR;
+ } else {
+ return JIM_OK;
+ }
+ case TS_CMD_EVENTLIST:
+ /* List for human, Events defined for this target.
+ * scripts/programs should use 'name cget -event NAME'
+ */
+ {
+ target_event_action_t *teap;
+ teap = target->event_action;
+ command_print( cmd_ctx, "Event actions for target (%d) %s\n",
+ target->target_number,
+ target->cmd_name );
+ command_print( cmd_ctx, "%-25s | Body", "Event");
+ command_print( cmd_ctx, "------------------------- | ----------------------------------------");
+ while( teap ){
+ command_print( cmd_ctx,
+ "%-25s | %s",
+ Jim_Nvp_value2name_simple( nvp_target_event, teap->event )->name,
+ Jim_GetString( teap->body, NULL ) );
+ teap = teap->next;
+ }
+ command_print( cmd_ctx, "***END***");
+ return JIM_OK;
+ }
+ case TS_CMD_CURSTATE:
+ if( goi.argc != 0 ){
+ Jim_WrongNumArgs( goi.interp, 0, argv, "[no parameters]");
+ return JIM_ERR;
+ }
+ Jim_SetResultString( goi.interp,
+ Jim_Nvp_value2name_simple(nvp_target_state,target->state)->name,-1);
+ return JIM_OK;
+ }
+ return JIM_ERR;
+}
+
+
+static int
+target_create( Jim_GetOptInfo *goi )
+{
+
+ Jim_Obj *new_cmd;
+ Jim_Cmd *cmd;
+ const char *cp;
+ char *cp2;
+ int e;
+ int x;
+ target_t *target;
+ struct command_context_s *cmd_ctx;
+
+ cmd_ctx = Jim_GetAssocData(goi->interp, "context");
+ if( goi->argc < 3 ){
+ Jim_WrongNumArgs( goi->interp, 1, goi->argv, "?name? ?type? ..options...");
+ return JIM_ERR;
+ }
+
+ /* COMMAND */
+ Jim_GetOpt_Obj( goi, &new_cmd );
+ /* does this command exist? */
+ cmd = Jim_GetCommand( goi->interp, new_cmd, JIM_ERRMSG );
+ if( cmd ){
+ cp = Jim_GetString( new_cmd, NULL );
+ Jim_SetResult_sprintf(goi->interp, "Command/target: %s Exists", cp);
+ return JIM_ERR;
+ }
+
+ /* TYPE */
+ e = Jim_GetOpt_String( goi, &cp2, NULL );
+ cp = cp2;
+ /* now does target type exist */
+ for( x = 0 ; target_types[x] ; x++ ){
+ if( 0 == strcmp( cp, target_types[x]->name ) ){
+ /* found */
+ break;
+ }
+ }
+ if( target_types[x] == NULL ){
+ Jim_SetResult_sprintf( goi->interp, "Unknown target type %s, try one of ", cp );
+ for( x = 0 ; target_types[x] ; x++ ){
+ if( target_types[x+1] ){
+ Jim_AppendStrings( goi->interp,
+ Jim_GetResult(goi->interp),
+ target_types[x]->name,
+ ", ", NULL);
+ } else {
+ Jim_AppendStrings( goi->interp,
+ Jim_GetResult(goi->interp),
+ " or ",
+ target_types[x]->name,NULL );
+ }
+ }
+ return JIM_ERR;
+ }
+
+
+ /* Create it */
+ target = calloc(1,sizeof(target_t));
+ /* set target number */
+ target->target_number = new_target_number();
+
+ /* allocate memory for each unique target type */
+ target->type = (target_type_t*)calloc(1,sizeof(target_type_t));
+
+ memcpy( target->type, target_types[x], sizeof(target_type_t));
+
+ /* will be set by "-endian" */
+ target->endianness = TARGET_ENDIAN_UNKNOWN;
+
+ target->working_area = 0x0;
+ target->working_area_size = 0x0;
+ target->working_areas = NULL;
+ target->backup_working_area = 0;
+
+ target->state = TARGET_UNKNOWN;
+ target->debug_reason = DBG_REASON_UNDEFINED;
+ target->reg_cache = NULL;
+ target->breakpoints = NULL;
+ target->watchpoints = NULL;
+ target->next = NULL;
+ target->arch_info = NULL;
+
+ /* initialize trace information */
+ target->trace_info = malloc(sizeof(trace_t));
+ target->trace_info->num_trace_points = 0;
+ target->trace_info->trace_points_size = 0;
+ target->trace_info->trace_points = NULL;
+ target->trace_info->trace_history_size = 0;
+ target->trace_info->trace_history = NULL;
+ target->trace_info->trace_history_pos = 0;
+ target->trace_info->trace_history_overflowed = 0;
+
+ target->dbgmsg = NULL;
+ target->dbg_msg_enabled = 0;
+
+ target->endianness = TARGET_ENDIAN_UNKNOWN;
+
+ /* Do the rest as "configure" options */
+ goi->isconfigure = 1;
+ e = target_configure( goi, target);
+ if( e != JIM_OK ){
+ free( target->type );
+ free( target );
+ return e;
+ }
+
+ if( target->endianness == TARGET_ENDIAN_UNKNOWN ){
+ /* default endian to little if not specified */
+ target->endianness = TARGET_LITTLE_ENDIAN;
+ }
+
+ /* create the target specific commands */
+ if( target->type->register_commands ){
+ (*(target->type->register_commands))( cmd_ctx );
+ }
+ if( target->type->target_create ){
+ (*(target->type->target_create))( target, goi->interp );
+ }
+
+ /* append to end of list */
+ {
+ target_t **tpp;
+ tpp = &(all_targets);
+ while( *tpp ){
+ tpp = &( (*tpp)->next );
+ }
+ *tpp = target;
+ }
+
+ cp = Jim_GetString( new_cmd, NULL );
+ target->cmd_name = strdup(cp);
+
+ /* now - create the new target name command */
+ e = Jim_CreateCommand( goi->interp,
+ /* name */
+ cp,
+ tcl_target_func, /* C function */
+ target, /* private data */
+ NULL ); /* no del proc */
+
+ (*(target->type->target_create))( target, goi->interp );
+ return e;
+}
+
+static int
+jim_target( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
+{
+ int x,r,e;
+ jim_wide w;
+ struct command_context_s *cmd_ctx;
+ const char *cp;
+ target_t *target;
+ Jim_GetOptInfo goi;
+ enum tcmd {
+ /* TG = target generic */
+ TG_CMD_CREATE,
+ TG_CMD_TYPES,
+ TG_CMD_NAMES,
+ TG_CMD_CURRENT,
+ TG_CMD_NUMBER,
+ TG_CMD_COUNT,
+ };
+ const char *target_cmds[] = {
+ "create", "types", "names", "current", "number",
+ "count",
+ NULL // terminate
+ };
+
+ LOG_DEBUG("Target command params:");
+ LOG_DEBUG(Jim_Debug_ArgvString( interp, argc, argv) );
+
+ cmd_ctx = Jim_GetAssocData( interp, "context" );
+
+ Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 );
+
+ if( goi.argc == 0 ){
+ Jim_WrongNumArgs(interp, 1, argv, "missing: command ...");
+ return JIM_ERR;
+ }
+
+ /* is this old syntax? */
+ /* To determine: We have to peek at argv[0]*/
+ cp = Jim_GetString( goi.argv[0], NULL );
+ for( x = 0 ; target_types[x] ; x++ ){
+ if( 0 == strcmp(cp,target_types[x]->name) ){
+ break;
+ }
+ }
+ if( target_types[x] ){
+ /* YES IT IS OLD SYNTAX */
+ Jim_Obj *new_argv[10];
+ int new_argc;
+
+ /* target_old_syntax
+ *
+ * argv[0] typename (above)
+ * argv[1] endian
+ * argv[2] reset method, deprecated/ignored
+ * argv[3] = old param
+ * argv[4] = old param
+ *
+ * We will combine all "old params" into a single param.
+ * Then later, split them again.
+ */
+ if( argc < 4 ){
+ Jim_WrongNumArgs( interp, 1, argv, "[OLDSYNTAX] ?TYPE? ?ENDIAN? ?RESET? ?old-params?");
+ return JIM_ERR;
+ }
+ /* the command */
+ new_argv[0] = argv[0];
+ new_argv[1] = Jim_NewStringObj( interp, "create", -1 );
+ {
+ char buf[ 30 ];
+ sprintf( buf, "target%d", new_target_number() );
+ new_argv[2] = Jim_NewStringObj( interp, buf , -1 );
+ }
+ new_argv[3] = goi.argv[0]; /* typename */
+ new_argv[4] = Jim_NewStringObj( interp, "-endian", -1 );
+ new_argv[5] = goi.argv[1];
+ new_argv[6] = Jim_NewStringObj( interp, "-chain-position", -1 );
+ new_argv[7] = goi.argv[2];
+ new_argv[8] = Jim_NewStringObj( interp, "-variant", -1 );
+ new_argv[9] = goi.argv[3];
+ new_argc = 10;
+ /*
+ * new arg syntax:
+ * argv[0] = command
+ * argv[1] = create
+ * argv[2] = cmdname
+ * argv[3] = typename
+ * argv[4] = **FIRST** "configure" option.
+ *
+ * Here, we make them:
+ *
+ * argv[4] = -endian
+ * argv[5] = little
+ * argv[6] = -position
+ * argv[7] = NUMBER
+ * argv[8] = -variant
+ * argv[9] = "somestring"
+ */
+
+ /* don't let these be released */
+ for( x = 0 ; x < new_argc ; x++ ){
+ Jim_IncrRefCount( new_argv[x]);
+ }
+ /* call our self */
+ LOG_DEBUG("Target OLD SYNTAX - converted to new syntax");
+
+ r = jim_target( goi.interp, new_argc, new_argv );
+
+ /* release? these items */
+ for( x = 0 ; x < new_argc ; x++ ){
+ Jim_DecrRefCount( interp, new_argv[x] );
+ }
+ return r;
+ }
+
+ //Jim_GetOpt_Debug( &goi );
+ r = Jim_GetOpt_Enum( &goi, target_cmds, &x );
+ if( r != JIM_OK ){
+ return r;
+ }
+
+ switch(x){
+ default:
+ Jim_Panic(goi.interp,"Why am I here?");
+ return JIM_ERR;
+ case TG_CMD_CURRENT:
+ if( goi.argc != 0 ){
+ Jim_WrongNumArgs( goi.interp, 1, goi.argv, "Too many parameters");
+ return JIM_ERR;
+ }
+ Jim_SetResultString( goi.interp, get_current_target( cmd_ctx )->cmd_name, -1 );
+ return JIM_OK;
+ case TG_CMD_TYPES:
+ if( goi.argc != 0 ){
+ Jim_WrongNumArgs( goi.interp, 1, goi.argv, "Too many parameters" );
+ return JIM_ERR;
+ }
+ Jim_SetResult( goi.interp, Jim_NewListObj( goi.interp, NULL, 0 ) );
+ for( x = 0 ; target_types[x] ; x++ ){
+ Jim_ListAppendElement( goi.interp,
+ Jim_GetResult(goi.interp),
+ Jim_NewStringObj( goi.interp, target_types[x]->name, -1 ) );
+ }
+ return JIM_OK;
+ case TG_CMD_NAMES:
+ if( goi.argc != 0 ){
+ Jim_WrongNumArgs( goi.interp, 1, goi.argv, "Too many parameters" );
+ return JIM_ERR;
+ }
+ Jim_SetResult( goi.interp, Jim_NewListObj( goi.interp, NULL, 0 ) );
+ target = all_targets;
+ while( target ){
+ Jim_ListAppendElement( goi.interp,
+ Jim_GetResult(goi.interp),
+ Jim_NewStringObj( goi.interp, target->cmd_name, -1 ) );
+ target = target->next;
+ }
+ return JIM_OK;
+ case TG_CMD_CREATE:
+ if( goi.argc < 3 ){
+ Jim_WrongNumArgs( goi.interp, goi.argc, goi.argv, "?name ... config options ...");
+ return JIM_ERR;
+ }
+ return target_create( &goi );
+ break;
+ case TG_CMD_NUMBER:
+ if( goi.argc != 1 ){
+ Jim_SetResult_sprintf( goi.interp, "expected: target number ?NUMBER?");
+ return JIM_ERR;
+ }
+ e = Jim_GetOpt_Wide( &goi, &w );
+ if( e != JIM_OK ){
+ return JIM_ERR;
+ }
+ {
+ target_t *t;
+ t = get_target_by_num(w);
+ if( t == NULL ){
+ Jim_SetResult_sprintf( goi.interp,"Target: number %d does not exist", (int)(w));
+ return JIM_ERR;
+ }
+ Jim_SetResultString( goi.interp, t->cmd_name, -1 );
+ return JIM_OK;
+ }
+ case TG_CMD_COUNT:
+ if( goi.argc != 0 ){
+ Jim_WrongNumArgs( goi.interp, 0, goi.argv, "<no parameters>");
+ return JIM_ERR;
+ }
+ Jim_SetResult( goi.interp,
+ Jim_NewIntObj( goi.interp, max_target_number()));
+ return JIM_OK;
+ }
+}
+
+
/*
* Local Variables: ***
diff --git a/src/target/target.h b/src/target/target.h
index 968d7ab8..c6f6bedd 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -199,10 +199,11 @@ typedef struct target_type_s
/* target algorithm support */
int (*run_algorithm_imp)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info);
int (*run_algorithm)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info);
-
- int (*register_commands)(struct command_context_s *cmd_ctx);
+
+ int (*register_commands)(struct command_context_s *cmd_ctx);
+
/* called when target is created */
- int (*target_jim_create)( struct target_s *target, Jim_Interp *interp );
+ int (*target_create)( struct target_s *target, Jim_Interp *interp );
/* called for various config parameters */
/* returns JIM_CONTINUE - if option not understood */
@@ -213,8 +214,6 @@ typedef struct target_type_s
/* returns JIM_OK, or JIM_ERR, or JIM_CONTINUE - if option not understood */
int (*target_jim_commands)( struct target_s *target, Jim_GetOptInfo *goi );
- /* old init function */
- int (*target_command)(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
/* invoked after JTAG chain has been examined & validated. During
* this stage the target is examined and any additional setup is
* performed.
@@ -271,19 +270,40 @@ typedef struct target_s
enum target_event
{
+ // OLD historical names
+ // - Prior to the great TCL change
+ // - June/July/Aug 2008
+ // - Duane Ellis
+ TARGET_EVENT_OLD_gdb_program_config,
+ TARGET_EVENT_OLD_pre_reset,
+ TARGET_EVENT_OLD_post_reset,
+ TARGET_EVENT_OLD_pre_resume,
+
TARGET_EVENT_HALTED, /* target entered debug state from normal execution or reset */
TARGET_EVENT_RESUMED, /* target resumed to normal execution */
TARGET_EVENT_RESUME_START,
TARGET_EVENT_RESUME_END,
TARGET_EVENT_RESET_START,
- TARGET_EVENT_RESET, /* target entered reset */
+ TARGET_EVENT_RESET_ASSERT_PRE,
+ TARGET_EVENT_RESET_ASSERT_POST,
+ TARGET_EVENT_RESET_DEASSERT_PRE,
+ TARGET_EVENT_RESET_DEASSERT_POST,
+ TARGET_EVENT_RESET_HALT_PRE,
+ TARGET_EVENT_RESET_HALT_POST,
+ TARGET_EVENT_RESET_WAIT_PRE,
+ TARGET_EVENT_RESET_WAIT_POST,
TARGET_EVENT_RESET_INIT,
TARGET_EVENT_RESET_END,
+
TARGET_EVENT_DEBUG_HALTED, /* target entered debug state, but was executing on behalf of the debugger */
TARGET_EVENT_DEBUG_RESUMED, /* target resumed to execute on behalf of the debugger */
+ TARGET_EVENT_EXAMINE_START,
+ TARGET_EVENT_EXAMINE_END,
+
+
TARGET_EVENT_GDB_ATTACH,
TARGET_EVENT_GDB_DETACH,
@@ -298,6 +318,7 @@ extern const Jim_Nvp nvp_target_event[];
struct target_event_action_s {
enum target_event event;
Jim_Obj *body;
+ int has_percent;
target_event_action_t *next;
};
@@ -392,7 +413,8 @@ int target_write_u8(struct target_s *target, u32 address, u8 value);
/* Issues USER() statements with target state information */
int target_arch_state(struct target_s *target);
-int target_invoke_script(struct command_context_s *cmd_ctx, target_t *target, char *name);
+void target_handle_event( target_t *t, enum target_event e);
+void target_all_handle_event( enum target_event e );
#define ERROR_TARGET_INVALID (-300)
@@ -407,6 +429,9 @@ int target_invoke_script(struct command_context_s *cmd_ctx, target_t *target, ch
#define ERROR_TARGET_NOT_RUNNING (-310)
#define ERROR_TARGET_NOT_EXAMINED (-311)
+extern const Jim_Nvp nvp_error_target[];
+extern const char *target_strerror_safe( int err );
+
#endif /* TARGET_H */
diff --git a/src/target/target/aduc702x.cfg b/src/target/target/aduc702x.cfg
index fdffbfea..3bc474f2 100644
--- a/src/target/target/aduc702x.cfg
+++ b/src/target/target/aduc702x.cfg
@@ -34,5 +34,5 @@ proc watchdog_service {} {
set watchdog_hdl [after 500 watchdog_service]
}
-proc target_0_post_halt {} { watchdog_service }
-proc arget_0_pre_resume {} { global watchdog_hdl; after cancel $watchdog_hdl }
+[new_target_name] configure -event old-post_halt { watchdog_service }
+[new_target_name] configure -event old-pre_resume { global watchdog_hdl; after cancel $watchdog_hdl }
diff --git a/src/target/target/at91eb40a.cfg b/src/target/target/at91eb40a.cfg
index f3fa08fe..b49150a7 100644
--- a/src/target/target/at91eb40a.cfg
+++ b/src/target/target/at91eb40a.cfg
@@ -32,7 +32,7 @@ working_area 0 0x00000000 0x20000 nobackup
global reset_count
set reset_count 0
-proc target_0_post_reset {} {
+[new_target_name] configure -event old-post_reset {
puts "Running reset init script for AT91EB40A"
global reset_count
# Reset script for AT91EB40a
@@ -46,10 +46,9 @@ proc target_0_post_reset {} {
set reset_count [expr $reset_count+1]
echo "Testing reset $reset_count !"
- asdfs
}
-proc target_0_pre_reset {} {
+[new_target_name] configure -event old-pre_reset {
global reset_count
set reset_count [expr $reset_count+1]
echo "Testing pre_reset $reset_count !"
diff --git a/src/target/target/at91r40008.cfg b/src/target/target/at91r40008.cfg
index e62a744c..7c4be18e 100644
--- a/src/target/target/at91r40008.cfg
+++ b/src/target/target/at91r40008.cfg
@@ -13,7 +13,7 @@ jtag_device 4 0x1 0xf 0xe
target arm7tdmi little 0 arm7tdmi
-target_script 0 reset event/at91r40008_reset.script
+[new_target_name] configure -event old-gdb_program_config { script event/at91r40008_reset.script }
working_area 0 0x3C000 0x4000 nobackup
flash bank cfi 0x10000000 0x400000 2 2 0
diff --git a/src/target/target/at91sam9260.cfg b/src/target/target/at91sam9260.cfg
index 21f92d79..f0f7929e 100644
--- a/src/target/target/at91sam9260.cfg
+++ b/src/target/target/at91sam9260.cfg
@@ -17,7 +17,7 @@ jtag_ntrst_delay 0
#target <type> <endianess> <reset mode> <JTAG pos> <variant>
target arm926ejs little 0 arm926ejs
-target_script 0 reset event/at91sam9260_reset.script
+[new_target_name] configure -event old-post_reset { script event/at91sam9260_reset.script }
#working area <target#> <address> <size> <backup|nobackup>
diff --git a/src/target/target/eir-sam7se512.cfg b/src/target/target/eir-sam7se512.cfg
index c33b4298..15f96858 100644
--- a/src/target/target/eir-sam7se512.cfg
+++ b/src/target/target/eir-sam7se512.cfg
@@ -8,7 +8,7 @@ jtag_device 4 0x1 0xf 0xe
target arm7tdmi little 0 arm7tdmi
-target_script 0 reset event/eir-sam7se512_reset.script
+[new_target_name] configure -event old-post_reset { script event/eir-sam7se512_reset.script }
working_area 0 0x00200000 0x4000 nobackup
diff --git a/src/target/target/hammer.cfg b/src/target/target/hammer.cfg
index 9daef590..6a4319f3 100644
--- a/src/target/target/hammer.cfg
+++ b/src/target/target/hammer.cfg
@@ -10,12 +10,12 @@ jtag_device 4 0x1 0xf 0xe
target arm920t little 0 arm920t
+[new_target_name] configure -event old-post_reset { script event/hammer_reset.script }
# speed up memory downloads
arm7 fast_memory_access enable
arm7_9 dcc_downloads enable
-target_script 0 reset event/hammer_reset.script
working_area 0 0x30800000 0x20000 nobackup
diff --git a/src/target/target/lpc2148.cfg b/src/target/target/lpc2148.cfg
index e76aa024..79ec9ecb 100644
--- a/src/target/target/lpc2148.cfg
+++ b/src/target/target/lpc2148.cfg
@@ -14,8 +14,7 @@ reset_config trst_and_srst srst_pulls_trst
jtag_device 4 0x1 0xf 0xe
target arm7tdmi little 0 arm7tdmi-s_r4
-
-proc target_0_post_reset {} {
+[new_target_name] configure -event old-post_reset {} {
# Force target into ARM state
soft_reset_halt
#do not remap 0x0000-0x0020 to anything but the flash
diff --git a/src/target/target/omap5912.cfg b/src/target/target/omap5912.cfg
index 3a8f4154..a00e9bf1 100644
--- a/src/target/target/omap5912.cfg
+++ b/src/target/target/omap5912.cfg
@@ -11,8 +11,7 @@ jtag_device 4 0x1 0x0 0xe
jtag_device 8 0x0 0x0 0x0
target arm926ejs little 1 arm926ejs
-target_script 0 reset event/omap5912_reset.script
-
+[new_target_name] configure -event old-post_reset { script event/omap5912_reset.script }
# omap5912 lcd frame buffer as working area
working_area 0 0x20000000 0x3e800 nobackup
diff --git a/src/target/target/pxa255.cfg b/src/target/target/pxa255.cfg
index b712cf37..daa49345 100644
--- a/src/target/target/pxa255.cfg
+++ b/src/target/target/pxa255.cfg
@@ -1,11 +1,13 @@
jtag_device 5 0x1 0x1f 0x1e
jtag_nsrst_delay 200
jtag_ntrst_delay 200
+
target xscale little 0 pxa255
+[new_target_name] configure -event old-post_reset { script event/pxa255_reset.script }
+
reset_config trst_and_srst
-target_script 0 reset event/pxa255_reset.script
#xscale debug_handler 0 0xFFFF0800 # debug handler base address
diff --git a/src/target/target/sam7x256.cfg b/src/target/target/sam7x256.cfg
index 663ac110..34556f87 100644
--- a/src/target/target/sam7x256.cfg
+++ b/src/target/target/sam7x256.cfg
@@ -8,9 +8,7 @@ jtag_device 4 0x1 0xf 0xe
#target <type> <startup mode>
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm7tdmi little 0 arm7tdmi
-
-
-target_script 0 reset event/sam7x256_reset.script
+[new_target_name] configure -event old-post_reset { script event/sam7x256_reset.script }
working_area 0 0x00200000 0x4000 nobackup
diff --git a/src/target/target/str710.cfg b/src/target/target/str710.cfg
index 45ea7055..59e7e179 100644
--- a/src/target/target/str710.cfg
+++ b/src/target/target/str710.cfg
@@ -1,11 +1,6 @@
#start slow, speed up after reset
jtag_khz 10
-proc target_0_pre_reset {} {
- jtag_khz 10
-}
-proc target_0_post_reset {} {
- jtag_khz 6000
-}
+
#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst srst_pulls_trst
@@ -17,9 +12,9 @@ jtag_device 4 0x1 0xf 0xe
#target <type> <startup mode>
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm7tdmi little 0 arm7tdmi
-
-
-target_script 0 gdb_program_config event/str710_program.script
+[new_target_name] configure -event old-pre_reset { jtag_khz 10 }
+[new_target_name] configure -event old-post_reset { jtag_khz 6000 }
+[new_target_name] configure -event old-gdb_program_config { script event/str710_program.script }
working_area 0 0x2000C000 0x4000 nobackup
diff --git a/src/target/target/str730.cfg b/src/target/target/str730.cfg
index 837dbcf4..a65f75a0 100644
--- a/src/target/target/str730.cfg
+++ b/src/target/target/str730.cfg
@@ -2,12 +2,6 @@
jtag_khz 3000
-proc target_0_pre_reset {} {
- jtag_khz 10
-}
-proc target_0_post_reset {} {
- jtag_khz 3000
-}
#use combined on interfaces or targets that can’t set TRST/SRST separately
@@ -23,10 +17,9 @@ jtag_nsrst_delay 500
jtag_ntrst_delay 500
target arm7tdmi little 0 arm7tdmi
-
-
-
-target_script 0 gdb_program_config event/str730_program.script
+[new_target_name] configure -event old-pre_reset { jtag_khz 10 }
+[new_target_name] configure -event old-post_reset { jtag_khz 3000 }
+[new_target_name] configure -event old-gdb_program_config { script event/str730_program.script }
working_area 0 0x40000000 0x4000 nobackup
diff --git a/src/target/target/str750.cfg b/src/target/target/str750.cfg
index 8572e1bd..7a8fde41 100644
--- a/src/target/target/str750.cfg
+++ b/src/target/target/str750.cfg
@@ -2,12 +2,7 @@
# jtag speed
jtag_khz 10
-proc target_0_pre_reset {} {
- jtag_khz 10
-}
-proc target_0_post_reset {} {
- jtag_khz 3000
-}
+
#use combined on interfaces or targets that can’t set TRST/SRST separately
#reset_config trst_and_srst srst_pulls_trst
@@ -25,9 +20,9 @@ jtag_ntrst_delay 500
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm7tdmi little 0 arm7tdmi
-
-
-target_script 0 gdb_program_config event/str750_program.script
+[new_target_name] configure -event old-pre_reset { jtag_khz 10 }
+[new_target_name] configure -event old-post_reset { jtag_khz 3000 }
+[new_target_name] configure -event old-gdb_program_config { script event/str750_program.script }
working_area 0 0x40000000 0x4000 nobackup
diff --git a/src/target/target/str912.cfg b/src/target/target/str912.cfg
index ca2fb8ca..2e0056a6 100644
--- a/src/target/target/str912.cfg
+++ b/src/target/target/str912.cfg
@@ -3,23 +3,6 @@
# jtag speed. We need to stick to 16kHz until we've finished reset.
jtag_rclk 16
-proc target_0_pre_reset {} {
- jtag_rclk 16
-}
-
-proc target_0_post_reset {} {
- # We can increase speed now that we know the target is halted.
- jtag_rclk 3000
-
- # -- Enable 96K RAM
- # PFQBC enabled / DTCM & AHB wait-states disabled
- mww 0x5C002034 0x0191
-
- str9x flash_config 0 4 2 0 0x80000
- flash protect 0 0 7 off
-
-
-}
jtag_nsrst_delay 100
@@ -38,6 +21,20 @@ jtag_device 5 0x1 0x1 0x1e
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm966e little 1 arm966e
+[new_target_name] configure -event old-pre_reset { jtag_rclk 16 }
+
+[new_target_name] configure -event old-post_reset {
+ # We can increase speed now that we know the target is halted.
+ jtag_rclk 3000
+
+ # -- Enable 96K RAM
+ # PFQBC enabled / DTCM & AHB wait-states disabled
+ mww 0x5C002034 0x0191
+
+ str9x flash_config 0 4 2 0 0x80000
+ flash protect 0 0 7 off
+}
+
working_area 0 0x50000000 16384 nobackup
diff --git a/src/target/target/wi-9c.cfg b/src/target/target/wi-9c.cfg
index eccb8fa4..08f326e6 100644
--- a/src/target/target/wi-9c.cfg
+++ b/src/target/target/wi-9c.cfg
@@ -17,7 +17,7 @@ jtag_ntrst_delay 0
#target <type> <endianess> <reset mode> <JTAG pos> <variant>
target arm926ejs big 0 arm926ejs
-target_script 0 reset event/wi-9c_reset.script
+[new_target_name] configure -event old-post_reset { script event/wi-9c_reset.script }
#working area <target#> <address> <size> <backup|nobackup>
diff --git a/src/target/target/xba_revA3.cfg b/src/target/target/xba_revA3.cfg
index c65f7350..dcac9dd2 100644
--- a/src/target/target/xba_revA3.cfg
+++ b/src/target/target/xba_revA3.cfg
@@ -10,7 +10,7 @@ jtag_ntrst_delay 100
jtag_device 7 0x1 0x7f 0x7e
target xscale big 0 ixp42x
-target_script 0 reset event/xba_revA3.script
+[new_target_name] configure -event old-post_reset { script event/xba_revA3.script }
flash bank cfi 0x50000000 0x400000 2 2 0
diff --git a/src/target/target/zy1000.cfg b/src/target/target/zy1000.cfg
index 9e8cdb9c..7a1b8b98 100644
--- a/src/target/target/zy1000.cfg
+++ b/src/target/target/zy1000.cfg
@@ -21,7 +21,7 @@ arm7_9 fast_memory_access enable
arm7_9 dcc_downloads enable
flash bank ecosflash 0x01000000 0x200000 2 2 0 ecos/at91eb40a.elf
-target_script 0 reset event/zy1000_reset.script
+[new_target_name] configure -event old-post_reset { script event/zy1000_reset.script }
# required for usable performance. Used for lots of
# other things than flash programming.
diff --git a/src/target/xscale.c b/src/target/xscale.c
index 87fb6acd..6b033cbd 100644
--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -53,7 +53,7 @@
int xscale_register_commands(struct command_context_s *cmd_ctx);
/* forward declarations */
-int xscale_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
+int xscale_target_create(struct target_s *target, Jim_Interp *interp);
int xscale_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int xscale_quit(void);
@@ -124,7 +124,7 @@ target_type_t xscale_target =
.remove_watchpoint = xscale_remove_watchpoint,
.register_commands = xscale_register_commands,
- .target_command = xscale_target_command,
+ .target_create = xscale_target_create,
.init_target = xscale_init_target,
.quit = xscale_quit,
@@ -3001,7 +3001,7 @@ int xscale_quit(void)
return ERROR_OK;
}
-int xscale_init_arch_info(target_t *target, xscale_common_t *xscale, int chain_pos, char *variant)
+int xscale_init_arch_info(target_t *target, xscale_common_t *xscale, int chain_pos, const char *variant)
{
armv4_5_common_t *armv4_5;
u32 high_reset_branch, low_reset_branch;
@@ -3112,24 +3112,11 @@ int xscale_init_arch_info(target_t *target, xscale_common_t *xscale, int chain_p
}
/* target xscale <endianess> <startup_mode> <chain_pos> <variant> */
-int xscale_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target)
+int xscale_target_create(struct target_s *target, Jim_Interp *interp)
{
- int chain_pos;
- char *variant = NULL;
- xscale_common_t *xscale = malloc(sizeof(xscale_common_t));
- memset(xscale, 0, sizeof(*xscale));
+ xscale_common_t *xscale = calloc(1,sizeof(xscale_common_t));
- if (argc < 5)
- {
- LOG_ERROR("'target xscale' requires four arguments: <endianess> <startup_mode> <chain_pos> <variant>");
- return ERROR_OK;
- }
-
- chain_pos = strtoul(args[3], NULL, 0);
-
- variant = args[4];
-
- xscale_init_arch_info(target, xscale, chain_pos, variant);
+ xscale_init_arch_info(target, xscale, target->chain_position, target->variant);
xscale_build_reg_cache(target);
return ERROR_OK;
@@ -3735,3 +3722,11 @@ int xscale_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
+
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */