summaryrefslogtreecommitdiffstats
path: root/src/arch/x86_64/include/bits/byteswap.h
diff options
context:
space:
mode:
authorMichael Brown2008-11-18 23:30:37 +0100
committerMichael Brown2008-12-05 01:06:27 +0100
commitce0a0ccf5c2b99be684f13a9418d1556bae5f0ed (patch)
tree965c86dafc3fbdca8e46ee22b94387242cc0e288 /src/arch/x86_64/include/bits/byteswap.h
parent[hermon] Fix permissions broken in 3a799e9 ("Add PCI ID for ConnectX QDR card") (diff)
downloadipxe-ce0a0ccf5c2b99be684f13a9418d1556bae5f0ed.tar.gz
ipxe-ce0a0ccf5c2b99be684f13a9418d1556bae5f0ed.tar.xz
ipxe-ce0a0ccf5c2b99be684f13a9418d1556bae5f0ed.zip
[x86_64] Add support for compilation as an x86_64 binary
Currently the only supported platform for x86_64 is EFI. Building an EFI64 gPXE requires a version of gcc that supports __attribute__((ms_abi)). This currently means a development build of gcc; the feature should be present when gcc 4.4 is released. In the meantime; you can grab a suitable gcc tree from git://git.etherboot.org/scm/people/mcb30/gcc/.git
Diffstat (limited to 'src/arch/x86_64/include/bits/byteswap.h')
-rw-r--r--src/arch/x86_64/include/bits/byteswap.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/arch/x86_64/include/bits/byteswap.h b/src/arch/x86_64/include/bits/byteswap.h
new file mode 100644
index 000000000..9ed85e8f8
--- /dev/null
+++ b/src/arch/x86_64/include/bits/byteswap.h
@@ -0,0 +1,22 @@
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H
+
+static inline __attribute__ (( always_inline, const )) uint16_t
+__bswap_variable_16 ( uint16_t x ) {
+ __asm__ ( "xchgb %b0,%h0" : "=Q" ( x ) : "0" ( x ) );
+ return x;
+}
+
+static inline __attribute__ (( always_inline, const )) uint32_t
+__bswap_variable_32 ( uint32_t x ) {
+ __asm__ ( "bswapl %k0" : "=r" ( x ) : "0" ( x ) );
+ return x;
+}
+
+static inline __attribute__ (( always_inline, const )) uint64_t
+__bswap_variable_64 ( uint64_t x ) {
+ __asm__ ( "bswapq %q0" : "=r" ( x ) : "0" ( x ) );
+ return x;
+}
+
+#endif /* _BITS_BYTESWAP_H */