
(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