[U-Boot] [PATCH v4 0/13] Introduce generic relocation feature

(This series has trivial conflicts with the generic board series in the arch/xxx/config.mk additions and also in that they both add include/linux/sections.h. I original had this series first in my list, but the generic board series now also applies directly to master, so I will leave this one as is until I know what ordering is required.)
This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series implements a generic relocation feature, which is the bridge between board_init_f() and board_init_r(). It then moves ARM over to use this framework, as an example.
On ARM the relocation code is duplicated for each CPU yet it is the same. We can bring this up to the arch level. But since (I believe) Elf relocation is basically the same process for all archs, there is no reason not to bring it up to the generic level.
Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. This is a static inline function to reduce code size overhead.
For ARM, a new arch/arm/lib/proc.S file is created, which holds generic ARM assembler code (things that cannot be written in C and are common functions used by all ARM CPUs). This helps reduce duplication. Interrupt handling code and perhaps even some startup code can move there later.
It may be useful for other architectures with a lot of different CPUs to have a similar file.
Code size on my ARMv7 system increases by 54 bytes with generic relocation. This overhead is mostly just literal pool access and setting up to call the relocated U-Boot at the end.
On my system, execution time increases from 10.8ms to 15.6ms due to the less efficient C implementations of the copy and zero loops. If execution time is of concern, you can define CONFIG_USE_ARCH_MEMSET and CONFIG_USE_ARCH_MEMCPY to reduce it. For me this reduces relocation time to 5.4ms, i.e. twice as fast as the old system.
To address the build failure in tx25 I have split out the memset()/memcpy() functions into their own file. I believe this is somewhat justified by the fact that they are now used for relocation, independently of what other part of U-Boot may or may not use the string functions. The problem with linking with the whole string.o object file is that the code size is too large for highly-constrained SPL builds which don't have -ffunction-sections defined.
Changes in v2: - Add README file for relocation - Add function comments - Import asm-generic/sections.h from Linux and add U-Boot extras - Make relocation symbols global so we can use them outside start.S - Move reloc.c into common/ - Squash generic link symbols patch into generic relocation patch - Use CONFIG_SYS_SKIP_RELOC instead of CONFIG_SYS_LEGACY_BOARD - Use an inline relocation function to reduce code size - Use memset, memcpy instead of inline code
Changes in v3: - Rebase to master - Remove the 'reloc' tag from each commit
Changes in v4: - Add new patch to fix davinci build warnings - Add new patch to fix smdk6400 with generic relocation - Add new patch to separate out memcpy(), memset() - Capital D on Define of CONFIG_SYS_SKIP_RELOC commit message - Put start_call_board_init_r() into each start.S, sadly - Rebase to master, also bring in ARM master - Remove proc.S file from Makefiles - Split out board changes into separate patches - Split out change to move relocation symbols to top of start.S files - Split out hawkboard changes into new patch - Split out mx31pdk changes into new patch - Split out start_call_board_init_r() addition into new patch - Split out tx25 changes into new patch - Update start.S pruning to fit with early patches - Use renamed start_call_board_init_r() function
Simon Glass (13): Define CONFIG_SYS_SKIP_RELOC for all archs Add generic relocation feature arm: Export and promote relocation symbols arm: Add start_call_board_init_r() to each start.S Move memcpy(), memset() into new lib/membasic.c arm: Add explicit __image_copy_end symbol for ARM926EJ-S davinci: Use correct #ifdef around gdata/bdata tx25: Modify to work with generic relocation hawkboard: Modify to work with generic relocation mx31pdk: Modify to work with generic relocation smdk6400: Modify to work with generic relocation arm: Move over to generic relocation arm: Remove unused code in start.S
README | 4 + arch/arm/cpu/arm1136/start.S | 142 +++-------------- arch/arm/cpu/arm1176/start.S | 221 +++----------------------- arch/arm/cpu/arm720t/start.S | 136 +++------------- arch/arm/cpu/arm920t/start.S | 144 +++-------------- arch/arm/cpu/arm925t/start.S | 144 +++-------------- arch/arm/cpu/arm926ejs/davinci/spl.c | 2 + arch/arm/cpu/arm926ejs/start.S | 157 ++++--------------- arch/arm/cpu/arm926ejs/u-boot.lds | 2 + arch/arm/cpu/arm946es/start.S | 139 +++-------------- arch/arm/cpu/arm_intcm/start.S | 144 +++-------------- arch/arm/cpu/armv7/start.S | 142 +++-------------- arch/arm/cpu/ixp/start.S | 136 +++------------- arch/arm/cpu/lh7a40x/start.S | 133 +++------------- arch/arm/cpu/pxa/start.S | 147 +++--------------- arch/arm/cpu/s3c44b0/start.S | 136 +++------------- arch/arm/cpu/sa1100/start.S | 133 +++------------- arch/arm/include/asm/reloc.h | 56 +++++++ arch/avr32/config.mk | 3 + arch/blackfin/config.mk | 3 + arch/m68k/config.mk | 3 + arch/microblaze/config.mk | 3 + arch/mips/config.mk | 3 + arch/nds32/config.mk | 3 + arch/nios2/config.mk | 3 + arch/powerpc/config.mk | 3 + arch/sandbox/config.mk | 3 + arch/sh/config.mk | 3 + arch/sparc/config.mk | 3 + arch/x86/config.mk | 3 + board/davinci/da8xxevm/u-boot-spl-hawk.lds | 1 + common/Makefile | 4 + common/reloc.c | 121 +++++++++++++++ doc/README.relocation | 87 +++++++++++ include/asm-generic/sections.h | 92 +++++++++++ include/configs/hawkboard.h | 2 + include/configs/tx25.h | 2 + include/reloc.h | 17 ++- lib/Makefile | 1 + lib/membasic.c | 103 +++++++++++++ lib/string.c | 71 --------- nand_spl/board/freescale/mx31pdk/Makefile | 6 + nand_spl/board/freescale/mx31pdk/u-boot.lds | 1 + nand_spl/board/karo/tx25/Makefile | 11 ++- nand_spl/board/karo/tx25/u-boot.lds | 1 + nand_spl/board/samsung/smdk6400/Makefile | 11 ++ 46 files changed, 924 insertions(+), 1761 deletions(-) create mode 100644 arch/arm/include/asm/reloc.h create mode 100644 common/reloc.c create mode 100644 doc/README.relocation create mode 100644 include/asm-generic/sections.h create mode 100644 lib/membasic.c

We are introducing a new generic relocation features and we want this to be the default. So we need to opt all architectures out first. Some may never have relocation, but those that do will eventually move over to this generic relocation framework.
This is part of the unified board effort, but since we are only dealing with relocation in this series, CONFIG_SYS_SKIP_RELOC is more appropriate than CONFIG_SYS_LEGACY_BOARD.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v2: - Use CONFIG_SYS_SKIP_RELOC instead of CONFIG_SYS_LEGACY_BOARD
Changes in v4: - Capital D on Define of CONFIG_SYS_SKIP_RELOC commit message
README | 4 ++++ arch/arm/config.mk | 3 +++ arch/avr32/config.mk | 3 +++ arch/blackfin/config.mk | 3 +++ arch/m68k/config.mk | 3 +++ arch/microblaze/config.mk | 3 +++ arch/mips/config.mk | 3 +++ arch/nds32/config.mk | 3 +++ arch/nios2/config.mk | 3 +++ arch/powerpc/config.mk | 3 +++ arch/sandbox/config.mk | 3 +++ arch/sh/config.mk | 3 +++ arch/sparc/config.mk | 3 +++ arch/x86/config.mk | 3 +++ 14 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/README b/README index 8964672..cbec491 100644 --- a/README +++ b/README @@ -2770,6 +2770,10 @@ Configuration Settings: cases. This setting can be used to tune behaviour; see lib/hashtable.c for details.
+- CONFIG_SYS_SKIP_RELOC + This makes U-Boot skip relocation for those architectures which + don't support it. It is normally defined in arch/xxx/config.mk + The following definitions that deal with the placement and management of environment data (variable area); in general, we support the following configurations: diff --git a/arch/arm/config.mk b/arch/arm/config.mk index 45f9dca..f47d4f7 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -81,3 +81,6 @@ endif ifndef CONFIG_NAND_SPL LDFLAGS_u-boot += -pie endif + +# We use legacy relocation for now +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/avr32/config.mk b/arch/avr32/config.mk index d8e7ebb..1995983 100644 --- a/arch/avr32/config.mk +++ b/arch/avr32/config.mk @@ -31,3 +31,6 @@ PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections LDFLAGS_u-boot = --gc-sections --relax
LDSCRIPT = $(SRCTREE)/$(CPUDIR)/u-boot.lds + +# We use legacy relocation for now +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/blackfin/config.mk b/arch/blackfin/config.mk index 3595aa2..56047c8 100644 --- a/arch/blackfin/config.mk +++ b/arch/blackfin/config.mk @@ -37,6 +37,9 @@ CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE))) PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
+# Blackfin does not do relocation +CONFIG_SYS_SKIP_RELOC := y + LDFLAGS_FINAL += --gc-sections LDFLAGS += -m elf32bfin PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections diff --git a/arch/m68k/config.mk b/arch/m68k/config.mk index 11ba334..52bfc81 100644 --- a/arch/m68k/config.mk +++ b/arch/m68k/config.mk @@ -29,3 +29,6 @@ PLATFORM_CPPFLAGS += -DCONFIG_M68K -D__M68K__ PLATFORM_LDFLAGS += -n PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections LDFLAGS_FINAL += --gc-sections + +# We use legacy relocation for now +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk index abea70b..7645f2e 100644 --- a/arch/microblaze/config.mk +++ b/arch/microblaze/config.mk @@ -29,3 +29,6 @@ CROSS_COMPILE ?= mb- CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__ + +# Microblaze does not do relocation +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/mips/config.mk b/arch/mips/config.mk index 6ab8acd..832b93f 100644 --- a/arch/mips/config.mk +++ b/arch/mips/config.mk @@ -52,3 +52,6 @@ PLATFORM_CPPFLAGS += -msoft-float PLATFORM_LDFLAGS += -G 0 -static -n -nostdlib PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections LDFLAGS_FINAL += --gc-sections + +# We use legacy relocation for now +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/nds32/config.mk b/arch/nds32/config.mk index c589829..4a4499b 100644 --- a/arch/nds32/config.mk +++ b/arch/nds32/config.mk @@ -33,3 +33,6 @@ PLATFORM_RELFLAGS += -gdwarf-2 PLATFORM_CPPFLAGS += -DCONFIG_NDS32 -D__nds32__ -G0 -ffixed-10 -fpie
LDFLAGS_u-boot = --gc-sections --relax + +# We use legacy relocation for now +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk index 7b03ed8..cde7f82 100644 --- a/arch/nios2/config.mk +++ b/arch/nios2/config.mk @@ -31,3 +31,6 @@ PLATFORM_CPPFLAGS += -G0
LDFLAGS_FINAL += --gc-sections PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections + +# NIOS2 does not do relocation +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk index a307154..eba562f 100644 --- a/arch/powerpc/config.mk +++ b/arch/powerpc/config.mk @@ -42,3 +42,6 @@ endif ifeq ($(CROSS_COMPILE),powerpc-openbsd-) PLATFORM_CPPFLAGS+= -D__PPC__ endif + +# We use legacy relocation for now +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 2ec1bb7..d71326f 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -19,3 +19,6 @@
PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ PLATFORM_LIBS += -lrt + +# Sandbox does not do relocation +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/sh/config.mk b/arch/sh/config.mk index 07ff8b9..48a7b37 100644 --- a/arch/sh/config.mk +++ b/arch/sh/config.mk @@ -31,3 +31,6 @@ endif PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__ PLATFORM_LDFLAGS += -e $(CONFIG_SYS_TEXT_BASE) --defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE) LDFLAGS_FINAL = --gc-sections + +# SH does not do relocation +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/sparc/config.mk b/arch/sparc/config.mk index cae7478..032659c 100644 --- a/arch/sparc/config.mk +++ b/arch/sparc/config.mk @@ -26,3 +26,6 @@ CROSS_COMPILE ?= sparc-elf- CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) -T sparc.lds
PLATFORM_CPPFLAGS += -DCONFIG_SPARC -D__sparc__ + +# Sparc does not do relocation +CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 23cacff..11f3d18 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -48,3 +48,6 @@ NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC))
export USE_PRIVATE_LIBGCC=$(shell dirname $(PREFIXED_LIBGCC)) + +# We use legacy relocation for now +CONFIG_SYS_SKIP_RELOC := y

On Monday 20 February 2012 20:32:43 Simon Glass wrote:
README | 4 ++++ arch/arm/config.mk | 3 +++ arch/avr32/config.mk | 3 +++ arch/blackfin/config.mk | 3 +++ arch/m68k/config.mk | 3 +++ arch/microblaze/config.mk | 3 +++ arch/mips/config.mk | 3 +++ arch/nds32/config.mk | 3 +++ arch/nios2/config.mk | 3 +++ arch/powerpc/config.mk | 3 +++ arch/sandbox/config.mk | 3 +++ arch/sh/config.mk | 3 +++ arch/sparc/config.mk | 3 +++ arch/x86/config.mk | 3 +++
why config.mk and not asm/config.h ? -mike

Hi Mike,
On Mon, Mar 5, 2012 at 9:04 PM, Mike Frysinger vapier@gentoo.org wrote:
On Monday 20 February 2012 20:32:43 Simon Glass wrote:
README | 4 ++++ arch/arm/config.mk | 3 +++ arch/avr32/config.mk | 3 +++ arch/blackfin/config.mk | 3 +++ arch/m68k/config.mk | 3 +++ arch/microblaze/config.mk | 3 +++ arch/mips/config.mk | 3 +++ arch/nds32/config.mk | 3 +++ arch/nios2/config.mk | 3 +++ arch/powerpc/config.mk | 3 +++ arch/sandbox/config.mk | 3 +++ arch/sh/config.mk | 3 +++ arch/sparc/config.mk | 3 +++ arch/x86/config.mk | 3 +++
why config.mk and not asm/config.h ?
Actually I think it would be better in asm/config.h. I hope that most of these will be removed in time. I will update the patch.
Regards, Simon
-mike

Add a relocation implementation as the first thing in the generic board library. This library is needed by SPL also.
We create a separate header file for link symbols defined by the link scripts. It is helpful to have these all in one place and try to make them common across architectures. Since Linux already has a similar file, we bring this in even though many of the symbols there are not relevant to us.
The __relocate_code() function is what we expect all architectures which support relocation will use eventually. For now, they all override this with their own version.
Note: The conflict with the generic board series is that the file include/asm-generic/sections.h is created in both. This should be easy to resolve once we know the order in which these series will be applied.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v2: - Add README file for relocation - Add function comments - Import asm-generic/sections.h from Linux and add U-Boot extras - Move reloc.c into common/ - Squash generic link symbols patch into generic relocation patch - Use memset, memcpy instead of inline code
Changes in v4: - Use renamed start_call_board_init_r() function
common/Makefile | 4 + common/reloc.c | 121 ++++++++++++++++++++++++++++++++++++++++ doc/README.relocation | 87 ++++++++++++++++++++++++++++ include/asm-generic/sections.h | 92 ++++++++++++++++++++++++++++++ include/reloc.h | 17 +++++- 5 files changed, 320 insertions(+), 1 deletions(-) create mode 100644 common/reloc.c create mode 100644 doc/README.relocation create mode 100644 include/asm-generic/sections.h
diff --git a/common/Makefile b/common/Makefile index 2d9ae8c..3801c28 100644 --- a/common/Makefile +++ b/common/Makefile @@ -189,6 +189,10 @@ COBJS-y += dlmalloc.o COBJS-y += memsize.o COBJS-y += stdio.o
+ifndef CONFIG_SYS_SKIP_RELOC +COBJS-y += reloc.o +endif +
COBJS := $(sort $(COBJS-y)) XCOBJS := $(sort $(XCOBJS-y)) diff --git a/common/reloc.c b/common/reloc.c new file mode 100644 index 0000000..85fdb6d --- /dev/null +++ b/common/reloc.c @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm-generic/sections.h> +#include <asm/reloc.h> +#include <reloc.h> +#include <nand.h> + +DECLARE_GLOBAL_DATA_PTR; + +static int reloc_make_copy(void) +{ + char *dst_addr = (char *)gd->relocaddr; + + /* TODO: __text_start would be better when we have it */ + char *src_addr = (char *)_start; + /* TODO: switch over to __image_copy_end when we can */ +#ifdef CONFIG_SPL_BUILD + char *end_addr = src_addr + _image_copy_end_ofs; +#else + char *end_addr = src_addr + _rel_dyn_start_ofs; +#endif + + if (dst_addr != src_addr) { + size_t size = end_addr - src_addr; + + debug("%s: copy code %p-%p to %p-%p\n", __func__, + src_addr, end_addr, dst_addr, dst_addr + size); + memcpy(dst_addr, src_addr, size); + } + return 0; +} + +static int reloc_elf(void) +{ +#ifndef CONFIG_SPL_BUILD + const Elf32_Rel *ptr, *end; + Elf32_Addr *addr; + char *src_addr = (char *)_start; + Elf32_Sym *dynsym; + ulong reloc_ofs = gd->reloc_off; + + /* scan the relocation table for relevant entries */ + ptr = (Elf32_Rel *)(src_addr + _rel_dyn_start_ofs); + end = (Elf32_Rel *)(src_addr + _rel_dyn_end_ofs); + dynsym = (Elf32_Sym *)(src_addr + _dynsym_start_ofs); + debug("%s: process reloc entries %p-%p, dynsym at %p\n", __func__, + ptr, end, dynsym); + for (; ptr < end; ptr++) { + addr = (Elf32_Addr *)(ptr->r_offset + reloc_ofs); + if (arch_elf_relocate_entry(addr, ptr->r_info, dynsym, + reloc_ofs)) + return -1; + } +#endif + return 0; +} + +static int reloc_clear_bss(void) +{ + char *dst_addr = (char *)_start + _bss_start_ofs; + size_t size = _bss_end_ofs - _bss_start_ofs; + +#ifndef CONFIG_SPL_BUILD + /* No relocation for SPL (TBD: better to set reloc_off to zero) */ + dst_addr += gd->reloc_off; +#endif + + /* TODO: use memset */ + debug("%s: zero bss %p-%p\n", __func__, dst_addr, dst_addr + size); + memset(dst_addr, '\0', size); + + return 0; +} + +void __relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr) +{ + ulong new_board_init_r = (uintptr_t)board_init_r + gd->reloc_off; + + /* TODO: It might be better to put the offsets in global data */ + debug("%s, dest_addr_sp=%lx, new_gd=%p, dest_addr=%lx\n", __func__, + dest_addr_sp, new_gd, dest_addr); + reloc_make_copy(); + reloc_elf(); + reloc_clear_bss(); + + debug("relocation complete: starting from board_init_r() at %lx\n", + new_board_init_r); + /* TODO: tidy this up since we don't want a separate nand_boot() */ +#ifdef CONFIG_NAND_SPL + nand_boot(); +#else + start_call_board_init_r(new_gd, dest_addr, + (board_init_r_func)new_board_init_r, + dest_addr_sp); +#endif +} + +/* Allow architectures to override this function - initially they all will */ +void relocate_code(ulong dest_sp, gd_t *new_gd, ulong dest_add) + __attribute__((weak, alias("__relocate_code"))); diff --git a/doc/README.relocation b/doc/README.relocation new file mode 100644 index 0000000..6dfbe9c --- /dev/null +++ b/doc/README.relocation @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +Generic Relocation Framework +============================ + +Since most architectures perform relocation and mostly share the same +procedure, a generic relocation framework has been created. + + +What is Relocation? +------------------- +The basic purpose of relocation is to move U-Boot from its starting +address (probably CONFIG_SYS_TEXT_BASE) to the top the RAM. This makes +it easy to use the rest of available RAM in one chunk for things like +loading a kernel or ram disk. + +The relocation code is in common/reloc.c in a function called +__relocate_code(). It is called right at the end of board_init_f() and +performs these steps: + +- Copies U-Boot to the top of RAM +- Adjusts any code/data which needs relocation for the new position +- Clears our the BSS (so that your global variables start as zero!) +- Jumps to the new U-Boot, to a function called board_init_r() + + +How do I use the framework? +--------------------------- +To use the generic framework, you should define a function for your +architecture in arch/xxx/include/asm/reloc.h like this: + +/** + * Process a single ELF relocation entry + * + * @param addr Pointer to address of intruction/data to relocate + * @param info The ELF information word / flags + * @param symtab The ELF relocation symbol table + * @param reloc_off Offset of relocated U-Boot relative to load address + * @return 0 if ok, -1 on error + */ +static inline int arch_elf_relocate_entry(Elf32_Addr *addr, Elf32_Word info, + Elf32_Sym *symtab, ulong reloc_off); + + +This function should relocate the code/data at the given relocated address +based on the relocation information in 'info'. The ELF symbol table and +relocation offset (new position minus CONFIG_SYS_TEXT_BASE) are provided. + + +How fast is relocation? +----------------------- +It's pretty fast, but if you want to speed up relocation, you can define +these two CONFIGs in your board file: + +#define CONFIG_USE_ARCH_MEMSET - speeds up BSS clearing +#define CONFIG_USE_ARCH_MEMCPY - speeds up copying of code/data + +Rough benchmarks on a Tegra2x ARM system showed that using both cut the total +relocation time by 65% (from 15ms to 5ms). + + +Opting Out +---------- +If you want to do relocation yourself, you can define your own +relocate_code() function. See include/reloc.h for the prototype. You +can also define CONFIG_SYS_SKIP_RELOC to disable the generic relocation +and remove its code. diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h new file mode 100644 index 0000000..2935dc1 --- /dev/null +++ b/include/asm-generic/sections.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* Taken from Linux kernel */ + +#ifndef _ASM_GENERIC_SECTIONS_H_ +#define _ASM_GENERIC_SECTIONS_H_ + +/* References to section boundaries */ + +extern char _text[], _stext[], _etext[]; +extern char _data[], _sdata[], _edata[]; +extern char __bss_start[], __bss_stop[]; +extern char __init_begin[], __init_end[]; +extern char _sinittext[], _einittext[]; +extern char _end[]; +extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[]; +extern char __kprobes_text_start[], __kprobes_text_end[]; +extern char __entry_text_start[], __entry_text_end[]; +extern char __initdata_begin[], __initdata_end[]; +extern char __start_rodata[], __end_rodata[]; + +/* Start and end of .ctors section - used for constructor calls. */ +extern char __ctors_start[], __ctors_end[]; + +/* function descriptor handling (if any). Override + * in asm/sections.h */ +#ifndef dereference_function_descriptor +#define dereference_function_descriptor(p) (p) +#endif + +/* random extra sections (if any). Override + * in asm/sections.h */ +#ifndef arch_is_kernel_text +static inline int arch_is_kernel_text(unsigned long addr) +{ + return 0; +} +#endif + +#ifndef arch_is_kernel_data +static inline int arch_is_kernel_data(unsigned long addr) +{ + return 0; +} +#endif + +#include <elf.h> + +/* U-Boot-specific things begin here */ + +/* Start of U-Boot text region */ +extern char __text_start[]; + +/* This marks the end of the text region which must be relocated */ +extern char __image_copy_end[]; + +/* + * This is the U-Boot entry point - prior to relocation it should be same + * as __text_start + */ +extern void _start(void); + +/* Start/end of the relocation entries, as an offset from _start */ +extern ulong _rel_dyn_start_ofs; +extern ulong _rel_dyn_end_ofs; + +/* Start/end of the relocation symbol table, as an offset from _start */ +extern ulong _dynsym_start_ofs; + +/* End of the region to be relocated, as an offset form _start */ +extern ulong _image_copy_end_ofs; + +#endif /* _ASM_GENERIC_SECTIONS_H_ */ diff --git a/include/reloc.h b/include/reloc.h index 3dc7b85..2a8778e 100644 --- a/include/reloc.h +++ b/include/reloc.h @@ -23,12 +23,27 @@ #ifndef __RELOC_H #define __RELOC_H
+/* This is the prototype for the post-relocation init function */ +typedef void (*board_init_r_func)(gd_t *, ulong); + +/** + * Call the relocated U-Boot. This is the last thing that is done after + * relocation. This function does not return. + * + * @param new_gd Pointer to the relocated global data + * @param dest_addr Base code address of relocated U-Boot + * @param board_init_r_func Pointer to relocated function to call + */ +void start_call_board_init_r(gd_t *new_gd, ulong dest_addr, + board_init_r_func board_init_r, ulong dest_addr_sp) + __attribute__ ((noreturn)); + /** * Relocate U-Boot and jump to the relocated coded * * This copies U-Boot to a new location, zeroes the BSS, sets up a new stack * and jumps to board_init_r() in the relocated code using the - * proc_call_board_init_r() function. It does not return. + * start_call_board_init_r() function. It does not return. * * @param dest_sp New stack pointer to use * @param new_gd Pointer to the relocated global data

Hi Simon,
Le 21/02/2012 02:32, Simon Glass a écrit :
The __relocate_code() function is what we expect all architectures which support relocation will use eventually. For now, they all override this with their own version.
Why the double underscore?
Amicalement,

Hi Albert,
On Tue, Feb 21, 2012 at 11:36 AM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
Hi Simon,
Le 21/02/2012 02:32, Simon Glass a écrit :
The __relocate_code() function is what we expect all architectures which support relocation will use eventually. For now, they all override this with their own version.
Why the double underscore?
It is a default implementation of relocate_code() - a weak function alias. It seems that this is the naming convention used in U-Boot for this, but I'm not sure why.
Amicalement,
Albert.
Regards, Simon

These symbols are currently part-way through each file. Most have the same code, but there are small variations.
We move all these relocation symbols to the start next to the other exported symbols, and export them so we can use them in generic relocation code.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v4: - Split out change to move relocation symbols to top of start.S files
arch/arm/cpu/arm1136/start.S | 19 ++++++++++++------- arch/arm/cpu/arm1176/start.S | 19 ++++++++++++------- arch/arm/cpu/arm720t/start.S | 19 ++++++++++++------- arch/arm/cpu/arm920t/start.S | 19 ++++++++++++------- arch/arm/cpu/arm925t/start.S | 19 ++++++++++++------- arch/arm/cpu/arm926ejs/start.S | 19 ++++++++++++------- arch/arm/cpu/arm946es/start.S | 19 ++++++++++++------- arch/arm/cpu/arm_intcm/start.S | 19 ++++++++++++------- arch/arm/cpu/armv7/start.S | 20 ++++++++++++++------ arch/arm/cpu/ixp/start.S | 19 ++++++++++++------- arch/arm/cpu/lh7a40x/start.S | 19 ++++++++++++------- arch/arm/cpu/pxa/start.S | 18 ++++++++++++------ arch/arm/cpu/s3c44b0/start.S | 19 ++++++++++++------- arch/arm/cpu/sa1100/start.S | 19 ++++++++++++------- 14 files changed, 170 insertions(+), 96 deletions(-)
diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S index c0db96c..28e059e 100644 --- a/arch/arm/cpu/arm1136/start.S +++ b/arch/arm/cpu/arm1136/start.S @@ -108,6 +108,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -283,13 +295,6 @@ _board_init_r_ofs: .word board_init_r - _start #endif
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S index 848144a..0c749b4 100644 --- a/arch/arm/cpu/arm1176/start.S +++ b/arch/arm/cpu/arm1176/start.S @@ -127,6 +127,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + /* IRQ stack memory (calculated at run-time) + 8 bytes */ .globl IRQ_STACK_START_IN IRQ_STACK_START_IN: @@ -385,13 +397,6 @@ _board_init_r_ofs: .word board_init_r - _start #endif
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - #ifdef CONFIG_ENABLE_MMU _mmu_table_base: .word mmu_table diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S index 540e3c2..80814d6 100644 --- a/arch/arm/cpu/arm720t/start.S +++ b/arch/arm/cpu/arm720t/start.S @@ -97,6 +97,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -254,13 +266,6 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/arm920t/start.S b/arch/arm/cpu/arm920t/start.S index 8c5612c..57b2b59 100644 --- a/arch/arm/cpu/arm920t/start.S +++ b/arch/arm/cpu/arm920t/start.S @@ -93,6 +93,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -305,13 +317,6 @@ _board_init_r_ofs: .word board_init_r - _start #endif
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/arm925t/start.S b/arch/arm/cpu/arm925t/start.S index dbb93ef..5dafc11 100644 --- a/arch/arm/cpu/arm925t/start.S +++ b/arch/arm/cpu/arm925t/start.S @@ -103,6 +103,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -299,13 +311,6 @@ _board_init_r_ofs: .word board_init_r - _start #endif
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index 6f05f1a..6b8fdc5 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -160,6 +160,18 @@ _end: .word __bss_end__ #endif
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -338,13 +350,6 @@ _board_init_r_ofs: .word board_init_r - _start #endif
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/arm946es/start.S b/arch/arm/cpu/arm946es/start.S index 89ba558..448979f 100644 --- a/arch/arm/cpu/arm946es/start.S +++ b/arch/arm/cpu/arm946es/start.S @@ -109,6 +109,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -265,13 +277,6 @@ _board_init_r_ofs: .word board_init_r - _start #endif
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/arm_intcm/start.S b/arch/arm/cpu/arm_intcm/start.S index 2033b36..7a9dbd1 100644 --- a/arch/arm/cpu/arm_intcm/start.S +++ b/arch/arm/cpu/arm_intcm/start.S @@ -105,6 +105,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -266,13 +278,6 @@ _board_init_r_ofs: .word board_init_r - _start #endif
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index ef08a55..8a616fa 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -101,6 +101,20 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+#ifndef CONFIG_SPL_BUILD +.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start +#endif + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -236,12 +250,6 @@ fixnext: cmp r2, r3 blo fixloop b clear_bss -_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start
#endif /* #ifndef CONFIG_SPL_BUILD */
diff --git a/arch/arm/cpu/ixp/start.S b/arch/arm/cpu/ixp/start.S index cb32121..68d8029 100644 --- a/arch/arm/cpu/ixp/start.S +++ b/arch/arm/cpu/ixp/start.S @@ -118,6 +118,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -360,13 +372,6 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /****************************************************************************/ /* */ /* Interrupt handling */ diff --git a/arch/arm/cpu/lh7a40x/start.S b/arch/arm/cpu/lh7a40x/start.S index 62de8b8..3274f43 100644 --- a/arch/arm/cpu/lh7a40x/start.S +++ b/arch/arm/cpu/lh7a40x/start.S @@ -93,6 +93,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -268,13 +280,6 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S index ba0de8f..9de1a4a 100644 --- a/arch/arm/cpu/pxa/start.S +++ b/arch/arm/cpu/pxa/start.S @@ -126,6 +126,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -290,12 +302,6 @@ _board_init_r_ofs: .word board_init_r - _start #endif
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start #endif /* ************************************************************************* diff --git a/arch/arm/cpu/s3c44b0/start.S b/arch/arm/cpu/s3c44b0/start.S index a29d5b4..ffb3ebf 100644 --- a/arch/arm/cpu/s3c44b0/start.S +++ b/arch/arm/cpu/s3c44b0/start.S @@ -84,6 +84,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -243,13 +255,6 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* * diff --git a/arch/arm/cpu/sa1100/start.S b/arch/arm/cpu/sa1100/start.S index 92546d8..168b11f 100644 --- a/arch/arm/cpu/sa1100/start.S +++ b/arch/arm/cpu/sa1100/start.S @@ -94,6 +94,18 @@ _bss_end_ofs: _end_ofs: .word _end - _start
+.globl _rel_dyn_start_ofs +_rel_dyn_start_ofs: + .word __rel_dyn_start - _start + +.globl _rel_dyn_end_ofs +_rel_dyn_end_ofs: + .word __rel_dyn_end - _start + +.globl _dynsym_start_ofs +_dynsym_start_ofs: + .word __dynsym_start - _start + #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START @@ -244,13 +256,6 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
-_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - /* ************************************************************************* *

We don't want this in a common file, or at least not yet, so add this function to every start.S individually. The existing code tacked on the end of a long relocation function and does not suit our needs since it doesn't allow the address of board_init_r() to be passed in and cannot be called from C since it expects values in registers r4 and above.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v4: - Put start_call_board_init_r() into each start.S, sadly - Split out start_call_board_init_r() addition into new patch
arch/arm/cpu/arm1136/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm1176/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm720t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm920t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm925t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm926ejs/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm946es/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm_intcm/start.S | 19 +++++++++++++++++++ arch/arm/cpu/armv7/start.S | 19 +++++++++++++++++++ arch/arm/cpu/ixp/start.S | 19 +++++++++++++++++++ arch/arm/cpu/lh7a40x/start.S | 19 +++++++++++++++++++ arch/arm/cpu/pxa/start.S | 20 ++++++++++++++++++++ arch/arm/cpu/s3c44b0/start.S | 19 +++++++++++++++++++ arch/arm/cpu/sa1100/start.S | 19 +++++++++++++++++++ 14 files changed, 267 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S index 28e059e..e74d5f9 100644 --- a/arch/arm/cpu/arm1136/start.S +++ b/arch/arm/cpu/arm1136/start.S @@ -295,6 +295,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S index 0c749b4..7fc6a18 100644 --- a/arch/arm/cpu/arm1176/start.S +++ b/arch/arm/cpu/arm1176/start.S @@ -397,6 +397,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + #ifdef CONFIG_ENABLE_MMU _mmu_table_base: .word mmu_table diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S index 80814d6..cdbe751 100644 --- a/arch/arm/cpu/arm720t/start.S +++ b/arch/arm/cpu/arm720t/start.S @@ -266,6 +266,25 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/arm920t/start.S b/arch/arm/cpu/arm920t/start.S index 57b2b59..3257df6 100644 --- a/arch/arm/cpu/arm920t/start.S +++ b/arch/arm/cpu/arm920t/start.S @@ -317,6 +317,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/arm925t/start.S b/arch/arm/cpu/arm925t/start.S index 5dafc11..b9181bf 100644 --- a/arch/arm/cpu/arm925t/start.S +++ b/arch/arm/cpu/arm925t/start.S @@ -311,6 +311,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index 6b8fdc5..2c8ff81 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -350,6 +350,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/arm946es/start.S b/arch/arm/cpu/arm946es/start.S index 448979f..469a141 100644 --- a/arch/arm/cpu/arm946es/start.S +++ b/arch/arm/cpu/arm946es/start.S @@ -277,6 +277,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/arm_intcm/start.S b/arch/arm/cpu/arm_intcm/start.S index 7a9dbd1..0e469e9 100644 --- a/arch/arm/cpu/arm_intcm/start.S +++ b/arch/arm/cpu/arm_intcm/start.S @@ -278,6 +278,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 8a616fa..5581387 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -298,6 +298,25 @@ jump_2_ram: _board_init_r_ofs: .word board_init_r - _start
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /************************************************************************* * * cpu_init_cp15 diff --git a/arch/arm/cpu/ixp/start.S b/arch/arm/cpu/ixp/start.S index 68d8029..f00ad38 100644 --- a/arch/arm/cpu/ixp/start.S +++ b/arch/arm/cpu/ixp/start.S @@ -372,6 +372,25 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /****************************************************************************/ /* */ /* Interrupt handling */ diff --git a/arch/arm/cpu/lh7a40x/start.S b/arch/arm/cpu/lh7a40x/start.S index 3274f43..48b8639 100644 --- a/arch/arm/cpu/lh7a40x/start.S +++ b/arch/arm/cpu/lh7a40x/start.S @@ -280,6 +280,25 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S index 9de1a4a..30f15b6 100644 --- a/arch/arm/cpu/pxa/start.S +++ b/arch/arm/cpu/pxa/start.S @@ -303,6 +303,26 @@ _board_init_r_ofs: #endif
#endif + +/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/s3c44b0/start.S b/arch/arm/cpu/s3c44b0/start.S index ffb3ebf..f470f10 100644 --- a/arch/arm/cpu/s3c44b0/start.S +++ b/arch/arm/cpu/s3c44b0/start.S @@ -255,6 +255,25 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* * diff --git a/arch/arm/cpu/sa1100/start.S b/arch/arm/cpu/sa1100/start.S index 168b11f..fce6f87 100644 --- a/arch/arm/cpu/sa1100/start.S +++ b/arch/arm/cpu/sa1100/start.S @@ -256,6 +256,25 @@ clbss_l:str r2, [r0] /* clear loop... */ _board_init_r_ofs: .word board_init_r - _start
+/** + * Jump to board_init_r with a new stack pointer + * + * @param gd Pointer to global data + * @param dest_addr Destination address from global data + * @param func Address of board_init_r function (relocated) + * @param sp New stack pointer + */ +.globl start_call_board_init_r +start_call_board_init_r: +#ifndef CONFIG_SYS_ICACHE_OFF + mcr p15, 0, r0, c7, c5, 0 @ invalidate icache + mcr p15, 0, r0, c7, c10, 4 @ DSB + mcr p15, 0, r0, c7, c5, 4 @ ISB +#endif + mov sp, r3 + /* jump to it ... */ + mov pc, r2 + /* ************************************************************************* *

Hi Simon,
Le 21/02/2012 02:32, Simon Glass a écrit :
We don't want this in a common file, or at least not yet, so add this function to every start.S individually. The existing code tacked on the end of a long relocation function and does not suit our needs since it doesn't allow the address of board_init_r() to be passed in and cannot be called from C since it expects values in registers r4 and above.
It is not really an addition, as every start.S file involved already has this sequence at the end of its relocate_code routine.
Signed-off-by: Simon Glasssjg@chromium.org
Changes in v4:
Put start_call_board_init_r() into each start.S, sadly
Split out start_call_board_init_r() addition into new patch
arch/arm/cpu/arm1136/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm1176/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm720t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm920t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm925t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm926ejs/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm946es/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm_intcm/start.S | 19 +++++++++++++++++++ arch/arm/cpu/armv7/start.S | 19 +++++++++++++++++++ arch/arm/cpu/ixp/start.S | 19 +++++++++++++++++++ arch/arm/cpu/lh7a40x/start.S | 19 +++++++++++++++++++ arch/arm/cpu/pxa/start.S | 20 ++++++++++++++++++++ arch/arm/cpu/s3c44b0/start.S | 19 +++++++++++++++++++ arch/arm/cpu/sa1100/start.S | 19 +++++++++++++++++++ 14 files changed, 267 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S index 28e059e..e74d5f9 100644 --- a/arch/arm/cpu/arm1136/start.S +++ b/arch/arm/cpu/arm1136/start.S @@ -295,6 +295,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/**
Do we agree to Doxygen annotations in U-Boot?
- Jump to board_init_r with a new stack pointer
- @param gd Pointer to global data
- @param dest_addr Destination address from global data
- @param func Address of board_init_r function (relocated)
- @param sp New stack pointer
- */
+.globl start_call_board_init_r +start_call_board_init_r:
Why "start_call_board_init_r"? "start_" may mislead readers into thinking we're starting something there and finishing it elsewhere, and "call_board_init_r" doesn't tell we're switching stacks etc.
I suggest "pivot_to_board_init_r", in analogy with Linux 'pivot_root'. Other suggestions are welcome.
Better yet, we could avoid this new function altogether and make start.S much cleaner by rewriting the startup sequence as:
1. start.S sets up the initial stack 2. start.S calls C function board_init_f 3. board_init_f allocates initial GD and stores final stack, final GD, and final base address within initial GD, then returns normally 4. start.S sets up the final stack and final GD 4. start.S calls C function relocate_code using relevant GD fields as its arguments 5. relocate_code returns normally 6. start.S calls either nand_boot or board_init_r()
This way all the logic would be in start.S and board_init_f(), relocate_code() and board_init_r() would be simple and independent functions.
Amicalement,

Hi Albert,
On Tue, Feb 21, 2012 at 11:32 AM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
Hi Simon,
Le 21/02/2012 02:32, Simon Glass a écrit :
We don't want this in a common file, or at least not yet, so add this function to every start.S individually. The existing code tacked on the end of a long relocation function and does not suit our needs since it doesn't allow the address of board_init_r() to be passed in and cannot be called from C since it expects values in registers r4 and above.
It is not really an addition, as every start.S file involved already has this sequence at the end of its relocate_code routine.
Signed-off-by: Simon Glasssjg@chromium.org
Changes in v4:
- Put start_call_board_init_r() into each start.S, sadly
- Split out start_call_board_init_r() addition into new patch
arch/arm/cpu/arm1136/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm1176/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm720t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm920t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm925t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm926ejs/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm946es/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm_intcm/start.S | 19 +++++++++++++++++++ arch/arm/cpu/armv7/start.S | 19 +++++++++++++++++++ arch/arm/cpu/ixp/start.S | 19 +++++++++++++++++++ arch/arm/cpu/lh7a40x/start.S | 19 +++++++++++++++++++ arch/arm/cpu/pxa/start.S | 20 ++++++++++++++++++++ arch/arm/cpu/s3c44b0/start.S | 19 +++++++++++++++++++ arch/arm/cpu/sa1100/start.S | 19 +++++++++++++++++++ 14 files changed, 267 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S index 28e059e..e74d5f9 100644 --- a/arch/arm/cpu/arm1136/start.S +++ b/arch/arm/cpu/arm1136/start.S @@ -295,6 +295,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/**
Do we agree to Doxygen annotations in U-Boot?
I hope so, it makes things easy to read for those with editors that support it.
- Jump to board_init_r with a new stack pointer
- @param gd Pointer to global data
- @param dest_addr Destination address from global data
- @param func Address of board_init_r function (relocated)
- @param sp New stack pointer
- */
+.globl start_call_board_init_r +start_call_board_init_r:
Why "start_call_board_init_r"? "start_" may mislead readers into thinking we're starting something there and finishing it elsewhere, and "call_board_init_r" doesn't tell we're switching stacks etc.
I suggest "pivot_to_board_init_r", in analogy with Linux 'pivot_root'. Other suggestions are welcome.
OK I will go with pivot_to_board_init_r.
Better yet, we could avoid this new function altogether and make start.S much cleaner by rewriting the startup sequence as:
- start.S sets up the initial stack
- start.S calls C function board_init_f
- board_init_f allocates initial GD and stores final stack, final GD,
and final base address within initial GD, then returns normally 4. start.S sets up the final stack and final GD 4. start.S calls C function relocate_code using relevant GD fields as its arguments 5. relocate_code returns normally 6. start.S calls either nand_boot or board_init_r()
This way all the logic would be in start.S and board_init_f(), relocate_code() and board_init_r() would be simple and independent functions.
Please see the generic relocation effort which I think is a better place to put this. If you like I can revisit this once we have that sorted out.
Amicalement,
Albert.
Regards, Simon

Hi Albert,
On Tue, Feb 21, 2012 at 12:02 PM, Simon Glass sjg@chromium.org wrote:
Hi Albert,
On Tue, Feb 21, 2012 at 11:32 AM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
Hi Simon,
Le 21/02/2012 02:32, Simon Glass a écrit :
We don't want this in a common file, or at least not yet, so add this function to every start.S individually. The existing code tacked on the end of a long relocation function and does not suit our needs since it doesn't allow the address of board_init_r() to be passed in and cannot be called from C since it expects values in registers r4 and above.
It is not really an addition, as every start.S file involved already has this sequence at the end of its relocate_code routine.
Signed-off-by: Simon Glasssjg@chromium.org
Changes in v4:
- Put start_call_board_init_r() into each start.S, sadly
- Split out start_call_board_init_r() addition into new patch
arch/arm/cpu/arm1136/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm1176/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm720t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm920t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm925t/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm926ejs/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm946es/start.S | 19 +++++++++++++++++++ arch/arm/cpu/arm_intcm/start.S | 19 +++++++++++++++++++ arch/arm/cpu/armv7/start.S | 19 +++++++++++++++++++ arch/arm/cpu/ixp/start.S | 19 +++++++++++++++++++ arch/arm/cpu/lh7a40x/start.S | 19 +++++++++++++++++++ arch/arm/cpu/pxa/start.S | 20 ++++++++++++++++++++ arch/arm/cpu/s3c44b0/start.S | 19 +++++++++++++++++++ arch/arm/cpu/sa1100/start.S | 19 +++++++++++++++++++ 14 files changed, 267 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S index 28e059e..e74d5f9 100644 --- a/arch/arm/cpu/arm1136/start.S +++ b/arch/arm/cpu/arm1136/start.S @@ -295,6 +295,25 @@ _board_init_r_ofs: .word board_init_r - _start #endif
+/**
Do we agree to Doxygen annotations in U-Boot?
I hope so, it makes things easy to read for those with editors that support it.
- Jump to board_init_r with a new stack pointer
- @param gd Pointer to global data
- @param dest_addr Destination address from global data
- @param func Address of board_init_r function (relocated)
- @param sp New stack pointer
- */
+.globl start_call_board_init_r +start_call_board_init_r:
Why "start_call_board_init_r"? "start_" may mislead readers into thinking we're starting something there and finishing it elsewhere, and "call_board_init_r" doesn't tell we're switching stacks etc.
I suggest "pivot_to_board_init_r", in analogy with Linux 'pivot_root'. Other suggestions are welcome.
OK I will go with pivot_to_board_init_r.
I have updated two of the patches to v5 to deal with this change.
Better yet, we could avoid this new function altogether and make start.S much cleaner by rewriting the startup sequence as:
- start.S sets up the initial stack
- start.S calls C function board_init_f
- board_init_f allocates initial GD and stores final stack, final GD,
and final base address within initial GD, then returns normally 4. start.S sets up the final stack and final GD 4. start.S calls C function relocate_code using relevant GD fields as its arguments 5. relocate_code returns normally 6. start.S calls either nand_boot or board_init_r()
This way all the logic would be in start.S and board_init_f(), relocate_code() and board_init_r() would be simple and independent functions.
Please see the generic relocation effort which I think is a better place to put this. If you like I can revisit this once we have that sorted out.
Sorry I meant the generic board init series. Once we have generic board init and generic relocation then everything becomes common. Then it might be easier to change the function signature of board_init_f() or board_init_r() if we want to.
One more point - as Graeme points out it would be nice to turn on the dcache earlier. Another thing to look at under generic board init I think.
Regards, Simon

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.
Also tidy up the checkpatch warnings and function comments at the same time.
I considered splitting these into two separate files, but I think that is overkill. The justification is that these two functions are needed regardless of what the 'user' code in U-Boot does, just to support relocation.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v4: - Add new patch to separate out memcpy(), memset()
lib/Makefile | 1 + lib/membasic.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/string.c | 71 -------------------------------------- 3 files changed, 104 insertions(+), 71 deletions(-) create mode 100644 lib/membasic.c
diff --git a/lib/Makefile b/lib/Makefile index e6e6ec6..0480824 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -57,6 +57,7 @@ endif
COBJS-y += ctype.o COBJS-y += div64.o +COBJS-y += membasic.o COBJS-y += string.o COBJS-y += time.o COBJS-$(CONFIG_BOOTP_PXE) += uuid.o diff --git a/lib/membasic.c b/lib/membasic.c new file mode 100644 index 0000000..2448e4c --- /dev/null +++ b/lib/membasic.c @@ -0,0 +1,103 @@ +/* + * Basic memory routines needed by relocation (memcpy, memset). + * + * Copyright (c) 2011 The Chromium OS Authors. + * Copyright (C) 1991, 1992 Linus Torvalds + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <linux/types.h> +#include <linux/string.h> + + +#ifndef __HAVE_ARCH_MEMSET +/** + * Fill a region of memory with the given value + * + * @param s Pointer to the start of the area. + * @param c The byte to fill the area with + * @param count The size of the area. + * @return pointer to start of the area (as passed in) + * + * Do not use memset() to access IO space, use memset_io() instead. + */ +void *memset(void *s, int c, size_t count) +{ + unsigned long *sl = (unsigned long *) s; + unsigned long cl = 0; + char *s8; + int i; + + /* do it one word at a time (32 bits or 64 bits) while possible */ + if (((ulong)s & (sizeof(*sl) - 1)) == 0) { + for (i = 0; i < sizeof(*sl); i++) { + cl <<= 8; + cl |= c & 0xff; + } + while (count >= sizeof(*sl)) { + *sl++ = cl; + count -= sizeof(*sl); + } + } + /* fill 8 bits at a time */ + s8 = (char *)sl; + while (count--) + *s8++ = c; + + return s; +} +#endif + +#ifndef __HAVE_ARCH_MEMCPY +/** + * Copy one area of memory to another + * + * You should not use this function to access IO space, use memcpy_toio() + * or memcpy_fromio() instead. + * + * @param dest Where to copy to + * @param src Where to copy from + * @param count The size of the area. + * @return destination address (as passed in) + */ +void *memcpy(void *dest, const void *src, size_t count) +{ + unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src; + char *d8, *s8; + + if (src == dest) + return dest; + + /* while all data is aligned (common case), copy a word at a time */ + if ((((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) { + while (count >= sizeof(*dl)) { + *dl++ = *sl++; + count -= sizeof(*dl); + } + } + /* copy the reset one byte at a time */ + d8 = (char *)dl; + s8 = (char *)sl; + while (count--) + *d8++ = *s8++; + + return dest; +} +#endif diff --git a/lib/string.c b/lib/string.c index c3ad055..5db0eaf 100644 --- a/lib/string.c +++ b/lib/string.c @@ -431,42 +431,6 @@ char *strswab(const char *s) } #endif
-#ifndef __HAVE_ARCH_MEMSET -/** - * memset - Fill a region of memory with the given value - * @s: Pointer to the start of the area. - * @c: The byte to fill the area with - * @count: The size of the area. - * - * Do not use memset() to access IO space, use memset_io() instead. - */ -void * memset(void * s,int c,size_t count) -{ - unsigned long *sl = (unsigned long *) s; - unsigned long cl = 0; - char *s8; - int i; - - /* do it one word at a time (32 bits or 64 bits) while possible */ - if ( ((ulong)s & (sizeof(*sl) - 1)) == 0) { - for (i = 0; i < sizeof(*sl); i++) { - cl <<= 8; - cl |= c & 0xff; - } - while (count >= sizeof(*sl)) { - *sl++ = cl; - count -= sizeof(*sl); - } - } - /* fill 8 bits at a time */ - s8 = (char *)sl; - while (count--) - *s8++ = c; - - return s; -} -#endif - #ifndef __HAVE_ARCH_BCOPY /** * bcopy - Copy one area of memory to another @@ -491,41 +455,6 @@ char * bcopy(const char * src, char * dest, int count) } #endif
-#ifndef __HAVE_ARCH_MEMCPY -/** - * memcpy - Copy one area of memory to another - * @dest: Where to copy to - * @src: Where to copy from - * @count: The size of the area. - * - * You should not use this function to access IO space, use memcpy_toio() - * or memcpy_fromio() instead. - */ -void * memcpy(void *dest, const void *src, size_t count) -{ - unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src; - char *d8, *s8; - - if (src == dest) - return dest; - - /* while all data is aligned (common case), copy a word at a time */ - if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) { - while (count >= sizeof(*dl)) { - *dl++ = *sl++; - count -= sizeof(*dl); - } - } - /* copy the reset one byte at a time */ - d8 = (char *)dl; - s8 = (char *)sl; - while (count--) - *d8++ = *s8++; - - return dest; -} -#endif - #ifndef __HAVE_ARCH_MEMMOVE /** * memmove - Copy one area of memory to another

On Monday 20 February 2012 20:32:47 Simon Glass wrote:
These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.
seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do. -mike

Hi Mike,
On Mon, Mar 5, 2012 at 9:05 PM, Mike Frysinger vapier@gentoo.org wrote:
On Monday 20 February 2012 20:32:47 Simon Glass wrote:
These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.
seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do.
I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.
IXP does enable it, but not ARM in general. Most archs use function-sections although not all. Perhaps there are some boards which don't work with this flag?
Albert do you know?
Regards, Simon
-mike

On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
On Mon, Mar 5, 2012 at 9:05 PM, Mike Frysinger wrote:
On Monday 20 February 2012 20:32:47 Simon Glass wrote:
These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.
seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do.
I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.
if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". plus, fixing this yields general improvements in anti-bloat for everyone.
function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core. -mike

Hi Mike,
On Tue, Mar 6, 2012 at 8:20 AM, Mike Frysinger vapier@gentoo.org wrote:
On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
On Mon, Mar 5, 2012 at 9:05 PM, Mike Frysinger wrote:
On Monday 20 February 2012 20:32:47 Simon Glass wrote:
These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.
seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do.
I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.
if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". plus, fixing this yields general improvements in anti-bloat for everyone.
function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.
While I agree with you, I am not sure that I can enable that for ARM this late in the game.
If I enable -ffunction-sections for the tx25 spl build, I get:
$ make clean && make tx25_config && make -j20 -s Configuring for tx25 board... Generating include/generated/asm-offsets.h string.o: In function `skip_spaces': /home/sjg/trunk/src/third_party/u-boot/files/lib/string.c:229: undefined reference to `_ctype' string.o: In function `strim': /home/sjg/trunk/src/third_party/u-boot/files/lib/string.c:255: undefined reference to `_ctype' string.o: In function `strdup': /home/sjg/trunk/src/third_party/u-boot/files/lib/string.c:292: undefined reference to `malloc' make[1]: *** [/home/sjg/trunk/src/third_party/u-boot/files/nand_spl/u-boot-spl] Error 1 make: *** [nand_spl] Error 2 make: *** Waiting for unfinished jobs....
The string.c library is using malloc() and ctype calls which are not in the build. If I add them to the build (and divide and various other things that aren't really needed) and enable -ffunction-sections I get a complete build but the result is a bit over 8KB instead of the original 2KB. The build does complete, though. Maybe just building is good enough for now, and we can deal any breakage next time?
Now I'm not sure if the tx25 can in fact deal with this, but it seems risky at this stage.
So in summary I wonder whether we should run with this simple split patch for now, and deal with moving ARM to -ffunction-sections in the next merge window, assuming Albert is keen on that idea? Alternatively I can update the tx25 patch (and perhaps1-2 others) to remove the need for this patch, with the possibility that these few boards will build but night not actually work.
Hmmm.
Regards, Simon
-mike

Hi Mike,
On Wed, Mar 7, 2012 at 3:20 AM, Mike Frysinger vapier@gentoo.org wrote:
On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
On Mon, Mar 5, 2012 at 9:05 PM, Mike Frysinger wrote:
On Monday 20 February 2012 20:32:47 Simon Glass wrote:
These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.
seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do.
I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.
if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". plus, fixing this yields general improvements in anti-bloat for everyone.
function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.
Can't the entry point be forced to be at the start of the u-boot image by putting that function in a dedicated section and specifying that section as the first in the linker script?
This has always bothered me:
######################################################################### # U-Boot objects....order is important (i.e. start must be first)
OBJS = $(CPUDIR)/start.o ifeq ($(CPU),x86) OBJS += $(CPUDIR)/start16.o OBJS += $(CPUDIR)/resetvec.o endif ifeq ($(CPU),ppc4xx) OBJS += $(CPUDIR)/resetvec.o endif ifeq ($(CPU),mpc85xx) OBJS += $(CPUDIR)/resetvec.o endif
I've been meaning to get rid of this for x86 as I believe this can be adequately handled by putting the code in relevant sections and locating the sections at the correct location using the linker script.
For x86 there are only two requirements: - The first byte of resetvec.o sits 16 bytes from the end of flash - The first byte of start.o is the first byte of the core u-boot image (there is other cruft above it in the flash like an embedded kernel image)
Regards,
Graeme

Hi Graeme,
On Tue, Mar 6, 2012 at 9:50 PM, Graeme Russ graeme.russ@gmail.com wrote:
Hi Mike,
On Wed, Mar 7, 2012 at 3:20 AM, Mike Frysinger vapier@gentoo.org wrote:
On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
On Mon, Mar 5, 2012 at 9:05 PM, Mike Frysinger wrote:
On Monday 20 February 2012 20:32:47 Simon Glass wrote:
These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.
seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do.
I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.
if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". plus, fixing this yields general improvements in anti-bloat for everyone.
function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.
Can't the entry point be forced to be at the start of the u-boot image by putting that function in a dedicated section and specifying that section as the first in the linker script?
This has always bothered me:
######################################################################### # U-Boot objects....order is important (i.e. start must be first)
OBJS = $(CPUDIR)/start.o ifeq ($(CPU),x86) OBJS += $(CPUDIR)/start16.o OBJS += $(CPUDIR)/resetvec.o endif ifeq ($(CPU),ppc4xx) OBJS += $(CPUDIR)/resetvec.o endif ifeq ($(CPU),mpc85xx) OBJS += $(CPUDIR)/resetvec.o endif
I've been meaning to get rid of this for x86 as I believe this can be adequately handled by putting the code in relevant sections and locating the sections at the correct location using the linker script.
For x86 there are only two requirements: - The first byte of resetvec.o sits 16 bytes from the end of flash - The first byte of start.o is the first byte of the core u-boot image (there is other cruft above it in the flash like an embedded kernel image)
Yes I don't think the order is important now as we have a link script as you say.
Regards,
Graeme

On Wednesday 07 March 2012 00:50:15 Graeme Russ wrote:
On Wed, Mar 7, 2012 at 3:20 AM, Mike Frysinger wrote:
On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
On Mon, Mar 5, 2012 at 9:05 PM, Mike Frysinger wrote:
On Monday 20 February 2012 20:32:47 Simon Glass wrote:
These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.
seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do.
I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.
if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". plus, fixing this yields general improvements in anti-bloat for everyone.
function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.
Can't the entry point be forced to be at the start of the u-boot image by putting that function in a dedicated section and specifying that section as the first in the linker script?
yes ... that's what Blackfin does: ... ENTRY(_start) SECTIONS { .text.pre : { arch/blackfin/cpu/start.o (.text .text.*) ... -mike

The start of the BSS is normally the end of the region in the image that must be copied for relocation to work. But for SPL this is apparently not always true, and ARMv7 has an explicit __image_copy_end symbol for this. Add this new symbol to ARM926EJ-S to support SPL under generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/arm/cpu/arm926ejs/start.S | 4 ++++ arch/arm/cpu/arm926ejs/u-boot.lds | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index 2c8ff81..ecb44f1 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -146,6 +146,10 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start
+.global _image_copy_end_ofs +_image_copy_end_ofs: + .word __image_copy_end - _start + .globl _bss_end_ofs _bss_end_ofs: .word __bss_end__ - _start diff --git a/arch/arm/cpu/arm926ejs/u-boot.lds b/arch/arm/cpu/arm926ejs/u-boot.lds index 1480e0c..069cd1b 100644 --- a/arch/arm/cpu/arm926ejs/u-boot.lds +++ b/arch/arm/cpu/arm926ejs/u-boot.lds @@ -52,6 +52,8 @@ SECTIONS
. = ALIGN(4);
+ __image_copy_end = .; + .rel.dyn : { __rel_dyn_start = .; *(.rel*)

This fixes the following warnings in an SPL build when libcommon is in use:
spl.c:37: warning: 'gdata' defined but not used spl.c:38: warning: 'bdata' defined but not used
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v4: - Add new patch to fix davinci build warnings
arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index b1eff26..2861907 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -32,10 +32,12 @@
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+#ifdef CONFIG_SPL_SPI_LOAD DECLARE_GLOBAL_DATA_PTR; /* Define global data structure pointer to it*/ static gd_t gdata __attribute__ ((section(".data"))); static bd_t bdata __attribute__ ((section(".data"))); +#endif
#else

On Mon, Feb 20, 2012 at 05:32:49PM -0800, Simon Glass wrote:
This fixes the following warnings in an SPL build when libcommon is in use:
spl.c:37: warning: 'gdata' defined but not used spl.c:38: warning: 'bdata' defined but not used
Signed-off-by: Simon Glass sjg@chromium.org
Acked-by: Tom Rini trini@ti.com

hi Simon,
On Mon Feb 20, 2012 at 05:32:49PM -0800, Simon Glass wrote:
This fixes the following warnings in an SPL build when libcommon is in use:
spl.c:37: warning: 'gdata' defined but not used spl.c:38: warning: 'bdata' defined but not used
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v4:
- Add new patch to fix davinci build warnings
arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index b1eff26..2861907 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -32,10 +32,12 @@
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+#ifdef CONFIG_SPL_SPI_LOAD DECLARE_GLOBAL_DATA_PTR; /* Define global data structure pointer to it*/ static gd_t gdata __attribute__ ((section(".data"))); static bd_t bdata __attribute__ ((section(".data"))); +#endif
Can you specify which boards you get this warning for. With your patch to add libcommon to hawkboard's spl image, this is now also needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
-sughosh

Hi Sughosh,
On Thu, Feb 23, 2012 at 9:25 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Simon,
On Mon Feb 20, 2012 at 05:32:49PM -0800, Simon Glass wrote:
This fixes the following warnings in an SPL build when libcommon is in use:
spl.c:37: warning: 'gdata' defined but not used spl.c:38: warning: 'bdata' defined but not used
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v4:
- Add new patch to fix davinci build warnings
arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index b1eff26..2861907 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -32,10 +32,12 @@
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+#ifdef CONFIG_SPL_SPI_LOAD DECLARE_GLOBAL_DATA_PTR; /* Define global data structure pointer to it*/ static gd_t gdata __attribute__ ((section(".data"))); static bd_t bdata __attribute__ ((section(".data"))); +#endif
Can you specify which boards you get this warning for. With your patch to add libcommon to hawkboard's spl image, this is now also needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
Perhaps it is any davinci board, with SPI? I don't have any of these - I was just fixing what I thought was a minor #ifdef bug in the code.
Regards, Simon
-sughosh

hi Simon,
On Sun Feb 26, 2012 at 09:56:37AM -0800, Simon Glass wrote:
Hi Sughosh,
On Thu, Feb 23, 2012 at 9:25 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Simon,
On Mon Feb 20, 2012 at 05:32:49PM -0800, Simon Glass wrote:
This fixes the following warnings in an SPL build when libcommon is in use:
spl.c:37: warning: 'gdata' defined but not used spl.c:38: warning: 'bdata' defined but not used
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v4:
- Add new patch to fix davinci build warnings
arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index b1eff26..2861907 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -32,10 +32,12 @@
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+#ifdef CONFIG_SPL_SPI_LOAD DECLARE_GLOBAL_DATA_PTR; /* Define global data structure pointer to it*/ static gd_t gdata __attribute__ ((section(".data"))); static bd_t bdata __attribute__ ((section(".data"))); +#endif
Can you specify which boards you get this warning for. With your patch to add libcommon to hawkboard's spl image, this is now also needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
Perhaps it is any davinci board, with SPI? I don't have any of these - I was just fixing what I thought was a minor #ifdef bug in the code.
I checked the configs for all the davinci boards, and cam_enc_4xx, da850* and hawkboard use spl. Out of these the da850* use a spi flash, while cam_enc_4xx and hawkboard both use a nand. So we should not be using the CONFIG_SPL_SPI_LOAD check to exclude the gdata and bdata objects -- these are now needed after adding the libcommon support to the hawkboard.
Also, the cam_enc_4xx board which uses a spl does not have CONFIG_SPL_LIBCOMMON_SUPPORT and CONFIG_SPL_LIBGENERIC_SUPPORT defined and this patchset does not add these defines for the board. Was adding these defines for the board missed out. If so, then this patch would no longer be needed.
-sughosh

Hi,
On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Simon,
On Sun Feb 26, 2012 at 09:56:37AM -0800, Simon Glass wrote:
Hi Sughosh,
On Thu, Feb 23, 2012 at 9:25 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Simon,
On Mon Feb 20, 2012 at 05:32:49PM -0800, Simon Glass wrote:
This fixes the following warnings in an SPL build when libcommon is in use:
spl.c:37: warning: 'gdata' defined but not used spl.c:38: warning: 'bdata' defined but not used
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v4:
- Add new patch to fix davinci build warnings
arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index b1eff26..2861907 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -32,10 +32,12 @@
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+#ifdef CONFIG_SPL_SPI_LOAD DECLARE_GLOBAL_DATA_PTR; /* Define global data structure pointer to it*/ static gd_t gdata __attribute__ ((section(".data"))); static bd_t bdata __attribute__ ((section(".data"))); +#endif
In arch/arm/cpu/arm926ejs/davinci/spl.c gdata and bdata are used for serial_init() to allow output to the console from the SPL. However, this is only the case when LIBCOMMON is used. LIBCOMMON is required for booting from SPI, but not for booting from NAND. Up to now davinci boards that boot from NAND with SPL did not use LIBCOMMON but used the puts and putc functions defined in spl.c for console output.
Can you specify which boards you get this warning for. With your patch to add libcommon to hawkboard's spl image, this is now also needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)
However, the patch fixes the warning, but now we use putc and puts from LIBCOMMON without initializing them. Thus it breaks the console output of the hawkboard SPL.
So the correct solution would be to keep the ifdefs around the definition of gdata and bdata as they are, but change board_init_f() like this:
void board_init_r(gd_t *id, ulong dummy) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
gd = &gdata; gd->bd = &bdata; gd->flags |= GD_FLG_RELOC; gd->baudrate = CONFIG_BAUDRATE; serial_init(); /* serial communications setup */ gd->have_console = 1; #endif #ifdef CONFIG_SPL_NAND_LOAD nand_init(); puts("Nand boot...\n"); nand_boot(); #endif #ifdef CONFIG_SPL_SPI_LOAD puts("SPI boot...\n"); spi_boot(); #endif }
Regards, Christian

hi Christian,
On Mon Feb 27, 2012 at 11:39:42AM +0100, Christian Riesch wrote:
Hi,
On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
<snip>
arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index b1eff26..2861907 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -32,10 +32,12 @@
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+#ifdef CONFIG_SPL_SPI_LOAD DECLARE_GLOBAL_DATA_PTR; /* Define global data structure pointer to it*/ static gd_t gdata __attribute__ ((section(".data"))); static bd_t bdata __attribute__ ((section(".data"))); +#endif
<snip>
Can you specify which boards you get this warning for. With your patch to add libcommon to hawkboard's spl image, this is now also needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)
LIBCOMMON is now needed as the generic relocation based functions are part of the libcommon.o, which are being enabled in the same patchset for all arm boards. So if i understand correct, all arm board based spl's now need libcommon and libgeneric.
The only thing i see is that libcommon and libgeneric are not defined for cam_enc_4xx board which uses spl, and this patchset does not add it either. Not sure whether it got missed.
However, the patch fixes the warning, but now we use putc and puts from LIBCOMMON without initializing them. Thus it breaks the console output of the hawkboard SPL.
So the correct solution would be to keep the ifdefs around the definition of gdata and bdata as they are, but change board_init_f() like this:
I have a patch for this, which i will send today. There is only one question i have though.
void board_init_r(gd_t *id, ulong dummy) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
Can you please explain why we need the mem_malloc_init. I did not include this, and spl boots up just fine on my board.
-sughosh

Hi Sughosh,
On Mon, Feb 27, 2012 at 11:56 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Christian,
On Mon Feb 27, 2012 at 11:39:42AM +0100, Christian Riesch wrote:
Hi,
On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
<snip>
arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index b1eff26..2861907 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -32,10 +32,12 @@
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+#ifdef CONFIG_SPL_SPI_LOAD DECLARE_GLOBAL_DATA_PTR; /* Define global data structure pointer to it*/ static gd_t gdata __attribute__ ((section(".data"))); static bd_t bdata __attribute__ ((section(".data"))); +#endif
<snip>
Can you specify which boards you get this warning for. With your patch to add libcommon to hawkboard's spl image, this is now also needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)
LIBCOMMON is now needed as the generic relocation based functions are part of the libcommon.o, which are being enabled in the same patchset for all arm boards. So if i understand correct, all arm board based spl's now need libcommon and libgeneric.
The only thing i see is that libcommon and libgeneric are not defined for cam_enc_4xx board which uses spl, and this patchset does not add it either. Not sure whether it got missed.
When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?
However, I we can make all davinci boards use LIBCOMMON, we can remove the putc/puts functions from spl.c.
However, the patch fixes the warning, but now we use putc and puts from LIBCOMMON without initializing them. Thus it breaks the console output of the hawkboard SPL.
So the correct solution would be to keep the ifdefs around the definition of gdata and bdata as they are, but change board_init_f() like this:
I have a patch for this, which i will send today. There is only one question i have though.
void board_init_r(gd_t *id, ulong dummy) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
Can you please explain why we need the mem_malloc_init. I did not include this, and spl boots up just fine on my board.
malloc is required for the SPI code only, so you could also put it within #ifdef CONFIG_SPL_SPI_LOAD
Regards, Christian

hi Christian,
On Mon Feb 27, 2012 at 12:37:16PM +0100, Christian Riesch wrote:
Hi Sughosh,
On Mon, Feb 27, 2012 at 11:56 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Christian,
On Mon Feb 27, 2012 at 11:39:42AM +0100, Christian Riesch wrote:
Hi,
On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
<snip>
> arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c > index b1eff26..2861907 100644 > --- a/arch/arm/cpu/arm926ejs/davinci/spl.c > +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c > @@ -32,10 +32,12 @@ > > #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT > > +#ifdef CONFIG_SPL_SPI_LOAD > DECLARE_GLOBAL_DATA_PTR; > /* Define global data structure pointer to it*/ > static gd_t gdata __attribute__ ((section(".data"))); > static bd_t bdata __attribute__ ((section(".data"))); > +#endif
<snip>
Can you specify which boards you get this warning for. With your patch to add libcommon to hawkboard's spl image, this is now also needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)
LIBCOMMON is now needed as the generic relocation based functions are part of the libcommon.o, which are being enabled in the same patchset for all arm boards. So if i understand correct, all arm board based spl's now need libcommon and libgeneric.
The only thing i see is that libcommon and libgeneric are not defined for cam_enc_4xx board which uses spl, and this patchset does not add it either. Not sure whether it got missed.
When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?
That is exactly what i reported in one of the threads in response to addition of libcommon and libgeneric to the hawkboard's spl. In fact, this might cause problems on quite a few boards with spl size restrictions. I am not sure, whether the generic relocation feature should be turned on by default on all boards or should be a config option -- at least for the spl builds. Another option would be to move it to a place where it is not needed to compile in the entire libcommon/libgeneric support that is not needed for the generic relocation code. I think that would help us keep the generic relocation without the size bloat that we see right now.
http://lists.denx.de/pipermail/u-boot/2012-February/118567.html
<snip>
void board_init_r(gd_t *id, ulong dummy) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
Can you please explain why we need the mem_malloc_init. I did not include this, and spl boots up just fine on my board.
malloc is required for the SPI code only, so you could also put it within #ifdef CONFIG_SPL_SPI_LOAD
Ok, i will move the common changes to a static function, and call it from both the nand and spi load cases. Or, should i wait till a consensus is drawn on whether to enable this feature for spl images also. In case this is not needed for spl, then we don't need this change.
-sughosh

Le 27/02/2012 13:02, Sughosh Ganu a écrit :
When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?
That is exactly what i reported in one of the threads in response to addition of libcommon and libgeneric to the hawkboard's spl. In fact, this might cause problems on quite a few boards with spl size restrictions. I am not sure, whether the generic relocation feature should be turned on by default on all boards or should be a config option -- at least for the spl builds. Another option would be to move it to a place where it is not needed to compile in the entire libcommon/libgeneric support that is not needed for the generic relocation code. I think that would help us keep the generic relocation without the size bloat that we see right now.
http://lists.denx.de/pipermail/u-boot/2012-February/118567.html
Sorry for appearing dumb, but can someone explain to me how SPL relates to relocation in the first place? I thought SPL was meant to be a preloader for the full(er) U-boot, small enough to be loaded by some SoCs' ROM code and possibly even to fit in SRAM. Why does it need relocation? And if it does not, how come it is affected by a rework of the relocation feature? I really would like a heads-up on this.
Amicalement,

On 02/28/2012 03:55 PM, Albert ARIBAUD wrote:
Le 27/02/2012 13:02, Sughosh Ganu a écrit :
When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?
That is exactly what i reported in one of the threads in response to addition of libcommon and libgeneric to the hawkboard's spl. In fact, this might cause problems on quite a few boards with spl size restrictions. I am not sure, whether the generic relocation feature should be turned on by default on all boards or should be a config option -- at least for the spl builds. Another option would be to move it to a place where it is not needed to compile in the entire libcommon/libgeneric support that is not needed for the generic relocation code. I think that would help us keep the generic relocation without the size bloat that we see right now.
http://lists.denx.de/pipermail/u-boot/2012-February/118567.html
Sorry for appearing dumb, but can someone explain to me how SPL relates to relocation in the first place? I thought SPL was meant to be a preloader for the full(er) U-boot, small enough to be loaded by some SoCs' ROM code and possibly even to fit in SRAM. Why does it need relocation? And if it does not, how come it is affected by a rework of the relocation feature? I really would like a heads-up on this.
SPL may need relocation to vacate a buffer that will be used for further I/O, such as on Freescale PPC (NAND boot execution begins in the NAND controller's SRAM), or possibly to allow the memory map to be transformed to what the final image is going to expect, etc.
Even in cases where the SPL text itself doesn't really need to move, you may need some other things that typically happen along with relocation, such as moving the stack to a larger memory after that memory is initialized, zeroing BSS, etc.
-Scott

Hi,
On Mon, Feb 27, 2012 at 4:02 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Christian,
On Mon Feb 27, 2012 at 12:37:16PM +0100, Christian Riesch wrote:
Hi Sughosh,
On Mon, Feb 27, 2012 at 11:56 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Christian,
On Mon Feb 27, 2012 at 11:39:42AM +0100, Christian Riesch wrote:
Hi,
On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
<snip>
>> arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ >> 1 files changed, 2 insertions(+), 0 deletions(-) >> >> diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c >> index b1eff26..2861907 100644 >> --- a/arch/arm/cpu/arm926ejs/davinci/spl.c >> +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c >> @@ -32,10 +32,12 @@ >> >> #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT >> >> +#ifdef CONFIG_SPL_SPI_LOAD >> DECLARE_GLOBAL_DATA_PTR; >> /* Define global data structure pointer to it*/ >> static gd_t gdata __attribute__ ((section(".data"))); >> static bd_t bdata __attribute__ ((section(".data"))); >> +#endif
<snip>
> Can you specify which boards you get this warning for. With your > patch to add libcommon to hawkboard's spl image, this is now also > needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)
LIBCOMMON is now needed as the generic relocation based functions are part of the libcommon.o, which are being enabled in the same patchset for all arm boards. So if i understand correct, all arm board based spl's now need libcommon and libgeneric.
The only thing i see is that libcommon and libgeneric are not defined for cam_enc_4xx board which uses spl, and this patchset does not add it either. Not sure whether it got missed.
When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?
If it pushes it over 16KB, although it's not clear that it will. So far I haven't seen this and I would hope that builds would fail in this case (normally I got a 'cannot move program counter backwards' error).
But clearly putting this code in spl.c is a bit ugly because it hard-codes the driver and duplicates code in common/console.c:
void putc(char c) { if (c == '\n') NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c); }
Can someone please check what is the maximum SPL size on one of these boards? Generic relocation increases the spl from 5.9KB to 10KB. Is there an 8KB limit?
One option if this really is a problem is to move common/reloc.c to lib/reloc.c, although there isn't really a huge amount of justification for that given that it is U-Boot code. Perhaps we could claim that it is a relocation library and not U-Boot-specific?
That is exactly what i reported in one of the threads in response to addition of libcommon and libgeneric to the hawkboard's spl. In fact, this might cause problems on quite a few boards with spl size restrictions. I am not sure, whether the generic relocation feature should be turned on by default on all boards or should be a config option -- at least for the spl builds. Another option would be to move it to a place where it is not needed to compile in the entire libcommon/libgeneric support that is not needed for the generic relocation code. I think that would help us keep the generic relocation without the size bloat that we see right now.
http://lists.denx.de/pipermail/u-boot/2012-February/118567.html
Well it would be nice to find out what the limit is. I might be able to squeeze it a bit more even in common. But failing that the putc() hack and lib/ might be the most expedient solution at this stage.
<snip>
void board_init_r(gd_t *id, ulong dummy) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
Can you please explain why we need the mem_malloc_init. I did not include this, and spl boots up just fine on my board.
malloc is required for the SPI code only, so you could also put it within #ifdef CONFIG_SPL_SPI_LOAD
Ok, i will move the common changes to a static function, and call it from both the nand and spi load cases. Or, should i wait till a consensus is drawn on whether to enable this feature for spl images also. In case this is not needed for spl, then we don't need this change.
My series removes the old relocation code, so it really does need to work for SPL also. I have put a bit of effort in here to tidy this up and I don't think it is hard to resolve this last problem.
I will investigate this a bit more and then suggest a solution.
Regards, Simon
-sughosh

Hi,
On Sat, Mar 3, 2012 at 12:22 PM, Simon Glass sjg@chromium.org wrote:
Hi,
On Mon, Feb 27, 2012 at 4:02 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Christian,
On Mon Feb 27, 2012 at 12:37:16PM +0100, Christian Riesch wrote:
Hi Sughosh,
On Mon, Feb 27, 2012 at 11:56 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Christian,
On Mon Feb 27, 2012 at 11:39:42AM +0100, Christian Riesch wrote:
Hi,
On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
<snip>
> >> arch/arm/cpu/arm926ejs/davinci/spl.c | 2 ++ > >> 1 files changed, 2 insertions(+), 0 deletions(-) > >> > >> diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c > >> index b1eff26..2861907 100644 > >> --- a/arch/arm/cpu/arm926ejs/davinci/spl.c > >> +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c > >> @@ -32,10 +32,12 @@ > >> > >> #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT > >> > >> +#ifdef CONFIG_SPL_SPI_LOAD > >> DECLARE_GLOBAL_DATA_PTR; > >> /* Define global data structure pointer to it*/ > >> static gd_t gdata __attribute__ ((section(".data"))); > >> static bd_t bdata __attribute__ ((section(".data"))); > >> +#endif
<snip>
> > Can you specify which boards you get this warning for. With your > > patch to add libcommon to hawkboard's spl image, this is now also > > needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.
Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)
LIBCOMMON is now needed as the generic relocation based functions are part of the libcommon.o, which are being enabled in the same patchset for all arm boards. So if i understand correct, all arm board based spl's now need libcommon and libgeneric.
The only thing i see is that libcommon and libgeneric are not defined for cam_enc_4xx board which uses spl, and this patchset does not add it either. Not sure whether it got missed.
When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?
If it pushes it over 16KB, although it's not clear that it will. So far I haven't seen this and I would hope that builds would fail in this case (normally I got a 'cannot move program counter backwards' error).
But clearly putting this code in spl.c is a bit ugly because it hard-codes the driver and duplicates code in common/console.c:
void putc(char c) { if (c == '\n') NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c); }
Can someone please check what is the maximum SPL size on one of these boards? Generic relocation increases the spl from 5.9KB to 10KB. Is there an 8KB limit?
One option if this really is a problem is to move common/reloc.c to lib/reloc.c, although there isn't really a huge amount of justification for that given that it is U-Boot code. Perhaps we could claim that it is a relocation library and not U-Boot-specific?
That is exactly what i reported in one of the threads in response to addition of libcommon and libgeneric to the hawkboard's spl. In fact, this might cause problems on quite a few boards with spl size restrictions. I am not sure, whether the generic relocation feature should be turned on by default on all boards or should be a config option -- at least for the spl builds. Another option would be to move it to a place where it is not needed to compile in the entire libcommon/libgeneric support that is not needed for the generic relocation code. I think that would help us keep the generic relocation without the size bloat that we see right now.
http://lists.denx.de/pipermail/u-boot/2012-February/118567.html
Well it would be nice to find out what the limit is. I might be able to squeeze it a bit more even in common. But failing that the putc() hack and lib/ might be the most expedient solution at this stage.
<snip>
void board_init_r(gd_t *id, ulong dummy) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
Can you please explain why we need the mem_malloc_init. I did not include this, and spl boots up just fine on my board.
malloc is required for the SPI code only, so you could also put it within #ifdef CONFIG_SPL_SPI_LOAD
Ok, i will move the common changes to a static function, and call it from both the nand and spi load cases. Or, should i wait till a consensus is drawn on whether to enable this feature for spl images also. In case this is not needed for spl, then we don't need this change.
My series removes the old relocation code, so it really does need to work for SPL also. I have put a bit of effort in here to tidy this up and I don't think it is hard to resolve this last problem.
I will investigate this a bit more and then suggest a solution.
Actually further to this it seems that it is just that raise() is calling printf(). Seems like we can punt this unless anyone has objections. Alternatively we could use puts() and just print a general message. I will send a patch.
Regards, Simon
Regards, Simon
-sughosh

Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v4: - Split out tx25 changes into new patch
include/configs/tx25.h | 2 ++ nand_spl/board/karo/tx25/Makefile | 11 ++++++++++- nand_spl/board/karo/tx25/u-boot.lds | 1 + 3 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/include/configs/tx25.h b/include/configs/tx25.h index 87bd8a6..115d810 100644 --- a/include/configs/tx25.h +++ b/include/configs/tx25.h @@ -58,6 +58,8 @@ #define CONFIG_SKIP_LOWLEVEL_INIT #endif
+#define CONFIG_SPL_LIBGENERIC_SUPPORT + #define CONFIG_DISPLAY_CPUINFO
#define CONFIG_CMDLINE_TAG /* enable passing of ATAGs */ diff --git a/nand_spl/board/karo/tx25/Makefile b/nand_spl/board/karo/tx25/Makefile index 0336346..c253d42 100644 --- a/nand_spl/board/karo/tx25/Makefile +++ b/nand_spl/board/karo/tx25/Makefile @@ -33,7 +33,10 @@ AFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
SOBJS = start.o lowlevel_init.o -COBJS = nand_boot_fsl_nfc.o +COBJS = nand_boot_fsl_nfc.o membasic.o +ifndef CONFIG_SYS_SKIP_RELOC +COBJS += reloc.o +endif
SRCS := $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c SRCS += $(SRCTREE)/arch/arm/cpu/arm926ejs/start.S @@ -71,6 +74,12 @@ $(obj)%.o: $(SRCTREE)/board/karo/tx25/%.S $(obj)%.o: $(SRCTREE)/nand_spl/%.c $(CC) $(CFLAGS) -c -o $@ $<
+$(obj)%.o: $(SRCTREE)/common/%.c + $(CC) $(CFLAGS) -c -o $@ $< + +$(obj)%.o: $(SRCTREE)/lib/%.c + $(CC) $(CFLAGS) -c -o $@ $< + # defines $(obj).depend target include $(SRCTREE)/rules.mk
diff --git a/nand_spl/board/karo/tx25/u-boot.lds b/nand_spl/board/karo/tx25/u-boot.lds index d2b08f6..2273e9b 100644 --- a/nand_spl/board/karo/tx25/u-boot.lds +++ b/nand_spl/board/karo/tx25/u-boot.lds @@ -51,6 +51,7 @@ SECTIONS __u_boot_cmd_end = .;
. = ALIGN(4); + __image_copy_end = .;
.rel.dyn : { __rel_dyn_start = .;

Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v4: - Split out hawkboard changes into new patch
board/davinci/da8xxevm/u-boot-spl-hawk.lds | 1 + include/configs/hawkboard.h | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/board/davinci/da8xxevm/u-boot-spl-hawk.lds b/board/davinci/da8xxevm/u-boot-spl-hawk.lds index b3a41af..4bbfa3d 100644 --- a/board/davinci/da8xxevm/u-boot-spl-hawk.lds +++ b/board/davinci/da8xxevm/u-boot-spl-hawk.lds @@ -58,6 +58,7 @@ SECTIONS }
. = ALIGN(4); + __image_copy_end = .; __rel_dyn_start = .; __rel_dyn_end = .; __dynsym_start = .; diff --git a/include/configs/hawkboard.h b/include/configs/hawkboard.h index 50a1c17..85a955b 100644 --- a/include/configs/hawkboard.h +++ b/include/configs/hawkboard.h @@ -63,6 +63,8 @@ #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_NAND_LOAD #define CONFIG_SPL_SERIAL_SUPPORT +#define CONFIG_SPL_LIBCOMMON_SUPPORT +#define CONFIG_SPL_LIBGENERIC_SUPPORT #define CONFIG_SPL_LDSCRIPT "board/$(BOARDDIR)/u-boot-spl-hawk.lds" #define CONFIG_SPL_TEXT_BASE 0xc1080000 #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR

On Mon, Feb 20, 2012 at 05:32:51PM -0800, Simon Glass wrote:
Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org
Acked-by: Tom Rini trini@ti.com

hi Simon, On Mon Feb 20, 2012 at 05:32:51PM -0800, Simon Glass wrote:
Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v4:
- Split out hawkboard changes into new patch
board/davinci/da8xxevm/u-boot-spl-hawk.lds | 1 + include/configs/hawkboard.h | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
I have tested these changes on the hawkboard. It requires setting up of the gd and bd pointers in the spl for this to work with the libcommon changes, which were not needed up until now in my spl. I will send a patch to fix this. Will also test the rest of your patchset on the board during the weekend.
Btw, i had quite a substantial increase in the spl image size with these additions with a 4.5 based toolchain(will provide exact toolchain details and size difference tonight). Building with a 4.6 based toolchain got the size increase down by quite a bit. Although i don't have any size restrictions with spl on my board, this could be a problem on boards which have these restrictions with toolchains before 4.6.
-sughosh

On Thu, Feb 23, 2012 at 2:13 PM, Sughosh Ganu urwithsughosh@gmail.comwrote:
hi Simon, On Mon Feb 20, 2012 at 05:32:51PM -0800, Simon Glass wrote:
Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v4:
- Split out hawkboard changes into new patch
board/davinci/da8xxevm/u-boot-spl-hawk.lds | 1 + include/configs/hawkboard.h | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
<snip>
Btw, i had quite a substantial increase in the spl image size with these additions with a 4.5 based toolchain(will provide exact toolchain details and size difference tonight). Building with a 4.6 based toolchain got the size increase down by quite a bit. Although i don't have any size restrictions with spl on my board, this could be a problem on boards which have these restrictions with toolchains before 4.6.
gcc(arm-none-linux-gnueabi) -- 4.5.2 binutils -- 2.20
spl size without this patch text data bss dec hex filename 5208 620 464 6292 1894 spl/u-boot-spl
spl size with this patch text data bss dec hex filename 8897 620 476 9993 2709 spl/u-boot-spl
gcc(arm-none-eabi) -- 4.6.2 binutils -- 2.21
spl size without this patch text data bss dec hex filename 4692 620 464 5776 1690 spl/u-boot-spl
spl size with this patch text data bss dec hex filename 4812 620 476 5908 1714 spl/u-boot-spl
-sughosh

Hi,
On Thu, Feb 23, 2012 at 7:11 AM, Sughosh Ganu urwithsughosh@gmail.com wrote:
On Thu, Feb 23, 2012 at 2:13 PM, Sughosh Ganu urwithsughosh@gmail.com wrote:
hi Simon, On Mon Feb 20, 2012 at 05:32:51PM -0800, Simon Glass wrote:
Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v4:
- Split out hawkboard changes into new patch
board/davinci/da8xxevm/u-boot-spl-hawk.lds | 1 + include/configs/hawkboard.h | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
<snip>
Btw, i had quite a substantial increase in the spl image size with these additions with a 4.5 based toolchain(will provide exact toolchain details and size difference tonight). Building with a 4.6 based toolchain got the size increase down by quite a bit. Although i don't have any size restrictions with spl on my board, this could be a problem on boards which have these restrictions with toolchains before 4.6.
gcc(arm-none-linux-gnueabi) -- 4.5.2 binutils -- 2.20
spl size without this patch text data bss dec hex filename 5208 620 464 6292 1894 spl/u-boot-spl
spl size with this patch text data bss dec hex filename 8897 620 476 9993 2709 spl/u-boot-spl
gcc(arm-none-eabi) -- 4.6.2 binutils -- 2.21
spl size without this patch text data bss dec hex filename 4692 620 464 5776 1690 spl/u-boot-spl
spl size with this patch text data bss dec hex filename 4812 620 476 5908 1714 spl/u-boot-spl
-sughosh
Thanks for looking at this.
I'm not sure why it doesn't happen with your 4.6.2 compiler. With my 4.6.0 I do see the size increase.
It seems to be due to vsprintf:
text data bss dec hex filename 4011 0 22 4033 fc1 spl/lib/vsprintf.o
I wonder if it is a call to printf that the older compiler is failing to optimize out?
Regards, Simon

This adds a link symbol and updates the board Makefile so that it's SPL implementation will work with generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v4: - Split out mx31pdk changes into new patch
nand_spl/board/freescale/mx31pdk/Makefile | 6 ++++++ nand_spl/board/freescale/mx31pdk/u-boot.lds | 1 + 2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/nand_spl/board/freescale/mx31pdk/Makefile b/nand_spl/board/freescale/mx31pdk/Makefile index 87784d2..4598206 100644 --- a/nand_spl/board/freescale/mx31pdk/Makefile +++ b/nand_spl/board/freescale/mx31pdk/Makefile @@ -13,6 +13,9 @@ CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
SOBJS = start.o lowlevel_init.o COBJS = nand_boot_fsl_nfc.o +ifndef CONFIG_SYS_SKIP_RELOC +COBJS += reloc.o +endif
SRCS := $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c SRCS += $(SRCTREE)/arch/arm/cpu/arm1136/start.S @@ -50,6 +53,9 @@ $(obj)%.o: $(SRCTREE)/board/freescale/mx31pdk/%.S $(obj)%.o: $(SRCTREE)/nand_spl/%.c $(CC) $(CFLAGS) -c -o $@ $<
+$(obj)%.o: $(SRCTREE)/common/%.c + $(CC) $(CFLAGS) -c -o $@ $< + # defines $(obj).depend target include $(SRCTREE)/rules.mk
diff --git a/nand_spl/board/freescale/mx31pdk/u-boot.lds b/nand_spl/board/freescale/mx31pdk/u-boot.lds index d2b08f6..2273e9b 100644 --- a/nand_spl/board/freescale/mx31pdk/u-boot.lds +++ b/nand_spl/board/freescale/mx31pdk/u-boot.lds @@ -51,6 +51,7 @@ SECTIONS __u_boot_cmd_end = .;
. = ALIGN(4); + __image_copy_end = .;
.rel.dyn : { __rel_dyn_start = .;

This seems to use an old SPL framework, or at least it is ugly enough that I hope it is old. Add symlinks for the new files required by generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v4: - Add new patch to fix smdk6400 with generic relocation
nand_spl/board/samsung/smdk6400/Makefile | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/nand_spl/board/samsung/smdk6400/Makefile b/nand_spl/board/samsung/smdk6400/Makefile index c9e75ba..c79e12b 100644 --- a/nand_spl/board/samsung/smdk6400/Makefile +++ b/nand_spl/board/samsung/smdk6400/Makefile @@ -39,6 +39,9 @@ CFLAGS += -DCONFIG_NAND_SPL -ffunction-sections
SOBJS = start.o cpu_init.o lowlevel_init.o COBJS = nand_boot.o nand_ecc.o s3c64xx.o smdk6400_nand_spl.o nand_base.o +ifndef CONFIG_SYS_SKIP_RELOC +COBJS += reloc.o membasic.o +endif
SRCS := $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c)) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) @@ -101,6 +104,14 @@ $(obj)smdk6400_nand_spl.c: $(obj)nand_base.c: @rm -f $@ @ln -s $(TOPDIR)/drivers/mtd/nand/nand_base.c $@ + +$(obj)reloc.c: + @rm -f $@ + @ln -s $(TOPDIR)/common/reloc.c $@ + +$(obj)membasic.c: + @rm -f $@ + @ln -s $(TOPDIR)/lib/membasic.c $@ #########################################################################
$(obj)%.o: $(obj)%.S

Add a function to process a single ELF relocation and switch ARM over to use generic relocation.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v2: - Use an inline relocation function to reduce code size
Changes in v4: - Remove proc.S file from Makefiles - Split out board changes into separate patches
arch/arm/config.mk | 3 -- arch/arm/include/asm/reloc.h | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/reloc.h
diff --git a/arch/arm/config.mk b/arch/arm/config.mk index f47d4f7..45f9dca 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -81,6 +81,3 @@ endif ifndef CONFIG_NAND_SPL LDFLAGS_u-boot += -pie endif - -# We use legacy relocation for now -CONFIG_SYS_SKIP_RELOC := y diff --git a/arch/arm/include/asm/reloc.h b/arch/arm/include/asm/reloc.h new file mode 100644 index 0000000..3b6491d --- /dev/null +++ b/arch/arm/include/asm/reloc.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <elf.h> + +/** + * Process a single ELF relocation entry + * + * @param addr Pointer to address of intruction/data to relocate + * @param info The ELF information word / flags + * @param symtab The ELF relocation symbol table + * @param reloc_off Offset of relocated U-Boot relative to load address + * @return 0 if ok, -1 on error + */ +static inline int arch_elf_relocate_entry(Elf32_Addr *addr, Elf32_Word info, + Elf32_Sym *symtab, ulong reloc_off) +{ + int sym; + + switch (ELF32_R_TYPE(info)) { + /* relative fix: increase location by offset */ + case 23: /* TODO: add R_ARM_... defines to elf.h */ + *addr += reloc_off; + break; + + /* absolute fix: set location to (offset) symbol value */ + case 2: + sym = ELF32_R_SYM(info); + *addr = symtab[sym].st_value + reloc_off; + break; + + default: + debug("*** Invalid relocation\n"); + return -1; + } + return 0; +}

Now that we are using the generic relocation framework, we don't need this code.
Note: Here we lose the ARM1176's enable_mmu code. This seems to duplicate code already in U-Boot now. Can anyone comment on this?
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v2: - Make relocation symbols global so we can use them outside start.S
Changes in v3: - Rebase to master - Remove the 'reloc' tag from each commit
Changes in v4: - Rebase to master, also bring in ARM master - Update start.S pruning to fit with early patches
arch/arm/cpu/arm1136/start.S | 114 ----------------------- arch/arm/cpu/arm1176/start.S | 193 ---------------------------------------- arch/arm/cpu/arm720t/start.S | 108 ---------------------- arch/arm/cpu/arm920t/start.S | 116 ------------------------ arch/arm/cpu/arm925t/start.S | 116 ------------------------ arch/arm/cpu/arm926ejs/start.S | 125 -------------------------- arch/arm/cpu/arm946es/start.S | 111 ----------------------- arch/arm/cpu/arm_intcm/start.S | 116 ------------------------ arch/arm/cpu/armv7/start.S | 121 ------------------------- arch/arm/cpu/ixp/start.S | 108 ---------------------- arch/arm/cpu/lh7a40x/start.S | 105 ---------------------- arch/arm/cpu/pxa/start.S | 121 ------------------------- arch/arm/cpu/s3c44b0/start.S | 108 ---------------------- arch/arm/cpu/sa1100/start.S | 105 ---------------------- 14 files changed, 0 insertions(+), 1667 deletions(-)
diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S index e74d5f9..06c91dd 100644 --- a/arch/arm/cpu/arm1136/start.S +++ b/arch/arm/cpu/arm1136/start.S @@ -181,120 +181,6 @@ call_board_init_f:
bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l -#endif /* #ifndef CONFIG_SPL_BUILD */ - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -#ifdef CONFIG_NAND_SPL - ldr r0, _nand_boot_ofs - mov pc, r0 - -_nand_boot_ofs: - .word nand_boot -#else -jump_2_ram: - ldr r0, _board_init_r_ofs - ldr r1, _TEXT_BASE - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start -#endif - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S index 7fc6a18..b393353 100644 --- a/arch/arm/cpu/arm1176/start.S +++ b/arch/arm/cpu/arm1176/start.S @@ -243,160 +243,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -#ifdef CONFIG_ENABLE_MMU -enable_mmu: - /* enable domain access */ - ldr r5, =0x0000ffff - mcr p15, 0, r5, c3, c0, 0 /* load domain access register */ - - /* Set the TTB register */ - ldr r0, _mmu_table_base - ldr r1, =CONFIG_SYS_PHY_UBOOT_BASE - ldr r2, =0xfff00000 - bic r0, r0, r2 - orr r1, r0, r1 - mcr p15, 0, r1, c2, c0, 0 - - /* Enable the MMU */ - mrc p15, 0, r0, c1, c0, 0 - orr r0, r0, #1 /* Set CR_M to enable MMU */ - - /* Prepare to enable the MMU */ - adr r1, skip_hw_init - and r1, r1, #0x3fc - ldr r2, _TEXT_BASE - ldr r3, =0xfff00000 - and r2, r2, r3 - orr r2, r2, r1 - b mmu_enable - - .align 5 - /* Run in a single cache-line */ -mmu_enable: - - mcr p15, 0, r0, c1, c0, 0 - nop - nop - mov pc, r2 -skip_hw_init: -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l - -#ifndef CONFIG_NAND_SPL - bl coloured_LED_init - bl red_led_on -#endif -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -#ifdef CONFIG_NAND_SPL - ldr pc, _nand_boot - -_nand_boot: .word nand_boot -#else - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start -#endif - /** * Jump to board_init_r with a new stack pointer * @@ -416,46 +262,7 @@ start_call_board_init_r: /* jump to it ... */ mov pc, r2
-#ifdef CONFIG_ENABLE_MMU -_mmu_table_base: - .word mmu_table -#endif - #ifndef CONFIG_NAND_SPL -/* - * we assume that cache operation is done before. (eg. cleanup_before_linux()) - * actually, we don't need to do anything about cache if not use d-cache in - * U-Boot. So, in this function we clean only MMU. by scsuh - * - * void theLastJump(void *kernel, int arch_num, uint boot_params); - */ -#ifdef CONFIG_ENABLE_MMU - .globl theLastJump -theLastJump: - mov r9, r0 - ldr r3, =0xfff00000 - ldr r4, _TEXT_PHY_BASE - adr r5, phy_last_jump - bic r5, r5, r3 - orr r5, r5, r4 - mov pc, r5 -phy_last_jump: - /* - * disable MMU stuff - */ - mrc p15, 0, r0, c1, c0, 0 - bic r0, r0, #0x00002300 /* clear bits 13, 9:8 (--V- --RS) */ - bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */ - orr r0, r0, #0x00000002 /* set bit 2 (A) Align */ - orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */ - mcr p15, 0, r0, c1, c0, 0 - - mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ - - mov r0, #0 - mov pc, r9 -#endif -
/* ************************************************************************* diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S index cdbe751..c9fbab0 100644 --- a/arch/arm/cpu/arm720t/start.S +++ b/arch/arm/cpu/arm720t/start.S @@ -158,114 +158,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l - - bl coloured_LED_init - bl red_led_on -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/arm920t/start.S b/arch/arm/cpu/arm920t/start.S index 3257df6..783a42f 100644 --- a/arch/arm/cpu/arm920t/start.S +++ b/arch/arm/cpu/arm920t/start.S @@ -201,122 +201,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l - - bl coloured_LED_init - bl red_led_on -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -#ifdef CONFIG_NAND_SPL - ldr r0, _nand_boot_ofs - mov pc, r0 - -_nand_boot_ofs: - .word nand_boot -#else - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start -#endif - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/arm925t/start.S b/arch/arm/cpu/arm925t/start.S index b9181bf..cdbc165 100644 --- a/arch/arm/cpu/arm925t/start.S +++ b/arch/arm/cpu/arm925t/start.S @@ -195,122 +195,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l - - bl coloured_LED_init - bl red_led_on -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -#ifdef CONFIG_NAND_SPL - ldr r0, _nand_boot_ofs - mov pc, r0 - -_nand_boot_ofs: - .word nand_boot -#else - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start -#endif - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index ecb44f1..3eacaac 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -229,131 +229,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - sub r9, r6, r0 /* r9 <- relocation offset */ - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifdef CONFIG_SPL_BUILD - /* No relocation for SPL */ - ldr r0, =__bss_start - ldr r1, =__bss_end__ -#else - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 -#endif - mov r2, #0x00000000 /* clear */ - -clbss_l:cmp r0, r1 /* clear loop... */ - bhs clbss_e /* if reached end of bss, exit */ - str r2, [r0] - add r0, r0, #4 - b clbss_l -clbss_e: - -#ifndef CONFIG_SPL_BUILD - bl coloured_LED_init - bl red_led_on -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -#ifdef CONFIG_NAND_SPL - ldr r0, _nand_boot_ofs - mov pc, r0 - -_nand_boot_ofs: - .word nand_boot -#else - ldr r0, _board_init_r_ofs - ldr r1, _TEXT_BASE - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start -#endif - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/arm946es/start.S b/arch/arm/cpu/arm946es/start.S index 469a141..991849d 100644 --- a/arch/arm/cpu/arm946es/start.S +++ b/arch/arm/cpu/arm946es/start.S @@ -166,117 +166,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - blo clbss_l -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -#ifdef CONFIG_NAND_SPL - ldr pc, _nand_boot - -_nand_boot: .word nand_boot -#else - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start -#endif - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/arm_intcm/start.S b/arch/arm/cpu/arm_intcm/start.S index 0e469e9..ab49055 100644 --- a/arch/arm/cpu/arm_intcm/start.S +++ b/arch/arm/cpu/arm_intcm/start.S @@ -162,122 +162,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l - - bl coloured_LED_init - bl red_led_on -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -#ifdef CONFIG_NAND_SPL - ldr r0, _nand_boot_ofs - mov pc, r0 - -_nand_boot_ofs: - .word nand_boot -#else - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start -#endif - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 5581387..ae1074e 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -177,127 +177,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - moveq r9, #0 /* no relocation. relocation offset(r9) = 0 */ - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _image_copy_end_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop - b clear_bss - -#endif /* #ifndef CONFIG_SPL_BUILD */ - -clear_bss: -#ifdef CONFIG_SPL_BUILD - /* No relocation for SPL */ - ldr r0, =__bss_start - ldr r1, =__bss_end__ -#else - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 -#endif - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -jump_2_ram: -/* - * If I-cache is enabled invalidate it - */ -#ifndef CONFIG_SYS_ICACHE_OFF - mcr p15, 0, r0, c7, c5, 0 @ invalidate icache - mcr p15, 0, r0, c7, c10, 4 @ DSB - mcr p15, 0, r0, c7, c5, 4 @ ISB -#endif - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/ixp/start.S b/arch/arm/cpu/ixp/start.S index f00ad38..5c0ea00 100644 --- a/arch/arm/cpu/ixp/start.S +++ b/arch/arm/cpu/ixp/start.S @@ -264,114 +264,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l - - bl coloured_LED_init - bl red_led_on -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/lh7a40x/start.S b/arch/arm/cpu/lh7a40x/start.S index 48b8639..64b7ef8 100644 --- a/arch/arm/cpu/lh7a40x/start.S +++ b/arch/arm/cpu/lh7a40x/start.S @@ -175,111 +175,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S index 30f15b6..e739aa7 100644 --- a/arch/arm/cpu/pxa/start.S +++ b/arch/arm/cpu/pxa/start.S @@ -183,127 +183,6 @@ call_board_init_f: ldr r0, =0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ -#ifndef CONFIG_SPL_BUILD -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - -/* Disable the Dcache RAM lock for stack now */ -#ifdef CONFIG_CPU_PXA25X - bl cpu_init_crit -#endif - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l -#endif /* #ifndef CONFIG_SPL_BUILD */ - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ -#ifdef CONFIG_ONENAND_SPL - ldr r0, _onenand_boot_ofs - mov pc, r0 - -_onenand_boot_ofs: - .word onenand_boot -#else -jump_2_ram: - ldr r0, _board_init_r_ofs - ldr r1, _TEXT_BASE - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start -#endif - -#endif - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/s3c44b0/start.S b/arch/arm/cpu/s3c44b0/start.S index f470f10..5425b95 100644 --- a/arch/arm/cpu/s3c44b0/start.S +++ b/arch/arm/cpu/s3c44b0/start.S @@ -147,114 +147,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l - - bl coloured_LED_init - bl red_led_on -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start - /** * Jump to board_init_r with a new stack pointer * diff --git a/arch/arm/cpu/sa1100/start.S b/arch/arm/cpu/sa1100/start.S index fce6f87..66c01c1 100644 --- a/arch/arm/cpu/sa1100/start.S +++ b/arch/arm/cpu/sa1100/start.S @@ -151,111 +151,6 @@ call_board_init_f: ldr r0,=0x00000000 bl board_init_f
-/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code (addr_sp, gd, addr_moni) - * - * This "function" does not return, instead it continues in RAM - * after relocating the monitor code. - * - */ - .globl relocate_code -relocate_code: - mov r4, r0 /* save addr_sp */ - mov r5, r1 /* save addr of gd */ - mov r6, r2 /* save addr of destination */ - - /* Set up the stack */ -stack_setup: - mov sp, r4 - - adr r0, _start - cmp r0, r6 - beq clear_bss /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _bss_start_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r9-r10} /* copy from source address [r0] */ - stmia r1!, {r9-r10} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - sub r9, r6, r0 /* r9 <- relocation offset */ - ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ - add r10, r10, r0 /* r10 <- sym table in FLASH */ - ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ - add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ - ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ - add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ -fixloop: - ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ - add r0, r0, r9 /* r0 <- location to fix up in RAM */ - ldr r1, [r2, #4] - and r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #2 /* absolute fixup? */ - beq fixabs - /* ignore unknown type of fixup */ - b fixnext -fixabs: - /* absolute fix: set location to (offset) symbol value */ - mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ - add r1, r10, r1 /* r1 <- address of symbol in table */ - ldr r1, [r1, #4] /* r1 <- symbol value */ - add r1, r1, r9 /* r1 <- relocated sym addr */ - b fixnext -fixrel: - /* relative fix: increase location by offset */ - ldr r1, [r0] - add r1, r1, r9 -fixnext: - str r1, [r0] - add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ - cmp r2, r3 - blo fixloop -#endif - -clear_bss: -#ifndef CONFIG_SPL_BUILD - ldr r0, _bss_start_ofs - ldr r1, _bss_end_ofs - mov r4, r6 /* reloc addr */ - add r0, r0, r4 - add r1, r1, r4 - mov r2, #0x00000000 /* clear */ - -clbss_l:str r2, [r0] /* clear loop... */ - add r0, r0, #4 - cmp r0, r1 - bne clbss_l -#endif - -/* - * We are done. Do not return, instead branch to second part of board - * initialization, now running from RAM. - */ - ldr r0, _board_init_r_ofs - adr r1, _start - add lr, r0, r1 - add lr, lr, r9 - /* setup parameters for board_init_r */ - mov r0, r5 /* gd_t */ - mov r1, r6 /* dest_addr */ - /* jump to it ... */ - mov pc, lr - -_board_init_r_ofs: - .word board_init_r - _start - /** * Jump to board_init_r with a new stack pointer *

Hi Simon,
One general question: am I right in saying that in the current implementation, relocate_code executes mostly on the final stack, whereas in your proposal, it runs on the initial stack?
Amicalement,

Hi Albert,
On Tue, Feb 21, 2012 at 11:40 AM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
Hi Simon,
One general question: am I right in saying that in the current implementation, relocate_code executes mostly on the final stack, whereas in your proposal, it runs on the initial stack?
Well the current relocation code is all in assembler and I don't believe it uses the stack at all. It does set up the stack pointer at the beginning if that's what you mean.
Yes this series uses the initial stack for all processing until it reaches board_init_r().
Amicalement,
Albert.
Regards, Simon

Hi Simon, Albert.
On 02/22/2012 07:07 AM, Simon Glass wrote:
Hi Albert,
On Tue, Feb 21, 2012 at 11:40 AM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
Hi Simon,
One general question: am I right in saying that in the current implementation, relocate_code executes mostly on the final stack, whereas in your proposal, it runs on the initial stack?
Well the current relocation code is all in assembler and I don't believe it uses the stack at all. It does set up the stack pointer at the beginning if that's what you mean.
Yes this series uses the initial stack for all processing until it reaches board_init_r().
<broken record>
See what x86 does - Code copy and relocation in C using final stack and full cache enabled...
</broken record> :)
Regards,
Graeme

Hi Graeme,
On Tue, Feb 21, 2012 at 12:10 PM, Graeme Russ graeme.russ@gmail.com wrote:
Hi Simon, Albert.
On 02/22/2012 07:07 AM, Simon Glass wrote:
Hi Albert,
On Tue, Feb 21, 2012 at 11:40 AM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
Hi Simon,
One general question: am I right in saying that in the current implementation, relocate_code executes mostly on the final stack, whereas in your proposal, it runs on the initial stack?
Well the current relocation code is all in assembler and I don't believe it uses the stack at all. It does set up the stack pointer at the beginning if that's what you mean.
Yes this series uses the initial stack for all processing until it reaches board_init_r().
<broken record>
See what x86 does - Code copy and relocation in C using final stack and full cache enabled...
</broken record> :)
Heading there, but we can't enable dcache prior to relocation on ARM yet. Generic relocation gives me something to work with that isn't just for one architecture,
Regards, Simon
Regards,
Graeme
participants (8)
-
Albert ARIBAUD
-
Christian Riesch
-
Graeme Russ
-
Mike Frysinger
-
Scott Wood
-
Simon Glass
-
Sughosh Ganu
-
Tom Rini