From 9f9871f81ecf6a9d9002b14c769a5812a20eda75 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 6 Mar 2002 14:37:38 +0000 Subject: 2002-03-06 Victor V. Vengerov * rtems/score/m68k.h [M68K_COLDFIRE_ARCH] (CPU_swap_u16, CPU_swap_u32): Generic implementation of endian swap primitives added for Coldfire family. --- cpukit/score/cpu/m68k/ChangeLog | 6 ++++++ cpukit/score/cpu/m68k/rtems/score/m68k.h | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'cpukit/score') diff --git a/cpukit/score/cpu/m68k/ChangeLog b/cpukit/score/cpu/m68k/ChangeLog index 8e6af4fe6f..7130470231 100644 --- a/cpukit/score/cpu/m68k/ChangeLog +++ b/cpukit/score/cpu/m68k/ChangeLog @@ -1,3 +1,9 @@ +2002-03-06 Victor V. Vengerov + + * rtems/score/m68k.h [M68K_COLDFIRE_ARCH] (CPU_swap_u16, CPU_swap_u32): + Generic implementation of endian swap primitives added for Coldfire + family. + 2002-01-29 Ralf Corsepius * rtems/Makefile.am: Removed. diff --git a/cpukit/score/cpu/m68k/rtems/score/m68k.h b/cpukit/score/cpu/m68k/rtems/score/m68k.h index bd8ec20475..419dffaa19 100644 --- a/cpukit/score/cpu/m68k/rtems/score/m68k.h +++ b/cpukit/score/cpu/m68k/rtems/score/m68k.h @@ -229,6 +229,10 @@ extern "C" { #endif +#ifndef ASM +#include +#endif + /* * If the above did not specify a ColdFire architecture, then set * this flag to indicate that it is not a ColdFire CPU. @@ -326,6 +330,34 @@ extern "C" { * The following routine swaps the endian format of an unsigned int. * It must be static because it is referenced indirectly. */ +#if ( M68K_COLDFIRE_ARCH == 1 ) + +/* There are no rotate commands in Coldfire architecture. We will use + * generic implementation of endian swapping for Coldfire. + */ +static inline unsigned int CPU_swap_u32( + unsigned int value + ) +{ + unsigned32 byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +static inline unsigned int m68k_swap_u16( + unsigned int value +) +{ + return (((value & 0xff) << 8) | ((value >> 8) & 0xff)); +} + +#else static inline unsigned int m68k_swap_u32( unsigned int value @@ -350,6 +382,7 @@ static inline unsigned int m68k_swap_u16( return( swapped ); } +#endif #define CPU_swap_u32( value ) m68k_swap_u32( value ) #define CPU_swap_u16( value ) m68k_swap_u16( value ) -- cgit v1.2.3