This is an automated email from Gerrit.

Spencer Oliver ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/1783

-- gerrit

commit 2b5f9d0a3c099cfedd5d38762c3ead62bd2aefe2
Author: Spencer Oliver <[email protected]>
Date:   Thu Oct 24 21:18:24 2013 +0100

    target: use target_buffer_set_u32_array
    
    Attempt to use target_buffer_set_u32_array to convert to target endian
    arrays rather reimplementing code.
    
    This also removed cfi_fix_code_endian as its functionality is also
    repeated.
    
    Change-Id: I7c359dbe46ea791cd5f6fb18d8b0fb6895c599d3
    Signed-off-by: Spencer Oliver <[email protected]>

diff --git a/src/flash/nand/arm_io.c b/src/flash/nand/arm_io.c
index 67b1508..d54958a 100644
--- a/src/flash/nand/arm_io.c
+++ b/src/flash/nand/arm_io.c
@@ -48,7 +48,6 @@ static int arm_code_to_working_area(struct target *target,
        unsigned additional, struct working_area **area)
 {
        uint8_t code_buf[code_size];
-       unsigned i;
        int retval;
        unsigned size = code_size + additional;
 
@@ -67,8 +66,7 @@ static int arm_code_to_working_area(struct target *target,
        }
 
        /* buffer code in target endianness */
-       for (i = 0; i < code_size / 4; i++)
-               target_buffer_set_u32(target, code_buf + i * 4, code[i]);
+       target_buffer_set_u32_array(target, code_buf, code_size / 4, code);
 
        /* copy code to work area */
        retval = target_write_memory(target, (*area)->address,
diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c
index 32db80b..0bfac6d 100644
--- a/src/flash/nor/cfi.c
+++ b/src/flash/nor/cfi.c
@@ -1103,19 +1103,6 @@ static int cfi_protect(struct flash_bank *bank, int set, 
int first, int last)
        }
 }
 
-/* Convert code image to target endian
- * FIXME create general block conversion fcts in target.c?) */
-static void cfi_fix_code_endian(struct target *target, uint8_t *dest,
-       const uint32_t *src, uint32_t count)
-{
-       uint32_t i;
-       for (i = 0; i < count; i++) {
-               target_buffer_set_u32(target, dest, *src);
-               dest += 4;
-               src++;
-       }
-}
-
 static uint32_t cfi_command_val(struct flash_bank *bank, uint8_t cmd)
 {
        struct target *target = bank->target;
@@ -1264,7 +1251,8 @@ static int cfi_intel_write_block(struct flash_bank *bank, 
uint8_t *buffer,
                                "Increase CFI_MAX_INTEL_CODESIZE and 
recompile.");
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
        }
-       cfi_fix_code_endian(target, target_code, target_code_src, 
target_code_size / 4);
+
+       target_buffer_set_u32_array(target, target_code, target_code_size / 4, 
target_code_src);
 
        /* Get memory for block write handler */
        retval = target_alloc_working_area(target,
@@ -1504,7 +1492,8 @@ static int cfi_spansion_write_block_mips(struct 
flash_bank *bank, uint8_t *buffe
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
-       cfi_fix_code_endian(target, target_code, target_code_src, 
target_code_size / 4);
+
+       target_buffer_set_u32_array(target, target_code, target_code_size / 4, 
target_code_src);
 
        /* allocate working area */
        retval = target_alloc_working_area(target, target_code_size,
@@ -1883,7 +1872,8 @@ static int cfi_spansion_write_block(struct flash_bank 
*bank, uint8_t *buffer,
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
-       cfi_fix_code_endian(target, target_code, target_code_src, 
target_code_size / 4);
+
+       target_buffer_set_u32_array(target, target_code, target_code_size / 4, 
target_code_src);
 
        /* allocate working area */
        retval = target_alloc_working_area(target, target_code_size,
diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index 7687466..f4cf376 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -2595,8 +2595,7 @@ int arm7_9_bulk_write_memory(struct target *target,
                }
 
                /* copy target instructions to target endianness */
-               for (i = 0; i < 6; i++)
-                       target_buffer_set_u32(target, dcc_code_buf + i*4, 
dcc_code[i]);
+               target_buffer_set_u32_array(target, dcc_code_buf, 
ARRAY_SIZE(dcc_code), dcc_code);
 
                /* write DCC code to working area, using the non-optimized
                 * memory write to avoid ending up here again */
diff --git a/src/target/feroceon.c b/src/target/feroceon.c
index acaa1b3..ee0bafd 100644
--- a/src/target/feroceon.c
+++ b/src/target/feroceon.c
@@ -510,8 +510,7 @@ static int feroceon_bulk_write_memory(struct target *target,
                }
 
                /* copy target instructions to target endianness */
-               for (i = 0; i < dcc_size/4; i++)
-                       target_buffer_set_u32(target, dcc_code_buf + i*4, 
dcc_code[i]);
+               target_buffer_set_u32_array(target, dcc_code_buf, 
ARRAY_SIZE(dcc_code), dcc_code);
 
                /* write DCC code to working area, using the non-optimized
                 * memory write to avoid ending up here again */

-- 

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to