summaryrefslogtreecommitdiff
path: root/src/target/mips_m4k.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/target/mips_m4k.c')
-rw-r--r--src/target/mips_m4k.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index c0adc066..8afee9cd 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -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;
}