summaryrefslogtreecommitdiffstats
path: root/cpukit/score/cpu/v850/rtems/score/cpu.h
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2012-06-12 17:57:35 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2012-06-12 17:58:01 -0500
commit1364eb9935cb6911598436a5cc5ca5c2705f088e (patch)
tree9d1d2ae445222b355c73be96a9703baf5c93253d /cpukit/score/cpu/v850/rtems/score/cpu.h
parentbsps: Replace NIRVANA region (diff)
downloadrtems-1364eb9935cb6911598436a5cc5ca5c2705f088e.tar.bz2
v850 - byte swap instructions not available on all multilibs
Diffstat (limited to 'cpukit/score/cpu/v850/rtems/score/cpu.h')
-rw-r--r--cpukit/score/cpu/v850/rtems/score/cpu.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/cpukit/score/cpu/v850/rtems/score/cpu.h b/cpukit/score/cpu/v850/rtems/score/cpu.h
index 591af00e36..875f1607c7 100644
--- a/cpukit/score/cpu/v850/rtems/score/cpu.h
+++ b/cpukit/score/cpu/v850/rtems/score/cpu.h
@@ -1154,10 +1154,23 @@ static inline uint32_t CPU_swap_u32(
uint32_t value
)
{
- unsigned int v, swapped;
+ unsigned int swapped;
- v = value;
- __asm__ __volatile__ ("bsw %0, %1" : "=r" (v), "=&r" (swapped) );
+ #if (V850_HAS_BYTE_SWAP_INSTRUCTION == 1)
+ unsigned int v;
+
+ v = value;
+ __asm__ __volatile__ ("bsw %0, %1" : "=r" (v), "=&r" (swapped) );
+ #else
+ uint32_t byte1, byte2, byte3, byte4;
+
+ byte4 = (value >> 24) & 0xff;
+ byte3 = (value >> 16) & 0xff;
+ byte2 = (value >> 8) & 0xff;
+ byte1 = value & 0xff;
+
+ swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
+ #endif
return swapped;
}
@@ -1174,10 +1187,16 @@ static inline uint32_t CPU_swap_u32(
*/
static inline uint16_t CPU_swap_u16( uint16_t value )
{
- unsigned int v, swapped;
+ unsigned int swapped;
+
+ #if (V850_HAS_BYTE_SWAP_INSTRUCTION == 1)
+ unsigned int v;
- v = value;
- __asm__ __volatile__ ("bsh %0, %1" : "=r" (v), "=&r" (swapped) );
+ v = value;
+ __asm__ __volatile__ ("bsh %0, %1" : "=r" (v), "=&r" (swapped) );
+ #else
+ swapped = ((value & 0xff) << 8) | ((value >> 8) & 0xff);
+ #endif
return swapped;
}