mips32: add fastdata loader working area
authorSpencer Oliver <ntfreak@users.sourceforge.net>
Tue, 4 Jan 2011 12:29:49 +0000 (12:29 +0000)
committerSpencer Oliver <ntfreak@users.sourceforge.net>
Tue, 4 Jan 2011 12:29:49 +0000 (12:29 +0000)
Add a working area that is preserved between calls to
mips_m4k_bulk_write_memory - this gives us a speed increase
of approx 3kb/sec during flash writes to the pic32mx.

This area is released during a resume/reset.

Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
src/target/mips32.c
src/target/mips32.h
src/target/mips32_pracc.c
src/target/mips_ejtag.c
src/target/mips_ejtag.h
src/target/mips_m4k.c

index 533701aaafde0e35f9c0053d34c6be7842e43920..e48a040cec6c9228adc30bfae344af79eb3edab5 100644 (file)
@@ -309,6 +309,7 @@ int mips32_init_arch_info(struct target *target, struct mips32_common *mips32, s
 {
        target->arch_info = mips32;
        mips32->common_magic = MIPS32_COMMON_MAGIC;
+       mips32->fast_data_area = NULL;
 
        /* has breakpoint/watchpint unit been scanned */
        mips32->bp_scanned = 0;
index 7ffe95fc0ff5a72e0871afac54882f0cd4839ac3..0d544a406958f78960fef8195e7eeee639053390 100644 (file)
@@ -57,6 +57,9 @@ struct mips32_common
        uint32_t core_regs[MIPS32NUMCOREREGS];
        enum mips32_isa_mode isa_mode;
 
+       /* working area for fastdata access */
+       struct working_area *fast_data_area;
+
        int bp_scanned;
        int num_inst_bpoints;
        int num_data_bpoints;
index 236f389466a44811c48e14968a9387f6959b4011..a4ea2d363f420d8403a8f8e452b65fa2004c42cd 100644 (file)
@@ -985,7 +985,12 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are
        }
 
        /* write program into RAM */
-       mips32_pracc_write_mem32(ejtag_info, source->address, ARRAY_SIZE(handler_code), handler_code);
+       if (write_t != ejtag_info->fast_access_save)
+       {
+               mips32_pracc_write_mem32(ejtag_info, source->address, ARRAY_SIZE(handler_code), handler_code);
+               /* save previous operation to speed to any consecutive read/writes */
+               ejtag_info->fast_access_save = write_t;
+       }
 
        LOG_DEBUG("%s using 0x%.8" PRIx32 " for write handler", __func__, source->address);
 
index 33507b5534c61af84822b1228894c40f84cd8817..e3810639ce81b474e63f200e6a0b4420118e2c7b 100644 (file)
@@ -300,6 +300,7 @@ int mips_ejtag_init(struct mips_ejtag *ejtag_info)
 
        /* set initial state for ejtag control reg */
        ejtag_info->ejtag_ctrl = EJTAG_CTRL_ROCC | EJTAG_CTRL_PRACC | EJTAG_CTRL_PROBEN | EJTAG_CTRL_SETDEV;
+       ejtag_info->fast_access_save = -1;
 
        return ERROR_OK;
 }
index a4430b6e9c8fca5e4fce9f468d0e4f61c738a374..0db0504a79dbb36d3cd0046d1793ea56ea1497bf 100644 (file)
@@ -128,6 +128,7 @@ struct mips_ejtag
        uint32_t impcode;
        uint32_t idcode;
        uint32_t ejtag_ctrl;
+       int fast_access_save;
 };
 
 int mips_ejtag_set_instr(struct mips_ejtag *ejtag_info,
index c0adc066e81d7c9ad7f6093ebbeaf2978fde5659..8afee9cd66a7a19aab138a21c27c1052430acd5a 100644 (file)
@@ -964,7 +964,6 @@ static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address,
 {
        struct mips32_common *mips32 = target_to_mips32(target);
        struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
-       struct working_area *source;
        int retval;
        int write_t = 1;
 
@@ -980,12 +979,23 @@ static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address,
        if (address & 0x3u)
                return ERROR_TARGET_UNALIGNED_ACCESS;
 
-       /* Get memory for block write handler */
-       retval = target_alloc_working_area(target, MIPS32_FASTDATA_HANDLER_SIZE, &source);
-       if (retval != ERROR_OK)
+       if (mips32->fast_data_area == NULL)
        {
-               LOG_WARNING("No working area available, falling back to non-bulk write");
-               return mips_m4k_write_memory(target, address, 4, count, buffer);
+               /* Get memory for block write handler
+                * we preserve this area between calls and gain a speed increase
+                * of about 3kb/sec when writing flash
+                * this will be released/nulled by the system when the target is resumed or reset */
+               retval = target_alloc_working_area(target,
+                               MIPS32_FASTDATA_HANDLER_SIZE,
+                               &mips32->fast_data_area);
+               if (retval != ERROR_OK)
+               {
+                       LOG_WARNING("No working area available, falling back to non-bulk write");
+                       return mips_m4k_write_memory(target, address, 4, count, buffer);
+               }
+
+               /* reset fastadata state so the algo get reloaded */
+               ejtag_info->fast_access_save = -1;
        }
 
        /* TAP data register is loaded LSB first (little endian) */
@@ -999,7 +1009,7 @@ static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address,
                }
        }
 
-       retval = mips32_pracc_fastdata_xfer(ejtag_info, source, write_t, address,
+       retval = mips32_pracc_fastdata_xfer(ejtag_info, mips32->fast_data_area, write_t, address,
                        count, (uint32_t*) (void *)buffer);
        if (retval != ERROR_OK)
        {
@@ -1008,9 +1018,6 @@ static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address,
                retval = mips_m4k_write_memory(target, address, 4, count, buffer);
        }
 
-       if (source)
-               target_free_working_area(target, source);
-
        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)