From 8ac2e518fea93dfda9e617a09d13252a0f67831f Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sun, 18 Oct 2020 11:40:30 +0200 Subject: fdt: Skip byteorder swap on big endian --- machine/fdt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/machine/fdt.c b/machine/fdt.c index 07b574f..4ec1530 100644 --- a/machine/fdt.c +++ b/machine/fdt.c @@ -9,9 +9,14 @@ static inline uint32_t bswap(uint32_t x) { +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ uint32_t y = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >> 8; uint32_t z = (y & 0x0000FFFF) << 16 | (y & 0xFFFF0000) >> 16; return z; +#else + /* No need to swap on big endian */ + return x; +#endif } static inline int isstring(char c) -- cgit v1.1 From 5752f0a173b84a76b772ee0abc8b4a1ad99d301d Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sun, 18 Oct 2020 11:42:15 +0200 Subject: pk: Fix pushing of argc to match linux kernel behaviour The linux kernel pushes argc as an int, not an uintptr_t. (The offset to the next element is still sizeof(uintptr_t).) --- pk/pk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pk/pk.c b/pk/pk.c index bce11a5..87dfc78 100644 --- a/pk/pk.c +++ b/pk/pk.c @@ -129,15 +129,15 @@ static void run_loaded_program(size_t argc, char** argv, uintptr_t kstack_top) // place argc, argv, envp, auxp on stack #define PUSH_ARG(type, value) do { \ *((type*)sp) = (type)value; \ - sp += sizeof(type); \ + sp ++; \ } while (0) #define STACK_INIT(type) do { \ unsigned naux = sizeof(aux)/sizeof(aux[0]); \ stack_top -= (1 + argc + 1 + envc + 1 + 2*naux) * sizeof(type); \ stack_top &= -16; \ - long sp = stack_top; \ - PUSH_ARG(type, argc); \ + type *sp = (void*)stack_top; \ + PUSH_ARG(int, argc); \ for (unsigned i = 0; i < argc; i++) \ PUSH_ARG(type, argv[i]); \ PUSH_ARG(type, 0); /* argv[argc] = NULL */ \ -- cgit v1.1