diff options
author | Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> | 2018-11-08 21:35:17 +0000 |
---|---|---|
committer | Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> | 2018-11-09 13:27:03 +0000 |
commit | 1a73b2d0892465e999ddc4aa319895f196e8c8d3 (patch) | |
tree | d118019e39e5db1950d4ec3ba9e11a427e1e6b61 /tools/firmware-utils/src | |
parent | 9a3c805584b6adf3fa4f0db5c127a056b0c6d667 (diff) | |
download | upstream-1a73b2d0892465e999ddc4aa319895f196e8c8d3.tar.gz upstream-1a73b2d0892465e999ddc4aa319895f196e8c8d3.tar.bz2 upstream-1a73b2d0892465e999ddc4aa319895f196e8c8d3.zip |
tools: firmware-utils: mksercommfw build on Darwin
asm/byteorder.h & hence __cpu_to_be32() doesn't exist on Darwin
Shamelessly copy some byte swap functions from oseama.c
Acked-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Diffstat (limited to 'tools/firmware-utils/src')
-rw-r--r-- | tools/firmware-utils/src/mksercommfw.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tools/firmware-utils/src/mksercommfw.c b/tools/firmware-utils/src/mksercommfw.c index e3b499a097..23e4dd06b2 100644 --- a/tools/firmware-utils/src/mksercommfw.c +++ b/tools/firmware-utils/src/mksercommfw.c @@ -3,7 +3,26 @@ #include <stdlib.h> #include <sys/types.h> #include <unistd.h> -#include <asm/byteorder.h> +#include <byteswap.h> +#include <endian.h> + +#if !defined(__BYTE_ORDER) +#error "Unknown byte order" +#endif + +#if __BYTE_ORDER == __BIG_ENDIAN +#define cpu_to_be32(x) (x) +#define be32_to_cpu(x) (x) +#define cpu_to_be16(x) (x) +#define be16_to_cpu(x) (x) +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#define cpu_to_be32(x) bswap_32(x) +#define be32_to_cpu(x) bswap_32(x) +#define cpu_to_be16(x) bswap_16(x) +#define be16_to_cpu(x) bswap_16(x) +#else +#error "Unsupported endianness" +#endif /* #define DEBUG 1 */ @@ -212,7 +231,7 @@ int main(int argc, char* argv[]) { image.file_name = argv[1]; kernel_offset = (u_int32_t) strtol(argv[2], NULL, 0); swVer = (u_int32_t) strtol(argv[5], NULL, 0); - swVer = __cpu_to_be32(swVer); + swVer = cpu_to_be32(swVer); /* Check if files actually exist */ if (access(sysupgrade.file_name, (F_OK | R_OK))) { |