summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ppc/lib/board.c16
-rw-r--r--arch/ppc/mach-mpc5xxx/start.S34
-rw-r--r--board/phycore_mpc5200b_tiny/u-boot.lds.S1
-rw-r--r--common/startup.c12
-rw-r--r--include/reloc.h3
5 files changed, 43 insertions, 23 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
diff --git a/board/phycore_mpc5200b_tiny/u-boot.lds.S b/board/phycore_mpc5200b_tiny/u-boot.lds.S
index 51ac70828c..a14709531f 100644
--- a/board/phycore_mpc5200b_tiny/u-boot.lds.S
+++ b/board/phycore_mpc5200b_tiny/u-boot.lds.S
@@ -107,7 +107,6 @@ SECTIONS
__early_init_data_begin = .;
.early_init_data : { *(.early_init_data) }
__early_init_data_end = .;
- __early_init_data_size = __early_init_data_end - __early_init_data_begin;
__start___ex_table = .;
__ex_table : { *(__ex_table) }
diff --git a/common/startup.c b/common/startup.c
index dac6659851..68753bdc1b 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -42,16 +42,14 @@
extern initcall_t __u_boot_initcalls_start[], __u_boot_early_initcalls_end[], __u_boot_initcalls_end[];
-const char *version_string =
+const char version_string[] =
"U-Boot " UTS_RELEASE " (" __DATE__ " - " __TIME__ ")"CONFIG_IDENT_STRING;
static int display_banner (void)
{
- const char *vers = RELOC_VAR(version_string);
-
- printf (RELOC("\n\n%s\n\n"), RELOC(vers));
+ printf (RELOC("\n\n%s\n\n"), RELOC_VAR(version_string));
debug (RELOC("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n"),
- _u_boot_start, _bss_start, _bss_end);
+ RELOC_VAR(_u_boot_start), RELOC_VAR(_bss_start), RELOC_VAR(_bss_end));
printf(RELOC("Board: " CONFIG_BOARDINFO "\n"));
return 0;
@@ -68,7 +66,7 @@ void early_init (void)
{
/* copy the early initdata segment to early init RAM */
memcpy((void *)EARLY_INITDATA, RELOC(&__early_init_data_begin),
- (ulong)&__early_init_data_size);
+ (ulong)&__early_init_data_end - (ulong)&__early_init_data_begin);
early_console_start(RELOC("psc3"), 115200);
display_banner();
@@ -87,7 +85,7 @@ void start_uboot (void)
* early RAM to RAM
*/
memcpy(&__early_init_data_begin, init_data_ptr,
- (ulong)&__early_init_data_size);
+ (ulong)&__early_init_data_end - (ulong)&__early_init_data_begin);
init_data_ptr = &__early_init_data_begin;
#endif /* CONFIG_HAS_EARLY_INIT */
diff --git a/include/reloc.h b/include/reloc.h
index df6500de0d..d450097dde 100644
--- a/include/reloc.h
+++ b/include/reloc.h
@@ -1,12 +1,11 @@
#ifndef __RELOC_H
#define __RELOC_H
-extern unsigned long _u_boot_start, _bss_start, _bss_end;
+extern unsigned long _u_boot_start, _bss_start, _bss_end, _text_base;
#ifdef CONFIG_HAS_EARLY_INIT
extern ulong __early_init_data_begin, __early_init_data_end;
-extern ulong __early_init_data_size;
/*
* The difference between our link address and the address we're