summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-02-24 23:12:00 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-02-24 23:12:00 +0000
commit00e5a9c0880a512acbd6c9c421b3d6bad3bcdcc1 (patch)
tree72516d65cb87f73bf7996a22f4ff3cc91884e64b /firmware/target/arm
parent9c2e7fd3626b87157cf06411dec43c00b49e962a (diff)
downloadrockbox-00e5a9c0880a512acbd6c9c421b3d6bad3bcdcc1.tar.gz
rockbox-00e5a9c0880a512acbd6c9c421b3d6bad3bcdcc1.zip
Use thumb-compatible byte swap routines when building with -mthumb.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29391 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/system-arm.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/firmware/target/arm/system-arm.h b/firmware/target/arm/system-arm.h
index e77b786866..9b92b7897d 100644
--- a/firmware/target/arm/system-arm.h
+++ b/firmware/target/arm/system-arm.h
@@ -207,6 +207,18 @@ static inline uint32_t swap32_hw(uint32_t value)
207 result[ 7.. 0] = value[31..24]; 207 result[ 7.. 0] = value[31..24];
208 */ 208 */
209{ 209{
210#ifdef __thumb__
211 uint32_t mask = 0x00FF00FF;
212 asm volatile (
213 "and %1, %0 \n\t" /* mask = .B.D */
214 "eor %0, %1 \n\t" /* val = A.C. */
215 "lsl %1, #8 \n\t" /* mask = B.D. */
216 "lsr %0, #8 \n\t" /* val = .A.C */
217 "orr %0, %1 \n\t" /* val = BADC */
218 "mov %1, #16 \n\t" /* mask = 16 */
219 "ror %0, %1 \n\t" /* val = DCBA */
220 : "+l"(value), "+l"(mask));
221#else
210 uint32_t tmp; 222 uint32_t tmp;
211 asm volatile ( 223 asm volatile (
212 "eor %1, %0, %0, ror #16 \n\t" 224 "eor %1, %0, %0, ror #16 \n\t"
@@ -215,6 +227,7 @@ static inline uint32_t swap32_hw(uint32_t value)
215 "eor %0, %0, %1, lsr #8 \n\t" 227 "eor %0, %0, %1, lsr #8 \n\t"
216 : "+r" (value), "=r" (tmp) 228 : "+r" (value), "=r" (tmp)
217 ); 229 );
230#endif
218 return value; 231 return value;
219} 232}
220 233
@@ -224,6 +237,16 @@ static inline uint32_t swap_odd_even32_hw(uint32_t value)
224 result[31..24],[15.. 8] = value[23..16],[ 7.. 0] 237 result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
225 result[23..16],[ 7.. 0] = value[31..24],[15.. 8] 238 result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
226 */ 239 */
240#ifdef __thumb__
241 uint32_t mask = 0x00FF00FF;
242 asm volatile (
243 "and %1, %0 \n\t" /* mask = .B.D */
244 "eor %0, %1 \n\t" /* val = A.C. */
245 "lsl %1, #8 \n\t" /* mask = B.D. */
246 "lsr %0, #8 \n\t" /* val = .A.C */
247 "orr %0, %1 \n\t" /* val = BADC */
248 : "+l"(value), "+l"(mask));
249#else
227 uint32_t tmp; 250 uint32_t tmp;
228 asm volatile ( /* ABCD */ 251 asm volatile ( /* ABCD */
229 "bic %1, %0, #0x00ff00 \n\t" /* AB.D */ 252 "bic %1, %0, #0x00ff00 \n\t" /* AB.D */
@@ -232,6 +255,7 @@ static inline uint32_t swap_odd_even32_hw(uint32_t value)
232 "orr %0, %0, %1, lsl #8 \n\t" /* B.D.|.A.C */ 255 "orr %0, %0, %1, lsl #8 \n\t" /* B.D.|.A.C */
233 : "+r" (value), "=r" (tmp) /* BADC */ 256 : "+r" (value), "=r" (tmp) /* BADC */
234 ); 257 );
258#endif
235 return value; 259 return value;
236} 260}
237 261
@@ -278,10 +302,17 @@ static inline uint32_t swaw32_hw(uint32_t value)
278 result[31..16] = value[15.. 0]; 302 result[31..16] = value[15.. 0];
279 result[15.. 0] = value[31..16]; 303 result[15.. 0] = value[31..16];
280 */ 304 */
305#ifdef __thumb__
306 asm volatile ("ror %0, %1" :
307 "+l"(value) : "l"(16));
308 return value;
309#else
281 uint32_t retval; 310 uint32_t retval;
282 asm volatile ("mov %0, %1, ror #16" : 311 asm volatile ("mov %0, %1, ror #16" :
283 "=r"(retval) : "r"(value)); 312 "=r"(retval) : "r"(value));
284 return retval; 313 return retval;
314#endif
315
285} 316}
286 317
287#endif /* SYSTEM_ARM_H */ 318#endif /* SYSTEM_ARM_H */