X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=util%2Fcbfstool%2Fcommon.h;h=7034e0c1cf4e221c3ce645c06e5a70b0d1f4f01b;hb=a1e4824f73602a411826b27160a8818049ce0f97;hp=8f397d8e65690632dbbfda1815bd07231d383a79;hpb=fe7d6b9a4a784f0b92b3c9dc5b6c6070b4c2e10c;p=coreboot.git diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h index 8f397d8e6..7034e0c1c 100644 --- a/util/cbfstool/common.h +++ b/util/cbfstool/common.h @@ -17,23 +17,23 @@ */ #include -#ifndef WIN32 -#include -#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; }