[U-Boot] [PATCH] arm: Add armv6 and armv7 optimized swab functions

Rob Herring robherring2 at gmail.com
Wed Dec 15 16:13:14 CET 2010


From: Rob Herring <rob.herring at calxeda.com>

swab functions are heavily used by FDT code, so enable
optimized assembly code for ARMv6 and later.

Signed-off-by: Rob Herring <rob.herring at calxeda.com>
---
 arch/arm/include/asm/byteorder.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/byteorder.h b/arch/arm/include/asm/byteorder.h
index c3489f1..9df5844 100644
--- a/arch/arm/include/asm/byteorder.h
+++ b/arch/arm/include/asm/byteorder.h
@@ -23,6 +23,22 @@
 #  define __SWAB_64_THRU_32__
 #endif
 
+#if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_6__)
+static inline __u16 __attribute__((const)) ___arch_swab16(__u16 x)
+{
+	__asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x));
+	return x;
+}
+#define __arch_swab16 ___arch_swab16
+
+static inline __u32 __attribute__((const)) ___arch_swab32(__u32 x)
+{
+	__asm__ ("rev %0, %1" : "=r" (x) : "r" (x));
+	return x;
+}
+#define __arch_swab32 ___arch_swab32
+#endif
+
 #ifdef __ARMEB__
 #include <linux/byteorder/big_endian.h>
 #else
-- 
1.7.1



More information about the U-Boot mailing list