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>
diff --git a/util/cbfstool/cbfs-mkpayload.c b/util/cbfstool/cbfs-mkpayload.c
index baa92ff..ff6479d 100644
--- a/util/cbfstool/cbfs-mkpayload.c
+++ b/util/cbfstool/cbfs-mkpayload.c
@@ -152,9 +152,9 @@
if (phdr[i].p_filesz == 0) {
segs[segments].type = PAYLOAD_SEGMENT_BSS;
segs[segments].load_addr =
- (unsigned long long)htonl(phdr[i].p_paddr);
+ (uint64_t)htonll(phdr[i].p_paddr);
segs[segments].mem_len =
- (unsigned int)htonl(phdr[i].p_memsz);
+ (uint32_t)htonl(phdr[i].p_memsz);
segs[segments].offset = htonl(doffset);
segments++;
@@ -162,8 +162,8 @@
}
segs[segments].type = PAYLOAD_SEGMENT_DATA;
- segs[segments].load_addr = (unsigned int)htonl(phdr[i].p_paddr);
- segs[segments].mem_len = (unsigned int)htonl(phdr[i].p_memsz);
+ segs[segments].load_addr = (uint64_t)htonll(phdr[i].p_paddr);
+ segs[segments].mem_len = (uint32_t)htonl(phdr[i].p_memsz);
segs[segments].compression = htonl(algo);
segs[segments].offset = htonl(doffset);
@@ -190,7 +190,7 @@
}
segs[segments].type = PAYLOAD_SEGMENT_ENTRY;
- segs[segments++].load_addr = (unsigned long long)htonl(ehdr->e_entry);
+ segs[segments++].load_addr = (uint64_t)htonll(ehdr->e_entry);
*output = sptr;