Browse Source

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>
tags/v0.5.0-rc1
Spencer Oliver 11 years ago
parent
commit
0cd84000da
6 changed files with 29 additions and 11 deletions
  1. +1
    -0
      src/target/mips32.c
  2. +3
    -0
      src/target/mips32.h
  3. +6
    -1
      src/target/mips32_pracc.c
  4. +1
    -0
      src/target/mips_ejtag.c
  5. +1
    -0
      src/target/mips_ejtag.h
  6. +17
    -10
      src/target/mips_m4k.c

+ 1
- 0
src/target/mips32.c View 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;


+ 3
- 0
src/target/mips32.h View 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;


+ 6
- 1
src/target/mips32_pracc.c View 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);



+ 1
- 0
src/target/mips_ejtag.c View 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;
}


+ 1
- 0
src/target/mips_ejtag.h View 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,


+ 17
- 10
src/target/mips_m4k.c 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;
}



Loading…
Cancel
Save