target: Retire target_bulk_write_memory()
[openocd.git] / src / flash / nand / arm_io.c
index 7c7148e6be1ba317fb6298bc84fec77315e210c8..aab1d050f4bc8a75d6e93b5bca13f34ef47d3c58 100644 (file)
@@ -30,7 +30,6 @@
 #include <target/arm.h>
 #include <target/algorithm.h>
 
-
 /**
  * Copies code to a working area.  This will allocate room for the code plus the
  * additional amount requested if the working area pointer is null.
@@ -44,8 +43,8 @@
  * @return Success or failure of the operation
  */
 static int arm_code_to_working_area(struct target *target,
-               const uint32_t *code, unsigned code_size,
-               unsigned additional, struct working_area **area)
+       const uint32_t *code, unsigned code_size,
+       unsigned additional, struct working_area **area)
 {
        uint8_t code_buf[code_size];
        unsigned i;
@@ -61,7 +60,7 @@ static int arm_code_to_working_area(struct target *target,
        if (NULL == *area) {
                retval = target_alloc_working_area(target, size, area);
                if (retval != ERROR_OK) {
-                       LOG_DEBUG("%s: no %d byte buffer", __FUNCTION__, (int) size);
+                       LOG_DEBUG("%s: no %d byte buffer", __func__, (int) size);
                        return ERROR_NAND_NO_BUFFER;
                }
        }
@@ -95,13 +94,13 @@ static int arm_code_to_working_area(struct target *target,
  */
 int arm_nandwrite(struct arm_nand_data *nand, uint8_t *data, int size)
 {
-       struct target           *target = nand->target;
-       struct arm_algorithm    algo;
-       struct arm              *armv4_5 = target->arch_info;
-       struct reg_param        reg_params[3];
-       uint32_t                target_buf;
-       uint32_t                exit = 0;
-       int                     retval;
+       struct target *target = nand->target;
+       struct arm_algorithm algo;
+       struct arm *arm = target->arch_info;
+       struct reg_param reg_params[3];
+       uint32_t target_buf;
+       uint32_t exit_var = 0;
+       int retval;
 
        /* Inputs:
         *  r0  NAND data address (byte wide)
@@ -121,20 +120,15 @@ int arm_nandwrite(struct arm_nand_data *nand, uint8_t *data, int size)
        if (nand->op != ARM_NAND_WRITE || !nand->copy_area) {
                retval = arm_code_to_working_area(target, code, sizeof(code),
                                nand->chunk_size, &nand->copy_area);
-               if (retval != ERROR_OK) {
+               if (retval != ERROR_OK)
                        return retval;
-               }
        }
 
        nand->op = ARM_NAND_WRITE;
 
        /* copy data to work area */
        target_buf = nand->copy_area->address + sizeof(code);
-       retval = target_bulk_write_memory(target, target_buf, size / 4, data);
-       if (retval == ERROR_OK && (size & 3) != 0)
-               retval = target_write_memory(target,
-                               target_buf + (size & ~3),
-                               1, size & 3, data + (size & ~3));
+       retval = target_write_buffer(target, target_buf, size, data);
        if (retval != ERROR_OK)
                return retval;
 
@@ -152,12 +146,12 @@ int arm_nandwrite(struct arm_nand_data *nand, uint8_t *data, int size)
        buf_set_u32(reg_params[2].value, 0, 32, size);
 
        /* armv4 must exit using a hardware breakpoint */
-       if (armv4_5->is_armv4)
-               exit = nand->copy_area->address + sizeof(code) - 4;
+       if (arm->is_armv4)
+               exit_var = nand->copy_area->address + sizeof(code) - 4;
 
        /* use alg to write data from work area to NAND chip */
        retval = target_run_algorithm(target, 0, NULL, 3, reg_params,
-                       nand->copy_area->address, exit, 1000, &algo);
+                       nand->copy_area->address, exit_var, 1000, &algo);
        if (retval != ERROR_OK)
                LOG_ERROR("error executing hosted NAND write");
 
@@ -181,10 +175,10 @@ int arm_nandread(struct arm_nand_data *nand, uint8_t *data, uint32_t size)
 {
        struct target *target = nand->target;
        struct arm_algorithm algo;
-       struct arm *armv4_5 = target->arch_info;
+       struct arm *arm = target->arch_info;
        struct reg_param reg_params[3];
        uint32_t target_buf;
-       uint32_t exit = 0;
+       uint32_t exit_var = 0;
        int retval;
 
        /* Inputs:
@@ -206,9 +200,8 @@ int arm_nandread(struct arm_nand_data *nand, uint8_t *data, uint32_t size)
        if (nand->op != ARM_NAND_READ || !nand->copy_area) {
                retval = arm_code_to_working_area(target, code, sizeof(code),
                                nand->chunk_size, &nand->copy_area);
-               if (retval != ERROR_OK) {
+               if (retval != ERROR_OK)
                        return retval;
-               }
        }
 
        nand->op = ARM_NAND_READ;
@@ -228,12 +221,12 @@ int arm_nandread(struct arm_nand_data *nand, uint8_t *data, uint32_t size)
        buf_set_u32(reg_params[2].value, 0, 32, size);
 
        /* armv4 must exit using a hardware breakpoint */
-       if (armv4_5->is_armv4)
-               exit = nand->copy_area->address + sizeof(code) - 4;
+       if (arm->is_armv4)
+               exit_var = nand->copy_area->address + sizeof(code) - 4;
 
        /* use alg to write data from NAND chip to work area */
        retval = target_run_algorithm(target, 0, NULL, 3, reg_params,
-                       nand->copy_area->address, exit, 1000, &algo);
+                       nand->copy_area->address, exit_var, 1000, &algo);
        if (retval != ERROR_OK)
                LOG_ERROR("error executing hosted NAND read");
 
@@ -246,4 +239,3 @@ int arm_nandread(struct arm_nand_data *nand, uint8_t *data, uint32_t size)
 
        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)