summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-04-22 09:37:23 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-04-22 09:37:23 +0000
commit61e457883396eaef07da6ab502697237bfe11c7c (patch)
tree89b84f6e25201c08092f1ad9f07c7479d2d8c76b /firmware
parent25ef8e4d3a009f0228d65614a7c916918567af88 (diff)
downloadrockbox-61e457883396eaef07da6ab502697237bfe11c7c.tar.gz
rockbox-61e457883396eaef07da6ab502697237bfe11c7c.zip
Uh, we already had SWAB macros :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@167 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/system.h48
1 files changed, 12 insertions, 36 deletions
diff --git a/firmware/system.h b/firmware/system.h
index 342b60cba0..1191e59843 100644
--- a/firmware/system.h
+++ b/firmware/system.h
@@ -22,36 +22,12 @@
22 22
23#include "sh7034.h" 23#include "sh7034.h"
24 24
25/* 25#define FREQ 12000000 /* cycle time ~83.3ns */
26 * 11.059,200 MHz => 90.4224537037037037037037037037037... ns
27 * 12.000,000 MHz => 83.3333333333333333333333333333333... ns
28 */
29
30#define FREQ 12000000
31#define BAUDRATE 9600 26#define BAUDRATE 9600
32 27
33//#define PHI ((int)(11.059200 MHz))
34//#define BAUDRATE 115200 /* 115200 - 9600 */
35
36#ifdef LITTLE_ENDIAN 28#ifdef LITTLE_ENDIAN
37#define SWAB16(x) (x) 29#define SWAB16(x) (x)
38#define SWAB32(x) (x) 30#define SWAB32(x) (x)
39#else
40#define SWAB16(x) \
41({ \
42 unsigned short __x = x; \
43 (((__x & 0x00ff) << 8) | \
44 ((__x & 0xff00) >> 8)); \
45})
46
47#define SWAB32(x) \
48({ \
49 unsigned long __x = x; \
50 (((__x & 0x000000ff) << 24) | \
51 ((__x & 0x0000ff00) << 8) | \
52 ((__x & 0x00ff0000) >> 8) | \
53 ((__x & 0xff000000) >> 24)); \
54})
55#endif 31#endif
56 32
57#define nop \ 33#define nop \
@@ -188,38 +164,38 @@ extern char __swap_bit[256];
188 164
189#ifndef SIMULATOR 165#ifndef SIMULATOR
190 166
191static inline short swabHI (short value) 167static inline short SWAB16(short value)
192 /* 168 /*
193 result[15..8] = value[ 7..0]; 169 result[15..8] = value[ 7..0];
194 result[ 7..0] = value[15..8]; 170 result[ 7..0] = value[15..8];
195 */ 171 */
196 { 172{
197 short result; 173 short result;
198 asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value)); 174 asm volatile ("swap.b\t%1,%0" : "=r"(result) : "r"(value));
199 return result; 175 return result;
200 } 176}
201 177
202static inline int swawSI (int value) 178static inline long SWAW32(long value)
203 /* 179 /*
204 result[31..16] = value[15.. 0]; 180 result[31..16] = value[15.. 0];
205 result[15.. 0] = value[31..16]; 181 result[15.. 0] = value[31..16];
206 */ 182 */
207 { 183{
208 int result; 184 long result;
209 asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value)); 185 asm volatile ("swap.w\t%1,%0" : "=r"(result) : "r"(value));
210 return result; 186 return result;
211 } 187}
212 188
213static inline int swabSI (int value) // should be avoided as much as possible 189static inline long SWAB32(long value)
214 /* 190 /*
215 result[31..24] = value[ 7.. 0]; 191 result[31..24] = value[ 7.. 0];
216 result[23..16] = value[15.. 8]; 192 result[23..16] = value[15.. 8];
217 result[15.. 8] = value[23..16]; 193 result[15.. 8] = value[23..16];
218 result[ 7.. 0] = value[31..24]; 194 result[ 7.. 0] = value[31..24];
219 */ 195 */
220 { 196{
221 return swabHI(swawSI(swabSI(value))); 197 return SWAB16(SWAW32(SWAB16(value)));
222 } 198}
223 199
224/* Test And Set - UNTESTED */ 200/* Test And Set - UNTESTED */
225static inline int tas (volatile int *pointer) 201static inline int tas (volatile int *pointer)