mips32: add fastdata loader working area

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>
This commit is contained in:
Spencer Oliver
2011-01-04 12:29:49 +00:00
parent dc1c5a7500
commit 0cd84000da
6 changed files with 29 additions and 11 deletions

View 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;
}