Cosmetic cleanup of dm_*() calls in riscv-013.c
Cleanup, non-functional changes: - Replaced one call of low-level function dm_op() by high-level dm_read(). - Made sure that truncation of values passed to dm_* is explicit. (Added explicit casts.) Change-Id: I1d1b2f29a822b6841373f3313de2b1e96f514116 Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
This commit is contained in:
parent
87331a82a2
commit
0e03f9bf0a
|
@ -955,10 +955,10 @@ static int write_abstract_arg(struct target *target, unsigned index,
|
||||||
LOG_TARGET_ERROR(target, "Unsupported size: %d bits", size_bits);
|
LOG_TARGET_ERROR(target, "Unsupported size: %d bits", size_bits);
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
case 64:
|
case 64:
|
||||||
dm_write(target, DM_DATA0 + offset + 1, value >> 32);
|
dm_write(target, DM_DATA0 + offset + 1, (uint32_t)(value >> 32));
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 32:
|
case 32:
|
||||||
dm_write(target, DM_DATA0 + offset, value);
|
dm_write(target, DM_DATA0 + offset, (uint32_t)value);
|
||||||
}
|
}
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
@ -1388,12 +1388,12 @@ static int scratch_write64(struct target *target, scratch_mem_t *scratch,
|
||||||
{
|
{
|
||||||
switch (scratch->memory_space) {
|
switch (scratch->memory_space) {
|
||||||
case SPACE_DM_DATA:
|
case SPACE_DM_DATA:
|
||||||
dm_write(target, DM_DATA0 + scratch->debug_address, value);
|
dm_write(target, DM_DATA0 + scratch->debug_address, (uint32_t)value);
|
||||||
dm_write(target, DM_DATA1 + scratch->debug_address, value >> 32);
|
dm_write(target, DM_DATA1 + scratch->debug_address, (uint32_t)(value >> 32));
|
||||||
break;
|
break;
|
||||||
case SPACE_DMI_PROGBUF:
|
case SPACE_DMI_PROGBUF:
|
||||||
dm_write(target, DM_PROGBUF0 + scratch->debug_address, value);
|
dm_write(target, DM_PROGBUF0 + scratch->debug_address, (uint32_t)value);
|
||||||
dm_write(target, DM_PROGBUF1 + scratch->debug_address, value >> 32);
|
dm_write(target, DM_PROGBUF1 + scratch->debug_address, (uint32_t)(value >> 32));
|
||||||
riscv013_invalidate_cached_progbuf(target);
|
riscv013_invalidate_cached_progbuf(target);
|
||||||
break;
|
break;
|
||||||
case SPACE_DMI_RAM:
|
case SPACE_DMI_RAM:
|
||||||
|
@ -2483,9 +2483,10 @@ static int sb_write_address(struct target *target, target_addr_t address,
|
||||||
if (sbasize > 64)
|
if (sbasize > 64)
|
||||||
dm_op(target, NULL, NULL, DMI_OP_WRITE, DM_SBADDRESS2, 0, false, false);
|
dm_op(target, NULL, NULL, DMI_OP_WRITE, DM_SBADDRESS2, 0, false, false);
|
||||||
if (sbasize > 32)
|
if (sbasize > 32)
|
||||||
dm_op(target, NULL, NULL, DMI_OP_WRITE, DM_SBADDRESS1, address >> 32, false, false);
|
dm_op(target, NULL, NULL, DMI_OP_WRITE, DM_SBADDRESS1,
|
||||||
return dm_op(target, NULL, NULL, DMI_OP_WRITE, DM_SBADDRESS0, address,
|
(uint32_t)(address >> 32), false, false);
|
||||||
false, ensure_success);
|
return dm_op(target, NULL, NULL, DMI_OP_WRITE, DM_SBADDRESS0,
|
||||||
|
(uint32_t)address, false, ensure_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int batch_run(const struct target *target, struct riscv_batch *batch)
|
static int batch_run(const struct target *target, struct riscv_batch *batch)
|
||||||
|
@ -3028,7 +3029,7 @@ static int read_memory_bus_word(struct target *target, target_addr_t address,
|
||||||
static int sbdata[4] = { DM_SBDATA0, DM_SBDATA1, DM_SBDATA2, DM_SBDATA3 };
|
static int sbdata[4] = { DM_SBDATA0, DM_SBDATA1, DM_SBDATA2, DM_SBDATA3 };
|
||||||
assert(size <= 16);
|
assert(size <= 16);
|
||||||
for (int i = (size - 1) / 4; i >= 0; i--) {
|
for (int i = (size - 1) / 4; i >= 0; i--) {
|
||||||
result = dm_op(target, &sbvalue[i], NULL, DMI_OP_READ, sbdata[i], 0, false, true);
|
result = dm_read(target, &sbvalue[i], sbdata[i]);
|
||||||
if (result != ERROR_OK)
|
if (result != ERROR_OK)
|
||||||
return result;
|
return result;
|
||||||
buf_set_u32(buffer + i * 4, 0, 8 * MIN(size, 4), sbvalue[i]);
|
buf_set_u32(buffer + i * 4, 0, 8 * MIN(size, 4), sbvalue[i]);
|
||||||
|
|
Loading…
Reference in New Issue