]> git.sur5r.net Git - openocd/commitdiff
remove target_type register_command callback
authorZachary T Welch <zw@superlucidity.net>
Mon, 23 Nov 2009 16:17:01 +0000 (08:17 -0800)
committerZachary T Welch <zw@superlucidity.net>
Wed, 25 Nov 2009 05:37:36 +0000 (21:37 -0800)
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.

31 files changed:
src/target/arm11.c
src/target/arm720t.c
src/target/arm7_9_common.c
src/target/arm7_9_common.h
src/target/arm7tdmi.c
src/target/arm920t.c
src/target/arm920t.h
src/target/arm926ejs.c
src/target/arm926ejs.h
src/target/arm966e.c
src/target/arm966e.h
src/target/arm9tdmi.c
src/target/arm9tdmi.h
src/target/armv4_5.c
src/target/armv4_5.h
src/target/armv7a.c
src/target/armv7a.h
src/target/armv7m.c
src/target/armv7m.h
src/target/avrt.c
src/target/cortex_a8.c
src/target/cortex_m3.c
src/target/etm.c
src/target/etm.h
src/target/fa526.c
src/target/feroceon.c
src/target/mips32.c
src/target/mips_m4k.c
src/target/target.c
src/target/target_type.h
src/target/xscale.c

index 835234cecd2c4fa3c08e5f1c1828da386b9d3266..7c6d39c9d42123d9163856e831c3223923e08459 100644 (file)
@@ -1616,6 +1616,12 @@ static const struct command_registration arm11_any_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 static const struct command_registration arm11_command_handlers[] = {
+       {
+               .chain = arm_command_handlers,
+       },
+       {
+               .chain = etm_command_handlers,
+       },
        {
                .name = "arm11",
                .mode = COMMAND_ANY,
@@ -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,
index 52a311c420c6391cc2469a1bf15a7034632fabb3..bae2561aea1679e3feecd689422f9ef040add7e8 100644 (file)
@@ -503,6 +503,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,
@@ -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,
index b40be8d4dca87d516fe6019dae03997025ee9b2e..c4775e8a819f6cde65b3c5da94014e604d5d0fd4 100644 (file)
@@ -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);
-}
index 2f7132a15bb1a1e6dbf03726f4f551bbb5084967..d43eaa6d5a733b01eadee2b8eaa0a270e02bcbcb 100644 (file)
@@ -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);
 
index 742eace77c8de3671996045cf6caa59fba071e15..7d14ed61490dc00bee00849f1f36f5f7027ee2e3 100644 (file)
@@ -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,
index 1e6019cb1c4ff49ca4c7cb604572d9f5df60d7f5..e6c2eed82d48928055667124e8abf97e9484b1c0 100644 (file)
@@ -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,
index ca6be7ea968094d3b7c274af5cbeb5cfd075cbbe..a75f01ab16805e4f36687e61fa46e2957eaaa57c 100644 (file)
@@ -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 */
index 329aa12a43c26eece14ebdad7c0d5989d513f6d6..408ede9debeb7bf82db75e9f625bbc8fed612ae9 100644 (file)
@@ -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,
index 514f054376592729af95d49ad6f670d1d5398c71..274733bfd29ddc464a95558d4a1ad9a1f8ec500e 100644 (file)
@@ -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 */
index 70cc3c4b702478adaa21a9a3ea9237247c91c148..9fe513c9ea404298ed9f209fbe04c7d7b6903c8e 100644 (file)
@@ -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,
index 45aeb4ef1e6f1399e95773b08fd7218a68128573..24dcec306401afe677c0368786df51f6e7e28429 100644 (file)
@@ -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 */
index 87ace05606fc0dd3e8b831297a99c184823d328d..7eb5641de9297f003c3cc2075135defa6dd57dae 100644 (file)
@@ -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,
index 351b00adfc26bb3221332f1e26b2bac0e70ffc20..aff9fc5f41aa0af9e91c89d95680f995674051fc 100644 (file)
@@ -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);
index dfb7094b6635e262932669801766939332516a7a..7e5bb0a1716123d703bea9235c2ec80ba358ee72 100644 (file)
@@ -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);
index 7a6cb61865d52f98db6304ca955fda4b03b89ddc..822d14393b2eb94c00ca7573fe907fab8bd9e88d 100644 (file)
@@ -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,
index 7cc22736e34c5208c6cf95d22e0336df57f8cddb..3d94329fd29558f7110a156dcbc6e2452fbfd1f1 100644 (file)
@@ -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);
-}
index 942bf8bff76353bae212950d92a093aaccc0e952..f843f03bdc5163761a03f2e5362fcacff3f14c31 100644 (file)
@@ -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 */
index 6d8ad5f1a0a9d5ac08318a46328d349932f004c8..9d89086eb2d373e54c017c5f226a92309d608579 100644 (file)
@@ -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);
-}
index 9dd4ddbb82267740d69ea0003a69bc6c3d088a69..7299bdf9f291eb6bda6310ea2da8cf4d7c8fc059 100644 (file)
@@ -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
  */
 
index cabb2725fa2534b2a575be6c6bd5fbd7c9fcbf42..dc527f5e5472b6107233d5871ff140376491e95c 100644 (file)
@@ -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));
index 325a54b521b9b2ff19cbbbf3770312b1a2ae9ada..b85481a9611a7fbd8c6690475b8ec472181e4491 100644 (file)
@@ -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,
index be81af98a1644977f8b7aab42be3e7125df10b4c..7cfe540a389a6aa700b31ad4628b0f4f9c151270 100644 (file)
@@ -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,
index 0f7b41ec0a0871a3958cbc4c5c4d9327467995ce..2465d5c1a48680170eed3635d01e249da778d48e 100644 (file)
@@ -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,
index b74c6d9049451665ad472123276de921a46a48d3..05e54959a0b32933a1a28d86f5577b5412492d6e 100644 (file)
@@ -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)
index 9c22a750b654a248f0242b61f98dfd081ecc33c6..32469d0d23fc5d194728c545e2bf87d4fb5f5176 100644 (file)
@@ -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,
index 8c05276692ffd2c1384a528164def955c89cf956..432d49d1b08d6fb4e6a484fa4e2bc1684672e3f3 100644 (file)
@@ -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,
index 0b8ebb4a1fd2b768abd9805781f3057e6d06579d..48d072021c3683b47710212b20cb014d2dc5ca41 100644 (file)
@@ -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*/
index 0a566c3444175ee8df3f534f48270ecfd7033c8e..a83217ff957498c016aad30b13315d250c86f929 100644 (file)
@@ -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);
index 6f48808fafdf5a80f1795e5829040ae7b3b94c2d..e999e68c198a0b314387a36dcf2683db38df2689 100644 (file)
@@ -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 */
index aa87a74495a2d2fa5eb3a872a3f4c43461bf676a..9a0709d859e33837d6dbb6cef508a547281596f7 100644 (file)
@@ -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);
index 965ac52e732a7ba9d92063873fdb95b728b83c55..e402a11cb1ac24c7a95ef12f436087ea03a78a48 100644 (file)
@@ -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,