diff options
author | Stefan Reinauer <reinauer@chromium.org> | 2011-10-21 14:24:57 -0700 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2011-10-24 20:29:29 +0200 |
commit | a1e4824f73602a411826b27160a8818049ce0f97 (patch) | |
tree | 777dcf31f4eddaaf0c68078814bd27fb63f03524 /util/cbfstool/cbfs-mkstage.c | |
parent | 3c976791b06c75e8983266b3551f133d89924376 (diff) | |
download | coreboot-a1e4824f73602a411826b27160a8818049ce0f97.tar.xz |
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/cbfs-mkstage.c')
-rw-r--r-- | util/cbfstool/cbfs-mkstage.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c index 2f81da07d5..c9163ef6cf 100644 --- a/util/cbfstool/cbfs-mkstage.c +++ b/util/cbfstool/cbfs-mkstage.c @@ -36,10 +36,12 @@ unsigned int idemp(unsigned int x) return x; } -unsigned int swap32(unsigned int x) +/* This is a wrapper around the swab32() macro to make it + * usable for the current implementation of parse_elf_to_stage() + */ +static unsigned int swap32(unsigned int x) { - return ((x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | - (x << 24)); + return swab32(x); } unsigned int (*elf32_to_native) (unsigned int) = idemp; @@ -59,7 +61,6 @@ int parse_elf_to_stage(unsigned char *input, unsigned char **output, unsigned int data_start, data_end, mem_end; int elf_bigendian = 0; - int host_bigendian = 0; comp_func_ptr compress = compression_function(algo); if (!compress) @@ -73,11 +74,6 @@ int parse_elf_to_stage(unsigned char *input, unsigned char **output, if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) { elf_bigendian = 1; } - char test[4] = "1234"; - uint32_t inttest = *(uint32_t *) test; - if (inttest == 0x31323334) { - host_bigendian = 1; - } if (elf_bigendian != host_bigendian) { elf32_to_native = swap32; } @@ -171,10 +167,10 @@ int parse_elf_to_stage(unsigned char *input, unsigned char **output, stage = (struct cbfs_stage *)out; - stage->load = data_start; + stage->load = data_start; /* FIXME: htonll */ stage->memlen = mem_end - data_start; stage->compression = algo; - stage->entry = ehdr->e_entry; + stage->entry = ehdr->e_entry; /* FIXME: htonll */ compress(buffer, data_end - data_start, (char *)(out + sizeof(struct cbfs_stage)), (int *)&stage->len); |