aboutsummaryrefslogtreecommitdiff
path: root/util/cbfstool/common.h
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2011-10-21 14:24:57 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2011-10-24 20:29:29 +0200
commita1e4824f73602a411826b27160a8818049ce0f97 (patch)
tree777dcf31f4eddaaf0c68078814bd27fb63f03524 /util/cbfstool/common.h
parent3c976791b06c75e8983266b3551f133d89924376 (diff)
Various fixes to cbfstool.
- add ntohll and htonll (as coreboot parses 64bit fields now) - use the same byte swapping code across platforms - detect endianess early - fix lots of warnings - Don't override CFLAGS in Makefile Change-Id: Iaea02ff7a31ab6a95fd47858d0efd9af764a3e5f Signed-off-by: Stefan Reinauer <reinauer@google.com> Reviewed-on: http://review.coreboot.org/313 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/cbfstool/common.h')
-rw-r--r--util/cbfstool/common.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 8f397d8e65..7034e0c1cf 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -17,23 +17,23 @@
*/
#include <stdint.h>
-#ifndef WIN32
-#include <arpa/inet.h>
-#else
-#define ntohl(x) (((x)>>24) | ((x)<<24) | (((x)>>8)&0xff00) | (((x)<<8)&0xff0000))
-#define htonl ntohl
-#endif
+#include "swab.h"
+#define ntohl(x) (host_bigendian?(x):swab32(x))
+#define htonl(x) (host_bigendian?(x):swab32(x))
+#define ntohll(x) (host_bigendian?(x):swab64(x))
+#define htonll(x) (host_bigendian?(x):swab64(x))
extern void *offset;
extern struct cbfs_header *master_header;
extern uint32_t phys_start, phys_end, align, romsize;
+extern int host_bigendian;
-static void *phys_to_virt(uint32_t addr)
+static inline void *phys_to_virt(uint32_t addr)
{
return offset + addr;
}
-static uint32_t virt_to_phys(void *addr)
+static inline uint32_t virt_to_phys(void *addr)
{
return (unsigned long)(addr - offset) & 0xffffffff;
}