types: write memory now uses const
[openocd.git] / src / target / mips_m4k.c
index 8afee9cd66a7a19aab138a21c27c1052430acd5a..10d3c7da4d0b448ef8bdb7b61527fe38f581da08 100644 (file)
@@ -421,7 +421,11 @@ static int mips_m4k_step(struct target *target, int current,
 
        /* current = 1: continue on current pc, otherwise continue at <address> */
        if (!current)
+       {
                buf_set_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32, address);
+               mips32->core_cache->reg_list[MIPS32_PC].dirty = 1;
+               mips32->core_cache->reg_list[MIPS32_PC].valid = 1;
+       }
 
        /* the front-end may request us not to handle breakpoints */
        if (handle_breakpoints) {
@@ -868,7 +872,7 @@ static int mips_m4k_read_memory(struct target *target, uint32_t address,
 }
 
 static int mips_m4k_write_memory(struct target *target, uint32_t address,
-               uint32_t size, uint32_t count, uint8_t *buffer)
+               uint32_t size, uint32_t count, const uint8_t *buffer)
 {
        struct mips32_common *mips32 = target_to_mips32(target);
        struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
@@ -936,7 +940,9 @@ static int mips_m4k_examine(struct target *target)
 
        if (!target_was_examined(target))
        {
-               mips_ejtag_get_idcode(ejtag_info, &idcode);
+               retval = mips_ejtag_get_idcode(ejtag_info, &idcode);
+               if (retval != ERROR_OK)
+                       return retval;
                ejtag_info->idcode = idcode;
 
                if (((idcode >> 1) & 0x7FF) == 0x29)
@@ -960,7 +966,7 @@ static int mips_m4k_examine(struct target *target)
 }
 
 static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address,
-               uint32_t count, uint8_t *buffer)
+               uint32_t count, const uint8_t *buffer)
 {
        struct mips32_common *mips32 = target_to_mips32(target);
        struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
@@ -998,19 +1004,34 @@ static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address,
                ejtag_info->fast_access_save = -1;
        }
 
+       uint8_t * t = NULL;
+
        /* TAP data register is loaded LSB first (little endian) */
        if (target->endianness == TARGET_BIG_ENDIAN)
        {
+               t = malloc(count * sizeof(uint32_t));
+               if (t == NULL)
+               {
+                       LOG_ERROR("Out of memory");
+                       return ERROR_FAIL;
+               }
+
                uint32_t i, t32;
                for(i = 0; i < (count * 4); i += 4)
                {
                        t32 = be_to_h_u32((uint8_t *) &buffer[i]);
-                       h_u32_to_le(&buffer[i], t32);
+                       h_u32_to_le(&t[i], t32);
                }
+
+               buffer = t;
        }
 
        retval = mips32_pracc_fastdata_xfer(ejtag_info, mips32->fast_data_area, write_t, address,
                        count, (uint32_t*) (void *)buffer);
+
+       if (t != NULL)
+               free(t);
+
        if (retval != ERROR_OK)
        {
                /* FASTDATA access failed, try normal memory write */

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)