ARM7/ARM9: use shared examine() method
authorDavid Brownell <dbrownell@users.sourceforge.net>
Sat, 14 Nov 2009 00:26:39 +0000 (16:26 -0800)
committerDavid Brownell <dbrownell@users.sourceforge.net>
Sat, 14 Nov 2009 00:26:39 +0000 (16:26 -0800)
No point in having two identical examine methods for the
ARM7TDMI and ARM9TDMI drivers; move, rename, shrink, share.

Add a bit of doxygen; stop needlessly exporting a method.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
12 files changed:
src/target/arm720t.c
src/target/arm7_9_common.c
src/target/arm7_9_common.h
src/target/arm7tdmi.c
src/target/arm7tdmi.h
src/target/arm920t.c
src/target/arm926ejs.c
src/target/arm966e.c
src/target/arm9tdmi.c
src/target/arm9tdmi.h
src/target/fa526.c
src/target/feroceon.c

index 145c8d15fa0255b158632f97d7a2b4e1f56a5f5b..eb66b120c2c358e1cd3eb9b49960a84bf0e748d1 100644 (file)
@@ -548,8 +548,7 @@ struct target_type arm720t_target =
        .register_commands = arm720t_register_commands,
        .target_create = arm720t_target_create,
        .init_target = arm720t_init_target,
-       .examine = arm7tdmi_examine,
+       .examine = arm7_9_examine,
        .mrc = arm720t_mrc,
        .mcr = arm720t_mcr,
-
 };
index ea04f3f85bb74e2c58487eebc9afca0525afc8e7..115a1d6bcb8ecef2377a89fac1b9b3072f1b102c 100644 (file)
 #include "arm_simulator.h"
 
 
-int arm7_9_debug_entry(struct target *target);
+/**
+ * @file
+ * Hold common code supporting the ARM7 and ARM9 core generations.
+ *
+ * While the ARM core implementations evolved substantially during these
+ * two generations, they look quite similar from the JTAG perspective.
+ * Both have similar debug facilities, based on the same two scan chains
+ * providing access to the core and to an EmbeddedICE module.  Both can
+ * support similar ETM and ETB modules, for tracing.  And both expose
+ * what could be viewed as "ARM Classic", with multiple processor modes,
+ * shadowed registers, and support for the Thumb instruction set.
+ *
+ * Processor differences include things like presence or absence of MMU
+ * and cache, pipeline sizes, use of a modified Harvard Architecure
+ * (with separate instruction and data busses from the CPU), support
+ * for cpu clock gating during idle, and more.
+ */
+
+static int arm7_9_debug_entry(struct target *target);
 
 /**
  * Clear watchpoints for an ARM7/9 target.
@@ -1311,7 +1329,7 @@ int arm7_9_halt(struct target *target)
  * @param target Pointer to target that is entering debug mode
  * @return Error code if anything fails, otherwise ERROR_OK
  */
-int arm7_9_debug_entry(struct target *target)
+static int arm7_9_debug_entry(struct target *target)
 {
        int i;
        uint32_t context[16];
@@ -2838,6 +2856,42 @@ int arm7_9_blank_check_memory(struct target *target, uint32_t address, uint32_t
        return ERROR_OK;
 }
 
+/**
+ * Perform per-target setup that requires JTAG access.
+ */
+int arm7_9_examine(struct target *target)
+{
+       struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
+       int retval;
+
+       if (!target_was_examined(target)) {
+               struct reg_cache *t, **cache_p;
+
+               t = embeddedice_build_reg_cache(target, arm7_9);
+               if (t == NULL)
+                       return ERROR_FAIL;
+
+               cache_p = register_get_last_cache_p(&target->reg_cache);
+               (*cache_p) = t;
+               arm7_9->eice_cache = (*cache_p);
+
+               if (arm7_9->armv4_5_common.etm)
+                       (*cache_p)->next = etm_build_reg_cache(target,
+                                       &arm7_9->jtag_info,
+                                       arm7_9->armv4_5_common.etm);
+
+               target_set_examined(target);
+       }
+
+       retval = embeddedice_setup(target);
+       if (retval == ERROR_OK)
+               retval = arm7_9_setup(target);
+       if (retval == ERROR_OK && arm7_9->armv4_5_common.etm)
+               retval = etm_setup(target);
+       return retval;
+}
+
+
 COMMAND_HANDLER(handle_arm7_9_write_xpsr_command)
 {
        uint32_t value;
index e46da8872c40cbdf55b41d28037520328b81a000..bbe95ca235a46ff7eb1cfc2e2ed3e1ecaf38e67a 100644 (file)
@@ -159,5 +159,6 @@ void arm7_9_disable_eice_step(struct target *target);
 int arm7_9_execute_sys_speed(struct target *target);
 
 int arm7_9_init_arch_info(struct target *target, struct arm7_9_common *arm7_9);
+int arm7_9_examine(struct target *target);
 
 #endif /* ARM7_9_COMMON_H */
index c7bbd776274a091494480758cc58818a109dec41..8be8a125e475868c85c7515e36d4f8fae1caf07e 100644 (file)
@@ -646,42 +646,6 @@ static void arm7tdmi_build_reg_cache(struct target *target)
        armv4_5->core_cache = (*cache_p);
 }
 
-int arm7tdmi_examine(struct target *target)
-{
-       struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
-       int retval;
-
-
-       if (!target_was_examined(target))
-       {
-               /* get pointers to arch-specific information */
-               struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
-               struct reg_cache *t = embeddedice_build_reg_cache(target, arm7_9);
-               if (t == NULL)
-                       return ERROR_FAIL;
-
-               (*cache_p) = t;
-               arm7_9->eice_cache = (*cache_p);
-
-               if (arm7_9->armv4_5_common.etm)
-                       (*cache_p)->next = etm_build_reg_cache(target,
-                                       &arm7_9->jtag_info,
-                                       arm7_9->armv4_5_common.etm);
-
-               target_set_examined(target);
-       }
-       if ((retval = embeddedice_setup(target)) != ERROR_OK)
-               return retval;
-       if ((retval = arm7_9_setup(target)) != ERROR_OK)
-               return retval;
-       if (arm7_9->armv4_5_common.etm)
-       {
-               if ((retval = etm_setup(target)) != ERROR_OK)
-                       return retval;
-       }
-       return ERROR_OK;
-}
-
 int arm7tdmi_init_target(struct command_context *cmd_ctx, struct target *target)
 {
        arm7tdmi_build_reg_cache(target);
@@ -786,5 +750,5 @@ struct target_type arm7tdmi_target =
        .register_commands  = arm7_9_register_commands,
        .target_create  = arm7tdmi_target_create,
        .init_target = arm7tdmi_init_target,
-       .examine = arm7tdmi_examine,
+       .examine = arm7_9_examine,
 };
index 85b64befa9dbd2f75748d69813f4ef84dc48200b..4ed6f3e23471de0952c6a70992e4ff2eb74194b6 100644 (file)
@@ -35,6 +35,5 @@ struct arm7tdmi_common
 
 int arm7tdmi_init_arch_info(struct target *target, struct arm7tdmi_common *arm7tdmi, struct jtag_tap *tap);
 int arm7tdmi_init_target(struct command_context *cmd_ctx, struct target *target);
-int arm7tdmi_examine(struct target *target);
 
 #endif /* ARM7TDMI_H */
index dd742cacf73466201d81b0a22cabcb03fc1dd527..9aa165c7b0aeb2cb4f32a426a19d6ac6a2f508bd 100644 (file)
@@ -1420,7 +1420,7 @@ struct target_type arm920t_target =
        .register_commands = arm920t_register_commands,
        .target_create = arm920t_target_create,
        .init_target = arm9tdmi_init_target,
-       .examine = arm9tdmi_examine,
+       .examine = arm7_9_examine,
        .mrc = arm920t_mrc,
        .mcr = arm920t_mcr,
 };
index c7609c472a41409fed0f2a81e0330b73cbbd1450..51b241a597b381bd5a9e3261d271bef0f32739cf 100644 (file)
@@ -877,7 +877,7 @@ struct target_type arm926ejs_target =
        .register_commands = arm926ejs_register_commands,
        .target_create = arm926ejs_target_create,
        .init_target = arm9tdmi_init_target,
-       .examine = arm9tdmi_examine,
+       .examine = arm7_9_examine,
        .virt2phys = arm926ejs_virt2phys,
        .mmu = arm926ejs_mmu,
 
index 61f9ae501d319092c7bde6f992a1020c163a429e..931db7487c310e330c5ae8d43dca81ab701b4595 100644 (file)
@@ -268,5 +268,5 @@ struct target_type arm966e_target =
        .register_commands = arm966e_register_commands,
        .target_create = arm966e_target_create,
        .init_target = arm9tdmi_init_target,
-       .examine = arm9tdmi_examine,
+       .examine = arm7_9_examine,
 };
index fc110733e015451e1b58df987234d66dbf253ab9..44a978ad58f5037cbc3cc6805c12e06451548f0f 100644 (file)
@@ -742,41 +742,6 @@ static void arm9tdmi_build_reg_cache(struct target *target)
        armv4_5->core_cache = (*cache_p);
 }
 
-int arm9tdmi_examine(struct target *target)
-{
-       int retval;
-       struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
-
-       if (!target_was_examined(target))
-       {
-               struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
-               struct reg_cache *t;
-               /* one extra register (vector catch) */
-               t = embeddedice_build_reg_cache(target, arm7_9);
-               if (t == NULL)
-                       return ERROR_FAIL;
-               (*cache_p) = t;
-               arm7_9->eice_cache = (*cache_p);
-
-               if (arm7_9->armv4_5_common.etm)
-                       (*cache_p)->next = etm_build_reg_cache(target,
-                                       &arm7_9->jtag_info,
-                                       arm7_9->armv4_5_common.etm);
-
-               target_set_examined(target);
-       }
-       if ((retval = embeddedice_setup(target)) != ERROR_OK)
-               return retval;
-       if ((retval = arm7_9_setup(target)) != ERROR_OK)
-               return retval;
-       if (arm7_9->armv4_5_common.etm)
-       {
-               if ((retval = etm_setup(target)) != ERROR_OK)
-                       return retval;
-       }
-       return ERROR_OK;
-}
-
 int arm9tdmi_init_target(struct command_context *cmd_ctx,
                struct target *target)
 {
@@ -986,5 +951,5 @@ struct target_type arm9tdmi_target =
        .register_commands = arm9tdmi_register_commands,
        .target_create = arm9tdmi_target_create,
        .init_target = arm9tdmi_init_target,
-       .examine = arm9tdmi_examine,
+       .examine = arm7_9_examine,
 };
index 34a63ee72961b7524e03d03b31df6edfa34b70ec..496e4c52d251358bab05ccd0546af0b8153820ee 100644 (file)
@@ -53,7 +53,6 @@ enum arm9tdmi_vector_bit
 
 int arm9tdmi_init_target(struct command_context *cmd_ctx,
                struct target *target);
-int arm9tdmi_examine(struct target *target);
 int arm9tdmi_init_arch_info(struct target *target,
                struct arm9tdmi_common *arm9tdmi, struct jtag_tap *tap);
 int arm9tdmi_register_commands(struct command_context *cmd_ctx);
index f3df24fe1ec1742c842632970121aad027d82d01..9e7b00da8792523938b91ab485d79a193bd8b289 100644 (file)
@@ -393,5 +393,5 @@ struct target_type fa526_target =
        .register_commands = arm920t_register_commands,
        .target_create = fa526_target_create,
        .init_target = arm9tdmi_init_target,
-       .examine = arm9tdmi_examine,
+       .examine = arm7_9_examine,
 };
index 96a048ac693bdee4f31e4b9659aaa965e220dba0..c029e44e69e088b2728d923e3c31e31ee841c6bd 100644 (file)
@@ -646,7 +646,7 @@ int feroceon_examine(struct target *target)
        struct arm7_9_common *arm7_9;
        int retval;
 
-       retval = arm9tdmi_examine(target);
+       retval = arm7_9_examine(target);
        if (retval != ERROR_OK)
                return retval;
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)