From: Zach W. <zw...@us...> - 2009-11-25 19:57:58
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via f74e2e033a2ad082e5bef67d0ddedd1db3f58300 (commit) via 66ee303456910f684244a20a0ac2e958d40b78cb (commit) via 144e3678bd2d518388b6c2d7f3d2a912a9ac2abd (commit) via 8a41656391bd8eb6854c8573920d1155d815966b (commit) via 5f6962b34f623e7daf0dfb1f6249620431b5ab79 (commit) via 4e67912fb01a0ab60c246c12c7ce50e361dd3e20 (commit) via c3800b5e674be3a9e1c7976925f9cfc52cba3ad5 (commit) via a17caa387c0fb08ee2604e066b436d90d9cf0a2f (commit) via dd063d99147ff08ad817fc3fbd306425b6933d8d (commit) via 8161fd3163142f828a0bd79e0b5ad339dc4aec6b (commit) via 97fbd793b3a4edec490b2b034f7b6fe5261ca03e (commit) via 28300bbf6ff726fe1ab807fa9796241bb3348cfd (commit) via df95fe25a4f01db9e131272ee72ebbf328ede428 (commit) via d79176e1bc4699a52663b87dc52f02fb7afa3d54 (commit) via 84c03168a54549e2a102ceb25219ac8a2281d954 (commit) via d1eca9a74c7c57ba6a3210c51b2a10cc5adb22e1 (commit) via 69908ddbd04fc9382d02819e296bb4384ef78810 (commit) via 11061486b5e18b43cca6a94bdd9e998d5dde44c4 (commit) via 509fe82b07df4a7e6217bfde37374e90262aa2de (commit) via e232dea176cc8c831e77a10903120ff057337f6c (commit) via e905fe6e756453daf27cd064285aa9cddf31b1ef (commit) via b40f265f9cb9e6be4c979e7f4e10072822dcb5c7 (commit) from 90d09e35e4be6f0b35899238b253154249f85cb6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f74e2e033a2ad082e5bef67d0ddedd1db3f58300 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 08:24:02 2009 -0800 remove register_commands from etm_capture_driver Converts callback to an array of command_registration records. Moves oocd_trace driver definition to end of file to eliminate useless forward declaration. diff --git a/src/target/etb.c b/src/target/etb.c index 63dee18..bc0e1bf 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -421,11 +421,6 @@ static const struct command_registration etb_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int etb_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, etb_command_handlers); -} - static int etb_init(struct etm_context *etm_ctx) { struct etb *etb = etm_ctx->capture_driver_priv; @@ -696,7 +691,7 @@ static int etb_stop_capture(struct etm_context *etm_ctx) struct etm_capture_driver etb_capture_driver = { .name = "etb", - .register_commands = etb_register_commands, + .commands = etb_command_handlers, .init = etb_init, .status = etb_status, .start_capture = etb_start_capture, diff --git a/src/target/etm.c b/src/target/etm.c index 2465d5c..4e7f917 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1471,8 +1471,9 @@ COMMAND_HANDLER(handle_etm_config_command) { if (strcmp(CMD_ARGV[4], etm_capture_drivers[i]->name) == 0) { - int retval; - if ((retval = etm_capture_drivers[i]->register_commands(CMD_CTX)) != ERROR_OK) + int retval = register_commands(CMD_CTX, NULL, + etm_capture_drivers[i]->commands); + if (ERROR_OK != retval) { free(etm_ctx); return retval; diff --git a/src/target/etm.h b/src/target/etm.h index 05e5495..c8da794 100644 --- a/src/target/etm.h +++ b/src/target/etm.h @@ -126,7 +126,7 @@ struct etm_context; struct etm_capture_driver { char *name; - int (*register_commands)(struct command_context *cmd_ctx); + const struct command_registration *commands; int (*init)(struct etm_context *etm_ctx); trace_status_t (*status)(struct etm_context *etm_ctx); int (*read_trace)(struct etm_context *etm_ctx); diff --git a/src/target/etm_dummy.c b/src/target/etm_dummy.c index 27a8eec..647774f 100644 --- a/src/target/etm_dummy.c +++ b/src/target/etm_dummy.c @@ -77,11 +77,6 @@ static const struct command_registration etm_dummy_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int etm_dummy_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, etm_dummy_command_handlers); -} - static int etm_dummy_init(struct etm_context *etm_ctx) { return ERROR_OK; @@ -110,7 +105,7 @@ static int etm_dummy_stop_capture(struct etm_context *etm_ctx) struct etm_capture_driver etm_dummy_capture_driver = { .name = "dummy", - .register_commands = etm_dummy_register_commands, + .commands = etm_dummy_command_handlers, .init = etm_dummy_init, .status = etm_dummy_status, .start_capture = etm_dummy_start_capture, diff --git a/src/target/oocd_trace.c b/src/target/oocd_trace.c index a34c63c..ac79f18 100644 --- a/src/target/oocd_trace.c +++ b/src/target/oocd_trace.c @@ -30,8 +30,6 @@ */ -static int oocd_trace_register_commands(struct command_context *cmd_ctx); - static int oocd_trace_read_reg(struct oocd_trace *oocd_trace, int reg, uint32_t *value) { size_t bytes_written, bytes_read, bytes_to_read; @@ -278,17 +276,6 @@ static int oocd_trace_stop_capture(struct etm_context *etm_ctx) return ERROR_OK; } -struct etm_capture_driver oocd_trace_capture_driver = -{ - .name = "oocd_trace", - .register_commands = oocd_trace_register_commands, - .init = oocd_trace_init, - .status = oocd_trace_status, - .start_capture = oocd_trace_start_capture, - .stop_capture = oocd_trace_stop_capture, - .read_trace = oocd_trace_read_trace, -}; - COMMAND_HANDLER(handle_oocd_trace_config_command) { struct target *target; @@ -438,7 +425,15 @@ static const struct command_registration oocd_trace_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -int oocd_trace_register_commands(struct command_context *cmd_ctx) +struct etm_capture_driver oocd_trace_capture_driver = { - return register_commands(cmd_ctx, NULL, oocd_trace_command_handlers); -} + .name = "oocd_trace", + .commands = oocd_trace_command_handlers, + .init = oocd_trace_init, + .status = oocd_trace_status, + .start_capture = oocd_trace_start_capture, + .stop_capture = oocd_trace_stop_capture, + .read_trace = oocd_trace_read_trace, +}; + + commit 66ee303456910f684244a20a0ac2e958d40b78cb Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 08:17:01 2009 -0800 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. diff --git a/src/target/arm11.c b/src/target/arm11.c index 835234c..7c6d39c 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -1617,6 +1617,12 @@ static const struct command_registration arm11_any_command_handlers[] = { }; static const struct command_registration arm11_command_handlers[] = { { + .chain = arm_command_handlers, + }, + { + .chain = etm_command_handlers, + }, + { .name = "arm11", .mode = COMMAND_ANY, .help = "ARM11 command group", @@ -1625,13 +1631,6 @@ static const struct command_registration arm11_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int arm11_register_commands(struct command_context *cmd_ctx) -{ - armv4_5_register_commands(cmd_ctx); - etm_register_commands(cmd_ctx); - return register_commands(cmd_ctx, NULL, arm11_command_handlers); -} - /** Holds methods for ARM11xx targets. */ struct target_type arm11_target = { .name = "arm11", @@ -1666,7 +1665,7 @@ struct target_type arm11_target = { .run_algorithm = armv4_5_run_algorithm, - .register_commands = arm11_register_commands, + .commands = arm11_command_handlers, .target_create = arm11_target_create, .init_target = arm11_init_target, .examine = arm11_examine, diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 52a311c..bae2561 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -504,6 +504,9 @@ static const struct command_registration arm720t_exec_command_handlers[] = { static const struct command_registration arm720t_command_handlers[] = { { + .chain = arm7_9_command_handlers, + }, + { .name = "arm720t", .mode = COMMAND_ANY, .help = "arm720t command group", @@ -512,12 +515,6 @@ static const struct command_registration arm720t_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int arm720t_register_commands(struct command_context *cmd_ctx) -{ - arm7_9_register_commands(cmd_ctx); - return register_commands(cmd_ctx, NULL, arm720t_command_handlers); -} - /** Holds methods for ARM720 targets. */ struct target_type arm720t_target = { @@ -555,7 +552,7 @@ struct target_type arm720t_target = .add_watchpoint = arm7_9_add_watchpoint, .remove_watchpoint = arm7_9_remove_watchpoint, - .register_commands = arm720t_register_commands, + .commands = arm720t_command_handlers, .target_create = arm720t_target_create, .init_target = arm720t_init_target, .examine = arm7_9_examine, diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index b40be8d..c4775e8 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -2873,7 +2873,13 @@ static const struct command_registration arm7_9_any_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; -static const struct command_registration arm7_9_command_handlers[] = { +const struct command_registration arm7_9_command_handlers[] = { + { + .chain = arm_command_handlers, + }, + { + .chain = etm_command_handlers, + }, { .name = "arm7_9", .mode = COMMAND_ANY, @@ -2882,10 +2888,3 @@ static const struct command_registration arm7_9_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; - -int arm7_9_register_commands(struct command_context *cmd_ctx) -{ - armv4_5_register_commands(cmd_ctx); - etm_register_commands(cmd_ctx); - return register_commands(cmd_ctx, NULL, arm7_9_command_handlers); -} diff --git a/src/target/arm7_9_common.h b/src/target/arm7_9_common.h index 2f7132a..d43eaa6 100644 --- a/src/target/arm7_9_common.h +++ b/src/target/arm7_9_common.h @@ -120,7 +120,7 @@ static inline bool is_arm7_9(struct arm7_9_common *arm7_9) return arm7_9->common_magic == ARM7_9_COMMON_MAGIC; } -int arm7_9_register_commands(struct command_context *cmd_ctx); +extern const struct command_registration arm7_9_command_handlers[]; int arm7_9_poll(struct target *target); diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c index 742eace..7d14ed6 100644 --- a/src/target/arm7tdmi.c +++ b/src/target/arm7tdmi.c @@ -747,7 +747,7 @@ struct target_type arm7tdmi_target = .add_watchpoint = arm7_9_add_watchpoint, .remove_watchpoint = arm7_9_remove_watchpoint, - .register_commands = arm7_9_register_commands, + .commands = arm7_9_command_handlers, .target_create = arm7tdmi_target_create, .init_target = arm7tdmi_init_target, .examine = arm7_9_examine, diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 1e6019c..e6c2eed 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -1396,7 +1396,10 @@ static const struct command_registration arm920t_exec_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; -static const struct command_registration arm920t_command_handlers[] = { +const struct command_registration arm920t_command_handlers[] = { + { + .chain = arm9tdmi_command_handlers, + }, { .name = "arm920t", .mode = COMMAND_ANY, @@ -1406,13 +1409,6 @@ static const struct command_registration arm920t_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -/** Registers commands to access coprocessor, cache, and MMU resources. */ -int arm920t_register_commands(struct command_context *cmd_ctx) -{ - arm9tdmi_register_commands(cmd_ctx); - return register_commands(cmd_ctx, NULL, arm920t_command_handlers); -} - /** Holds methods for ARM920 targets. */ struct target_type arm920t_target = { @@ -1452,7 +1448,7 @@ struct target_type arm920t_target = .add_watchpoint = arm7_9_add_watchpoint, .remove_watchpoint = arm7_9_remove_watchpoint, - .register_commands = arm920t_register_commands, + .commands = arm920t_command_handlers, .target_create = arm920t_target_create, .init_target = arm9tdmi_init_target, .examine = arm7_9_examine, diff --git a/src/target/arm920t.h b/src/target/arm920t.h index ca6be7e..a75f01a 100644 --- a/src/target/arm920t.h +++ b/src/target/arm920t.h @@ -71,6 +71,7 @@ void arm920t_disable_mmu_caches(struct target *target, int mmu, int d_u_cache, int i_cache); void arm920t_enable_mmu_caches(struct target *target, int mmu, int d_u_cache, int i_cache); -int arm920t_register_commands(struct command_context *cmd_ctx); + +extern const struct command_registration arm920t_command_handlers[]; #endif /* ARM920T_H */ diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 329aa12..408ede9 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -766,7 +766,10 @@ static const struct command_registration arm926ejs_exec_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; -static const struct command_registration arm926ejs_command_handlers[] = { +const struct command_registration arm926ejs_command_handlers[] = { + { + .chain = arm9tdmi_command_handlers, + }, { .name = "arm926ejs", .mode = COMMAND_ANY, @@ -776,13 +779,6 @@ static const struct command_registration arm926ejs_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -/** Registers commands to access coprocessor, cache, and debug resources. */ -int arm926ejs_register_commands(struct command_context *cmd_ctx) -{ - arm9tdmi_register_commands(cmd_ctx); - return register_commands(cmd_ctx, NULL, arm926ejs_command_handlers); -} - /** Holds methods for ARM926 targets. */ struct target_type arm926ejs_target = { @@ -817,7 +813,7 @@ struct target_type arm926ejs_target = .add_watchpoint = arm7_9_add_watchpoint, .remove_watchpoint = arm7_9_remove_watchpoint, - .register_commands = arm926ejs_register_commands, + .commands = arm926ejs_command_handlers, .target_create = arm926ejs_target_create, .init_target = arm9tdmi_init_target, .examine = arm7_9_examine, diff --git a/src/target/arm926ejs.h b/src/target/arm926ejs.h index 514f054..274733b 100644 --- a/src/target/arm926ejs.h +++ b/src/target/arm926ejs.h @@ -48,10 +48,11 @@ target_to_arm926(struct target *target) int arm926ejs_init_arch_info(struct target *target, struct arm926ejs_common *arm926ejs, struct jtag_tap *tap); -int arm926ejs_register_commands(struct command_context *cmd_ctx); int arm926ejs_arch_state(struct target *target); int arm926ejs_write_memory(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); int arm926ejs_soft_reset_halt(struct target *target); +extern const struct command_registration arm926ejs_command_handlers[]; + #endif /* ARM926EJS_H */ diff --git a/src/target/arm966e.c b/src/target/arm966e.c index 70cc3c4..9fe513c 100644 --- a/src/target/arm966e.c +++ b/src/target/arm966e.c @@ -232,7 +232,10 @@ static const struct command_registration arm966e_exec_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static const struct command_registration arm966e_command_handlers[] = { +const struct command_registration arm966e_command_handlers[] = { + { + .chain = arm9tdmi_command_handlers, + }, { .name = "arm966e", .mode = COMMAND_ANY, @@ -242,13 +245,6 @@ static const struct command_registration arm966e_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -/** Registers commands used to access coprocessor resources. */ -int arm966e_register_commands(struct command_context *cmd_ctx) -{ - arm9tdmi_register_commands(cmd_ctx); - return register_commands(cmd_ctx, NULL, arm966e_command_handlers); -} - /** Holds methods for ARM966 targets. */ struct target_type arm966e_target = { @@ -283,7 +279,7 @@ struct target_type arm966e_target = .add_watchpoint = arm7_9_add_watchpoint, .remove_watchpoint = arm7_9_remove_watchpoint, - .register_commands = arm966e_register_commands, + .commands = arm966e_command_handlers, .target_create = arm966e_target_create, .init_target = arm9tdmi_init_target, .examine = arm7_9_examine, diff --git a/src/target/arm966e.h b/src/target/arm966e.h index 45aeb4e..24dcec3 100644 --- a/src/target/arm966e.h +++ b/src/target/arm966e.h @@ -43,7 +43,8 @@ target_to_arm966(struct target *target) int arm966e_init_arch_info(struct target *target, struct arm966e_common *arm966e, struct jtag_tap *tap); -int arm966e_register_commands(struct command_context *cmd_ctx); int arm966e_write_cp15(struct target *target, int reg_addr, uint32_t value); +extern const struct command_registration arm966e_command_handlers[]; + #endif /* ARM966E_H */ diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index 87ace05..7eb5641 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -917,7 +917,10 @@ static const struct command_registration arm9tdmi_exec_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; -static const struct command_registration arm9tdmi_command_handlers[] = { +const struct command_registration arm9tdmi_command_handlers[] = { + { + .chain = arm7_9_command_handlers, + }, { .name = "arm9tdmi", .mode = COMMAND_ANY, @@ -927,12 +930,6 @@ static const struct command_registration arm9tdmi_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -int arm9tdmi_register_commands(struct command_context *cmd_ctx) -{ - arm7_9_register_commands(cmd_ctx); - return register_commands(cmd_ctx, NULL, arm9tdmi_command_handlers); -} - /** Holds methods for ARM9TDMI targets. */ struct target_type arm9tdmi_target = { @@ -967,7 +964,7 @@ struct target_type arm9tdmi_target = .add_watchpoint = arm7_9_add_watchpoint, .remove_watchpoint = arm7_9_remove_watchpoint, - .register_commands = arm9tdmi_register_commands, + .commands = arm9tdmi_command_handlers, .target_create = arm9tdmi_target_create, .init_target = arm9tdmi_init_target, .examine = arm7_9_examine, diff --git a/src/target/arm9tdmi.h b/src/target/arm9tdmi.h index 351b00a..aff9fc5 100644 --- a/src/target/arm9tdmi.h +++ b/src/target/arm9tdmi.h @@ -29,7 +29,7 @@ int arm9tdmi_init_target(struct command_context *cmd_ctx, struct target *target); int arm9tdmi_init_arch_info(struct target *target, struct arm7_9_common *arm7_9, struct jtag_tap *tap); -int arm9tdmi_register_commands(struct command_context *cmd_ctx); +extern const struct command_registration arm9tdmi_command_handlers[]; int arm9tdmi_clock_out(struct arm_jtag *jtag_info, uint32_t instr, uint32_t out, uint32_t *in, int sysspeed); diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index dfb7094..7e5bb0a 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -809,7 +809,7 @@ static const struct command_registration arm_exec_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; -static const struct command_registration arm_command_handlers[] = { +const struct command_registration arm_command_handlers[] = { { .name = "arm", .mode = COMMAND_ANY, @@ -819,11 +819,6 @@ static const struct command_registration arm_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -int armv4_5_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, arm_command_handlers); -} - int armv4_5_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size) { struct arm *armv4_5 = target_to_armv4_5(target); diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index 7a6cb61..822d143 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -27,6 +27,8 @@ #define ARMV4_5_H #include "target.h" +#include "command.h" + typedef enum armv4_5_mode { @@ -155,7 +157,8 @@ int armv4_5_arch_state(struct target *target); int armv4_5_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size); -int armv4_5_register_commands(struct command_context *cmd_ctx); +extern const struct command_registration arm_command_handlers[]; + int armv4_5_init_arch_info(struct target *target, struct arm *armv4_5); int armv4_5_run_algorithm(struct target *target, diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 7cc2273..3d94329 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -181,7 +181,7 @@ static const struct command_registration armv7a_exec_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; -static const struct command_registration armv7a_command_handlers[] = { +const struct command_registration armv7a_command_handlers[] = { { .name = "dap", .mode = COMMAND_ANY, @@ -191,7 +191,3 @@ static const struct command_registration armv7a_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -int armv7a_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, armv7a_command_handlers); -} diff --git a/src/target/armv7a.h b/src/target/armv7a.h index 942bf8b..f843f03 100644 --- a/src/target/armv7a.h +++ b/src/target/armv7a.h @@ -103,7 +103,8 @@ struct armv7a_core_reg int armv7a_arch_state(struct target *target); struct reg_cache *armv7a_build_reg_cache(struct target *target, struct armv7a_common *armv7a_common); -int armv7a_register_commands(struct command_context *cmd_ctx); int armv7a_init_arch_info(struct target *target, struct armv7a_common *armv7a); +extern const struct command_registration armv7a_command_handlers[]; + #endif /* ARMV4_5_H */ diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 6d8ad5f..9d89086 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -832,7 +832,7 @@ static const struct command_registration armv7m_exec_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; -static const struct command_registration armv7m_command_handlers[] = { +const struct command_registration armv7m_command_handlers[] = { { .name = "dap", .mode = COMMAND_ANY, @@ -841,8 +841,3 @@ static const struct command_registration armv7m_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; - -int armv7m_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, armv7m_command_handlers); -} diff --git a/src/target/armv7m.h b/src/target/armv7m.h index 9dd4ddb..7299bdf 100644 --- a/src/target/armv7m.h +++ b/src/target/armv7m.h @@ -143,7 +143,6 @@ int armv7m_arch_state(struct target *target); int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size); -int armv7m_register_commands(struct command_context *cmd_ctx); int armv7m_init_arch_info(struct target *target, struct armv7m_common *armv7m); int armv7m_run_algorithm(struct target *target, @@ -161,6 +160,8 @@ int armv7m_checksum_memory(struct target *target, int armv7m_blank_check_memory(struct target *target, uint32_t address, uint32_t count, uint32_t* blank); +extern const struct command_registration armv7m_command_handlers[]; + /* Thumb mode instructions */ diff --git a/src/target/avrt.c b/src/target/avrt.c index cabb272..dc527f5 100644 --- a/src/target/avrt.c +++ b/src/target/avrt.c @@ -28,9 +28,6 @@ #define AVR_JTAG_INS_LEN 4 -/* cli handling */ -int avr_register_commands(struct command_context *cmd_ctx); - /* forward declarations */ int avr_target_create(struct target *target, Jim_Interp *interp); int avr_init_target(struct command_context *cmd_ctx, struct target *target); @@ -91,17 +88,10 @@ struct target_type avr_target = .add_watchpoint = avr_add_watchpoint, .remove_watchpoint = avr_remove_watchpoint, */ - .register_commands = avr_register_commands, .target_create = avr_target_create, .init_target = avr_init_target, }; -int avr_register_commands(struct command_context *cmd_ctx) -{ - LOG_DEBUG("%s", __FUNCTION__); - return ERROR_OK; -} - int avr_target_create(struct target *target, Jim_Interp *interp) { struct avr_common *avr = calloc(1, sizeof(struct avr_common)); diff --git a/src/target/cortex_a8.c b/src/target/cortex_a8.c index 325a54b..b85481a 100644 --- a/src/target/cortex_a8.c +++ b/src/target/cortex_a8.c @@ -1642,6 +1642,12 @@ static const struct command_registration cortex_a8_exec_command_handlers[] = { }; static const struct command_registration cortex_a8_command_handlers[] = { { + .chain = arm_command_handlers, + }, + { + .chain = armv7a_command_handlers, + }, + { .name = "cortex_a8", .mode = COMMAND_ANY, .help = "Cortex-A8 command group", @@ -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, diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index be81af9..7cfe540 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -1938,6 +1938,12 @@ static const struct command_registration cortex_m3_exec_command_handlers[] = { }; static const struct command_registration cortex_m3_command_handlers[] = { { + .chain = arm_command_handlers, + }, + { + .chain = armv7m_command_handlers, + }, + { .name = "cortex_m3", .mode = COMMAND_ANY, .help = "Cortex-M3 command group", @@ -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, diff --git a/src/target/etm.c b/src/target/etm.c index 0f7b41e..2465d5c 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -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, diff --git a/src/target/etm.h b/src/target/etm.h index b74c6d9..05e5495 100644 --- a/src/target/etm.h +++ b/src/target/etm.h @@ -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) diff --git a/src/target/fa526.c b/src/target/fa526.c index 9c22a75..32469d0 100644 --- a/src/target/fa526.c +++ b/src/target/fa526.c @@ -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, diff --git a/src/target/feroceon.c b/src/target/feroceon.c index 8c05276..432d49d 100644 --- a/src/target/feroceon.c +++ b/src/target/feroceon.c @@ -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, diff --git a/src/target/mips32.c b/src/target/mips32.c index 0b8ebb4..48d0720 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -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*/ diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c index 0a566c3..a83217f 100644 --- a/src/target/mips_m4k.c +++ b/src/target/mips_m4k.c @@ -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); diff --git a/src/target/target.c b/src/target/target.c index 6f48808..e999e68 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -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 */ diff --git a/src/target/target_type.h b/src/target/target_type.h index aa87a74..9a0709d 100644 --- a/src/target/target_type.h +++ b/src/target/target_type.h @@ -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); diff --git a/src/target/xscale.c b/src/target/xscale.c index 965ac52..e402a11 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -3653,6 +3653,9 @@ static const struct command_registration xscale_any_command_handlers[] = { }; static const struct command_registration xscale_command_handlers[] = { { + .chain = arm_command_handlers, + }, + { .name = "xscale", .mode = COMMAND_ANY, .help = "xscale command group", @@ -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, commit 144e3678bd2d518388b6c2d7f3d2a912a9ac2abd Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 07:43:06 2009 -0800 xscale: use register_commands() diff --git a/src/target/xscale.c b/src/target/xscale.c index c2b3493..965ac52 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -3554,31 +3554,115 @@ COMMAND_HANDLER(xscale_handle_cp15) return ERROR_OK; } +static const struct command_registration xscale_exec_command_handlers[] = { + { + .name = "cache_info", + .handler = &xscale_handle_cache_info_command, + .mode = COMMAND_EXEC, NULL, + }, + + { + .name = "mmu", + .handler = &xscale_handle_mmu_command, + .mode = COMMAND_EXEC, + .usage = "[enable|disable]", + .help = "enable or disable the MMU", + }, + { + .name = "icache", + .handler = &xscale_handle_idcache_command, + .mode = COMMAND_EXEC, + .usage = "[enable|disable]", + .help = "enable or disable the ICache", + }, + { + .name = "dcache", + .handler = &xscale_handle_idcache_command, + .mode = COMMAND_EXEC, + .usage = "[enable|disable]", + .help = "enable or disable the DCache", + }, + + { + .name = "vector_catch", + .handler = &xscale_handle_vector_catch_command, + .mode = COMMAND_EXEC, + .help = "mask of vectors that should be caught", + .usage = "[<mask>]", + }, + { + .name = "vector_table", + .handler = &xscale_handle_vector_table_command, + .mode = COMMAND_EXEC, + .usage = "<high|low> <index> <code>", + .help = "set static code for exception handler entry", + }, + + { + .name = "trace_buffer", + .handler = &xscale_handle_trace_buffer_command, + .mode = COMMAND_EXEC, + .usage = "<enable | disable> [fill [n]|wrap]", + }, + { + .name = "dump_trace", + .handler = &xscale_handle_dump_trace_command, + .mode = COMMAND_EXEC, + .help = "dump content of trace buffer to <file>", + .usage = "<file>", + }, + { + .name = "analyze_trace", + .handler = &xscale_handle_analyze_trace_buffer_command, + .mode = COMMAND_EXEC, + .help = "analyze content of trace buffer", + }, + { + .name = "trace_image", + .handler = &xscale_handle_trace_image_command, + COMMAND_EXEC, + .help = "load image from <file> [base address]", + .usage = "<file> [address] [type]", + }, + + { + .name = "cp15", + .handler = &xscale_handle_cp15, + .mode = COMMAND_EXEC, + .help = "access coproc 15", + .usage = "<register> [value]", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration xscale_any_command_handlers[] = { + { + .name = "debug_handler", + .handler = &xscale_handle_debug_handler_command, + .mode = COMMAND_ANY, + .usage = "<target#> <address>", + }, + { + .name = "cache_clean_address", + .handler = &xscale_handle_cache_clean_address_command, + .mode = COMMAND_ANY, + }, + { + .chain = xscale_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration xscale_command_handlers[] = { + { + .name = "xscale", + .mode = COMMAND_ANY, + .help = "xscale command group", + .chain = xscale_any_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int xscale_register_commands(struct command_context *cmd_ctx) { - struct command *xscale_cmd; - - xscale_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "xscale", NULL, COMMAND_ANY, "xscale specific commands"); - - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "debug_handler", xscale_handle_debug_handler_command, COMMAND_ANY, "'xscale debug_handler <target#> <address>' command takes two required operands"); - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "cache_clean_address", xscale_handle_cache_clean_address_command, COMMAND_ANY, NULL); - - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "cache_info", xscale_handle_cache_info_command, COMMAND_EXEC, NULL); - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "mmu", xscale_handle_mmu_command, COMMAND_EXEC, "['enable'|'disable'] the MMU"); - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "icache", xscale_handle_idcache_command, COMMAND_EXEC, "['enable'|'disable'] the ICache"); - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "dcache", xscale_handle_idcache_command, COMMAND_EXEC, "['enable'|'disable'] the DCache"); - - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "vector_catch", xscale_handle_vector_catch_command, COMMAND_EXEC, "<mask> of vectors that should be catched"); - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "vector_table", xscale_handle_vector_table_command, COMMAND_EXEC, "<high|low> <index> <code> set static code for exception handler entry"); - - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "trace_buffer", xscale_handle_trace_buffer_command, COMMAND_EXEC, "<enable | disable> ['fill' [n]|'wrap']"); - - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "dump_trace", xscale_handle_dump_trace_command, COMMAND_EXEC, "dump content of trace buffer to <file>"); - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "analyze_trace", xscale_handle_analyze_trace_buffer_command, COMMAND_EXEC, "analyze content of trace buffer"); - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "trace_image", xscale_handle_trace_image_command, - COMMAND_EXEC, "load image from <file> [base address]"); - - COMMAND_REGISTER(cmd_ctx, xscale_cmd, "cp15", xscale_handle_cp15, COMMAND_EXEC, "access coproc 15 <register> [value]"); armv4_5_register_commands(cmd_ctx); commit 8a41656391bd8eb6854c8573920d1155d815966b Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 07:43:06 2009 -0800 trace: use register_commands() diff --git a/src/target/trace.c b/src/target/trace.c index c3897a0..f257592 100644 --- a/src/target/trace.c +++ b/src/target/trace.c @@ -156,16 +156,35 @@ COMMAND_HANDLER(handle_trace_history_command) return ERROR_OK; } +static const struct command_registration trace_exec_command_handlers[] = { + { + .name = "history", + .handler = &handle_trace_history_command, + .mode = COMMAND_EXEC, + .help = "display trace history, clear history or set [size]", + .usage = "[clear|<size>]", + }, + { + .name = "point", + .handler = &handle_trace_point_command, + .mode = COMMAND_EXEC, + .help = "display trace points, clear list of trace points, " + "or add new tracepoint at [address]", + .usage = "[clear|<address>]", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration trace_command_handlers[] = { + { + .name = "trace", + .mode = COMMAND_ANY, + .help = "trace command group", + .chain = trace_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + int trace_register_commands(struct command_context *cmd_ctx) { - struct command *trace_cmd = - COMMAND_REGISTER(cmd_ctx, NULL, "trace", NULL, COMMAND_ANY, "trace commands"); - - COMMAND_REGISTER(cmd_ctx, trace_cmd, "history", handle_trace_history_command, - COMMAND_EXEC, "display trace history, ['clear'] history or set [size]"); - - COMMAND_REGISTER(cmd_ctx, trace_cmd, "point", handle_trace_point_command, - COMMAND_EXEC, "display trace points, ['clear'] list of trace points, or add new tracepoint at [address]"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, trace_command_handlers); } commit 5f6962b34f623e7daf0dfb1f6249620431b5ab79 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 07:43:06 2009 -0800 target_request: use register_commands() diff --git a/src/target/target_request.c b/src/target/target_request.c index a02e2c1..9e78178 100644 --- a/src/target/target_request.c +++ b/src/target/target_request.c @@ -35,7 +35,6 @@ #include "log.h" -static struct command *target_request_cmd = NULL; static int charmsg_mode = 0; static int target_asciimsg(struct target *target, uint32_t length) @@ -300,13 +299,27 @@ COMMAND_HANDLER(handle_target_request_debugmsgs_command) return ERROR_OK; } +static const struct command_registration target_req_exec_command_handlers[] = { + { + .name = "debugmsgs", + .handler = &handle_target_request_debugmsgs_command, + .mode = COMMAND_EXEC, + .help = "set reception of debug messages from target", + .usage = "(enable|disable)", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration target_req_command_handlers[] = { + { + .name = "target_request", + .mode = COMMAND_ANY, + .help = "target request command group", + .chain = target_req_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + int target_request_register_commands(struct command_context *cmd_ctx) { - target_request_cmd = - COMMAND_REGISTER(cmd_ctx, NULL, "target_request", NULL, COMMAND_ANY, "target_request commands"); - - COMMAND_REGISTER(cmd_ctx, target_request_cmd, "debugmsgs", handle_target_request_debugmsgs_command, - COMMAND_EXEC, "enable/disable reception of debug messages from target"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, target_req_command_handlers); } commit 4e67912fb01a0ab60c246c12c7ce50e361dd3e20 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 07:43:06 2009 -0800 target: use register_commands() diff --git a/src/target/target.c b/src/target/target.c index 2e93382..6f48808 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4762,19 +4762,211 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } +static const struct command_registration target_command_handlers[] = { + { + .name = "targets", + .handler = &handle_targets_command, + .mode = COMMAND_ANY, + .help = "change current command line target (one parameter) " + "or list targets (no parameters)", + .usage = "[<new_current_target>]", + }, + COMMAND_REGISTRATION_DONE +}; + int target_register_commands(struct command_context *cmd_ctx) { - - COMMAND_REGISTER(cmd_ctx, NULL, "targets", - handle_targets_command, COMMAND_EXEC, - "change current command line target (one parameter) " - "or list targets (no parameters)"); - register_jim(cmd_ctx, "target", jim_target, "configure target"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, target_command_handlers); } +static const struct command_registration target_exec_command_handlers[] = { + { + .name = "fast_load_image", + .handler = &handle_fast_load_image_command, + .mode = COMMAND_ANY, + .help = "Load image into memory, mainly for profiling purposes", + .usage = "<file> <address> ['bin'|'ihex'|'elf'|'s19'] " + "[min_address] [max_length]", + }, + { + .name = "fast_load", + .handler = &handle_fast_load_command, + .mode = COMMAND_ANY, + .help = "loads active fast load image to current target " + "- mainly for profiling purposes", + }, + { + .name = "profile", + .handler = &handle_profile_command, + .mode = COMMAND_EXEC, + .help = "profiling samples the CPU PC", + }, + /** @todo don't register virt2phys() unless target supports it */ + { + .name = "virt2phys", + .handler = &handle_virt2phys_command, + .mode = COMMAND_ANY, + .help = "translate a virtual address into a physical address", + }, + + { + .name = "reg", + .handler = &handle_reg_command, + .mode = COMMAND_EXEC, + .help = "display or set a register", + }, + + { + .name = "poll", + .handler = &handle_poll_command, + .mode = COMMAND_EXEC, + .help = "poll target state", + }, + { + .name = "wait_halt", + .handler = &handle_wait_halt_command, + .mode = COMMAND_EXEC, + .help = "wait for target halt", + .usage = "[time (s)]", + }, + { + .name = "halt", + .handler = &handle_halt_command, + .mode = COMMAND_EXEC, + .help = "halt target", + }, + { + .name = "resume", + .handler = &handle_resume_command, + .mode = COMMAND_EXEC, + .help = "resume target", + .usage = "[<address>]", + }, + { + .name = "reset", + .handler = &handle_reset_command, + .mode = COMMAND_EXEC, + .usage = "[run|halt|init]", + .help = "Reset all targets into the specified mode." + "Default reset mode is run, if not given.", + }, + { + .name = "soft_reset_halt", + .handler = &handle_soft_reset_halt_command, + .mode = COMMAND_EXEC, + .help = "halt the target and do a soft reset", + }, + { + + .name = "step", + .handler = &handle_step_command, + .mode = COMMAND_EXEC, + .help = "step one instruction from current PC or [addr]", + .usage = "[<address>]", + }, + { + + .name = "mdw", + .handler = &handle_md_command, + .mode = COMMAND_EXEC, + .help = "display memory words", + .usage = "[phys] <addr> [count]", + }, + { + .name = "mdh", + .handler = &handle_md_command, + .mode = COMMAND_EXEC, + .help = "display memory half-words", + .usage = "[phys] <addr> [count]", + }, + { + .name = "mdb", + .handler = &handle_md_command, + .mode = COMMAND_EXEC, + .help = "display memory bytes", + .usage = "[phys] <addr> [count]", + }, + { + + .name = "mww", + .handler = &handle_mw_command, + .mode = COMMAND_EXEC, + .help = "write memory word", + .usage = "[phys] <addr> <value> [count]", + }, + { + .name = "mwh", + .handler = &handle_mw_command, + .mode = COMMAND_EXEC, + .help = "write memory half-word", + .usage = "[phys] <addr> <value> [count]", + }, + { + .name = "mwb", + .handler = &handle_mw_command, + .mode = COMMAND_EXEC, + .help = "write memory byte", + .usage = "[phys] <addr> <value> [count]", + }, + { + + .name = "bp", + .handler = &handle_bp_command, + .mode = COMMAND_EXEC, + .help = "list or set breakpoint", + .usage = "[<address> <length> [hw]]", + }, + { + .name = "rbp", + .handler = &handle_rbp_command, + .mode = COMMAND_EXEC, + .help = "remove breakpoint", + .usage = "<address>", + }, + { + + .name = "wp", + .handler = &handle_wp_command, + .mode = COMMAND_EXEC, + .help = "list or set watchpoint", + .usage = "[<address> <length> <r/w/a> [value] [mask]]", + }, + { + .name = "rwp", + .handler = &handle_rwp_command, + .mode = COMMAND_EXEC, + .help = "remove watchpoint", + .usage = "<address>", + + }, + { + .name = "load_image", + .handler = &handle_load_image_command, + .mode = COMMAND_EXEC, + .usage = "<file> <address> ['bin'|'ihex'|'elf'|'s19'] " + "[min_address] [max_length]", + }, + { + .name = "dump_image", + .handler = &handle_dump_image_command, + .mode = COMMAND_EXEC, + .usage = "<file> <address> <size>", + }, + { + .name = "verify_image", + .handler = &handle_verify_image_command, + .mode = COMMAND_EXEC, + .usage = "<file> [offset] [type]", + }, + { + .name = "test_image", + .handler = &handle_test_image_command, + .mode = COMMAND_EXEC, + .usage = "<file> [offset] [type]", + }, + COMMAND_REGISTRATION_DONE +}; int target_register_user_commands(struct command_context *cmd_ctx) { int retval = ERROR_OK; @@ -4784,10 +4976,6 @@ int target_register_user_commands(struct command_context *cmd_ctx) if ((retval = trace_register_commands(cmd_ctx)) != ERROR_OK) return retval; - COMMAND_REGISTER(cmd_ctx, NULL, "profile", - handle_profile_command, COMMAND_EXEC, - "profiling samples the CPU PC"); - register_jim(cmd_ctx, "ocd_mem2array", jim_mem2array, "read memory and return as a TCL array for script processing " "<ARRAYNAME> <WIDTH = 32/16/8> <ADDRESS> <COUNT>"); @@ -4796,96 +4984,5 @@ int target_register_user_commands(struct command_context *cmd_ctx) "convert a TCL array to memory locations and write the values " "<ARRAYNAME> <WIDTH = 32/16/8> <ADDRESS> <COUNT>"); - COMMAND_REGISTER(cmd_ctx, NULL, "fast_load_image", - handle_fast_load_image_command, COMMAND_ANY, - "same CMD_ARGV as load_image, image stored in memory " - "- mainly for profiling purposes"); - - COMMAND_REGISTER(cmd_ctx, NULL, "fast_load", - handle_fast_load_command, COMMAND_ANY, - "loads active fast load image to current target " - "- mainly for profiling purposes"); - - /** @todo don't register virt2phys() unless target supports it */ - COMMAND_REGISTER(cmd_ctx, NULL, "virt2phys", - handle_virt2phys_command, COMMAND_ANY, - "translate a virtual address into a physical address"); - - COMMAND_REGISTER(cmd_ctx, NULL, "reg", - handle_reg_command, COMMAND_EXEC, - "display or set a register"); - - COMMAND_REGISTER(cmd_ctx, NULL, "poll", - handle_poll_command, COMMAND_EXEC, - "poll target state"); - COMMAND_REGISTER(cmd_ctx, NULL, "wait_halt", - handle_wait_halt_command, COMMAND_EXEC, - "wait for target halt [time (s)]"); - COMMAND_REGISTER(cmd_ctx, NULL, "halt", - handle_halt_command, COMMAND_EXEC, - "halt target"); - COMMAND_REGISTER(cmd_ctx, NULL, "resume", - handle_resume_command, COMMAND_EXEC, - "resume target [addr]"); - COMMAND_REGISTER(cmd_ctx, NULL, "reset", - handle_reset_command, COMMAND_EXEC, - "reset target [run | halt | init] - default is run"); - COMMAND_REGISTER(cmd_ctx, NULL, "soft_reset_halt", - handle_soft_reset_halt_command, COMMAND_EXEC, - "halt the target and do a soft reset"); - - COMMAND_REGISTER(cmd_ctx, NULL, "step", - handle_step_command, COMMAND_EXEC, - "step one instruction from current PC or [addr]"); - - COMMAND_REGISTER(cmd_ctx, NULL, "mdw", - handle_md_command, COMMAND_EXEC, - "display memory words [phys] <addr> [count]"); - COMMAND_REGISTER(cmd_ctx, NULL, "mdh", - handle_md_command, COMMAND_EXEC, - "display memory half-words [phys] <addr> [count]"); - COMMAND_REGISTER(cmd_ctx, NULL, "mdb", - handle_md_command, COMMAND_EXEC, - "display memory bytes [phys] <addr> [count]"); - - COMMAND_REGISTER(cmd_ctx, NULL, "mww", - handle_mw_command, COMMAND_EXEC, - "write memory word [phys] <addr> <value> [count]"); - COMMAND_REGISTER(cmd_ctx, NULL, "mwh", - handle_mw_command, COMMAND_EXEC, - "write memory half-word [phys] <addr> <value> [count]"); - COMMAND_REGISTER(cmd_ctx, NULL, "mwb", - handle_mw_command, COMMAND_EXEC, - "write memory byte [phys] <addr> <value> [count]"); - - COMMAND_REGISTER(cmd_ctx, NULL, "bp", - handle_bp_command, COMMAND_EXEC, - "list or set breakpoint [<address> <length> [hw]]"); - COMMAND_REGISTER(cmd_ctx, NULL, "rbp", - handle_rbp_command, COMMAND_EXEC, - "remove breakpoint <address>"); - - COMMAND_REGISTER(cmd_ctx, NULL, "wp", - handle_wp_command, COMMAND_EXEC, - "list or set watchpoint " - "[<address> <length> <r/w/a> [value] [mask]]"); - COMMAND_REGISTER(cmd_ctx, NULL, "rwp", - handle_rwp_command, COMMAND_EXEC, - "remove watchpoint <address>"); - - COMMAND_REGISTER(cmd_ctx, NULL, "load_image", - handle_load_image_command, COMMAND_EXEC, - "load_image <file> <address> " - "['bin'|'ihex'|'elf'|'s19'] [min_address] [max_length]"); - COMMAND_REGISTER(cmd_ctx, NULL, "dump_image", - handle_dump_image_command, COMMAND_EXEC, - "dump_image <file> <address> <size>"); - COMMAND_REGISTER(cmd_ctx, NULL, "verify_image", - handle_verify_image_command, COMMAND_EXEC, - "verify_image <file> [offset] [type]"); - COMMAND_REGISTER(cmd_ctx, NULL, "test_image", - handle_test_image_command, COMMAND_EXEC, - "test_image <file> [offset] [type]"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, target_exec_command_handlers); } commit c3800b5e674be3a9e1c7976925f9cfc52cba3ad5 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 07:43:06 2009 -0800 oocd_trace: use register_commands() diff --git a/src/target/oocd_trace.c b/src/target/oocd_trace.c index 596a4d6..a34c63c 100644 --- a/src/target/oocd_trace.c +++ b/src/target/oocd_trace.c @@ -407,16 +407,38 @@ COMMAND_HANDLER(handle_oocd_trace_resync_command) return ERROR_OK; } +static const struct command_registration oocd_trace_all_command_handlers[] = { + { + .name = "config", + .handler = &handle_oocd_trace_config_command, + .mode = COMMAND_CONFIG, + .usage = "<target>", + }, + { + .name = "status", + .handler = &handle_oocd_trace_status_command, + .mode = COMMAND_EXEC, + .help = "display OpenOCD + trace status", + }, + { + .name = "resync", + .handler = handle_oocd_trace_resync_command, + .mode = COMMAND_EXEC, + .help = "resync OpenOCD + trace capture clock", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration oocd_trace_command_handlers[] = { + { + .name = "oocd_trace", + .mode = COMMAND_ANY, + .help = "OpenOCD trace capture driver command group", + .chain = oocd_trace_all_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + int oocd_trace_register_commands(struct command_context *cmd_ctx) { - struct command *oocd_trace_cmd; - - oocd_trace_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "oocd_trace", NULL, COMMAND_ANY, "OpenOCD + trace"); - - COMMAND_REGISTER(cmd_ctx, oocd_trace_cmd, "config", handle_oocd_trace_config_command, COMMAND_CONFIG, NULL); - - COMMAND_REGISTER(cmd_ctx, oocd_trace_cmd, "status", handle_oocd_trace_status_command, COMMAND_EXEC, "display OpenOCD + trace status"); - COMMAND_REGISTER(cmd_ctx, oocd_trace_cmd, "resync", handle_oocd_trace_resync_command, COMMAND_EXEC, "resync OpenOCD + trace capture clock"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, oocd_trace_command_handlers); } commit a17caa387c0fb08ee2604e066b436d90d9cf0a2f Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 07:43:06 2009 -0800 etm_dummy: use register_commands() diff --git a/src/target/etm_dummy.c b/src/target/etm_dummy.c index 2df8943..27a8eec 100644 --- a/src/target/etm_dummy.c +++ b/src/target/etm_dummy.c @@ -58,15 +58,28 @@ COMMAND_HANDLER(handle_etm_dummy_config_command) return ERROR_OK; } +static const struct command_registration etm_dummy_config_command_handlers[] = { + { + .name = "config", + .handler = &handle_etm_dummy_config_command, + .mode = COMMAND_CONFIG, + .usage = "<target>", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration etm_dummy_command_handlers[] = { + { + .name = "etm_dummy", + .mode = COMMAND_ANY, + .help = "Dummy ETM capture driver command group", + .chain = etm_dummy_config_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int etm_dummy_register_commands(struct command_context *cmd_ctx) { - struct command *etm_dummy_cmd; - - etm_dummy_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "etm_dummy", NULL, COMMAND_ANY, "Dummy ETM capture driver"); - - COMMAND_REGISTER(cmd_ctx, etm_dummy_cmd, "config", handle_etm_dummy_config_command, COMMAND_CONFIG, NULL); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, etm_dummy_command_handlers); } static int etm_dummy_init(struct etm_context *etm_ctx) commit dd063d99147ff08ad817fc3fbd306425b6933d8d Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 07:43:06 2009 -0800 etm: use register_commands() diff --git a/src/target/etm.c b/src/target/etm.c index 6df354a..0f7b41e 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 = "<target> <port_width> <port_mode> " + "<clocking> <capture_driver>", + }, + 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 <target> <port_width> <port_mode> <clocking> <capture_driver>"); - - 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 = "<none | data | address | all> " + "<context_id_bits> <cycle_accurate> <branch_output>", + }, + { + .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 (<percent>) 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 <file> [base address]", + }, + { + .name = "dump", + .handler = &handle_etm_dump_command, + .mode = COMMAND_EXEC, + .help = "dump captured trace data <file>", + }, + { + .name = "load", + .handler = &handle_etm_load_command, + .mode = COMMAND_EXEC, + .help = "load trace data for analysis <file>", + }, + 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: " - "<none | data | address | all> " - "<context_id_bits> <cycle_accurate> <branch_output>"); - - 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 (<percent>) 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 t... [truncated message content] |