[RFC] target: Move bulk_write_memory to arm7_9 20/1220/3
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Mon, 11 Mar 2013 21:21:13 +0000 (22:21 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Fri, 13 Sep 2013 19:33:28 +0000 (19:33 +0000)
The only remaining user is arm7_9 so remove it from the target API and add
it to struct arm7_9_common to support all its variants with minimal
changes. Many of the variants are likely not correct in the cache/mmu
handling when the bulk write is triggered. This patch does nothing to
change that, except for arm946e, where it was easier to do what might be
the right thing.

Change-Id: Ie73ac07507ff0936fefdb90760046cc8810ed182
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1220
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
15 files changed:
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/arm946e.c
src/target/arm966e.c
src/target/arm9tdmi.c
src/target/fa526.c
src/target/feroceon.c
src/target/target.c
src/target/target_type.h

index d38fc82b389ec42551869168b39cc44cf69468b5..619c80a130ba36a94aa11cc8fc1f70704e128adb 100644 (file)
@@ -565,14 +565,12 @@ struct target_type arm720t_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm720t_read_memory,
-       .write_memory = arm7_9_write_memory,
+       .write_memory = arm7_9_write_memory_opt,
        .read_phys_memory = arm720t_read_phys_memory,
        .write_phys_memory = arm720t_write_phys_memory,
        .mmu = arm720_mmu,
        .virt2phys = arm720_virt2phys,
 
-       .bulk_write_memory = arm7_9_bulk_write_memory,
-
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
 
index 587cb0ee635ea7785d07b2bab45333c377c747b4..6eade96a16a66f9bfbc8cc2809e7cd9579ac4958 100644 (file)
@@ -2469,6 +2469,20 @@ int arm7_9_write_memory(struct target *target,
        return ERROR_OK;
 }
 
+int arm7_9_write_memory_opt(struct target *target,
+       uint32_t address,
+       uint32_t size,
+       uint32_t count,
+       const uint8_t *buffer)
+{
+       struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
+
+       if (size == 4 && count > 32 && arm7_9->bulk_write_memory)
+               return arm7_9->bulk_write_memory(target, address, count, buffer);
+       else
+               return arm7_9_write_memory(target, address, size, count, buffer);
+}
+
 static int dcc_count;
 static const uint8_t *dcc_buffer;
 
index 737cbae5559c04491c8c17c85cb3582d64861734..85e5ac045657b2c824c6a89c789bee5daa011f8c 100644 (file)
@@ -118,6 +118,13 @@ struct arm7_9_common {
 
        void (*pre_restore_context)(struct target *target);
        /**< Callback function called before restoring the processor context */
+
+       /**
+        * Write target memory in multiples of 4 bytes, optimized for
+        * writing large quantities of data.
+        */
+       int (*bulk_write_memory)(struct target *target, uint32_t address,
+                       uint32_t count, const uint8_t *buffer);
 };
 
 static inline struct arm7_9_common *target_to_arm7_9(struct target *target)
@@ -151,6 +158,8 @@ int arm7_9_read_memory(struct target *target, uint32_t address,
                uint32_t size, uint32_t count, uint8_t *buffer);
 int arm7_9_write_memory(struct target *target, uint32_t address,
                uint32_t size, uint32_t count, const uint8_t *buffer);
+int arm7_9_write_memory_opt(struct target *target, uint32_t address,
+               uint32_t size, uint32_t count, const uint8_t *buffer);
 int arm7_9_bulk_write_memory(struct target *target, uint32_t address,
                uint32_t count, const uint8_t *buffer);
 
index 3ef977769b2cc4261e5a10076fde1225eb8b56f1..4c7cce19ebd707990c3bb5a4e540a9a725017305 100644 (file)
@@ -648,6 +648,8 @@ int arm7tdmi_init_arch_info(struct target *target,
        arm7_9->enable_single_step = arm7_9_enable_eice_step;
        arm7_9->disable_single_step = arm7_9_disable_eice_step;
 
+       arm7_9->bulk_write_memory = arm7_9_bulk_write_memory;
+
        arm7_9->post_debug_entry = NULL;
 
        arm7_9->pre_restore_context = NULL;
@@ -694,8 +696,7 @@ struct target_type arm7tdmi_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm7_9_read_memory,
-       .write_memory = arm7_9_write_memory,
-       .bulk_write_memory = arm7_9_bulk_write_memory,
+       .write_memory = arm7_9_write_memory_opt,
 
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
index 41d64733693188d9320ec8ed16a84b3f7065987a..98bd12f56b07b4e4d7f9f89a8a847b4756760c84 100644 (file)
@@ -740,6 +740,17 @@ int arm920t_write_memory(struct target *target, uint32_t address,
        return ERROR_OK;
 }
 
+int arm920t_write_memory_opt(struct target *target, uint32_t address,
+       uint32_t size, uint32_t count, const uint8_t *buffer)
+{
+       struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
+
+       if (size == 4 && count > 32 && arm7_9->bulk_write_memory)
+               return arm7_9->bulk_write_memory(target, address, count, buffer);
+       else
+               return arm920t_write_memory(target, address, size, count, buffer);
+}
+
 /* EXPORTED to FA256 */
 int arm920t_soft_reset_halt(struct target *target)
 {
@@ -1697,14 +1708,12 @@ struct target_type arm920t_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm920t_read_memory,
-       .write_memory = arm920t_write_memory,
+       .write_memory = arm920t_write_memory_opt,
        .read_phys_memory = arm920t_read_phys_memory,
        .write_phys_memory = arm920t_write_phys_memory,
        .mmu = arm920_mmu,
        .virt2phys = arm920_virt2phys,
 
-       .bulk_write_memory = arm7_9_bulk_write_memory,
-
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
 
index 71876a69bc126245e82cd5b5afc887a5d4c93dd0..37745130fefc555caf73b7745741cb2b01aa9708 100644 (file)
@@ -60,6 +60,8 @@ int arm920t_read_memory(struct target *target,
        uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
 int arm920t_write_memory(struct target *target,
        uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
+int arm920t_write_memory_opt(struct target *target,
+       uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
 int arm920t_post_debug_entry(struct target *target);
 void arm920t_pre_restore_context(struct target *target);
 int arm920t_get_ttb(struct target *target, uint32_t *result);
index 95930e685d6c7c094427367dd2a8289c9c5ee304..1e0a579028fe6e1c0baf35d7f06df1e59e9f04af 100644 (file)
@@ -656,6 +656,17 @@ int arm926ejs_write_memory(struct target *target, uint32_t address,
        return retval;
 }
 
+int arm926ejs_write_memory_opt(struct target *target, uint32_t address,
+       uint32_t size, uint32_t count, const uint8_t *buffer)
+{
+       struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
+
+       if (size == 4 && count > 32 && arm7_9->bulk_write_memory)
+               return arm7_9->bulk_write_memory(target, address, count, buffer);
+       else
+               return arm926ejs_write_memory(target, address, size, count, buffer);
+}
+
 static int arm926ejs_write_phys_memory(struct target *target,
                uint32_t address, uint32_t size,
                uint32_t count, const uint8_t *buffer)
@@ -808,8 +819,7 @@ struct target_type arm926ejs_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm7_9_read_memory,
-       .write_memory = arm926ejs_write_memory,
-       .bulk_write_memory = arm7_9_bulk_write_memory,
+       .write_memory = arm926ejs_write_memory_opt,
 
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
index cc19c9fc5181d154c757f8489a99900c0a68f092..6dde4c6ff2a9952de62f6f5cc0a2effff3adfaf3 100644 (file)
@@ -50,6 +50,8 @@ int arm926ejs_init_arch_info(struct target *target,
 int arm926ejs_arch_state(struct target *target);
 int arm926ejs_write_memory(struct target *target,
                uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
+int arm926ejs_write_memory_opt(struct target *target,
+               uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
 int arm926ejs_soft_reset_halt(struct target *target);
 
 extern const struct command_registration arm926ejs_command_handlers[];
index 7ffab7ad5b169ef6293463a9af43fd531c51b027..5c85845d1a74cb115382bbd75514220171eeefbc 100644 (file)
@@ -504,7 +504,7 @@ int arm946e_write_memory(struct target *target, uint32_t address,
        /**
         * Write memory
         */
-       retval = arm7_9_write_memory(target, address, size, count, buffer);
+       retval = arm7_9_write_memory_opt(target, address, size, count, buffer);
        if (retval != ERROR_OK)
                return retval;
 
@@ -764,8 +764,6 @@ struct target_type arm946e_target = {
        .read_memory = arm946e_read_memory,
        .write_memory = arm946e_write_memory,
 
-       .bulk_write_memory = arm7_9_bulk_write_memory,
-
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
 
index 39653c2ef16044c5ae798015058ccf49426d98cb..6a96ab18f2d6fab0f4c73e5ea71400be9f23a8e7 100644 (file)
@@ -264,8 +264,7 @@ struct target_type arm966e_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm7_9_read_memory,
-       .write_memory = arm7_9_write_memory,
-       .bulk_write_memory = arm7_9_bulk_write_memory,
+       .write_memory = arm7_9_write_memory_opt,
 
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
index c468282bc8e9503c5935dc8830fa48b3ec07f0c1..d93c15f7cb3521a02dc69ea0600fc040b6f85ecc 100644 (file)
@@ -752,6 +752,8 @@ int arm9tdmi_init_arch_info(struct target *target,
        arm7_9->enable_single_step = arm9tdmi_enable_single_step;
        arm7_9->disable_single_step = arm9tdmi_disable_single_step;
 
+       arm7_9->bulk_write_memory = arm7_9_bulk_write_memory;
+
        arm7_9->post_debug_entry = NULL;
 
        arm7_9->pre_restore_context = NULL;
@@ -902,8 +904,7 @@ struct target_type arm9tdmi_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm7_9_read_memory,
-       .write_memory = arm7_9_write_memory,
-       .bulk_write_memory = arm7_9_bulk_write_memory,
+       .write_memory = arm7_9_write_memory_opt,
 
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
index aeef858e577356612f2bc6db367f44b9d0f216ed..a33b4a1c678fd4265c136d70ce1a97d7b8d1f13b 100644 (file)
@@ -284,6 +284,8 @@ static int fa526_init_arch_info_2(struct target *target,
        arm7_9->enable_single_step = arm9tdmi_enable_single_step;
        arm7_9->disable_single_step = arm9tdmi_disable_single_step;
 
+       arm7_9->bulk_write_memory = arm7_9_bulk_write_memory;
+
        arm7_9->post_debug_entry = NULL;
 
        arm7_9->pre_restore_context = NULL;
@@ -366,8 +368,7 @@ struct target_type fa526_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm920t_read_memory,
-       .write_memory = arm920t_write_memory,
-       .bulk_write_memory = arm7_9_bulk_write_memory,
+       .write_memory = arm920t_write_memory_opt,
 
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
index ab43f3dfcee68719997333e1a734c1a0ba95ab9f..d3037c5433ade42e126698da5b57ca31bb8da282 100644 (file)
@@ -605,6 +605,8 @@ static void feroceon_common_setup(struct target *target)
        arm7_9->enable_single_step = feroceon_enable_single_step;
        arm7_9->disable_single_step = feroceon_disable_single_step;
 
+       arm7_9->bulk_write_memory = feroceon_bulk_write_memory;
+
        /* MOE is not implemented */
        arm7_9->examine_debug_reason = feroceon_examine_debug_reason;
 
@@ -695,8 +697,7 @@ struct target_type feroceon_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm7_9_read_memory,
-       .write_memory = arm926ejs_write_memory,
-       .bulk_write_memory = feroceon_bulk_write_memory,
+       .write_memory = arm926ejs_write_memory_opt,
 
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
@@ -733,8 +734,7 @@ struct target_type dragonite_target = {
        .get_gdb_reg_list = arm_get_gdb_reg_list,
 
        .read_memory = arm7_9_read_memory,
-       .write_memory = arm7_9_write_memory,
-       .bulk_write_memory = feroceon_bulk_write_memory,
+       .write_memory = arm7_9_write_memory_opt,
 
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
index 29a011cea13756efd635fe822c1a298c41a6a45e..6aee09832e3983362d278c3caef9394c66cf7fed 100644 (file)
@@ -986,12 +986,6 @@ int target_write_phys_memory(struct target *target,
        return target->type->write_phys_memory(target, address, size, count, buffer);
 }
 
-static int target_bulk_write_memory_default(struct target *target,
-               uint32_t address, uint32_t count, const uint8_t *buffer)
-{
-       return target_write_memory(target, address, 4, count, buffer);
-}
-
 int target_add_breakpoint(struct target *target,
                struct breakpoint *breakpoint)
 {
@@ -1173,9 +1167,6 @@ static int target_init_one(struct command_context *cmd_ctx,
        if (target->type->write_buffer == NULL)
                target->type->write_buffer = target_write_buffer_default;
 
-       if (target->type->bulk_write_memory == NULL)
-               target->type->bulk_write_memory = target_bulk_write_memory_default;
-
        if (target->type->get_gdb_fileio_info == NULL)
                target->type->get_gdb_fileio_info = target_get_gdb_fileio_info_default;
 
@@ -1802,16 +1793,9 @@ static int target_write_buffer_default(struct target *target, uint32_t address,
        if (size >= 4) {
                int aligned = size - (size % 4);
 
-               /* use bulk writes above a certain limit. This may have to be changed */
-               if (aligned > 128) {
-                       retval = target->type->bulk_write_memory(target, address, aligned / 4, buffer);
-                       if (retval != ERROR_OK)
-                               return retval;
-               } else {
-                       retval = target_write_memory(target, address, 4, aligned / 4, buffer);
-                       if (retval != ERROR_OK)
-                               return retval;
-               }
+               retval = target_write_memory(target, address, 4, aligned / 4, buffer);
+               if (retval != ERROR_OK)
+                       return retval;
 
                buffer += aligned;
                address += aligned;
index 21439b656aa396dff6db63ba18e207dfd6dc2c57..cf81708b8b2ff0eed1c9eb2b1e987f17594b2f90 100644 (file)
@@ -130,14 +130,6 @@ struct target_type {
        int (*write_buffer)(struct target *target, uint32_t address,
                        uint32_t size, const uint8_t *buffer);
 
-       /**
-        * Write target memory in multiples of 4 bytes, optimized for
-        * writing large quantities of data.  Do @b not call this
-        * function directly, use target_bulk_write_memory() instead.
-        */
-       int (*bulk_write_memory)(struct target *target, uint32_t address,
-                       uint32_t count, const uint8_t *buffer);
-
        int (*checksum_memory)(struct target *target, uint32_t address,
                        uint32_t count, uint32_t *checksum);
        int (*blank_check_memory)(struct target *target, uint32_t address,

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)