arm7_9: Fix broken halfword/byte memory reads
Always scan out all bits, but make sure only the allowed number of bytes end up in the caller-provided buffer. Discard the rest by adding another scan field when size < 4. Rewrite the endianness callback to avoid reading outside allocated memory. Make it directly usable as a callback without the need for a wrapper. Move the shared callback to a more suitable home in arm7_9_common. This fixes the regressions introduced in commits991ed5a2b6cb90d32e38andc3074f377cChange-Id: Ia8bde8c5a9844e89a1d6c0bc8534cd26f02f8d11 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/789 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
This commit is contained in:
committed by
Freddie Chopin
parent
47728f9215
commit
0989cd4d5d
@@ -2659,6 +2659,46 @@ int arm7_9_check_reset(struct target *target)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int arm7_9_endianness_callback(jtag_callback_data_t pu8_in,
|
||||
jtag_callback_data_t i_size, jtag_callback_data_t i_be,
|
||||
jtag_callback_data_t i_flip)
|
||||
{
|
||||
uint8_t *in = (uint8_t *)pu8_in;
|
||||
int size = (int)i_size;
|
||||
int be = (int)i_be;
|
||||
int flip = (int)i_flip;
|
||||
uint32_t readback;
|
||||
|
||||
switch (size) {
|
||||
case 4:
|
||||
readback = le_to_h_u32(in);
|
||||
if (flip)
|
||||
readback = flip_u32(readback, 32);
|
||||
if (be)
|
||||
h_u32_to_be(in, readback);
|
||||
else
|
||||
h_u32_to_le(in, readback);
|
||||
break;
|
||||
case 2:
|
||||
readback = le_to_h_u16(in);
|
||||
if (flip)
|
||||
readback = flip_u32(readback, 16);
|
||||
if (be)
|
||||
h_u16_to_be(in, readback & 0xffff);
|
||||
else
|
||||
h_u16_to_le(in, readback & 0xffff);
|
||||
break;
|
||||
case 1:
|
||||
readback = *in;
|
||||
if (flip)
|
||||
readback = flip_u32(readback, 8);
|
||||
*in = readback & 0xff;
|
||||
break;
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
COMMAND_HANDLER(handle_arm7_9_dbgrq_command)
|
||||
{
|
||||
struct target *target = get_current_target(CMD_CTX);
|
||||
|
||||
Reference in New Issue
Block a user