Commit 66ee3034 authored by Zachary T Welch's avatar Zachary T Welch
Browse files

remove target_type register_command callback

Uses chaining of command_registration structures to eliminate all
target_type register_callback routines.  Exports the command_handler
registration arrays for those target types that are used by others.
parent 144e3678
......@@ -1641,6 +1641,12 @@ static const struct command_registration cortex_a8_exec_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
static const struct command_registration cortex_a8_command_handlers[] = {
{
.chain = arm_command_handlers,
},
{
.chain = armv7a_command_handlers,
},
{
.name = "cortex_a8",
.mode = COMMAND_ANY,
......@@ -1650,13 +1656,6 @@ static const struct command_registration cortex_a8_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
static int cortex_a8_register_commands(struct command_context *cmd_ctx)
{
armv4_5_register_commands(cmd_ctx);
armv7a_register_commands(cmd_ctx);
return register_commands(cmd_ctx, NULL, cortex_a8_command_handlers);
}
struct target_type cortexa8_target = {
.name = "cortex_a8",
......@@ -1689,7 +1688,7 @@ struct target_type cortexa8_target = {
.add_watchpoint = NULL,
.remove_watchpoint = NULL,
.register_commands = cortex_a8_register_commands,
.commands = cortex_a8_command_handlers,
.target_create = cortex_a8_target_create,
.init_target = cortex_a8_init_target,
.examine = cortex_a8_examine,
......
......@@ -1937,6 +1937,12 @@ static const struct command_registration cortex_m3_exec_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
static const struct command_registration cortex_m3_command_handlers[] = {
{
.chain = arm_command_handlers,
},
{
.chain = armv7m_command_handlers,
},
{
.name = "cortex_m3",
.mode = COMMAND_ANY,
......@@ -1946,12 +1952,6 @@ static const struct command_registration cortex_m3_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
static int cortex_m3_register_commands(struct command_context *cmd_ctx)
{
armv7m_register_commands(cmd_ctx);
return register_commands(cmd_ctx, NULL, cortex_m3_command_handlers);
}
struct target_type cortexm3_target =
{
.name = "cortex_m3",
......@@ -1984,7 +1984,7 @@ struct target_type cortexm3_target =
.add_watchpoint = cortex_m3_add_watchpoint,
.remove_watchpoint = cortex_m3_remove_watchpoint,
.register_commands = cortex_m3_register_commands,
.commands = cortex_m3_command_handlers,
.target_create = cortex_m3_target_create,
.init_target = cortex_m3_init_target,
.examine = cortex_m3_examine,
......
......@@ -2103,7 +2103,7 @@ static const struct command_registration etm_config_command_handlers[] = {
},
COMMAND_REGISTRATION_DONE
};
static const struct command_registration etm_command_handlers[] = {
const struct command_registration etm_command_handlers[] = {
{
.name = "etm",
.mode = COMMAND_ANY,
......@@ -2113,11 +2113,6 @@ static const struct command_registration etm_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
int etm_register_commands(struct command_context *cmd_ctx)
{
return register_commands(cmd_ctx, NULL, etm_command_handlers);
}
static const struct command_registration etm_exec_command_handlers[] = {
{
.name = "tracemode", handle_etm_tracemode_command,
......
......@@ -212,7 +212,7 @@ struct reg_cache* etm_build_reg_cache(struct target *target,
int etm_setup(struct target *target);
int etm_register_commands(struct command_context *cmd_ctx);
extern const struct command_registration etm_command_handlers[];
#define ERROR_ETM_INVALID_DRIVER (-1300)
#define ERROR_ETM_PORTMODE_NOT_SUPPORTED (-1301)
......
......@@ -385,7 +385,7 @@ struct target_type fa526_target =
.add_watchpoint = arm7_9_add_watchpoint,
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm920t_register_commands,
.commands = arm920t_command_handlers,
.target_create = fa526_target_create,
.init_target = arm9tdmi_init_target,
.examine = arm7_9_examine,
......
......@@ -709,7 +709,7 @@ struct target_type feroceon_target =
.add_watchpoint = arm7_9_add_watchpoint,
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm926ejs_register_commands,
.commands = arm926ejs_command_handlers,
.target_create = feroceon_target_create,
.init_target = feroceon_init_target,
.examine = feroceon_examine,
......@@ -748,7 +748,7 @@ struct target_type dragonite_target =
.add_watchpoint = arm7_9_add_watchpoint,
.remove_watchpoint = arm7_9_remove_watchpoint,
.register_commands = arm966e_register_commands,
.commands = arm966e_command_handlers,
.target_create = dragonite_target_create,
.init_target = feroceon_init_target,
.examine = feroceon_examine,
......
......@@ -320,11 +320,6 @@ int mips32_init_arch_info(struct target *target, struct mips32_common *mips32, s
return ERROR_OK;
}
int mips32_register_commands(struct command_context *cmd_ctx)
{
return ERROR_OK;
}
int mips32_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t entry_point, uint32_t exit_point, int timeout_ms, void *arch_info)
{
/*TODO*/
......
......@@ -41,7 +41,6 @@ int mips_m4k_resume(struct target *target, int current, uint32_t address, int ha
int mips_m4k_step(struct target *target, int current, uint32_t address, int handle_breakpoints);
int mips_m4k_read_memory(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
int mips_m4k_write_memory(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
int mips_m4k_register_commands(struct command_context *cmd_ctx);
int mips_m4k_init_target(struct command_context *cmd_ctx, struct target *target);
int mips_m4k_target_create(struct target *target, Jim_Interp *interp);
......@@ -82,7 +81,6 @@ struct target_type mips_m4k_target =
.add_watchpoint = mips_m4k_add_watchpoint,
.remove_watchpoint = mips_m4k_remove_watchpoint,
.register_commands = mips_m4k_register_commands,
.target_create = mips_m4k_target_create,
.init_target = mips_m4k_init_target,
.examine = mips_m4k_examine,
......@@ -902,14 +900,6 @@ int mips_m4k_write_memory(struct target *target, uint32_t address, uint32_t size
return mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
}
int mips_m4k_register_commands(struct command_context *cmd_ctx)
{
int retval;
retval = mips32_register_commands(cmd_ctx);
return retval;
}
int mips_m4k_init_target(struct command_context *cmd_ctx, struct target *target)
{
mips32_build_reg_cache(target);
......
......@@ -4353,9 +4353,14 @@ static int target_create(Jim_GetOptInfo *goi)
if (!target->variant)
target->variant = strdup("");
cp = Jim_GetString(new_cmd, NULL);
target->cmd_name = strdup(cp);
/* create the target specific commands */
if (target->type->register_commands) {
(*(target->type->register_commands))(cmd_ctx);
if (target->type->commands) {
e = register_commands(cmd_ctx, NULL, target->type->commands);
if (ERROR_OK != e)
LOG_ERROR("unable to register '%s' commands", cp);
}
if (target->type->target_create) {
(*(target->type->target_create))(target, goi->interp);
......@@ -4371,9 +4376,6 @@ static int target_create(Jim_GetOptInfo *goi)
*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 */
......
......@@ -148,7 +148,7 @@ struct target_type
*/
int (*run_algorithm)(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_param, uint32_t entry_point, uint32_t exit_point, int timeout_ms, void *arch_info);
int (*register_commands)(struct command_context *cmd_ctx);
const struct command_registration *commands;
/* called when target is created */
int (*target_create)(struct target *target, Jim_Interp *interp);
......
......@@ -3652,6 +3652,9 @@ static const struct command_registration xscale_any_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
static const struct command_registration xscale_command_handlers[] = {
{
.chain = arm_command_handlers,
},
{
.name = "xscale",
.mode = COMMAND_ANY,
......@@ -3661,14 +3664,6 @@ static const struct command_registration xscale_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
static int xscale_register_commands(struct command_context *cmd_ctx)
{
armv4_5_register_commands(cmd_ctx);
return ERROR_OK;
}
struct target_type xscale_target =
{
.name = "xscale",
......@@ -3702,7 +3697,7 @@ struct target_type xscale_target =
.add_watchpoint = xscale_add_watchpoint,
.remove_watchpoint = xscale_remove_watchpoint,
.register_commands = xscale_register_commands,
.commands = xscale_command_handlers,
.target_create = xscale_target_create,
.init_target = xscale_init_target,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment