From dd063d99147ff08ad817fc3fbd306425b6933d8d Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Mon, 23 Nov 2009 07:43:06 -0800 Subject: [PATCH] etm: use register_commands() --- src/target/etm.c | 126 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 89 insertions(+), 37 deletions(-) diff --git a/src/target/etm.c b/src/target/etm.c index 6df354a5d..0f7b41ec0 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -221,8 +221,6 @@ static int etm_register_user_commands(struct command_context *cmd_ctx); static int etm_set_reg_w_exec(struct reg *reg, uint8_t *buf); static int etm_write_reg(struct reg *reg, uint32_t value); -static struct command *etm_cmd; - static const struct reg_arch_type etm_scan6_type = { .get = etm_get_reg, .set = etm_set_reg_w_exec, @@ -2095,45 +2093,99 @@ COMMAND_HANDLER(handle_etm_analyze_command) return retval; } +static const struct command_registration etm_config_command_handlers[] = { + { + .name = "config", + .handler = &handle_etm_config_command, + .mode = COMMAND_CONFIG, + .usage = " " + " ", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration etm_command_handlers[] = { + { + .name = "etm", + .mode = COMMAND_ANY, + .help = "Emebdded Trace Macrocell command group", + .chain = etm_config_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + int etm_register_commands(struct command_context *cmd_ctx) { - etm_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "etm", NULL, COMMAND_ANY, "Embedded Trace Macrocell"); - - COMMAND_REGISTER(cmd_ctx, etm_cmd, "config", handle_etm_config_command, - COMMAND_CONFIG, "etm config "); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, etm_command_handlers); } +static const struct command_registration etm_exec_command_handlers[] = { + { + .name = "tracemode", handle_etm_tracemode_command, + .mode = COMMAND_EXEC, + .help = "configure/display trace mode", + .usage = " " + " ", + }, + { + .name = "info", + .handler = &handle_etm_info_command, + .mode = COMMAND_EXEC, + .help = "display info about the current target's ETM", + }, + { + .name = "trigger_percent", + .handler = &handle_etm_trigger_percent_command, + .mode = COMMAND_EXEC, + .help = "amount () of trace buffer " + "to be filled after the trigger occured", + }, + { + .name = "status", + .handler = &handle_etm_status_command, + .mode = COMMAND_EXEC, + .help = "display current target's ETM status", + }, + { + .name = "start", + .handler = &handle_etm_start_command, + .mode = COMMAND_EXEC, + .help = "start ETM trace collection", + }, + { + .name = "stop", + .handler = &handle_etm_stop_command, + .mode = COMMAND_EXEC, + .help = "stop ETM trace collection", + }, + { + .name = "analyze", + .handler = &handle_etm_analyze_command, + .mode = COMMAND_EXEC, + .help = "anaylze collected ETM trace", + }, + { + .name = "image", + .handler = &handle_etm_image_command, + .mode = COMMAND_EXEC, + .help = "load image from [base address]", + }, + { + .name = "dump", + .handler = &handle_etm_dump_command, + .mode = COMMAND_EXEC, + .help = "dump captured trace data ", + }, + { + .name = "load", + .handler = &handle_etm_load_command, + .mode = COMMAND_EXEC, + .help = "load trace data for analysis ", + }, + COMMAND_REGISTRATION_DONE +}; + static int etm_register_user_commands(struct command_context *cmd_ctx) { - COMMAND_REGISTER(cmd_ctx, etm_cmd, "tracemode", handle_etm_tracemode_command, - COMMAND_EXEC, "configure/display trace mode: " - " " - " "); - - COMMAND_REGISTER(cmd_ctx, etm_cmd, "info", handle_etm_info_command, - COMMAND_EXEC, "display info about the current target's ETM"); - - COMMAND_REGISTER(cmd_ctx, etm_cmd, "trigger_percent", handle_etm_trigger_percent_command, - COMMAND_EXEC, "amount () of trace buffer to be filled after the trigger occured"); - COMMAND_REGISTER(cmd_ctx, etm_cmd, "status", handle_etm_status_command, - COMMAND_EXEC, "display current target's ETM status"); - COMMAND_REGISTER(cmd_ctx, etm_cmd, "start", handle_etm_start_command, - COMMAND_EXEC, "start ETM trace collection"); - COMMAND_REGISTER(cmd_ctx, etm_cmd, "stop", handle_etm_stop_command, - COMMAND_EXEC, "stop ETM trace collection"); - - COMMAND_REGISTER(cmd_ctx, etm_cmd, "analyze", handle_etm_analyze_command, - COMMAND_EXEC, "anaylze collected ETM trace"); - - COMMAND_REGISTER(cmd_ctx, etm_cmd, "image", handle_etm_image_command, - COMMAND_EXEC, "load image from [base address]"); - - COMMAND_REGISTER(cmd_ctx, etm_cmd, "dump", handle_etm_dump_command, - COMMAND_EXEC, "dump captured trace data "); - COMMAND_REGISTER(cmd_ctx, etm_cmd, "load", handle_etm_load_command, - COMMAND_EXEC, "load trace data for analysis "); - - return ERROR_OK; + struct command *etm_cmd = command_find_in_context(cmd_ctx, "etm"); + return register_commands(cmd_ctx, etm_cmd, etm_exec_command_handlers); }