From 858290178f222d998b6425d85cf06822467918f3 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 21 Sep 2009 11:20:25 -0500 Subject: ppc: Enable full relocation to RAM The following changes allow U-Boot to fully relocate from flash to RAM: - Remove linker scripts' .fixup sections from the .text section - Add -mrelocatable to PLATFORM_RELFLAGS for all boards - Define CONFIG_RELOC_FIXUP_WORKS for all boards Previously, U-Boot would partially relocate, but statically initialized pointers needed to be manually relocated. Signed-off-by: Peter Tyser --- lib_ppc/config.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'lib_ppc') diff --git a/lib_ppc/config.mk b/lib_ppc/config.mk index 010d874..06a3b10 100644 --- a/lib_ppc/config.mk +++ b/lib_ppc/config.mk @@ -25,6 +25,7 @@ CROSS_COMPILE ?= ppc_8xx- STANDALONE_LOAD_ADDR = 0x40000 +PLATFORM_RELFLAGS += -mrelocatable PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__ PLATFORM_LDFLAGS += -n -- cgit v1.1 From 244615197469dd6fe75ae082f38424b97c79aeaf Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 21 Sep 2009 11:20:26 -0500 Subject: ppc: Check for compilers that don't support relocation Certain ppc compilers are known not to generate the .fixup section properly. The .fixup section is necessary to create a relocatable U-Boot image. A basic check for the existence of the .fixup section should hopefully catch the majority of broken compilers which don't support relocation. Signed-off-by: Peter Tyser --- lib_ppc/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib_ppc') diff --git a/lib_ppc/Makefile b/lib_ppc/Makefile index 60ea0c9..399b41e 100644 --- a/lib_ppc/Makefile +++ b/lib_ppc/Makefile @@ -42,6 +42,12 @@ SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y)) $(LIB): $(obj).depend $(OBJS) + @if ! $(CROSS_COMPILE)readelf -S $(OBJS) | grep -q '\.fixup.*PROGBITS';\ + then \ + echo "ERROR: Your compiler doesn't generate .fixup sections!";\ + echo " Upgrade to a recent toolchain."; \ + exit 1; \ + fi; $(AR) $(ARFLAGS) $@ $(OBJS) ######################################################################### -- cgit v1.1 From a0e2066f392782730f0398095e583c87812d97f2 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 21 Sep 2009 11:20:27 -0500 Subject: ppc: Remove board.c relocation fixups Signed-off-by: Peter Tyser --- lib_ppc/board.c | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) (limited to 'lib_ppc') diff --git a/lib_ppc/board.c b/lib_ppc/board.c index f9dbdb9..8b8ddb5 100644 --- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -627,13 +627,8 @@ void board_init_f (ulong bootflag) */ void board_init_r (gd_t *id, ulong dest_addr) { - cmd_tbl_t *cmdtp; char *s; bd_t *bd; - extern void malloc_bin_reloc (void); -#ifndef CONFIG_ENV_IS_NOWHERE - extern char * env_name_spec; -#endif ulong malloc_start; #ifndef CONFIG_SYS_NO_FLASH @@ -646,18 +641,7 @@ void board_init_r (gd_t *id, ulong dest_addr) gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ /* The Malloc area is immediately below the monitor copy in DRAM */ -#if defined(CONFIG_RELOC_FIXUP_WORKS) - gd->reloc_off = 0; malloc_start = dest_addr - TOTAL_MALLOC_LEN; -#else - gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE; - malloc_start = CONFIG_SYS_MONITOR_BASE + gd->reloc_off - - TOTAL_MALLOC_LEN; -#endif - -#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) - gd->cpu += gd->reloc_off; -#endif #ifdef CONFIG_SERIAL_MULTI serial_initialize(); @@ -682,38 +666,6 @@ void board_init_r (gd_t *id, ulong dest_addr) monitor_flash_len = (ulong)&__init_end - dest_addr; - /* - * We have to relocate the command table manually - */ - for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { - ulong addr; - addr = (ulong) (cmdtp->cmd) + gd->reloc_off; -#if 0 - printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", - cmdtp->name, (ulong) (cmdtp->cmd), addr); -#endif - cmdtp->cmd = - (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; - - addr = (ulong)(cmdtp->name) + gd->reloc_off; - cmdtp->name = (char *)addr; - - if (cmdtp->usage) { - addr = (ulong)(cmdtp->usage) + gd->reloc_off; - cmdtp->usage = (char *)addr; - } -#ifdef CONFIG_SYS_LONGHELP - if (cmdtp->help) { - addr = (ulong)(cmdtp->help) + gd->reloc_off; - cmdtp->help = (char *)addr; - } -#endif - } - /* there are some other pointer constants we must deal with */ -#ifndef CONFIG_ENV_IS_NOWHERE - env_name_spec += gd->reloc_off; -#endif - WATCHDOG_RESET (); #ifdef CONFIG_LOGBUFFER @@ -721,7 +673,6 @@ void board_init_r (gd_t *id, ulong dest_addr) #endif #ifdef CONFIG_POST post_output_backlog (); - post_reloc (); #endif WATCHDOG_RESET(); @@ -752,7 +703,6 @@ void board_init_r (gd_t *id, ulong dest_addr) asm ("sync ; isync"); mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN); - malloc_bin_reloc (); #if !defined(CONFIG_SYS_NO_FLASH) puts ("FLASH: "); -- cgit v1.1 From e6b05e774d7ce1641613cdeffb69c1d48139a869 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 21 Sep 2009 11:20:29 -0500 Subject: ppc: Remove extable relocation fixups Signed-off-by: Peter Tyser --- lib_ppc/extable.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'lib_ppc') diff --git a/lib_ppc/extable.c b/lib_ppc/extable.c index 91e2b3d..7408d5c 100644 --- a/lib_ppc/extable.c +++ b/lib_ppc/extable.c @@ -53,27 +53,13 @@ search_one_table(const struct exception_table_entry *first, unsigned long value) { long diff; - if ((ulong) first > CONFIG_SYS_MONITOR_BASE) { - /* exception occurs in FLASH, before u-boot relocation. - * No relocation offset is needed. - */ - while (first <= last) { - diff = first->insn - value; - if (diff == 0) - return first->fixup; - first++; - } - } else { - /* exception occurs in RAM, after u-boot relocation. - * A relocation offset should be added. - */ - while (first <= last) { - diff = (first->insn + gd->reloc_off) - value; - if (diff == 0) - return (first->fixup + gd->reloc_off); - first++; - } + while (first <= last) { + diff = first->insn - value; + if (diff == 0) + return first->fixup; + first++; } + return 0; } -- cgit v1.1 From 310cecb8ccdbc8a9be580e75b2fd362179d78535 Mon Sep 17 00:00:00 2001 From: Luigi 'Comio' Mantellini Date: Sat, 10 Oct 2009 12:42:21 +0200 Subject: Add bb_miiphy_init call before any ethernet bring-up code. Signed-off-by: Luigi 'Comio' Mantellini Signed-off-by: Ben Warren --- lib_ppc/board.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib_ppc') diff --git a/lib_ppc/board.c b/lib_ppc/board.c index 8b8ddb5..796d002 100644 --- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -83,6 +83,10 @@ #include #endif +#ifdef CONFIG_BITBANGMII +#include +#endif + #ifdef CONFIG_SYS_UPDATE_FLASH_SIZE extern int update_flash_size (int flash_size); #endif @@ -942,6 +946,9 @@ void board_init_r (gd_t *id, ulong dest_addr) doc_init (); #endif +#ifdef CONFIG_BITBANGMII + bb_miiphy_init(); +#endif #if defined(CONFIG_CMD_NET) #if defined(CONFIG_NET_MULTI) WATCHDOG_RESET (); -- cgit v1.1