Introduce generic relocation feature
Subsystems (10)
v3 cover Introduce generic relocation feature
(I am resending this rebased so I can continue with this board-unification work and allow people to review patches. There were some comments on the v2 series but my questions have been sitting on the list for 2 weeks so it is probably time for a new series.)
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 met this reduces relocation time to 5.4ms, i.e. twice as fast as the old system.
One problem remains which causes mx31pdk to fail to build. It doesn't have string.c in its SPL code and the architecture-specific versions of memset()/memcpy() are too large. I propose to add a local change to reloc.c that uses inline code for boards that use the old legacy SPL framework. We can remove it later. This is not included in v2 but I am interested in comments on this approach. An alternative would be just to add simple memset()/memcpy() functions just for this board (and one other affected MX31 board).
Changes in v2:
- Use CONFIG_SYS_SKIP_RELOC instead of CONFIG_SYS_LEGACY_BOARD
- Import asm-generic/sections.h from Linux and add U-Boot extras
- Squash generic link symbols patch into generic relocation patch
- Move reloc.c into common/
- Add function comments
- Use memset, memcpy instead of inline code
- Add README file for relocation
- Invalidate I-cache when we jump to relocated code
- Use an inline relocation function to reduce code size
- Make relocation symbols global so we can use them outside start.S
Changes in v3:
- Remove the 'reloc' tag from each commit
- Rebase to master
Simon Glass (6):
Create reloc.h and include it where needed
define CONFIG_SYS_SKIP_RELOC for all archs
Add generic relocation feature
arm: Add processor function library
arm: Move over to generic relocation
arm: Remove unused code in start.S
README | 4 + arch/arm/cpu/arm1136/start.S | 133 ++------------ arch/arm/cpu/arm1176/start.S | 214 ++------------------- arch/arm/cpu/arm720t/start.S | 127 ++----------- arch/arm/cpu/arm920t/start.S | 135 ++------------ arch/arm/cpu/arm925t/start.S | 135 ++------------ arch/arm/cpu/arm926ejs/davinci/spl.c | 1 + arch/arm/cpu/arm926ejs/start.S | 144 ++------------- arch/arm/cpu/arm946es/start.S | 130 ++----------- arch/arm/cpu/arm_intcm/start.S | 135 ++------------ arch/arm/cpu/armv7/omap-common/spl.c | 1 + arch/arm/cpu/armv7/start.S | 140 ++------------ arch/arm/cpu/ixp/start.S | 127 ++----------- arch/arm/cpu/lh7a40x/start.S | 124 ++----------- arch/arm/cpu/pxa/start.S | 138 ++------------ arch/arm/cpu/s3c44b0/start.S | 127 ++----------- arch/arm/cpu/sa1100/start.S | 124 ++----------- arch/arm/include/asm/reloc.h | 56 ++++++ arch/arm/lib/Makefile | 2 + arch/arm/lib/board.c | 1 + arch/arm/lib/proc.S | 40 ++++ arch/avr32/config.mk | 3 + arch/avr32/lib/board.c | 1 + arch/blackfin/config.mk | 3 + arch/m68k/config.mk | 3 + arch/m68k/lib/board.c | 1 + arch/microblaze/config.mk | 3 + arch/mips/config.mk | 3 + arch/mips/lib/board.c | 1 + arch/nds32/config.mk | 3 + arch/nds32/lib/board.c | 1 + arch/nios2/config.mk | 3 + arch/powerpc/config.mk | 3 + arch/powerpc/lib/board.c | 1 + arch/sandbox/config.mk | 3 + arch/sh/config.mk | 3 + arch/sparc/config.mk | 3 + arch/x86/config.mk | 3 + arch/x86/lib/board.c | 1 + board/freescale/mpc8313erdb/mpc8313erdb.c | 1 + board/freescale/mpc8315erdb/mpc8315erdb.c | 1 + board/samsung/smdk6400/smdk6400_nand_spl.c | 1 + board/sheldon/simpc8313/simpc8313.c | 1 + common/Makefile | 4 + common/reloc.c | 121 ++++++++++++ doc/README.relocation | 87 +++++++++ include/asm-generic/sections.h | 92 +++++++++ include/common.h | 2 +- include/reloc.h | 54 +++++ nand_spl/board/freescale/mpc8536ds/nand_boot.c | 1 + nand_spl/board/freescale/mpc8569mds/nand_boot.c | 1 + nand_spl/board/freescale/mpc8572ds/nand_boot.c | 1 + nand_spl/board/freescale/mx31pdk/Makefile | 8 +- nand_spl/board/freescale/mx31pdk/u-boot.lds | 1 + nand_spl/board/freescale/p1010rdb/nand_boot.c | 1 + nand_spl/board/freescale/p1023rds/nand_boot.c | 1 + nand_spl/board/freescale/p1_p2_rdb/nand_boot.c | 1 + nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c | 1 + nand_spl/board/karo/tx25/Makefile | 8 +- nand_spl/board/karo/tx25/u-boot.lds | 1 + nand_spl/nand_boot_fsl_nfc.c | 1 + 61 files changed, 705 insertions(+), 1765 deletions(-) create mode 100644 arch/arm/include/asm/reloc.h create mode 100644 arch/arm/lib/proc.S create mode 100644 common/reloc.c create mode 100644 doc/README.relocation create mode 100644 include/asm-generic/sections.h create mode 100644 include/reloc.h
Signature · 1 line
1.7.3.1
PATCH v3 1/6 Create reloc.h and include it where needed
Before adding new relocation functions, move this prototype out of common.h where things are pretty crowded.
---
arch/arm/cpu/arm926ejs/davinci/spl.c | 1 + arch/arm/cpu/armv7/omap-common/spl.c | 1 + arch/arm/lib/board.c | 1 + arch/avr32/lib/board.c | 1 + arch/m68k/lib/board.c | 1 + arch/mips/lib/board.c | 1 + arch/nds32/lib/board.c | 1 + arch/powerpc/lib/board.c | 1 + arch/x86/lib/board.c | 1 + board/freescale/mpc8313erdb/mpc8313erdb.c | 1 + board/freescale/mpc8315erdb/mpc8315erdb.c | 1 + board/samsung/smdk6400/smdk6400_nand_spl.c | 1 + board/sheldon/simpc8313/simpc8313.c | 1 + include/common.h | 2 +- include/reloc.h | 39 +++++++++++++++++++++ nand_spl/board/freescale/mpc8536ds/nand_boot.c | 1 + nand_spl/board/freescale/mpc8569mds/nand_boot.c | 1 + nand_spl/board/freescale/mpc8572ds/nand_boot.c | 1 + nand_spl/board/freescale/p1010rdb/nand_boot.c | 1 + nand_spl/board/freescale/p1023rds/nand_boot.c | 1 + nand_spl/board/freescale/p1_p2_rdb/nand_boot.c | 1 + nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c | 1 + nand_spl/nand_boot_fsl_nfc.c | 1 + 23 files changed, 61 insertions(+), 1 deletions(-) create mode 100644 include/reloc.h
arch/arm/cpu/arm926ejs/davinci/spl.c +1 -0
@@ -24,6 +24,7 @@#include <asm/u-boot.h> #include <asm/utils.h> #include <nand.h> +#include <reloc.h> #include <asm/arch/dm365_lowlevel.h> #include <ns16550.h>
arch/arm/cpu/armv7/omap-common/spl.c +1 -0
@@ -35,6 +35,7 @@#include <i2c.h> #include <image.h> #include <malloc.h> +#include <reloc.h> DECLARE_GLOBAL_DATA_PTR ;
arch/arm/lib/board.c +1 -0
@@ -41,6 +41,7 @@#include <common.h> #include <command.h> #include <malloc.h> +#include <reloc.h> #include <stdio_dev.h> #include <version.h> #include <net.h>
arch/avr32/lib/board.c +1 -0
@@ -22,6 +22,7 @@#include <common.h> #include <command.h> #include <malloc.h> +#include <reloc.h> #include <stdio_dev.h> #include <version.h> #include <net.h>
arch/m68k/lib/board.c +1 -0
@@ -28,6 +28,7 @@#include <watchdog.h> #include <command.h> #include <malloc.h> +#include <reloc.h> #include <stdio_dev.h> #include <asm/immap.h>
arch/mips/lib/board.c +1 -0
@@ -24,6 +24,7 @@#include <common.h> #include <command.h> #include <malloc.h> +#include <reloc.h> #include <stdio_dev.h> #include <version.h> #include <net.h>
arch/nds32/lib/board.c +1 -0
@@ -28,6 +28,7 @@#include <common.h> #include <command.h> #include <malloc.h> +#include <reloc.h> #include <stdio_dev.h> #include <timestamp.h> #include <version.h>
arch/powerpc/lib/board.c +1 -0
@@ -25,6 +25,7 @@#include <watchdog.h> #include <command.h> #include <malloc.h> +#include <reloc.h> #include <stdio_dev.h> #ifdef CONFIG_8xx#include <mpc8xx.h>
arch/x86/lib/board.c +1 -0
@@ -35,6 +35,7 @@#include <watchdog.h> #include <command.h> #include <stdio_dev.h> +#include <reloc.h> #include <version.h> #include <malloc.h> #include <net.h>
board/freescale/mpc8313erdb/mpc8313erdb.c +1 -0
@@ -27,6 +27,7 @@#include <libfdt.h> #endif #include <pci.h> +#include <reloc.h> #include <mpc83xx.h> #include <vsc7385.h> #include <ns16550.h>
board/freescale/mpc8315erdb/mpc8315erdb.c +1 -0
@@ -34,6 +34,7 @@#include <asm/io.h> #include <ns16550.h> #include <nand.h> +#include <reloc.h> DECLARE_GLOBAL_DATA_PTR ;
board/samsung/smdk6400/smdk6400_nand_spl.c +1 -0
@@ -29,6 +29,7 @@*/ #include <common.h> +#include <reloc.h> void board_init_f (unsigned long bootflag) {
board/sheldon/simpc8313/simpc8313.c +1 -0
@@ -29,6 +29,7 @@#include <mpc83xx.h> #include <ns16550.h> #include <nand.h> +#include <reloc.h> #include <asm/io.h> DECLARE_GLOBAL_DATA_PTR ;
include/common.h +1 -1
@@ -477,7 +477,7 @@ int dcache_status (void);void dcache_enable (void );void dcache_disable (void );void mmu_disable (void ); -void relocate_code (ulong ,gd_t *,ulong ) __attribute__ ((noreturn)); +#include <reloc.h> ulong get_endaddr (void );void trap_init (ulong ); #if defined (CONFIG_4xx) || \
include/reloc.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* 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 +*/ + +#ifndef __RELOC_H +#define __RELOC_H + +/** +* 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. +* +* @param dest_sp New stack pointer to use +* @param new_gd Pointer to the relocated global data +* @param dest_addr Base code address of relocated U-Boot +*/ +void relocate_code (ulong dest_sp,gd_t *new_gd,ulong dest_addr) + __attribute__ ((noreturn)); +#endif
nand_spl/board/freescale/mpc8536ds/nand_boot.c +1 -0
@@ -23,6 +23,7 @@#include <ns16550.h> #include <asm/io.h> #include <nand.h> +#include <reloc.h> u32 sysclk_tbl[] = {33333000 ,39999600 ,49999500 ,66666000 ,
nand_spl/board/freescale/mpc8569mds/nand_boot.c +1 -0
@@ -23,6 +23,7 @@#include <asm/io.h> #include <ns16550.h> #include <nand.h> +#include <reloc.h> #include <asm/mmu.h> #include <asm/immap_85xx.h> #include <asm/fsl_ddr_sdram.h>
nand_spl/board/freescale/mpc8572ds/nand_boot.c +1 -0
@@ -23,6 +23,7 @@#include <ns16550.h> #include <asm/io.h> #include <nand.h> +#include <reloc.h> u32 sysclk_tbl[] = {33333000 ,39999600 ,49999500 ,66666000 ,
nand_spl/board/freescale/p1010rdb/nand_boot.c +1 -0
@@ -23,6 +23,7 @@#include <asm/io.h> #include <ns16550.h> #include <nand.h> +#include <reloc.h> #include <asm/mmu.h> #include <asm/immap_85xx.h> #include <asm/fsl_ddr_sdram.h>
nand_spl/board/freescale/p1023rds/nand_boot.c +1 -0
@@ -24,6 +24,7 @@#include <ns16550.h> #include <asm/io.h> #include <nand.h> +#include <reloc.h> #include <asm/fsl_law.h> /* Fixed sdram init -- doesn't use serial presence detect. */
nand_spl/board/freescale/p1_p2_rdb/nand_boot.c +1 -0
@@ -23,6 +23,7 @@#include <asm/io.h> #include <ns16550.h> #include <nand.h> +#include <reloc.h> #include <asm/mmu.h> #include <asm/immap_85xx.h> #include <asm/fsl_ddr_sdram.h>
nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c +1 -0
@@ -23,6 +23,7 @@#include <ns16550.h> #include <asm/io.h> #include <nand.h> +#include <reloc.h> #include <asm/fsl_law.h> #include <asm/fsl_ddr_sdram.h>
nand_spl/nand_boot_fsl_nfc.c +1 -0
@@ -29,6 +29,7 @@#include <asm/arch/imx-regs.h> #include <asm/io.h> #include <fsl_nfc.h> +#include <reloc.h> static struct fsl_nfc_regs *const nfc = (void *)NFC_BASE_ADDR ;
Signature · 1 line
1.7.3.1
PATCH v3 2/6 define CONFIG_SYS_SKIP_RELOC for all archs
In reply to Simon GlassWe 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.
---
Changes in v2:
- Use CONFIG_SYS_SKIP_RELOC instead of CONFIG_SYS_LEGACY_BOARD
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(-)
README +4 -0
@@ -2741,6 +2741,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:
arch/arm/config.mk +3 -0
@@ -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
arch/avr32/config.mk +3 -0
@@ -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
arch/blackfin/config.mk +3 -0
@@ -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
arch/m68k/config.mk +3 -0
@@ -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
arch/microblaze/config.mk +3 -0
@@ -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
arch/mips/config.mk +3 -0
@@ -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
arch/nds32/config.mk +3 -0
@@ -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
arch/nios2/config.mk +3 -0
@@ -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
arch/powerpc/config.mk +3 -0
@@ -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
arch/sandbox/config.mk +3 -0
@@ -19,3 +19,6 @@ PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ PLATFORM_LIBS += -lrt + +# Sandbox does not do relocation +CONFIG_SYS_SKIP_RELOC := y
arch/sh/config.mk +3 -0
@@ -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
arch/sparc/config.mk +3 -0
@@ -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
arch/x86/config.mk +3 -0
@@ -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
Signature · 1 line
1.7.3.1
PATCH v3 3/6 Add generic relocation feature
In reply to Simon GlassAdd 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.
---
Changes in v2:
- Import asm-generic/sections.h from Linux and add U-Boot extras
- Squash generic link symbols patch into generic relocation patch
- Move reloc.c into common/
- Add function comments
- Use memset, memcpy instead of inline code
- Add README file for relocation
common/Makefile | 4 + common/reloc.c | 121 ++++++++++++++++++++++++++++++++++++++++ doc/README.relocation | 87 ++++++++++++++++++++++++++++ include/asm-generic/sections.h | 92 ++++++++++++++++++++++++++++++ include/reloc.h | 15 +++++ 5 files changed, 319 insertions(+), 0 deletions(-) create mode 100644 common/reloc.c create mode 100644 doc/README.relocation create mode 100644 include/asm-generic/sections.h
common/Makefile +4 -0
@@ -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))
common/reloc.c new file +121 -0
121 lines not on this page · raw message
doc/README.relocation new file +87 -0
87 lines not on this page · raw message
include/asm-generic/sections.h new file +92 -0
92 lines not on this page · raw message
include/reloc.h +15 -0
@@ -23,6 +23,21 @@#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 proc_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 *
Signature · 1 line
1.7.3.1
PATCH v3 4/6 arm: Add processor function library
In reply to Simon GlassAdd a library to hold ARM assembler code which is generic across all ARM CPUs. At first it just holds some basic relocation code. The plan is to move more start.S code here.
---
Changes in v2:
- Invalidate I-cache when we jump to relocated code
arch/arm/lib/Makefile | 2 ++ arch/arm/lib/proc.S | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 0 deletions(-) create mode 100644 arch/arm/lib/proc.S
arch/arm/lib/Makefile +2 -0
@@ -48,6 +48,8 @@ SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o endif +SOBJS-y += proc.o + SRCS := $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \ $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
arch/arm/lib/proc.S new file +40 -0
@@ -0,0 +1,40 @@ +/* + * 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 + */ + + +/** + * 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 proc_call_board_init_r +proc_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
Signature · 1 line
1.7.3.1
PATCH v3 5/6 arm: Move over to generic relocation
In reply to Simon GlassAdd a function to process a single ELF relocation and switch ARM over to use generic relocation.
Unfortunately a few boards need to be modified to make this work (mostly adding link symbols to the .lds files).
---
Changes in v2:
- Use an inline relocation function to reduce code size
arch/arm/config.mk | 3 - arch/arm/include/asm/reloc.h | 56 +++++++++++++++++++++++++++ nand_spl/board/freescale/mx31pdk/Makefile | 8 +++- nand_spl/board/freescale/mx31pdk/u-boot.lds | 1 + nand_spl/board/karo/tx25/Makefile | 8 +++- nand_spl/board/karo/tx25/u-boot.lds | 1 + 6 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 arch/arm/include/asm/reloc.h
arch/arm/config.mk +0 -3
@@ -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
arch/arm/include/asm/reloc.h new file +56 -0
56 lines not on this page · raw message
nand_spl/board/freescale/mx31pdk/Makefile +7 -1
@@ -11,7 +11,7 @@ LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \ AFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL -SOBJS = start.o lowlevel_init.o +SOBJS = start.o lowlevel_init.o proc.o reloc.o COBJS = nand_boot_fsl_nfc.o SRCS := $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c
@@ -50,6 +50,12 @@ $(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 $@ $< + +$(obj)%.o: $(SRCTREE)/arch/arm/lib/%.S + $(CC) $(AFLAGS) -c -o $@ $< + # defines $(obj).depend target include $(SRCTREE)/rules.mk
nand_spl/board/freescale/mx31pdk/u-boot.lds +1 -0
@@ -51,6 +51,7 @@ SECTIONS __u_boot_cmd_end = .; . = ALIGN(4); + __image_copy_end = .; .rel.dyn : { __rel_dyn_start = .;
nand_spl/board/karo/tx25/Makefile +7 -1
@@ -32,7 +32,7 @@ LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \ AFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL -SOBJS = start.o lowlevel_init.o +SOBJS = start.o lowlevel_init.o proc.o reloc.o COBJS = nand_boot_fsl_nfc.o SRCS := $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c
@@ -71,6 +71,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)/arch/arm/lib/%.S + $(CC) $(AFLAGS) -c -o $@ $< + # defines $(obj).depend target include $(SRCTREE)/rules.mk
nand_spl/board/karo/tx25/u-boot.lds +1 -0
@@ -51,6 +51,7 @@ SECTIONS __u_boot_cmd_end = .; . = ALIGN(4); + __image_copy_end = .; .rel.dyn : { __rel_dyn_start = .;
Signature · 1 line
1.7.3.1
PATCH v3 6/6 arm: Remove unused code in start.S
In reply to Simon GlassNow 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?
---
Changes in v2:
- Make relocation symbols global so we can use them outside start.S
Changes in v3:
- Remove the 'reloc' tag from each commit
- Rebase to master
arch/arm/cpu/arm1136/start.S | 133 +++---------------------- arch/arm/cpu/arm1176/start.S | 214 +++------------------------------------- arch/arm/cpu/arm720t/start.S | 127 +++--------------------- arch/arm/cpu/arm920t/start.S | 135 +++----------------------- arch/arm/cpu/arm925t/start.S | 135 +++----------------------- arch/arm/cpu/arm926ejs/start.S | 144 +++------------------------ arch/arm/cpu/arm946es/start.S | 130 +++---------------------- arch/arm/cpu/arm_intcm/start.S | 135 +++----------------------- arch/arm/cpu/armv7/start.S | 140 +++----------------------- arch/arm/cpu/ixp/start.S | 127 +++--------------------- arch/arm/cpu/lh7a40x/start.S | 124 +++--------------------- arch/arm/cpu/pxa/start.S | 138 +++----------------------- arch/arm/cpu/s3c44b0/start.S | 127 +++--------------------- arch/arm/cpu/sa1100/start.S | 124 +++--------------------- 14 files changed, 171 insertions(+), 1762 deletions(-)
arch/arm/cpu/arm1136/start.S +12 -121
@@ -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
@@ -169,127 +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 - -_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 - /* ************************************************************************* *
arch/arm/cpu/arm1176/start.S +12 -202
226 lines not on this page · raw message
arch/arm/cpu/arm720t/start.S +12 -115
139 lines not on this page · raw message
arch/arm/cpu/arm920t/start.S +12 -123
147 lines not on this page · raw message
arch/arm/cpu/arm925t/start.S +12 -123
147 lines not on this page · raw message
arch/arm/cpu/arm926ejs/start.S +12 -132
156 lines not on this page · raw message
arch/arm/cpu/arm946es/start.S +12 -118
142 lines not on this page · raw message
arch/arm/cpu/arm_intcm/start.S +12 -123
147 lines not on this page · raw message
arch/arm/cpu/armv7/start.S +15 -125
158 lines not on this page · raw message
arch/arm/cpu/ixp/start.S +12 -115
139 lines not on this page · raw message
arch/arm/cpu/lh7a40x/start.S +12 -112
136 lines not on this page · raw message
arch/arm/cpu/pxa/start.S +12 -126
150 lines not on this page · raw message
arch/arm/cpu/s3c44b0/start.S +12 -115
139 lines not on this page · raw message
arch/arm/cpu/sa1100/start.S +12 -112
136 lines not on this page · raw message
Signature · 1 line
1.7.3.1
v3 cover Introduce generic relocation feature
In reply to Simon GlassHi Simon,
Le 26/12/2011 19:24, Simon Glass a ?crit :
Quoted 11 lines
(I am resending this rebased so I can continue with this board-unification work and allow people to review patches. There were some comments on the v2 series but my questions have been sitting on the list for 2 weeks so it is probably time for a new series.)
This is the second patch series aiming to unify the various
board.cfiles in each architecture into a single one. This series implements a generic relocation feature, which is the bridge betweenboard_init_f()andboard_init_r(). It then moves ARM over to use this framework, as an example.
Quoted 8 lines
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.
Agreed.
Quoted 7 lines
For ARM, a new
arch/arm/lib/proc.Sfile 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.
NAK for several reasons:
1. The code that goes on proc.S is already in start.S, which already contains "things which cannot be written in C and are common functions used by all ARM CPUs". Granted, right now start.S is duplicated in multiple CPU directories; so the thing to do is to merge all ARM start.S files into a single one, rather than merging only one of its parts.
2. There is no interest in moving this segment of code from all start.S files into a new proc.S file: there is no gain is code size obviously, and there is an increase in source file count.
3. I consider that files should contain 'things' based on their common /functionality/, not on their similar /nature/, and "going about starting up U-Boot" is a functionality.
Note that eventually, having a single start.S will achieve the same effect as this 'proc.S' patch.
Note also that this start.S commonalization should be a completely different patch set.
Quoted 9 lines
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_MEMSETandCONFIG_USE_ARCH_MEMCPYto reduce it. For met this reduces relocation time to 5.4ms, i.e. twice as fast as the old system.
Side question: is there any reason not to define these CONFIG options systematically?
Quoted 8 lines
One problem remains which causes mx31pdk to fail to build. It doesn't have
string.cin its SPL code and the architecture-specific versions of memset()/memcpy() are too large. I propose to add a local change toreloc.cthat uses inline code for boards that use the old legacy SPL framework. We can remove it later. This is not included in v2 but I am interested in comments on this approach. An alternative would be just to add simple memset()/memcpy() functions just for this board (and one other affected MX31 board).
I am not too fond of the "later removal" approach. In my experience, this invariably tends to the "old bloat in the code no one knows the reason of" situations.
Quoted 86 lines
Changes in v2:
- UseCONFIG_SYS_SKIP_RELOCinstead ofCONFIG_SYS_LEGACY_BOARD
- Importasm-generic/sections.hfrom Linux and add U-Boot extras
- Squash generic link symbols patch into generic relocation patch
- Movereloc.cinto common/
- Add function comments
- Use memset, memcpy instead of inline code
- Add README file for relocation
- Invalidate I-cache when we jump to relocated code
- Use an inline relocation function to reduce code size
- Make relocation symbols global so we can use them outsidestart.SChanges in v3:
- Remove the 'reloc' tag from each commit
- Rebase to masterSimon Glass (6):
Createreloc.hand include it where needed
defineCONFIG_SYS_SKIP_RELOCfor all archs
Add generic relocation feature
arm: Add processor function library
arm: Move over to generic relocation
arm: Remove unused code instart.SREADME | 4 + arch/arm/cpu/arm1136/start.S | 133 ++------------ arch/arm/cpu/arm1176/start.S | 214 ++------------------- arch/arm/cpu/arm720t/start.S | 127 ++----------- arch/arm/cpu/arm920t/start.S | 135 ++------------ arch/arm/cpu/arm925t/start.S | 135 ++------------ arch/arm/cpu/arm926ejs/davinci/spl.c | 1 + arch/arm/cpu/arm926ejs/start.S | 144 ++------------- arch/arm/cpu/arm946es/start.S | 130 ++----------- arch/arm/cpu/arm_intcm/start.S | 135 ++------------ arch/arm/cpu/armv7/omap-common/spl.c | 1 + arch/arm/cpu/armv7/start.S | 140 ++------------ arch/arm/cpu/ixp/start.S | 127 ++----------- arch/arm/cpu/lh7a40x/start.S | 124 ++----------- arch/arm/cpu/pxa/start.S | 138 ++------------ arch/arm/cpu/s3c44b0/start.S | 127 ++----------- arch/arm/cpu/sa1100/start.S | 124 ++----------- arch/arm/include/asm/reloc.h | 56 ++++++ arch/arm/lib/Makefile | 2 + arch/arm/lib/board.c | 1 + arch/arm/lib/proc.S | 40 ++++ arch/avr32/config.mk | 3 + arch/avr32/lib/board.c | 1 + arch/blackfin/config.mk | 3 + arch/m68k/config.mk | 3 + arch/m68k/lib/board.c | 1 + arch/microblaze/config.mk | 3 + arch/mips/config.mk | 3 + arch/mips/lib/board.c | 1 + arch/nds32/config.mk | 3 + arch/nds32/lib/board.c | 1 + arch/nios2/config.mk | 3 + arch/powerpc/config.mk | 3 + arch/powerpc/lib/board.c | 1 + arch/sandbox/config.mk | 3 + arch/sh/config.mk | 3 + arch/sparc/config.mk | 3 + arch/x86/config.mk | 3 + arch/x86/lib/board.c | 1 + board/freescale/mpc8313erdb/mpc8313erdb.c | 1 + board/freescale/mpc8315erdb/mpc8315erdb.c | 1 + board/samsung/smdk6400/smdk6400_nand_spl.c | 1 + board/sheldon/simpc8313/simpc8313.c | 1 + common/Makefile | 4 + common/reloc.c | 121 ++++++++++++ doc/README.relocation | 87 +++++++++ include/asm-generic/sections.h | 92 +++++++++ include/common.h | 2 +- include/reloc.h | 54 +++++ nand_spl/board/freescale/mpc8536ds/nand_boot.c | 1 + nand_spl/board/freescale/mpc8569mds/nand_boot.c | 1 + nand_spl/board/freescale/mpc8572ds/nand_boot.c | 1 + nand_spl/board/freescale/mx31pdk/Makefile | 8 +- nand_spl/board/freescale/mx31pdk/u-boot.lds | 1 + nand_spl/board/freescale/p1010rdb/nand_boot.c | 1 + nand_spl/board/freescale/p1023rds/nand_boot.c | 1 + nand_spl/board/freescale/p1_p2_rdb/nand_boot.c | 1 + nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c | 1 + nand_spl/board/karo/tx25/Makefile | 8 +- nand_spl/board/karo/tx25/u-boot.lds | 1 + nand_spl/nand_boot_fsl_nfc.c | 1 + 61 files changed, 705 insertions(+), 1765 deletions(-)
Quoted 6 lines
create mode 100644
arch/arm/include/asm/reloc.hcreate mode 100644arch/arm/lib/proc.Screate mode 100644common/reloc.c
create mode 100644 doc/README.relocation create mode 100644include/asm-generic/sections.hcreate mode 100644include/reloc.h
Amicalement,
Signature · 1 line
Albert.
v3 cover Introduce generic relocation feature
[+TI maintainers, tx25 board maintainer]
Hi Albert,
Quoted 20 lines · Albert ARIBAUD
Hi Simon,
Le 26/12/2011 19:24, Simon Glass a ?crit :
Quoted 16 lines
(I am resending this rebased so I can continue with this board-unification work and allow people to review patches. There were some comments on the v2 series but my questions have been sitting on the list for 2 weeks so it is probably time for a new series.)
This is the second patch series aiming to unify the various
board.cfiles in each architecture into a single one. This series implements a generic relocation feature, which is the bridge betweenboard_init_f()andboard_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.
Quoted 6 lines
Quoted 3 lines
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.Agreed.
OK, that is the first three patches.
Quoted 7 lines
Quoted 7 lines
For ARM, a new
arch/arm/lib/proc.Sfile 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.
Quoted 5 lines
Quoted 2 lines
It may be useful for other architectures with a lot of different CPUs to have a similar file.
NAK for several reasons:
I think you are NAKing the 'arm: Add processor function library' patch out of the series:
Create reloc.h and include it where needed
define CONFIG_SYS_SKIP_RELOC for all archs
Add generic relocation feature
arm: Add processor function library
arm: Move over to generic relocation
arm: Remove unused code in start.S
Q1: Should I remove that patch and just repeat the code from there in each start.S file? The impact would be to remove most of the code in the relocate_code() function in each start.S except for the last few instructions (reproduced below).
Quoted 6 lines
1. The code that goes on
proc.Sis already instart.S, which already contains "things which cannot be written in C and are common functions used by all ARM CPUs". Granted, right nowstart.Sis duplicated in multiple CPU directories; so the thing to do is to merge all ARMstart.Sfiles into a single one, rather than merging only one of its parts.
Q2: What should this merged file be called and what directory should it be in? This is the question I asked last time, and the lack of an answer is the reason why I have been unable to make progress here. Please advise your preference and I will sort it out.
Note I don't think I can do this in one series - there is far too much variation between the files for me to take on that way. I need a new file than I can bit I bit move things over into, allowing affected parties to comment on each as I go.
Quoted 4 lines
2. There is no interest in moving this segment of code from all
start.Sfiles into a newproc.Sfile: there is no gain is code size obviously, and there is an increase in source file count.
Just checking that you see that the code is removed from start.S, not moved. The code in proc.S is:
.globl proc_call_board_init_rproc_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
which is taken from the end of each relocate_code() copy. Assuming we are on the page, then ok.
Quoted 4 lines
3. I consider that files should contain 'things' based on their common /functionality/, not on their similar /nature/, and "going about starting up U-Boot" is a functionality.
The code here sets the stack pointer and calls a function. However I agree this unlikely to be useful outside starting up. See Q2.
Quoted 3 lines
Note that eventually, having a single
start.Swill achieve the same effect as this 'proc.S' patch.
At present start.S runs for a bit and then jumps to board_init_f(). At the end of board_init_f() we jump back to start.S (relocate_code() function) and from there to board_init_r(). Also start.S has exception handling code.
I think start.S should be thought of as in three parts:
- early CPU init (hardest to make common)
- relocation code (last 3 patches of this series)
- exception code
The first one clearly belongs in start.S. I don't think the other two do. They are not related to CPU start-up. The relocation code is only there because of the need to call a function with a new stack pointer. Other than that it can be written in C. Apart from reset the exception code isn't related to starting up the CPU - it is only there because the it is a convenient assembler file (your reasoning suggests that you would in fact want this in a new except.S file).
So maybe we want start.S, reloc.S and except.S?
Quoted 3 lines
Note also that this
start.Scommonalization should be a completely different patch set.
Are you saying you want a later series which moves all the start.S relocate_code() code from each cpu dir into a single place? If so, please see Q2.
Quoted 13 lines
Quoted 11 lines
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_MEMSETandCONFIG_USE_ARCH_MEMCPYto reduce it. For met this reduces relocation time to 5.4ms, i.e. twice as fast as the old system.
Quoted 2 lines
Side question: is there any reason not to define these CONFIG options systematically?
Code size.
Quoted 12 lines
Quoted 10 lines
One problem remains which causes mx31pdk to fail to build. It doesn't have
string.cin its SPL code and the architecture-specific versions of memset()/memcpy() are too large. I propose to add a local change toreloc.cthat uses inline code for boards that use the old legacy SPL framework. We can remove it later. This is not included in v2 but I am interested in comments on this approach. An alternative would be just to add simple memset()/memcpy() functions just for this board (and one other affected MX31 board).
Quoted 3 lines
I am not too fond of the "later removal" approach. In my experience, this invariably tends to the "old bloat in the code no one knows the reason of" situations.
Me neither. The only board affected is the tx25. We could let the maintainer fix it up, I suppose. I have no way of testing it.
Quoted 97 lines
Quoted 88 lines
Changes in v2:
- UseCONFIG_SYS_SKIP_RELOCinstead ofCONFIG_SYS_LEGACY_BOARD
- Importasm-generic/sections.hfrom Linux and add U-Boot extras
- Squash generic link symbols patch into generic relocation patch
- Movereloc.cinto common/
- Add function comments
- Use memset, memcpy instead of inline code
- Add README file for relocation
- Invalidate I-cache when we jump to relocated code
- Use an inline relocation function to reduce code size
- Make relocation symbols global so we can use them outsidestart.SChanges in v3:
- Remove the 'reloc' tag from each commit
- Rebase to masterSimon Glass (6):
? Createreloc.hand include it where needed
? defineCONFIG_SYS_SKIP_RELOCfor all archs
? Add generic relocation feature
? arm: Add processor function library
? arm: Move over to generic relocation
? arm: Remove unused code instart.S?README ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?4 + ?arch/arm/cpu/arm1136/start.S ? ? ? ? ? ? ? ? ? ? ?| ?133 ++------------ ?arch/arm/cpu/arm1176/start.S ? ? ? ? ? ? ? ? ? ? ?| ?214 ++------------------- ?arch/arm/cpu/arm720t/start.S ? ? ? ? ? ? ? ? ? ? ?| ?127 ++----------- ?arch/arm/cpu/arm920t/start.S ? ? ? ? ? ? ? ? ? ? ?| ?135 ++------------ ?arch/arm/cpu/arm925t/start.S ? ? ? ? ? ? ? ? ? ? ?| ?135 ++------------ ?arch/arm/cpu/arm926ejs/davinci/spl.c ? ? ? ? ? ? ?| ? ?1 + ?arch/arm/cpu/arm926ejs/start.S ? ? ? ? ? ? ? ? ? ?| ?144 ++------------- ?arch/arm/cpu/arm946es/start.S ? ? ? ? ? ? ? ? ? ? | ?130 ++----------- ?arch/arm/cpu/arm_intcm/start.S ? ? ? ? ? ? ? ? ? ?| ?135 ++------------ ?arch/arm/cpu/armv7/omap-common/spl.c ? ? ? ? ? ? ?| ? ?1 + ?arch/arm/cpu/armv7/start.S ? ? ? ? ? ? ? ? ? ? ? ?| ?140 ++------------ ?arch/arm/cpu/ixp/start.S ? ? ? ? ? ? ? ? ? ? ? ? ?| ?127 ++----------- ?arch/arm/cpu/lh7a40x/start.S ? ? ? ? ? ? ? ? ? ? ?| ?124 ++----------- ?arch/arm/cpu/pxa/start.S ? ? ? ? ? ? ? ? ? ? ? ? ?| ?138 ++------------ ?arch/arm/cpu/s3c44b0/start.S ? ? ? ? ? ? ? ? ? ? ?| ?127 ++----------- ?arch/arm/cpu/sa1100/start.S ? ? ? ? ? ? ? ? ? ? ? | ?124 ++----------- ?arch/arm/include/asm/reloc.h ? ? ? ? ? ? ? ? ? ? ?| ? 56 ++++++ ?arch/arm/lib/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?2 + ?arch/arm/lib/board.c ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?arch/arm/lib/proc.S ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? 40 ++++ ?arch/avr32/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 + ?arch/avr32/lib/board.c ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?arch/blackfin/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?3 + ?arch/m68k/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?3 + ?arch/m68k/lib/board.c ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?1 + ?arch/microblaze/config.mk ? ? ? ? ? ? ? ? ? ? ? ? | ? ?3 + ?arch/mips/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?3 + ?arch/mips/lib/board.c ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?1 + ?arch/nds32/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 + ?arch/nds32/lib/board.c ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?arch/nios2/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 + ?arch/powerpc/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 + ?arch/powerpc/lib/board.c ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?arch/sandbox/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 + ?arch/sh/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?3 + ?arch/sparc/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 + ?arch/x86/config.mk ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 + ?arch/x86/lib/board.c ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?board/freescale/mpc8313erdb/mpc8313erdb.c ? ? ? ? | ? ?1 + ?board/freescale/mpc8315erdb/mpc8315erdb.c ? ? ? ? | ? ?1 + ?board/samsung/smdk6400/smdk6400_nand_spl.c ? ? ? ?| ? ?1 + ?board/sheldon/simpc8313/simpc8313.c ? ? ? ? ? ? ? | ? ?1 + ?common/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?4 + ?common/reloc.c ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ?121 ++++++++++++ ?doc/README.relocation ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? 87 +++++++++ ?include/asm-generic/sections.h ? ? ? ? ? ? ? ? ? ?| ? 92 +++++++++ ?include/common.h ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?2 +- ?include/reloc.h ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | ? 54 +++++ ?nand_spl/board/freescale/mpc8536ds/nand_boot.c ? ?| ? ?1 + ?nand_spl/board/freescale/mpc8569mds/nand_boot.c ? | ? ?1 + ?nand_spl/board/freescale/mpc8572ds/nand_boot.c ? ?| ? ?1 + ?nand_spl/board/freescale/mx31pdk/Makefile ? ? ? ? | ? ?8 +- ?nand_spl/board/freescale/mx31pdk/u-boot.lds ? ? ? | ? ?1 + ?nand_spl/board/freescale/p1010rdb/nand_boot.c ? ? | ? ?1 + ?nand_spl/board/freescale/p1023rds/nand_boot.c ? ? | ? ?1 + ?nand_spl/board/freescale/p1_p2_rdb/nand_boot.c ? ?| ? ?1 + ?nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c | ? ?1 + ?nand_spl/board/karo/tx25/Makefile ? ? ? ? ? ? ? ? | ? ?8 +- ?nand_spl/board/karo/tx25/u-boot.lds ? ? ? ? ? ? ? | ? ?1 + ?nand_spl/nand_boot_fsl_nfc.c ? ? ? ? ? ? ? ? ? ? ?| ? ?1 +Quoted 7 lines
?61 files changed, 705 insertions(+), 1765 deletions(-) ?create mode 100644
arch/arm/include/asm/reloc.h?create mode 100644arch/arm/lib/proc.S?create mode 100644common/reloc.c
?create mode 100644 doc/README.relocation ?create mode 100644include/asm-generic/sections.h?create mode 100644include/reloc.h
Quoted 3 lines
Amicalement,
--
Albert.
Regards,
Simon
v3 cover Introduce generic relocation feature
Hi Simon,
Le 18/01/2012 20:31, Simon Glass a ?crit :
Quoted 9 lines
[+TI maintainers, tx25 board maintainer]
Hi Albert,
Quoted 5 lines
Quoted 5 lines
For ARM, a new
arch/arm/lib/proc.Sfile 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.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
It may be useful for other architectures with a lot of different CPUs to have a similar file.
NAK for several reasons:
I think you are NAKing the 'arm: Add processor function library' patch out of the series:
Yes. Wasn't that clear?
Quoted 9 lines
Create
reloc.hand include it where needed
defineCONFIG_SYS_SKIP_RELOCfor all archs
Add generic relocation feature
arm: Add processor function library
arm: Move over to generic relocation
arm: Remove unused code instart.SQ1: Should I remove that patch and just repeat the code from there in each
start.Sfile?
You should keep the code that jumps to board_init_r as it is.
Quoted 3 lines
The impact would be to remove most of the code in
therelocate_code()function in eachstart.Sexcept for the last few instructions (reproduced below).
Yes.
Quoted 10 lines
Quoted 5 lines
1. The code that goes on
proc.Sis already instart.S, which already contains "things which cannot be written in C and are common functions used by all ARM CPUs". Granted, right nowstart.Sis duplicated in multiple CPU directories; so the thing to do is to merge all ARMstart.Sfiles into a single one, rather than merging only one of its parts.Q2: What should this merged file be called and what directory should it be in? This is the question I asked last time, and the lack of an answer is the reason why I have been unable to make progress here. Please advise your preference and I will sort it out.
Sorry if I missed this question. Obviously the file will be called start.S exactly like all its merge ancestors, and it should reside in arch/arm/cpu.
Note that I already said the merging of start.S should *not* be part of this patch set, and should be a patch set of its own.
Quoted 4 lines
Note I don't think I can do this in one series - there is far too much variation between the files for me to take on that way. I need a new file than I can bit I bit move things over into, allowing affected parties to comment on each as I go.
Note that I do not require that *you* do such a merge either, though help is always welcome of course.
Quoted 18 lines
Quoted 3 lines
2. There is no interest in moving this segment of code from all
start.Sfiles into a newproc.Sfile: there is no gain is code size obviously, and there is an increase in source file count.Just checking that you see that the code is removed from
start.S, not moved. The code inproc.Sis:.globl
proc_call_board_init_rproc_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
Quoted 2 lines
which is taken from the end of each
relocate_code()copy. Assuming we are on the page, then ok.
We are -- the code removed from start.S is relocation, which I quite agree with since you replace it with the C relocation code.
Quoted 6 lines
Quoted 3 lines
3. I consider that files should contain 'things' based on their common /functionality/, not on their similar /nature/, and "going about starting up U-Boot" is a functionality.
The code here sets the stack pointer and calls a function. However I agree this unlikely to be useful outside starting up. See Q2.
Ditto.
Quoted 8 lines
Quoted 2 lines
Note that eventually, having a single
start.Swill achieve the same effect as this 'proc.S' patch.At present
start.Sruns for a bit and then jumps toboard_init_f(). At the end ofboard_init_f()we jump back tostart.S(relocate_code()function) and from there toboard_init_r(). Alsostart.Shas exception handling code.
Quoted 7 lines
I think
start.Sshould be thought of as in three parts:
- early CPU init (hardest to make common)
- relocation code (last 3 patches of this series)
- exception codeThe first one clearly belongs in
start.S. I don't think the other two do. They are not related to CPU start-up
Exception code is indeed related to startup code in that they are vectored through the same ARM-defined exception vectors table.
Quoted 2 lines
The relocation code is only
there because of the need to call a function with a new stack pointer.
No -- the relocation code is there *and* we need a switch of stack pointer, but relocation and stack switching are functionally unrelated.
Quoted 4 lines
Other than that it can be written in C. Apart from reset the exception code isn't related to starting up the CPU - it is only there because the it is a convenient assembler file (your reasoning suggests that you would in fact want this in a new
except.Sfile).
I disagree.
Quoted 1 line
So maybe we want
start.S,reloc.Sandexcept.S?
No. I just agree that relocation can and should go out of start.S. The rest -- exception vectors table, startup until board_init_f(), pivot to board_init_r() and exception handlers -- stays in start.S
Quoted 6 lines
Quoted 2 lines
Note also that this
start.Scommonalization should be a completely different patch set.Are you saying you want a later series which moves all the
start.Srelocate_code()code from each cpu dir into a single place? If so, please see Q2.
I would like such a patch series, but I don't ask anyone for it. If I have time I might submit it myself.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
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_MEMSETandCONFIG_USE_ARCH_MEMCPYto reduce it. For met this reduces relocation time to 5.4ms, i.e. twice as fast as the old system.
Quoted 4 lines
Quoted 2 lines
Side question: is there any reason not to define these CONFIG options systematically?
Code size.
What is the code size increase of using arch-specific mem ops?
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
One problem remains which causes mx31pdk to fail to build. It doesn't have
string.cin its SPL code and the architecture-specific versions of memset()/memcpy() are too large. I propose to add a local change toreloc.cthat uses inline code for boards that use the old legacy SPL framework. We can remove it later. This is not included in v2 but I am interested in comments on this approach. An alternative would be just to add simple memset()/memcpy() functions just for this board (and one other affected MX31 board).
Quoted 6 lines
Quoted 3 lines
I am not too fond of the "later removal" approach. In my experience, this invariably tends to the "old bloat in the code no one knows the reason of" situations.
Me neither. The only board affected is the tx25. We could let the maintainer fix it up, I suppose. I have no way of testing it.
John: ping?
Quoted 2 lines
Regards,
Simon
Amicalement,
Signature · 1 line
Albert.
v3 cover Introduce generic relocation feature
Hi Albert,
Quoted 19 lines · Albert ARIBAUD
Hi Simon,
Le 18/01/2012 20:31, Simon Glass a ?crit :
Quoted 15 lines
[+TI maintainers, tx25 board maintainer]
Hi Albert,
Quoted 10 lines
Quoted 8 lines
For ARM, a new
arch/arm/lib/proc.Sfile 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.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
NAK for several reasons:
I think you are NAKing the 'arm: Add processor function library' patch out of the series:
Yes. Wasn't that clear?
It would be better if you NAKed the specific patch, but anyway, I understood what you meant.
Quoted 8 lines
Quoted 8 lines
Create
reloc.hand include it where needed
defineCONFIG_SYS_SKIP_RELOCfor all archs
Add generic relocation feature
arm: Add processor function library
arm: Move over to generic relocation
arm: Remove unused code instart.S
Quoted 5 lines
Quoted 2 lines
Q1: Should I remove that patch and just repeat the code from there in each
start.Sfile?You should keep the code that jumps to
board_init_ras it is.
I have had a look at this and I don't believe that I can. I need to call it from C and so it needs to conform to the C calling standard. I will send a new series showing what I mean.
Quoted 25 lines
Quoted 5 lines
The impact would be to remove most of the code in
therelocate_code()function in eachstart.Sexcept for the last few instructions (reproduced below).Yes.
Quoted 9 lines
Quoted 7 lines
1. The code that goes on
proc.Sis already instart.S, which already contains "things which cannot be written in C and are common functions used
by all ARM CPUs". Granted, right nowstart.Sis duplicated in multiple CPU
directories; so the thing to do is to merge all ARMstart.Sfiles into a single one, rather than merging only one of its parts.Quoted 4 lines
Q2: What should this merged file be called and what directory should it be in? This is the question I asked last time, and the lack of an answer is the reason why I have been unable to make progress here. Please advise your preference and I will sort it out.
Quoted 5 lines
Sorry if I missed this question. Obviously the file will be called
start.Sexactly like all its merge ancestors, and it should reside inarch/arm/cpu.Note that I already said the merging of
start.Sshould *not* be part of this patch set, and should be a patch set of its own.
Yes I don't propose to do this now. I believe that the first 100 instructions may well need to have differences between the CPUs. I believe we need a common file but that each CPU will need the ability to override this, using the common file as needed.
Are you saying that you want a start.S in arch/arm/cpu and each arch/arch/cpu/*/ ? I would prefer there was only one file named start.S.
Quoted 11 lines
Quoted 6 lines
Note I don't think I can do this in one series - there is far too much variation between the files for me to take on that way. I need a new file than I can bit I bit move things over into, allowing affected parties to comment on each as I go.
Note that I do not require that *you* do such a merge either, though help is always welcome of course.
I am happy to take these sorts of things on over time, but really I want to get the existing efforts in first.
Quoted 65 lines
Quoted 21 lines
Quoted 5 lines
2. There is no interest in moving this segment of code from all
start.Sfiles into a newproc.Sfile: there is no gain is code size obviously, and
there is an increase in source file count.Just checking that you see that the code is removed from
start.S, not moved. The code inproc.Sis:.globl
proc_call_board_init_rproc_call_board_init_r:
#ifndefCONFIG_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, r2Quoted 2 lines
which is taken from the end of each
relocate_code()copy. Assuming we are on the page, then ok.We are -- the code removed from
start.Sis relocation, which I quite agree with since you replace it with the C relocation code.Quoted 8 lines
Quoted 4 lines
3. I consider that files should contain 'things' based on their common /functionality/, not on their similar /nature/, and "going about starting up
U-Boot" is a functionality.The code here sets the stack pointer and calls a function. However I agree this unlikely to be useful outside starting up. See Q2.
Ditto.
Quoted 10 lines
Quoted 3 lines
Note that eventually, having a single
start.Swill achieve the same effect
as this 'proc.S' patch.At present
start.Sruns for a bit and then jumps toboard_init_f(). At the end ofboard_init_f()we jump back tostart.S(relocate_code()function) and from there toboard_init_r(). Alsostart.Shas exception handling code.Quoted 7 lines
I think
start.Sshould be thought of as in three parts:
- early CPU init (hardest to make common)
- relocation code (last 3 patches of this series)
- exception codeThe first one clearly belongs in
start.S. I don't think the other two do. They are not related to CPU start-upException code is indeed related to startup code in that they are vectored through the same ARM-defined exception vectors table.
Quoted 6 lines
Quoted 2 lines
?The relocation code is only
?there because of the need to call a function with a new stack pointer.No -- the relocation code is there *and* we need a switch of stack pointer, but relocation and stack switching are functionally unrelated.
Yes, and I would love to change the function signature of board_init_r() to remove the parameters, and add a generic 'change sp and jump' function to each architecture. Not planning to do so though. For now, this code needs to be specific to this task - only able to call board_init_r() with the parameters it needs and in the right order.
Quoted 11 lines
Quoted 6 lines
Other than that it can be written in C. Apart from reset the exception code isn't related to starting up the CPU - it is only there because the it is a convenient assembler file (your reasoning suggests that you would in fact want this in a new
except.Sfile).I disagree.
Quoted 6 lines
Quoted 1 line
So maybe we want
start.S,reloc.Sandexcept.S?No. I just agree that relocation can and should go out of
start.S. The rest -- exception vectors table, startup untilboard_init_f(), pivot toboard_init_r()and exception handlers -- stays instart.S
We can't agree on everything...anyway that discussion is not relevant to this series at present.
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Note also that this
start.Scommonalization should be a completely different
patch set.
Quoted 7 lines
Quoted 3 lines
Are you saying you want a later series which moves all the
start.Srelocate_code()code from each cpu dir into a single place? If so, please see Q2.I would like such a patch series, but I don't ask anyone for it. If I have time I might submit it myself.
OK and I hope that file is not arch/arm/cpu/start.S which would introduce confusion I think.
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 13 lines
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 defineCONFIG_USE_ARCH_MEMSETandCONFIG_USE_ARCH_MEMCPYto reduce it. For met this reduces relocation time
to 5.4ms, i.e. twice as fast as the old system.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Side question: is there any reason not to define these CONFIG options systematically?
Code size.
What is the code size increase of using arch-specific mem ops?
About 800 bytes for me:
text data bss dec hex filename 177653 3932 218240 399825 619d1 u-boot 178429 3932 218240 400601 61cd9 u-boot
Quoted 18 lines
Quoted 18 lines
Quoted 16 lines
Quoted 10 lines
One problem remains which causes mx31pdk to fail to build. It doesn't have
string.cin its SPL code and the architecture-specific versions of memset()/memcpy() are too large. I propose to add a local change toreloc.cthat uses inline code for boards that use the old legacy SPL framework. We can remove it later. This is not included in v2 but I am interested in comments on this approach. An alternative would be just to add simple memset()/memcpy() functions just for this board (and one other affected MX31 board).I am not too fond of the "later removal" approach. In my experience, this invariably tends to the "old bloat in the code no one knows the reason of"
situations.
Quoted 5 lines
Quoted 2 lines
Me neither. The only board affected is the tx25. We could let the maintainer fix it up, I suppose. I have no way of testing it.
John: ping?
Since I didn't hear anything I have elected to patch this up a different way - basically splitting out memcpy() and memset() from string.c. See what you think of the new series. It introduces no breakages now, at least.
Quoted 4 lines
Amicalement,
--
Albert.
Regards,
Simon
v3 cover Introduce generic relocation feature
Hi Simon,
Le 20/02/2012 23:38, Simon Glass a ?crit :
Quoted 5 lines
Quoted 1 line
You should keep the code that jumps to
board_init_ras it is.I have had a look at this and I don't believe that I can. I need to call it from C and so it needs to conform to the C calling standard. I will send a new series showing what I mean.
No need to call it from C. The most correct flow should be that the start.S code would call board_init_f, relocate_code() and board_init_r, so that no C code should call assembly language code, and setting the C environment or modifying it would only happen outside of C code.
Quoted 6 lines
Are you saying that you want a
start.Sinarch/arm/cpuand eacharch/arch/cpu/*/? I would prefer there was only one file namedstart.S.OK and I hope that file is not
arch/arm/cpu/start.Swhich would introduce confusion I think.
I don't want multiple homonym files either. I want a start.S file responsible for the generic ARM startup and another asm or include file responsible for the ARM-architecture specifics (i.e. ARM1176, ARM926EJS etc) if required. The name of that second file I'll think over, but it won't be start.S
Quoted 7 lines
Quoted 1 line
What is the code size increase of using arch-specific mem ops?
About 800 bytes for me:
text data bss dec hex filename 177653 3932 218240 399825 619d1 u-boot 178429 3932 218240 400601 61cd9 u-boot
Thanks.
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 10 lines
Quoted 8 lines
One problem remains which causes mx31pdk to fail to build. It doesn't have
string.cin its SPL code and the architecture-specific versions of memset()/memcpy() are too large. I propose to add a local change toreloc.cthat uses inline code for boards that use the old legacy SPL framework. We can remove it later. This is not included in v2 but I am interested in comments on this approach. An alternative would be just to add simple memset()/memcpy() functions just for this board (and one other affected MX31 board).Quoted 4 lines
I am not too fond of the "later removal" approach. In my experience, this invariably tends to the "old bloat in the code no one knows the reason of"
situations.Me neither. The only board affected is the tx25. We could let the maintainer fix it up, I suppose. I have no way of testing it.
Quoted 6 lines
Quoted 1 line
John: ping?
Since I didn't hear anything I have elected to patch this up a different way - basically splitting out
memcpy()andmemset()fromstring.c. See what you think of the new series. It introduces no breakages now, at least.
I'll look this up today.
Quoted 2 lines
Regards,
Simon
Amicalement,
Signature · 1 line
Albert.
v3 cover Introduce generic relocation feature
Hi Albert,
Quoted 13 lines · Albert ARIBAUD
Hi Simon,
Le 20/02/2012 23:38, Simon Glass a ?crit :
Quoted 6 lines
Quoted 1 line
You should keep the code that jumps to
board_init_ras it is.I have had a look at this and I don't believe that I can. I need to call it from C and so it needs to conform to the C calling standard. I will send a new series showing what I mean.
Quoted 4 lines
No need to call it from C. The most correct flow should be that the
start.Scode would callboard_init_f,relocate_code()andboard_init_r, so that no C code should call assembly language code, and setting the C environment or modifying it would only happen outside of C code.
(sorry what follows is pretty hard to follow, but I think it is correct, and shows how I got to where I am with this)
That has a certain elegance about it, but it means that I need to access global_data structure members from assembly. I need relocaddr, start_addr_sp and the new gd pointer. These are all calculated in board_init_f() and passed to relocate_code() as parameters at present. I know it is possible to access global data from assembly using the offsets header or similar, but I think we currently avoiding this on ARM at present, to my delight.
It also means that board_init_f() would need to return, which puts ARM at odds with every other architecture (it will have to have its own prototype for board_init_f()). Even sandbox uses this no-return prototype.
So to recap the reason for my change to the code that calls board_init_r() is that relocate_code() used to be an assembly routine. It did the relocation and then called board_init_r() in the new location with the new stack.
Now relocate_code() is entirely written in C, but we still need to call board_init_r() with a new stack when relocation is done. So the grubby stack change stuff is no longer at the end of relocate_code() but in the new pivot_to_board_init_r(), although still in start.S. It's actually quite a minor change.
Part of the reason for this change is that there is no need for relocate_code() to be written in assembly (in any architecture I think). The pivot stack thing is all that remains.
Quoted 11 lines
Quoted 9 lines
Are you saying that you want a
start.Sinarch/arm/cpuand eacharch/arch/cpu/*/? I would prefer there was only one file namedstart.S.OK and I hope that file is not
arch/arm/cpu/start.Swhich would introduce confusion I think.
Quoted 5 lines
I don't want multiple homonym files either. I want a
start.Sfile responsible for the generic ARM startup and another asm or include file responsible for the ARM-architecture specifics (i.e. ARM1176, ARM926EJS etc) if required. The name of that second file I'll think over, but it won't bestart.S
That was the idea behind my original proc.S, but it's not exactly an inspiring name.
Quoted 42 lines
Quoted 10 lines
Quoted 3 lines
What is the code size increase of using arch-specific mem ops?
About 800 bytes for me:
? ?text ? ? ? ? ? data ? ? bss ? ? dec ? ? hex filename ?177653 ? ? ? ? ? 3932 ?218240 ?399825 ? 619d1 u-boot ?178429 ? ? ? ? ? 3932 ?218240 ?400601 ? 61cd9 u-boot
Thanks.
Quoted 27 lines
Quoted 25 lines
Quoted 20 lines
Quoted 12 lines
Quoted 9 lines
One problem remains which causes mx31pdk to fail to build. It doesn't have
string.cin its SPL code and the architecture-specific versions of
memset()/memcpy() are too large. I propose to add a local change toreloc.cthat uses inline code for boards that use the old legacy SPL framework. We can remove it later. This is not included in v2 but I am interested in comments on this approach. An alternative would be just to add simple memset()/memcpy() functions just for this board (and one other affected MX31 board).Quoted 5 lines
I am not too fond of the "later removal" approach. In my experience, this
invariably tends to the "old bloat in the code no one knows the reason of"
situations.Quoted 2 lines
Me neither. The only board affected is the tx25. We could let the maintainer fix it up, I suppose. I have no way of testing it.
John: ping?
Quoted 8 lines
Quoted 4 lines
Since I didn't hear anything I have elected to patch this up a different way - basically splitting out
memcpy()andmemset()fromstring.c. See what you think of the new series. It introduces no breakages now, at least.I'll look this up today.
Thanks.
Quoted 8 lines
Quoted 3 lines
Regards,
SimonAmicalement,
--
Albert.
Regards,
Simon