forked from auracaster/openocd
target: or1k: remove wrong endian swap from or1k generic code
We don't need to swap the endianness in the target generic code. This swap is necessary because of the adv_debug_if debug unit. This patch moves this specific piece of code from or1k.c to or1k_du_adv.c. Change-Id: I3acea092fe6edfa79b4a87861b5f01204f071bf0 Signed-off-by: Franck Jullien <franck.jullien@gmail.com> Reviewed-on: http://openocd.zylin.com/1663 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
This commit is contained in:
committed by
Andreas Fritiofson
parent
c8c10f77dc
commit
ae3baa9d5a
@@ -846,7 +846,7 @@ static int or1k_adv_jtag_read_memory(struct or1k_jtag *jtag_info,
|
||||
|
||||
int block_count_left = count;
|
||||
uint32_t block_count_address = addr;
|
||||
uint8_t *block_count_buffer = (uint8_t *)buffer;
|
||||
uint8_t *block_count_buffer = buffer;
|
||||
|
||||
while (block_count_left) {
|
||||
|
||||
@@ -863,6 +863,23 @@ static int or1k_adv_jtag_read_memory(struct or1k_jtag *jtag_info,
|
||||
block_count_buffer += size * MAX_BURST_SIZE;
|
||||
}
|
||||
|
||||
/* The adv_debug_if always return words and half words in
|
||||
* little-endian order no matter what the target endian is.
|
||||
* So if the target endian is big, change the order.
|
||||
*/
|
||||
|
||||
struct target *target = jtag_info->target;
|
||||
if ((target->endianness == TARGET_BIG_ENDIAN) && (size != 1)) {
|
||||
switch (size) {
|
||||
case 4:
|
||||
buf_bswap32(buffer, buffer, size * count);
|
||||
break;
|
||||
case 2:
|
||||
buf_bswap16(buffer, buffer, size * count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -882,6 +899,31 @@ static int or1k_adv_jtag_write_memory(struct or1k_jtag *jtag_info,
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
/* The adv_debug_if wants words and half words in little-endian
|
||||
* order no matter what the target endian is. So if the target
|
||||
* endian is big, change the order.
|
||||
*/
|
||||
|
||||
void *t = NULL;
|
||||
struct target *target = jtag_info->target;
|
||||
if ((target->endianness == TARGET_BIG_ENDIAN) && (size != 1)) {
|
||||
t = malloc(count * size * sizeof(uint8_t));
|
||||
if (t == NULL) {
|
||||
LOG_ERROR("Out of memory");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
switch (size) {
|
||||
case 4:
|
||||
buf_bswap32(t, buffer, size * count);
|
||||
break;
|
||||
case 2:
|
||||
buf_bswap16(t, buffer, size * count);
|
||||
break;
|
||||
}
|
||||
buffer = t;
|
||||
}
|
||||
|
||||
int block_count_left = count;
|
||||
uint32_t block_count_address = addr;
|
||||
uint8_t *block_count_buffer = (uint8_t *)buffer;
|
||||
@@ -894,14 +936,20 @@ static int or1k_adv_jtag_write_memory(struct or1k_jtag *jtag_info,
|
||||
retval = adbg_wb_burst_write(jtag_info, block_count_buffer,
|
||||
size, blocks_this_round,
|
||||
block_count_address);
|
||||
if (retval != ERROR_OK)
|
||||
if (retval != ERROR_OK) {
|
||||
if (t != NULL)
|
||||
free(t);
|
||||
return retval;
|
||||
}
|
||||
|
||||
block_count_left -= blocks_this_round;
|
||||
block_count_address += size * MAX_BURST_SIZE;
|
||||
block_count_buffer += size * MAX_BURST_SIZE;
|
||||
}
|
||||
|
||||
if (t != NULL)
|
||||
free(t);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user