Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/include Add BSWAP16 and BSWAP32 macros for use ...



details:   https://anonhg.NetBSD.org/src/rev/8e9e27a9285d
branches:  trunk
changeset: 780211:8e9e27a9285d
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Jul 15 19:59:48 2012 +0000

description:
Add BSWAP16 and BSWAP32 macros for use in assembly.

diffstat:

 sys/arch/arm/include/byte_swap.h |  30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diffs (50 lines):

diff -r 8da163d63ad5 -r 8e9e27a9285d sys/arch/arm/include/byte_swap.h
--- a/sys/arch/arm/include/byte_swap.h  Sun Jul 15 18:38:44 2012 +0000
+++ b/sys/arch/arm/include/byte_swap.h  Sun Jul 15 19:59:48 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: byte_swap.h,v 1.9 2012/07/12 17:23:02 matt Exp $       */
+/*     $NetBSD: byte_swap.h,v 1.10 2012/07/15 19:59:48 matt Exp $      */
 
 /*-
  * Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc.
@@ -32,6 +32,33 @@
 #ifndef _ARM_BYTE_SWAP_H_
 #define        _ARM_BYTE_SWAP_H_
 
+#ifdef _LOCORE
+
+#if (ARM_ARCH_6 + ARM_ARCH_7) > 0
+
+#define        BSWAP16(_src, _dst, _tmp)               \
+       rev16   _dst, _src
+#define        BSWAP32(_src, _dst, _tmp)               \
+       rev     _dst, _src
+
+#else
+
+#define        BSWAP16(_src, _dst, _tmp)               \
+       mov     _tmp, _src, ror #8              ;\
+       orr     _tmp, _tmp, _tmp, lsr #16       ;\
+       bic     _dst, _tmp, _tmp, lsl #16
+
+#define        BSWAP32(_src, _dst, _tmp)               \
+       eor     _tmp, _src, _src, ror #16       ;\
+       bic     _tmp, _tmp, #0x00FF0000         ;\
+       mov     _dst, _src, ror #8              ;\
+       eor     _dst, _dst, _tmp, lsr #8
+
+#endif
+
+
+#else
+
 #ifdef __GNUC__
 #include <sys/types.h>
 __BEGIN_DECLS
@@ -87,5 +114,6 @@
 __END_DECLS
 #endif
 
+#endif /* _LOCORE */
 
 #endif /* _ARM_BYTE_SWAP_H_ */



Home | Main Index | Thread Index | Old Index