summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-06-28 10:32:58 +0000
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-06-28 10:32:58 +0000
commit32c6d70f6acd41dd1af5ea73051dd6c8a46eac14 (patch)
tree7e9cf887c56d41c12cc894f95481c7aa85ddb73e /src/helper
parent8c290412d28f9eef568dac0cfc20ccd4a9eca4d5 (diff)
downloadopenocd+libswd-32c6d70f6acd41dd1af5ea73051dd6c8a46eac14.tar.gz
openocd+libswd-32c6d70f6acd41dd1af5ea73051dd6c8a46eac14.tar.bz2
openocd+libswd-32c6d70f6acd41dd1af5ea73051dd6c8a46eac14.tar.xz
openocd+libswd-32c6d70f6acd41dd1af5ea73051dd6c8a46eac14.zip
- fixed endianness helper macros (thanks to obilix and wiml for finding and fixing this bug)
- added declarations for 32bit fileio access functions (network byte order) - fixed bug in etm trace dump file handling - added XScale trace buffer decoding - fixed arm_simulator ERROR numbers (-7xx used twice) - fixed minor bug in debug output in stellaris.c git-svn-id: svn://svn.berlios.de/openocd/trunk@178 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/fileio.h2
-rw-r--r--src/helper/types.h28
2 files changed, 16 insertions, 14 deletions
diff --git a/src/helper/fileio.h b/src/helper/fileio.h
index 55e6f323..5c0a88da 100644
--- a/src/helper/fileio.h
+++ b/src/helper/fileio.h
@@ -82,6 +82,8 @@ extern int fileio_read(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_read);
extern int fileio_seek(fileio_t *fileio, u32 position);
extern int fileio_close(fileio_t *fileio);
extern int fileio_open(fileio_t *fileio, char *url, enum fileio_access access, enum fileio_type type);
+extern int fileio_read_u32(fileio_t *fileio, u32 *data);
+extern int fileio_write_u32(fileio_t *fileio, u32 data);
#define ERROR_FILEIO_LOCATION_UNKNOWN (-1200)
#define ERROR_FILEIO_NOT_FOUND (-1201)
diff --git a/src/helper/types.h b/src/helper/types.h
index 69cb16a2..a68c301e 100644
--- a/src/helper/types.h
+++ b/src/helper/types.h
@@ -40,23 +40,23 @@ typedef unsigned long long u64;
#ifdef WORDS_BIGENDIAN /* big endian host */
-#define le_to_h_u32(x) (u32)(x[0] | x[1] << 8 | x[2] << 16 | x[3] << 24)
-#define le_to_h_u16(x) (u16)(x[0] | x[1] << 8)
+#define le_to_h_u32(x) (u32)((x)[0] | (x)[1] << 8 | (x)[2] << 16 | (x)[3] << 24)
+#define le_to_h_u16(x) (u16)((x)[0] | (x)[1] << 8)
#define be_to_h_u32(x) (*(u32*)(x))
#define be_to_h_u16(x) (*(u16*)(x))
#define h_u32_to_le(buf, val) \
do { \
- buf[3] = (val & 0xff000000) >> 24; \
- buf[2] = (val & 0x00ff0000) >> 16; \
- buf[1] = (val & 0x0000ff00) >> 8; \
- buf[0] = (val & 0x000000ff); \
+ (buf)[3] = ((val) & 0xff000000) >> 24; \
+ (buf)[2] = ((val) & 0x00ff0000) >> 16; \
+ (buf)[1] = ((val) & 0x0000ff00) >> 8; \
+ (buf)[0] = ((val) & 0x000000ff); \
} while (0)
#define h_u16_to_le(buf, val) \
do { \
- buf[0] = (val & 0xff000) >> 8; \
- buf[1] = (val & 0x00ff); \
+ (buf)[0] = ((val) & 0xff000) >> 8; \
+ (buf)[1] = ((val) & 0x00ff); \
} while (0)
#define h_u32_to_be(buf, val) do { *(u32*)(buf) = (val); } while (0)
@@ -73,16 +73,16 @@ typedef unsigned long long u64;
#define h_u32_to_be(buf, val) \
do { \
- buf[0] = (val & 0xff000000) >> 24; \
- buf[1] = (val & 0x00ff0000) >> 16; \
- buf[2] = (val & 0x0000ff00) >> 8; \
- buf[3] = (val & 0x000000ff); \
+ (buf)[0] = ((val) & 0xff000000) >> 24; \
+ (buf)[1] = ((val) & 0x00ff0000) >> 16; \
+ (buf)[2] = ((val) & 0x0000ff00) >> 8; \
+ (buf)[3] = ((val) & 0x000000ff); \
} while (0)
#define h_u16_to_be(buf, val) \
do { \
- buf[0] = (val & 0xff000) >> 8; \
- buf[1] = (val & 0x00ff); \
+ (buf)[0] = ((val) & 0xff000) >> 8; \
+ (buf)[1] = ((val) & 0x00ff); \
} while (0)
#endif