This is an automated email from Gerrit.

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

-- gerrit

commit 0a34f3c861ffb7c1454bcd7f7bdb8d9d3d3fa7b7
Author: Oleksij Rempel <[email protected]>
Date:   Mon May 18 09:53:10 2015 +0200

    cortex_a: add cortex_a_[read|write]_buffer
    
    Change-Id: I82011822d913aa7228f5c6262b540156494bedfe
    Signed-off-by: Oleksij Rempel <[email protected]>

diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index df6c0d2..e160b7d 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -2714,6 +2714,74 @@ static int cortex_a_write_memory(struct target *target, 
uint32_t address,
        return retval;
 }
 
+static int cortex_a_read_buffer(struct target *target, uint32_t address,
+                               uint32_t count, uint8_t *buffer)
+{
+       uint32_t size;
+
+       /* Align up to maximum 4 bytes. The loop condition makes sure the next 
pass
+        * will have something to do with the size we leave to it. */
+       for (size = 1; size < 4 && count >= size * 2 + (address & size); size 
*= 2) {
+               if (address & size) {
+                       int retval = target_read_memory(target, address, size, 
1, buffer);
+                       if (retval != ERROR_OK)
+                               return retval;
+                       address += size;
+                       count -= size;
+                       buffer += size;
+               }
+       }
+
+       /* Read the data with as large access size as possible. */
+       for (; size > 0; size /= 2) {
+               uint32_t aligned = count - count % size;
+               if (aligned > 0) {
+                       int retval = target_read_memory(target, address, size, 
aligned / size, buffer);
+                       if (retval != ERROR_OK)
+                               return retval;
+                       address += aligned;
+                       count -= aligned;
+                       buffer += aligned;
+               }
+       }
+
+       return ERROR_OK;
+}
+
+static int cortex_a_write_buffer(struct target *target, uint32_t address,
+                                uint32_t count, const uint8_t *buffer)
+{
+       uint32_t size;
+
+       /* Align up to maximum 4 bytes. The loop condition makes sure the next 
pass
+        * will have something to do with the size we leave to it. */
+       for (size = 1; size < 4 && count >= size * 2 + (address & size); size 
*= 2) {
+               if (address & size) {
+                       int retval = target_write_memory(target, address, size, 
1, buffer);
+                       if (retval != ERROR_OK)
+                               return retval;
+                       address += size;
+                       count -= size;
+                       buffer += size;
+               }
+       }
+
+       /* Write the data with as large access size as possible. */
+       for (; size > 0; size /= 2) {
+               uint32_t aligned = count - count % size;
+               if (aligned > 0) {
+                       int retval = target_write_memory(target, address, size, 
aligned / size, buffer);
+                       if (retval != ERROR_OK)
+                               return retval;
+                       address += aligned;
+                       count -= aligned;
+                       buffer += aligned;
+               }
+       }
+
+       return ERROR_OK;
+}
+
 static int cortex_a_handle_target_request(void *priv)
 {
        struct target *target = priv;
@@ -3194,6 +3262,9 @@ struct target_type cortexa_target = {
        .read_memory = cortex_a_read_memory,
        .write_memory = cortex_a_write_memory,
 
+       .read_buffer = cortex_a_read_buffer,
+       .write_buffer = cortex_a_write_buffer,
+
        .checksum_memory = arm_checksum_memory,
        .blank_check_memory = arm_blank_check_memory,
 

-- 

------------------------------------------------------------------------------
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to