diff options
author | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-07-25 12:25:01 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-07-25 12:25:01 +0200 |
commit | 654bb6b0b88504a0768d706a207085cc5064640e (patch) | |
tree | 4104cf567b2a90ca5c82ae4fc32de6005e7e5f5e /arch | |
parent | dd13f2cdda205ff10e61bc3a0277457b026b70ee (diff) | |
download | barebox-654bb6b0b88504a0768d706a207085cc5064640e.tar.gz barebox-654bb6b0b88504a0768d706a207085cc5064640e.tar.xz |
further reloc fixes
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ppc/lib/board.c | 16 | ||||
-rw-r--r-- | arch/ppc/mach-mpc5xxx/start.S | 34 |
2 files changed, 37 insertions, 13 deletions
diff --git a/arch/ppc/lib/board.c b/arch/ppc/lib/board.c index 9ade2dac8e..d0cd42cfdc 100644 --- a/arch/ppc/lib/board.c +++ b/arch/ppc/lib/board.c @@ -29,6 +29,7 @@ #include <mem_malloc.h> #include <init.h> #include <net.h> +#include <reloc.h> char *strmhz (char *buf, long hz) { @@ -55,9 +56,22 @@ char *strmhz (char *buf, long hz) void board_init_r (ulong end_of_ram) { + unsigned long malloc_end; + asm ("sync ; isync"); - mem_malloc_init((void *)(end_of_ram - 4096 - CFG_MALLOC_LEN), (void *)(end_of_ram - 4096)); + _text_base += reloc_offset(); + + /* + * FIXME: 128k stack size. Is this enough? should + * it be configurable? + */ + malloc_end = (_text_base - (128 << 10)) & ~(4095); + + debug("malloc_end: 0x%08x\n", malloc_end); + debug("TEXT_BASE after relocation: 0x%08x\n", _text_base); + + mem_malloc_init((void *)(malloc_end - CFG_MALLOC_LEN), (void *)malloc_end); /* * Setup trap handlers diff --git a/arch/ppc/mach-mpc5xxx/start.S b/arch/ppc/mach-mpc5xxx/start.S index 868829a596..933215c4f2 100644 --- a/arch/ppc/mach-mpc5xxx/start.S +++ b/arch/ppc/mach-mpc5xxx/start.S @@ -309,22 +309,21 @@ _end_of_vectors: . = 0x3000 _continue_init: - mr r1, r3 /* Set new stack pointer at end of RAM */ - subi r1, r1, 0x10 mr r9, r3 /* Save copy of end of RAM */ -#ifdef CONFIG_RELOCATABLE - subi r3, r3, 0x8000 /* reserve for stack FIXME */ - - lis r10, __init_size@h /* Size */ - ori r10, r10, __init_size@l +#ifdef CONFIG_RELOCATABLE + lis r10, (_end - _start)@h /* Size */ + ori r10, r10, (_end - _start)@l sub r3, r3, r10 - - mr r9, r3 + subi r3, r3, 0x100 #else lis r3, (TEXT_BASE)@h /* Destination Address */ ori r3, r3, (TEXT_BASE)@l #endif + + mr r1, r3 /* Set new stack just below U-Boot code */ + subi r1, r1, 0x10 + mr r10, r3 /* Save copy of Destination Address */ bl calc_source /* Calculate Source Address */ @@ -336,6 +335,16 @@ calc_source: lis r5, __init_size@h /* Size */ ori r5, r5, __init_size@l +before_relocate: + /* + * We are now ready to copy U-Boot to RAM. + * + * destination = r3 + * source = r4 + * size = r5 + * + */ + li r6, CONFIG_CACHELINE_SIZE /* Cache Line Size */ /* @@ -810,10 +819,11 @@ reloc_offset: bl pc pc: mfspr r3, LR - subi r3, r3, (pc - _start) mtspr LR, r4 - lis r4, TEXT_BASE@h - ori r4, r4, TEXT_BASE@l + addi r4, r3, (_text_base - pc) + subi r3, r3, (pc - _start) + lwz r4, 0(r4) + sub r3, r3, r4 subi r3, r3, 0x100 blr |