Commit 0cd84000 authored by Spencer Oliver's avatar Spencer Oliver
Browse files

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: default avatarSpencer Oliver <ntfreak@users.sourceforge.net>
parent dc1c5a75
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment