[coreboot] New patch to review for coreboot: 20a75ca Add macros for 64bit byte order swapping

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Sat Oct 15 00:27:02 CEST 2011


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/275

-gerrit

commit 20a75ca9c0a326ab4113311f6a56dd668be4e283
Author: Stefan Reinauer <reinauer at chromium.org>
Date:   Fri Oct 14 15:11:16 2011 -0700

    Add macros for 64bit byte order swapping
    
    Change-Id: Ic31ccd41ba3e0af7046eafc29221810d4cd196c8
    Signed-off-by: Stefan Reinauer <reinauer at google.com>
---
 src/arch/x86/include/arch/byteorder.h |    4 ++++
 src/include/swab.h                    |   11 +++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/arch/x86/include/arch/byteorder.h b/src/arch/x86/include/arch/byteorder.h
index ab344e6..7ba6290 100644
--- a/src/arch/x86/include/arch/byteorder.h
+++ b/src/arch/x86/include/arch/byteorder.h
@@ -5,10 +5,14 @@
 
 #include <swab.h>
 
+#define cpu_to_le64(x) ((unsigned long)(x))
+#define le64_to_cpu(x) ((unsigned long)(x))
 #define cpu_to_le32(x) ((unsigned int)(x))
 #define le32_to_cpu(x) ((unsigned int)(x))
 #define cpu_to_le16(x) ((unsigned short)(x))
 #define le16_to_cpu(x) ((unsigned short)(x))
+#define cpu_to_be64(x) swab64(x)
+#define be64_to_cpu(x) swab64(x)
 #define cpu_to_be32(x) swab32((x))
 #define be32_to_cpu(x) swab32((x))
 #define cpu_to_be16(x) swab16((x))
diff --git a/src/include/swab.h b/src/include/swab.h
index 3a16686..c5e4370 100644
--- a/src/include/swab.h
+++ b/src/include/swab.h
@@ -30,4 +30,15 @@
 		(((unsigned int)(x) & (unsigned int)0x00ff0000UL) >>  8) | \
 		(((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24) ))
 
+#define swab64(x) \
+	((uint64_t)( \
+		(((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+		(((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+		(((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+		(((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) <<  8) | \
+		(((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >>  8) | \
+		(((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+		(((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+		(((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56) ))
+
 #endif /* _SWAB_H */




More information about the coreboot mailing list