diff options
Diffstat (limited to 'arch/mips/lib/reloc.c')
-rw-r--r-- | arch/mips/lib/reloc.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/arch/mips/lib/reloc.c b/arch/mips/lib/reloc.c index df9760e38c..a9078aa813 100644 --- a/arch/mips/lib/reloc.c +++ b/arch/mips/lib/reloc.c @@ -41,7 +41,7 @@ #include <asm-generic/memory_layout.h> void main_entry(void *fdt, u32 fdt_size); -void relocate_code(void *fdt, u32 fdt_size, u32 relocaddr); +void __noreturn relocate_code(void *fdt, u32 fdt_size, u32 relocaddr); /** * read_uint() - Read an unsigned integer from the buffer @@ -106,10 +106,9 @@ static void apply_reloc(unsigned int type, void *addr, long off) } } -void relocate_code(void *fdt, u32 fdt_size, u32 ram_size) +void __noreturn relocate_code(void *fdt, u32 fdt_size, u32 ram_size) { - unsigned long addr, length, bss_len; - u32 relocaddr, new_stack; + unsigned long addr, length, bss_len, relocaddr, new_stack; uint8_t *buf; unsigned int type; long off; @@ -118,9 +117,13 @@ void relocate_code(void *fdt, u32 fdt_size, u32 ram_size) memset(__bss_start, 0, bss_len); cpu_probe(); - length = barebox_image_size + bss_len; + length = __bss_stop - __image_start; relocaddr = ALIGN_DOWN(ram_size - length, SZ_64K); - relocaddr = KSEG0ADDR(relocaddr); + if (IS_ENABLED(CONFIG_MMU)) { + relocaddr = CKSEG0ADDR(relocaddr); + } else { + relocaddr = CKSEG1ADDR(relocaddr); + } new_stack = relocaddr - MALLOC_SIZE - 16; /* @@ -130,7 +133,7 @@ void relocate_code(void *fdt, u32 fdt_size, u32 ram_size) * space in the Barebox binary & complexity in handling them. */ off = relocaddr - (unsigned long)__image_start; - if (off & 0xffff) + if (!IS_ALIGNED(off, SZ_64K)) panic("Mis-aligned relocation\n"); /* Copy Barebox to RAM */ |