Further cleanup to MIPS target read/write memory function:
- Move the mips32_..._read_mem calls to top-level of read_mem function. - Change: Only perform mips_m4k_read_mem conversion when retval == ERROR_OK. - Prevents pointless conversions of bogus read values after failures. - Eliminate retval variable from mips_m4k_write_mem; return directly. - Move declaration of retval variable to point of first use. - Remove the now redundant switch statements testing size: - argument sanitizing already covers these cases. git-svn-id: svn://svn.berlios.de/openocd/trunk@2220 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
parent
c6e80f63a3
commit
7fdce0e8bc
|
@ -732,7 +732,6 @@ int mips_m4k_read_memory(struct target_s *target, u32 address, u32 size, u32 cou
|
||||||
{
|
{
|
||||||
mips32_common_t *mips32 = target->arch_info;
|
mips32_common_t *mips32 = target->arch_info;
|
||||||
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
|
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
|
||||||
int retval;
|
|
||||||
|
|
||||||
LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
|
LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
|
||||||
|
|
||||||
|
@ -749,22 +748,14 @@ int mips_m4k_read_memory(struct target_s *target, u32 address, u32 size, u32 cou
|
||||||
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
|
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
|
||||||
return ERROR_TARGET_UNALIGNED_ACCESS;
|
return ERROR_TARGET_UNALIGNED_ACCESS;
|
||||||
|
|
||||||
switch (size)
|
/* if noDMA off, use DMAACC mode for memory read */
|
||||||
{
|
int retval;
|
||||||
case 4:
|
if(ejtag_info->impcode & EJTAG_IMP_NODMA)
|
||||||
case 2:
|
retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
|
||||||
case 1:
|
else
|
||||||
/* if noDMA off, use DMAACC mode for memory read */
|
retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer);
|
||||||
if(ejtag_info->impcode & EJTAG_IMP_NODMA)
|
if (ERROR_OK != retval)
|
||||||
retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
|
return retval;
|
||||||
else
|
|
||||||
retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG_ERROR("BUG: we shouldn't get here");
|
|
||||||
exit(-1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TAP data register is loaded LSB first (little endian) */
|
/* TAP data register is loaded LSB first (little endian) */
|
||||||
if (target->endianness == TARGET_BIG_ENDIAN)
|
if (target->endianness == TARGET_BIG_ENDIAN)
|
||||||
|
@ -787,15 +778,14 @@ int mips_m4k_read_memory(struct target_s *target, u32 address, u32 size, u32 cou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer)
|
int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer)
|
||||||
{
|
{
|
||||||
mips32_common_t *mips32 = target->arch_info;
|
mips32_common_t *mips32 = target->arch_info;
|
||||||
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
|
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
|
||||||
int retval;
|
|
||||||
|
|
||||||
LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
|
LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
|
||||||
|
|
||||||
|
@ -812,19 +802,6 @@ int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 co
|
||||||
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
|
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
|
||||||
return ERROR_TARGET_UNALIGNED_ACCESS;
|
return ERROR_TARGET_UNALIGNED_ACCESS;
|
||||||
|
|
||||||
switch (size)
|
|
||||||
{
|
|
||||||
case 4:
|
|
||||||
case 2:
|
|
||||||
case 1:
|
|
||||||
/* if noDMA off, use DMAACC mode for memory write */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG_ERROR("BUG: we shouldn't get here");
|
|
||||||
exit(-1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TAP data register is loaded LSB first (little endian) */
|
/* TAP data register is loaded LSB first (little endian) */
|
||||||
if (target->endianness == TARGET_BIG_ENDIAN)
|
if (target->endianness == TARGET_BIG_ENDIAN)
|
||||||
{
|
{
|
||||||
|
@ -847,13 +824,11 @@ int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if noDMA off, use DMAACC mode for memory write */
|
||||||
if(ejtag_info->impcode & EJTAG_IMP_NODMA)
|
if(ejtag_info->impcode & EJTAG_IMP_NODMA)
|
||||||
retval = mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
|
return mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
|
||||||
else
|
else
|
||||||
retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
|
return mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
|
||||||
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mips_m4k_register_commands(struct command_context_s *cmd_ctx)
|
int mips_m4k_register_commands(struct command_context_s *cmd_ctx)
|
||||||
|
|
Loading…
Reference in New Issue