mips32, write handler code in a more compact way

Less code and probably cleaner.
Don't check if it is ever ERROR_OK.

Change-Id: I1045b58fd4542ec24430332f49679364ae97b1dc
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/4018
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
gitignore-build
Salvador Arroyo 2017-02-24 23:39:39 +01:00 committed by Freddie Chopin
parent bff6205bab
commit cb317eabf2
1 changed files with 17 additions and 29 deletions

View File

@ -921,7 +921,6 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are
int write_t, uint32_t addr, int count, uint32_t *buf) int write_t, uint32_t addr, int count, uint32_t *buf)
{ {
uint32_t handler_code[] = { uint32_t handler_code[] = {
/* caution when editing, table is modified below */
/* r15 points to the start of this code */ /* r15 points to the start of this code */
MIPS32_SW(8, MIPS32_FASTDATA_HANDLER_SIZE - 4, 15), MIPS32_SW(8, MIPS32_FASTDATA_HANDLER_SIZE - 4, 15),
MIPS32_SW(9, MIPS32_FASTDATA_HANDLER_SIZE - 8, 15), MIPS32_SW(9, MIPS32_FASTDATA_HANDLER_SIZE - 8, 15),
@ -933,8 +932,9 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are
MIPS32_LW(9, 0, 8), /* start addr in t1 */ MIPS32_LW(9, 0, 8), /* start addr in t1 */
MIPS32_LW(10, 0, 8), /* end addr to t2 */ MIPS32_LW(10, 0, 8), /* end addr to t2 */
/* loop: */ /* loop: */
/* 8 */ MIPS32_LW(11, 0, 0), /* lw t3,[t8 | r9] */ write_t ? MIPS32_LW(11, 0, 8) : MIPS32_LW(11, 0, 9), /* from xfer area : from memory */
/* 9 */ MIPS32_SW(11, 0, 0), /* sw t3,[r9 | r8] */ write_t ? MIPS32_SW(11, 0, 9) : MIPS32_SW(11, 0, 8), /* to memory : to xfer area */
MIPS32_BNE(10, 9, NEG16(3)), /* bne $t2,t1,loop */ MIPS32_BNE(10, 9, NEG16(3)), /* bne $t2,t1,loop */
MIPS32_ADDI(9, 9, 4), /* addi t1,t1,4 */ MIPS32_ADDI(9, 9, 4), /* addi t1,t1,4 */
@ -949,24 +949,9 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are
MIPS32_MFC0(15, 31, 0), /* move COP0 DeSave to $15 */ MIPS32_MFC0(15, 31, 0), /* move COP0 DeSave to $15 */
}; };
uint32_t jmp_code[] = {
/* 0 */ MIPS32_LUI(15, 0), /* addr of working area added below */
/* 1 */ MIPS32_ORI(15, 15, 0), /* addr of working area added below */
MIPS32_JR(15), /* jump to ram program */
MIPS32_NOP,
};
if (source->size < MIPS32_FASTDATA_HANDLER_SIZE) if (source->size < MIPS32_FASTDATA_HANDLER_SIZE)
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
if (write_t) {
handler_code[8] = MIPS32_LW(11, 0, 8); /* load data from probe at fastdata area */
handler_code[9] = MIPS32_SW(11, 0, 9); /* store data to RAM @ r9 */
} else {
handler_code[8] = MIPS32_LW(11, 0, 9); /* load data from RAM @ r9 */
handler_code[9] = MIPS32_SW(11, 0, 8); /* store data to probe at fastdata area */
}
/* write program into RAM */ /* write program into RAM */
if (write_t != ejtag_info->fast_access_save) { if (write_t != ejtag_info->fast_access_save) {
mips32_pracc_write_mem(ejtag_info, source->address, 4, ARRAY_SIZE(handler_code), handler_code); mips32_pracc_write_mem(ejtag_info, source->address, 4, ARRAY_SIZE(handler_code), handler_code);
@ -976,9 +961,14 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are
LOG_DEBUG("%s using 0x%.8" TARGET_PRIxADDR " for write handler", __func__, source->address); LOG_DEBUG("%s using 0x%.8" TARGET_PRIxADDR " for write handler", __func__, source->address);
jmp_code[0] |= UPPER16(source->address); uint32_t jmp_code[] = {
jmp_code[1] |= LOWER16(source->address); MIPS32_LUI(15, UPPER16(source->address)), /* load addr of jump in $15 */
MIPS32_ORI(15, 15, LOWER16(source->address)),
MIPS32_JR(15), /* jump to ram program */
MIPS32_NOP,
};
/* execute jump code, with no address check */
for (unsigned i = 0; i < ARRAY_SIZE(jmp_code); i++) { for (unsigned i = 0; i < ARRAY_SIZE(jmp_code); i++) {
int retval = wait_for_pracc_rw(ejtag_info); int retval = wait_for_pracc_rw(ejtag_info);
if (retval != ERROR_OK) if (retval != ERROR_OK)
@ -1020,9 +1010,7 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
jtag_add_clocks(num_clocks); jtag_add_clocks(num_clocks);
retval = mips_ejtag_fastdata_scan(ejtag_info, write_t, buf++); mips_ejtag_fastdata_scan(ejtag_info, write_t, buf++);
if (retval != ERROR_OK)
return retval;
} }
retval = jtag_execute_queue(); retval = jtag_execute_queue();