diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-05-07 14:25:34 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-05-07 14:25:34 +0000 |
commit | ee793f0fcbd2d7e4ad08e61d242ba178e8909b45 (patch) | |
tree | 772607aa303278b216305ccf40fc88d76511edf2 /src/helper | |
parent | a197e759ffcb047a383adf686966f68934fef206 (diff) | |
download | riscv-openocd-ee793f0fcbd2d7e4ad08e61d242ba178e8909b45.zip riscv-openocd-ee793f0fcbd2d7e4ad08e61d242ba178e8909b45.tar.gz riscv-openocd-ee793f0fcbd2d7e4ad08e61d242ba178e8909b45.tar.bz2 |
This matters for embedded devices, but is probably not observably better for PC hosted OpenOCD.
git-svn-id: svn://svn.berlios.de/openocd/trunk@647 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/binarybuffer.c | 37 | ||||
-rw-r--r-- | src/helper/binarybuffer.h | 43 | ||||
-rw-r--r-- | src/helper/log.h | 2 |
3 files changed, 42 insertions, 40 deletions
diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index 6aa847a..184d166 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -49,43 +49,6 @@ const unsigned char bit_reverse_table256[] = 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF }; -int buf_set_u32(u8* buffer, unsigned int first, unsigned int num, u32 value) -{ - unsigned int i; - - if (!buffer) - return ERROR_INVALID_ARGUMENTS; - - for (i=first; i<first+num; i++) - { - if (((value >> (i-first))&1) == 1) - buffer[i/8] |= 1 << (i%8); - else - buffer[i/8] &= ~(1 << (i%8)); - } - - return ERROR_OK; -} - -u32 buf_get_u32(u8* buffer, unsigned int first, unsigned int num) -{ - u32 result = 0; - unsigned int i; - - if (!buffer) - { - LOG_ERROR("buffer not initialized"); - return 0; - } - - for (i=first; i<first+num; i++) - { - if (((buffer[i/8]>>(i%8))&1) == 1) - result |= 1 << (i-first); - } - - return result; -} u8* buf_cpy(u8 *from, u8 *to, int size) { diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 34a167d..47ae193 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -26,8 +26,47 @@ * flip_u32 inverses the bit order inside a 32-bit word (31..0 -> 0..31) */ -extern int buf_set_u32(u8* buffer, unsigned int first, unsigned int num, u32 value); -extern u32 buf_get_u32(u8* buffer, unsigned int first, unsigned int num); +/* inlining this will help show what fn that is taking time during profiling. */ +static __inline void buf_set_u32(u8* buffer, unsigned int first, unsigned int num, u32 value) +{ + if ((num==32)&&(first==0)) + { + buffer[3]=(value>>24)&0xff; + buffer[2]=(value>>16)&0xff; + buffer[1]=(value>>8)&0xff; + buffer[0]=(value>>0)&0xff; + } else + { + unsigned int i; + + for (i=first; i<first+num; i++) + { + if (((value >> (i-first))&1) == 1) + buffer[i/8] |= 1 << (i%8); + else + buffer[i/8] &= ~(1 << (i%8)); + } + } +} +static __inline u32 buf_get_u32(u8* buffer, unsigned int first, unsigned int num) +{ + if ((num==32)&&(first==0)) + { + return (((u32)buffer[3])<<24)|(((u32)buffer[2])<<16)|(((u32)buffer[1])<<8)|(((u32)buffer[0])<<0); + } else + { + u32 result = 0; + unsigned int i; + + for (i=first; i<first+num; i++) + { + if (((buffer[i/8]>>(i%8))&1) == 1) + result |= 1 << (i-first); + } + + return result; + } +} extern u32 flip_u32(u32 value, unsigned int num); diff --git a/src/helper/log.h b/src/helper/log.h index 9929d42..6d61cf5 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -80,7 +80,7 @@ extern int debug_level; #define LOG_DEBUG(expr ...) \ - log_printf_lf (LOG_LVL_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr) + if (debug_level >= LOG_LVL_DEBUG) { log_printf_lf (LOG_LVL_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr); } #define LOG_INFO(expr ...) \ log_printf_lf (LOG_LVL_INFO, __FILE__, __LINE__, __FUNCTION__, expr) |