Uh, we already had SWAB macros :)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@167 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-04-22 09:37:23 +00:00
parent 25ef8e4d3a
commit 61e4578833

View file

@ -22,36 +22,12 @@
#include "sh7034.h" #include "sh7034.h"
/* #define FREQ 12000000 /* cycle time ~83.3ns */
* 11.059,200 MHz => 90.4224537037037037037037037037037... ns
* 12.000,000 MHz => 83.3333333333333333333333333333333... ns
*/
#define FREQ 12000000
#define BAUDRATE 9600 #define BAUDRATE 9600
//#define PHI ((int)(11.059200 MHz))
//#define BAUDRATE 115200 /* 115200 - 9600 */
#ifdef LITTLE_ENDIAN #ifdef LITTLE_ENDIAN
#define SWAB16(x) (x) #define SWAB16(x) (x)
#define SWAB32(x) (x) #define SWAB32(x) (x)
#else
#define SWAB16(x) \
({ \
unsigned short __x = x; \
(((__x & 0x00ff) << 8) | \
((__x & 0xff00) >> 8)); \
})
#define SWAB32(x) \
({ \
unsigned long __x = x; \
(((__x & 0x000000ff) << 24) | \
((__x & 0x0000ff00) << 8) | \
((__x & 0x00ff0000) >> 8) | \
((__x & 0xff000000) >> 24)); \
})
#endif #endif
#define nop \ #define nop \
@ -188,38 +164,38 @@ extern char __swap_bit[256];
#ifndef SIMULATOR #ifndef SIMULATOR
static inline short swabHI (short value) static inline short SWAB16(short value)
/* /*
result[15..8] = value[ 7..0]; result[15..8] = value[ 7..0];
result[ 7..0] = value[15..8]; result[ 7..0] = value[15..8];
*/ */
{ {
short result; short result;
asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value)); asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value));
return result; return result;
} }
static inline int swawSI (int value) static inline long SWAW32(long value)
/* /*
result[31..16] = value[15.. 0]; result[31..16] = value[15.. 0];
result[15.. 0] = value[31..16]; result[15.. 0] = value[31..16];
*/ */
{ {
int result; long result;
asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value)); asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value));
return result; return result;
} }
static inline int swabSI (int value) // should be avoided as much as possible static inline long SWAB32(long value)
/* /*
result[31..24] = value[ 7.. 0]; result[31..24] = value[ 7.. 0];
result[23..16] = value[15.. 8]; result[23..16] = value[15.. 8];
result[15.. 8] = value[23..16]; result[15.. 8] = value[23..16];
result[ 7.. 0] = value[31..24]; result[ 7.. 0] = value[31..24];
*/ */
{ {
return swabHI(swawSI(swabSI(value))); return SWAB16(SWAW32(SWAB16(value)));
} }
/* Test And Set - UNTESTED */ /* Test And Set - UNTESTED */
static inline int tas (volatile int *pointer) static inline int tas (volatile int *pointer)