From ef139a3a5e41fbcbabdf4be0ecbbb5591448ad2e Mon Sep 17 00:00:00 2001 From: drath Date: Fri, 23 Jun 2006 07:54:01 +0000 Subject: - added support for AT91SAM7A3 flash (patch from andre renaud, thanks) - fix trunk build for mac os x (patch from Lauri Leukkunen, thanks) - added check for host endianness, defines WORDS_BIGENDIAN on a big-endian host (e.g. mac os-x) - fixed bug where endianness of memory accesses could be swapped on BE hosts - added space for zero termination of ftd2xx_layout string (from Magnus Ludin, tahnks) git-svn-id: svn://svn.berlios.de/openocd/trunk@73 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/target/target.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/target/target.c') diff --git a/src/target/target.c b/src/target/target.c index 98407afb..34dc60a7 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -111,6 +111,42 @@ enum daemon_startup_mode startup_mode = DAEMON_ATTACH; static int target_continous_poll = 1; +/* read a u32 from a buffer in target memory endianness */ +u32 target_buffer_get_u32(target_t *target, u8 *buffer) +{ + if (target->endianness == TARGET_LITTLE_ENDIAN) + return le_to_h_u32(buffer); + else + return be_to_h_u32(buffer); +} + +/* read a u16 from a buffer in target memory endianness */ +u16 target_buffer_get_u16(target_t *target, u8 *buffer) +{ + if (target->endianness == TARGET_LITTLE_ENDIAN) + return le_to_h_u16(buffer); + else + return be_to_h_u16(buffer); +} + +/* write a u32 to a buffer in target memory endianness */ +void target_buffer_set_u32(target_t *target, u8 *buffer, u32 value) +{ + if (target->endianness == TARGET_LITTLE_ENDIAN) + h_u32_to_le(buffer, value); + else + h_u32_to_be(buffer, value); +} + +/* write a u16 to a buffer in target memory endianness */ +void target_buffer_set_u16(target_t *target, u8 *buffer, u16 value) +{ + if (target->endianness == TARGET_LITTLE_ENDIAN) + h_u16_to_le(buffer, value); + else + h_u16_to_be(buffer, value); +} + /* returns a pointer to the n-th configured target */ target_t* get_target_by_num(int num) { -- cgit v1.2.3