reboard: Introduce generic relocation feature
Subsystems (10)
v2 cover reboard: Introduce generic relocation feature
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
Simon Glass (6):
reboard: Create reloc.h and include it where needed
reboard: define CONFIG_SYS_SKIP_RELOC for all archs
reboard: Add generic relocation feature
reboard: arm: Add processor function library
reboard: arm: Move over to generic relocation
reboard: 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 | 141 ++------------ 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(+), 1766 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 v2 1/6 reboard: 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
@@ -470,7 +470,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 v2 1/6 reboard: Create reloc.h and include it where needed
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 30 lines
Before adding new relocation functions, move this prototype out of
common.hwhere things are pretty crowded.Signed-off-by Simon Glass<[email protected]>---
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(-)
Quoted 1 line
create mode 100644
include/reloc.h
Since this patch set indicates that ARM, and only ARM, is moved over to relocation, I would prefer it that no other arch file be modified in this patch, and that the move of ARM to the new relocation mechanism be done in an atomic commit, so that other architectures can refer to a single commit in order to do their own move.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/6 reboard: Create reloc.h and include it where needed
Hi Albert,
Quoted 36 lines · Albert ARIBAUD
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 30 lines
Before adding new relocation functions, move this prototype out of
common.hwhere things are pretty crowded.Signed-off-by Simon Glass<[email protected]>---
?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 +Quoted 2 lines
?23 files changed, 61 insertions(+), 1 deletions(-) ?create mode 100644
include/reloc.h
Quoted 5 lines
Since this patch set indicates that ARM, and only ARM, is moved over to relocation, I would prefer it that no other arch file be modified in this patch, and that the move of ARM to the new relocation mechanism be done in an atomic commit, so that other architectures can refer to a single commit in order to do their own move.
What specifically are you asking for in this patch? I added this at the request of a reviewer of v1, who felt that we should be removing code from common.h instead of adding it, and that relocation is done in only a few sites so should not be in common.h. Do you think this patch should be pulled out of the series and done on its own?
Quoted 4 lines
Amicalement,
--
Albert.
Regards,
Simon
PATCH v2 1/6 reboard: Create reloc.h and include it where needed
Hi Simon,
Le 11/12/2011 22:33, Simon Glass a ?crit :
Quoted 46 lines
Hi Albert,
Quoted 36 lines · Albert ARIBAUD
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 31 lines
Before adding new relocation functions, move this prototype out of
common.hwhere things are pretty crowded.Signed-off-by Simon Glass<[email protected]>---
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(-)Quoted 1 line
create mode 100644
include/reloc.hQuoted 5 lines
Since this patch set indicates that ARM, and only ARM, is moved over to relocation, I would prefer it that no other arch file be modified in this patch, and that the move of ARM to the new relocation mechanism be done in an atomic commit, so that other architectures can refer to a single commit in order to do their own move.
Quoted 5 lines
What specifically are you asking for in this patch? I added this at the request of a reviewer of v1, who felt that we should be removing code from
common.hinstead of adding it, and that relocation is done in only a few sites so should not be incommon.h. Do you think this patch should be pulled out of the series and done on its own?
What I am asking for, since your whole patch series only applies the 'new' relocation to ARM, is that this patch should not change anything to any arch other than ARM. Any other arch should only be touched by a later patch, whoever submits it, that will specifically aim to switch that arch to the 'new' relocation.
Quoted 2 lines
Regards,
Simon
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/6 reboard: Create reloc.h and include it where needed
In reply to Simon GlassHi Simon,
Quoted 46 lines · Simon Glass
Hi Albert,
Quoted 36 lines · Albert ARIBAUD
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 30 lines
Before adding new relocation functions, move this prototype out of
common.hwhere things are pretty crowded.Signed-off-by Simon Glass<[email protected]>---
?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 +Quoted 2 lines
?23 files changed, 61 insertions(+), 1 deletions(-) ?create mode 100644
include/reloc.hQuoted 5 lines
Since this patch set indicates that ARM, and only ARM, is moved over to relocation, I would prefer it that no other arch file be modified in this patch, and that the move of ARM to the new relocation mechanism be done in an atomic commit, so that other architectures can refer to a single commit in order to do their own move.
Quoted 5 lines
What specifically are you asking for in this patch? I added this at the request of a reviewer of v1, who felt that we should be removing code from
common.hinstead of adding it, and that relocation is done in only a few sites so should not be incommon.h. Do you think this patch should be pulled out of the series and done on its own?
I think the point is that when we pull stuff out of common.h into, say, foo.h then only include foo.h where the functionality moved into foo.h is _currently_ used.
It looks like you've pulled out the functions definitions into reloc.h then included reloc.h everywhere (including common.h). Better would be to moved the definitions to reloc.h, do not include reloc.h in common.h and include reloc.h only where it is strictly needed right now - Add #include <reloc.h> to each arch file as and when it is needed
Regards,
Graeme
PATCH v2 1/6 reboard: Create reloc.h and include it where needed
Hi Gream,
Le 11/12/2011 22:45, Graeme Russ a ?crit :
Quoted 10 lines
I think the point is that when we pull stuff out of
common.hinto, say,foo.hthen only includefoo.hwhere the functionality moved intofoo.his _currently_ used.It looks like you've pulled out the functions definitions into
reloc.hthen includedreloc.heverywhere (includingcommon.h). Better would be to moved the definitions toreloc.h, do not includereloc.hincommon.hand includereloc.honly where it is strictly needed right now - Add #include<reloc.h> to each arch file as and when it is needed
Thanks Greame. This is indeed what I meant.
Quoted 3 lines
Regards,
Graeme
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/6 reboard: Create reloc.h and include it where needed
Le 11/12/2011 23:29, Albert ARIBAUD a ?crit :
Quoted 1 line
Hi Gream,
Argh. s/Gream/Greame/, with my apologies.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/6 reboard: Create reloc.h and include it where needed
In reply to Albert ARIBAUDHi,
Quoted 17 lines · Albert ARIBAUD
Hi Gream,
Le 11/12/2011 22:45, Graeme Russ a ?crit :
Quoted 10 lines
I think the point is that when we pull stuff out of
common.hinto, say,foo.hthen only includefoo.hwhere the functionality moved intofoo.his _currently_ used.It looks like you've pulled out the functions definitions into
reloc.hthen includedreloc.heverywhere (includingcommon.h). Better would be to moved the definitions toreloc.h, do not includereloc.hincommon.hand includereloc.honly where it is strictly needed right now - Add #include<reloc.h> ?to each arch file as and when it is needed
Quoted 1 line
Thanks Greame. This is indeed what I meant.
OK I understand, and that was my intention with this patch. Other than the mistake of leaving the #include in common.h where it is not now needed, is this patch correct?
Regards,
Simon
Quoted 9 lines
Quoted 4 lines
Regards,
Graeme
Amicalement,
--
Albert.
PATCH v2 2/6 reboard: 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
@@ -2707,6 +2707,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
@@ -18,3 +18,6 @@ # MA 02111-1307 USA PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ + +# 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 v2 2/6 reboard: define CONFIG_SYS_SKIP_RELOC for all archs
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 8 lines
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_RELOCis more appropriate thanCONFIG_SYS_LEGACY_BOARD.
I'm afraid I haven't made myself clear on CONFIG_SYS_SKIP_RELOC. I did not mean it to be an 'old vs new reloc' choice mechanism; I mean it to be the controlling option for whether relocation happens at all or not.
I want a relocation skip option, because it is useful for boards which, for any reason, know that they are already residing at the Right Address(tm).
As far as an option to switch from old to new relocation... If there is a consensus from all custodians that all arches should move to generic relocation, then I think we should avoid allowing the older mechanism to persist at all.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 2/6 reboard: define CONFIG_SYS_SKIP_RELOC for all archs
Hi Albert,
Quoted 16 lines · Albert ARIBAUD
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 8 lines
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_RELOCis more appropriate thanCONFIG_SYS_LEGACY_BOARD.I'm afraid I haven't made myself clear on
CONFIG_SYS_SKIP_RELOC. I did not mean it to be an 'old vs new reloc' choice mechanism; I mean it to be the controlling option for whether relocation happens at all or not.
Quoted 7 lines
I want a relocation skip option, because it is useful for boards which, for any reason, know that they are already residing at the Right Address(tm).
As far as an option to switch from old to new relocation... If there is a consensus from all custodians that all arches should move to generic relocation, then I think we should avoid allowing the older mechanism to persist at all.
OK I see. That is a different thing to this patch. So what should I call CONFIG_SYS_SKIP_RELOC? Should it be renamed to CONFIG_SYS_LEGACY_RELOC?
With what you are looking for, there was a patch on the list some time ago which disables relocation under CONFIG control. From memory it received a cool reception. IMO there is value in it, but this again is a separate patch. There are three parts to relocate_code():
- copy the code
- relocate the code
- zero the BSS
While the first two can be skipped if the code doesn't need to move, the last must always be done.
Regards,
Simon
Quoted 4 lines
Amicalement,
--
Albert.
Regards,
Simon
PATCH v2 3/6 reboard: 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
@@ -192,6 +192,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 v2 4/6 reboard: 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 v2 4/6 reboard: arm: Add processor function library
Hi Simon,
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 3 lines
Add 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.Scode here.
I still don't see the point in this new file, as this code is common across all ARM boards and start.S already has much of such common code. I'd rather see start.S keeping the common code and moving up the hierarchy, and and the {ISA, core, SoC, board} specific code be moved out of start.S and down into their 'natural' specific location.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 4/6 reboard: arm: Add processor function library
Hi Albert,
Quoted 9 lines · Albert ARIBAUD
Hi Simon,
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 3 lines
Add 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.Scode here.
Quoted 5 lines
I still don't see the point in this new file, as this code is common across all ARM boards and
start.Salready has much of such common code. I'd rather seestart.Skeeping the common code and moving up the hierarchy, and and the {ISA, core, SoC, board} ?specific code be moved out ofstart.Sand down into their 'natural' specific location.
If we do this then it would be a separate series focused on refactoring start.S. Are you saying that you want that series before we address this relocation series? Where specifically should we put the new start.S and what should we call it? I assume that all the little start.S files will remain or are you wanting to rename all of those into some other filename in arch/arm/cpu/... In which case what should those be called?
It is good to be really specific so that I know the destination port before embarking on a new voyage.
Regards,
Simon
Quoted 4 lines
Amicalement,
--
Albert.
PATCH v2 4/6 reboard: arm: Add processor function library
Hi Albert,
Quoted 27 lines · Simon Glass
Hi Albert,
Quoted 9 lines · Albert ARIBAUD
Hi Simon,
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 3 lines
Add 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.Scode here.Quoted 5 lines
I still don't see the point in this new file, as this code is common across all ARM boards and
start.Salready has much of such common code. I'd rather seestart.Skeeping the common code and moving up the hierarchy, and and the {ISA, core, SoC, board} ?specific code be moved out ofstart.Sand down into their 'natural' specific location.If we do this then it would be a separate series focused on refactoring
start.S. Are you saying that you want that series before we address this relocation series? Where specifically should we put the newstart.Sand what should we call it? I assume that all the littlestart.Sfiles will remain or are you wanting to rename all of those into some other filename inarch/arm/cpu/... In which case what should those be called?
Quoted 5 lines
It is good to be really specific so that I know the destination port before embarking on a new voyage.
Regards,
Simon
Thanks for your comments.
Still I am not sure what is needed here. Short of refactoring all of start.S (which is a separate and larger effort0 I am not sure what to do. My purpose with this series is to move ARM to generic relocation which is why I am removing all the repeated relocation code from each start.S.
I think we need an assembler file shared across all ARM. Since it cannot be start.S (certainly not now and perhaps not ever if the early code is too different between different ARM architectures or cannot easily be tested) then what should it be? I have proposed arch/arm/lib/proc.S.
(No I really don't want to provide 10 copies of my little board_init_r()-caller function in each start.S, I hope you are not suggesting that!)
My idea is that the various start.S files will shrink down with time as code in there becomes common (IMO the first priority after relocation would be exception handling). But it is going to break a few eggs, since there are subtle differences between the different copies, and some people will ask why we are breaking their chip, or introducing the possibility of breakage. At least with relocation we see a real performance benefit and substantial LOC reduction which helps people stay motivated.
I have the generic board series waiting but would like to get this one sorted out first. Looking forward to your clarification when you have time.
Again the main question is where to put the common ARM assembler code.
Regards,
Simon
Quoted 5 lines
Quoted 5 lines
Amicalement,
--
Albert.
PATCH v2 5/6 reboard: 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 v2 6/6 reboard: 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
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 | 141 +++----------------------- 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(+), 1763 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 -126
159 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
PATCH v2 6/6 reboard: arm: Remove unused code in start.S
Hi Simon,
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 5 lines
Now that we are using the generic relocation framework, we don't need this code.
Note: Here we lose the ARM1176's
enable_mmucode. This seems to duplicate code already in U-Boot now. Can anyone comment on this?
First thing would be for you to explain why it is removed when it is not related to relocation, I think.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 6/6 reboard: arm: Remove unused code in start.S
Hi Albert,
Quoted 7 lines · Albert ARIBAUD
Hi Simon,
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 3 lines
Now that we are using the generic relocation framework, we don't need this code.
Quoted 6 lines
Quoted 2 lines
Note: Here we lose the ARM1176's
enable_mmucode. This seems to duplicate code already in U-Boot now. Can anyone comment on this?First thing would be for you to explain why it is removed when it is not related to relocation, I think.
Well the code is unique to that cpu, with no real justification as to why only ARM1176 needs it. Also it is buried in the relocation code, which is now becoming generic, so to keep it around we would need to re-implement ic C code something that seems like a hack. Finally, we already have a way of turning on the caches and MMU in ARM now, so it seems superfluous.
Regards,
Simon
Quoted 4 lines
Amicalement,
--
Albert.
v2 cover reboard: Introduce generic relocation feature
In reply to Simon GlassHi Simon,
General comments here, detailed comments in reply to n/6 patches.
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 10 lines
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.
Actually most of start.S is very similar across all its avatars in arch/arm, and is a good candidate for being generalized. I would prefer a generalization of start.S with the vector table, generic startup sequence prepare for calling board_init_f, jump to board_init_r with a possible stack switch, exception handlers) , and anything specific moved into the adequate subdirectory.
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.
I assume this is due to some arch other than armnot using the same set of entry types, right? If so, I think it would be better to keep arch-specific entry relocation code under conditional complilation in the generic ELF relication source file, so that all ELF-structure dependent code is in a single file.
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.
Indeed, but I think start.S is a better candidate for this, see comment above.
Quoted 19 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.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 10 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
Seeing as inline will only avoid pushing a couple argument registers and doing a branch, and OTOH may require additional register shuffling in the calling code, how much code does this inlining save?
Quoted 1 line
- Make relocation symbols global so we can use them outside
start.S
Why should they relocation symbols ever be used outside of actually relocating?
Amicalement,
Signature · 1 line
Albert.
v2 cover reboard: Introduce generic relocation feature
Hi Albert,
Quoted 3 lines · Albert ARIBAUD
Hi Simon,
General comments here, detailed comments in reply to n/6 patches.
Thanks for looking at this.
Quoted 15 lines
Le 10/12/2011 20:16, Simon Glass a ?crit :
Quoted 10 lines
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
Actually most of
start.Sis very similar across all its avatars inarch/arm, and is a good candidate for being generalized. I would prefer a generalization ofstart.Swith the vector table, generic startup sequence prepare for callingboard_init_f, jump toboard_init_rwith a possible stack switch, exception handlers) , and anything specific moved into the adequate subdirectory.
Yes I agree. However this is not actually the purpose of this series, which is to head (so far as is possible) towards a generic board.c file for all architectures. While I completely agree that start.S is a mess, that is a separate problem!
Quoted 7 lines
Quoted 5 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.
Quoted 5 lines
I assume this is due to some arch other than armnot using the same set of entry types, right? If so, I think it would be better to keep arch-specific entry relocation code under conditional complilation in the generic ELF relication source file, so that all ELF-structure dependent code is in a single file.
Yes that takes things one step further. I did look at it but could not find an elf.h with defines for all the different relocations. Do you know where to find that?
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 6 lines
Quoted 2 lines
It may be useful for other architectures with a lot of different CPUs to have a similar file.
Indeed, but I think
start.Sis a better candidate for this, see comment above.
My understanding of start.S is that it is the start-up code for the machine, and that over time we would hope to reduce it to a small amount of code which is specific to that particular cpu (i.e. the shared and common code moves out).
We can do this in many small steps - certainly I don't have the appetite for changing everything around all at once.
Anyway. as I may have mentioned before, I feel that calling back into start.S from C code is wrong. That file sits at the beginning of the image whereas the code you call back to doesn't need to. It also means that there is (currently) no generic ARM assembler file (apart from low_level.S) which C code can call to do things which are specific to the architecture (but not the cpu).
Quoted 34 lines
Quoted 22 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.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 10 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
Quoted 3 lines
Seeing as inline will only avoid pushing a couple argument registers and doing a branch, and OTOH may require additional register shuffling in the calling code, how much code does this inlining save?
About 48 bytes all up from memory.
Quoted 7 lines
Quoted 3 lines
- Make relocation symbols global so we can use them outside
start.SWhy should they relocation symbols ever be used outside of actually relocating?
Well since relocation is moving out of start.S to a generic library which is not architecture-specific, we must make these symbols available to it. Otherwise the generic code doesn't know what it is relocating.
Quoted 4 lines
Amicalement,
--
Albert.
Regards,
Simon
v2 cover reboard: Introduce generic relocation feature
Hi againLe 11/12/2011 22:30, Simon Glass a ?crit :
Quoted 11 lines
Quoted 6 lines
Actually most of
start.Sis very similar across all its avatars inarch/arm, and is a good candidate for being generalized. I would prefer a generalization ofstart.Swith the vector table, generic startup sequence prepare for callingboard_init_f, jump toboard_init_rwith a possible stack switch, exception handlers) , and anything specific moved into the adequate subdirectory.Yes I agree. However this is not actually the purpose of this series, which is to head (so far as is possible) towards a generic
board.cfile for all architectures. While I completely agree thatstart.Sis a mess, that is a separate problem!
Indeed, Generalizing start.S is a separate problem from generalizing board.c; and that means your reboard patch series is unaffected whether you move some code into proc.S or not. Actually, that move to proc.S is just a code factorization, unrelated to relocation -- your series can work just as well without it, only it will keep on taking up code size that could be reduced regardless to the way relocation is done.
Now, seen from the reverse perspective of generalizing start.S, the move to proc.S in this reboard series is a step in the wrong direction, which is why I do not want it. Plus, it'll make your 'reboard' patch more focused on what it is about, i.e. generalizing relocation.
(BTW, even though I understand your greater goal about board.c, I still think the patch subjects should *not* contain this "reboard" prefix nor mention that greater goal. The patch series is about relocation, and should be clear about it.)
Quoted 10 lines
Quoted 10 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.I assume this is due to some arch other than armnot using the same set of entry types, right? If so, I think it would be better to keep arch-specific entry relocation code under conditional complilation in the generic ELF relication source file, so that all ELF-structure dependent code is in a single file.
(sorry for the typoes, BTW)
Quoted 3 lines
Yes that takes things one step further. I did look at it but could not find an
elf.hwith defines for all the different relocations. Do you know where to find that?
We don't need to find a header file with all the relocation types we will need, we only need one with the two ARM relocation types we need now. Adding them to include/elf.h.
/>>> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
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.
Indeed, but I think
start.Sis a better candidate for this, see comment above.
Quoted 7 lines
My understanding of
start.Sis that it is the start-up code for the machine, and that over time we would hope to reduce it to a small amount of code which is specific to that particular cpu (i.e. the shared and common code moves out).We can do this in many small steps - certainly I don't have the appetite for changing everything around all at once.
This view of start.S is kind of an /a priori/ -- just because the name has start.S does not mean that there should only be startup code in there. Conversively, one could argue that handling the returning from board_init_f and branching into board_init_r is *still* startup code.
But yes, maybe one day start.S will be split into a file with only the startup code and a file with everything else. Only this is totally unrelated to relocation, and thus will not happen in this patch series.
Quoted 6 lines
Anyway. as I may have mentioned before, I feel that calling back into
start.Sfrom C code is wrong. That file sits at the beginning of the image whereas the code you call back to doesn't need to. It also means that there is (currently) no generic ARM assembler file (apart fromlow_level.S) which C code can call to do things which are specific to the architecture (but not the cpu).
I fail to see the point in your argument about about start.S being "far away" from the C code that call into it or return to it. Never do we consider the "distance" between C callers and callees, so why should we do it here?
As for there being no generic ARM assembler file etc., before complaining that there isn't one, I would like to see why one should be created. For me, just having a couple pieces of code that are 'generic ARM code that C can call' is not a criterion for putting them in a new file. Files must group pieces of code that have common functional purpose, not simply pieces of code that have a common characteristic.
Quoted 5 lines
Quoted 3 lines
Seeing as inline will only avoid pushing a couple argument registers and doing a branch, and OTOH may require additional register shuffling in the calling code, how much code does this inlining save?
About 48 bytes all up from memory.
About 12 instructions? Funny, I wouldn't have thought inlining a function called only once would save that much. Thanks for the info.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
- Make relocation symbols global so we can use them outside
start.SWhy should they relocation symbols ever be used outside of actually relocating?
Well since relocation is moving out of
start.Sto a generic library which is not architecture-specific, we must make these symbols available to it. Otherwise the generic code doesn't know what it is relocating.
Understood. My point is that they should not be made available to code other than the relocation code.
Quoted 2 lines
Regards,
Simon
Amicalement,
Signature · 1 line
Albert.
v2 cover reboard: Introduce generic relocation feature
Hi Albert,
Quoted 20 lines · Albert ARIBAUD
Hi againLe 11/12/2011 22:30, Simon Glass a ?crit :
Quoted 11 lines
Quoted 9 lines
Actually most of
start.Sis very similar across all its avatars inarch/arm,
and is a good candidate for being generalized. I would prefer a generalization ofstart.Swith the vector table, generic startup sequence prepare for callingboard_init_f, jump toboard_init_rwith a possible stack
switch, exception handlers) , and anything specific moved into the adequate
subdirectory.Quoted 4 lines
Yes I agree. However this is not actually the purpose of this series, which is to head (so far as is possible) towards a generic
board.cfile for all architectures. While I completely agree thatstart.Sis a mess, that is a separate problem!
Quoted 6 lines
Indeed, Generalizing
start.Sis a separate problem from generalizingboard.c; and that means your reboard patch series is unaffected whether you move some code intoproc.Sor not. Actually, that move toproc.Sis just a code factorization, unrelated to relocation -- your series can work just as well without it, only it will keep on taking up code size that could be reduced regardless to the way relocation is done.
OK but sorry I am still a bit unclear.
Since I need to call from C the assembler function which sets up the stack, invalidates the I-cache and jumps to board_init_r(), I need this function to be somewhere. Perhaps in the future we might devise a way of doing some of this in C code, or we might change the API. But for now we need it.
Given that we need it, it makes little sense to me to put it in start.S. It then gets repeated 10 times throughout the code, with every cpu having its own version.
Quoted 5 lines
Now, seen from the reverse perspective of generalizing
start.S, the move toproc.Sin this reboard series is a step in the wrong direction, which is why I do not want it. Plus, it'll make your 'reboard' patch more focused on what it is about, i.e. generalizing relocation.
OK, so where should this code go? Repeated 10 times in start.S? Or are you asking for a new start.S file in arch/arm/lib/ ? If so, I would want to call it something else since link scripts may assume there is only one start.o.
Quoted 5 lines
(BTW, even though I understand your greater goal about
board.c, I still think the patch subjects should *not* contain this "reboard" prefix nor mention that greater goal. The patch series is about relocation, and should be clear about it.)
OK. Should is use something like 'reloc', or just drop the prefix altogether?
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 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.Quoted 6 lines
Quoted 6 lines
I assume this is due to some arch other than armnot using the same set of entry types, right? If so, I think it would be better to keep arch-specific
entry relocation code under conditional complilation in the generic ELF relication source file, so that all ELF-structure dependent code is in a single file.
Quoted 1 line
(sorry for the typoes, BTW)
And sorry for mine :-)
Quoted 10 lines
Quoted 5 lines
Yes that takes things one step further. I did look at it but could not find an
elf.hwith defines for all the different relocations. Do you know where to find that?We don't need to find a header file with all the relocation types we will need, we only need one with the two ARM relocation types we need now. Adding them to
include/elf.h.
OK, will do.
Quoted 26 lines
/>>> For ARM, a new
arch/arm/lib/proc.Sfile is created, which holds genericQuoted 14 lines
Quoted 5 lines
Quoted 5 lines
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 2 lines
It may be useful for other architectures with a lot of different CPUs to have a similar file.
Indeed, but I think
start.Sis a better candidate for this, see comment above.Quoted 7 lines
My understanding of
start.Sis that it is the start-up code for the machine, and that over time we would hope to reduce it to a small amount of code which is specific to that particular cpu (i.e. the shared and common code moves out).We can do this in many small steps - certainly I don't have the appetite for changing everything around all at once.
Quoted 8 lines
This view of
start.Sis kind of an /a priori/ -- just because the name hasstart.Sdoes not mean that there should only be startup code in there. Conversively, one could argue that handling the returning fromboard_init_fand branching intoboard_init_ris *still* startup code.But yes, maybe one day
start.Swill be split into a file with only the startup code and a file with everything else. Only this is totally unrelated to relocation, and thus will not happen in this patch series.
OK, will await your response on where this goes.
Quoted 10 lines
Quoted 8 lines
Anyway. as I may have mentioned before, I feel that calling back into
start.Sfrom C code is wrong. That file sits at the beginning of the image whereas the code you call back to doesn't need to. It also means that there is (currently) no generic ARM assembler file (apart fromlow_level.S) which C code can call to do things which are specific to the architecture (but not the cpu).
Quoted 4 lines
I fail to see the point in your argument about about
start.Sbeing "far away" from the C code that call into it or return to it. Never do we consider the "distance" between C callers and callees, so why should we do it here?
Well let's leave that one as it is a matter of taste. For the moment we have a start.S for each cpu so my objection would be repeating this code in each one. See above.
Quoted 7 lines
As for there being no generic ARM assembler file etc., before complaining that there isn't one, I would like to see why one should be created. For me, just having a couple pieces of code that are 'generic ARM code that C can call' is not a criterion for putting them in a new file. Files must group pieces of code that have common functional purpose, not simply pieces of code that have a common characteristic.
OK, will await your response.
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines
Seeing as inline will only avoid pushing a couple argument registers and doing a branch, and OTOH may require additional register shuffling in the calling code, how much code does this inlining save?
About 48 bytes all up from memory.
About 12 instructions? Funny, I wouldn't have thought inlining a function called only once would save that much. Thanks for the info.
v2 cover reboard: Introduce generic relocation feature
Hi Simon,
Quoted 39 lines · Simon Glass
Hi Albert,
Quoted 20 lines · Albert ARIBAUD
Hi againLe 11/12/2011 22:30, Simon Glass a ?crit :
Quoted 11 lines
Quoted 9 lines
Actually most of
start.Sis very similar across all its avatars inarch/arm,
and is a good candidate for being generalized. I would prefer a generalization ofstart.Swith the vector table, generic startup sequence prepare for callingboard_init_f, jump toboard_init_rwith a possible stack
switch, exception handlers) , and anything specific moved into the adequate
subdirectory.Quoted 4 lines
Yes I agree. However this is not actually the purpose of this series, which is to head (so far as is possible) towards a generic
board.cfile for all architectures. While I completely agree thatstart.Sis a mess, that is a separate problem!Quoted 6 lines
Indeed, Generalizing
start.Sis a separate problem from generalizingboard.c; and that means your reboard patch series is unaffected whether you move some code intoproc.Sor not. Actually, that move toproc.Sis just a code factorization, unrelated to relocation -- your series can work just as well without it, only it will keep on taking up code size that could be reduced regardless to the way relocation is done.OK but sorry I am still a bit unclear.
Since I need to call from C the assembler function which sets up the stack, invalidates the I-cache and jumps to
board_init_r(), I need this function to be somewhere. Perhaps in the future we might devise a way of doing some of this in C code, or we might change the API. But for now we need it.
Quoted 4 lines
Given that we need it, it makes little sense to me to put it in
start.S. It then gets repeated 10 times throughout the code, with every cpu having its own version.
[snip]
The 'problem' is that in order to implement the centralisation of the relocation code, you need to do some non-relocation related fix-ups along the way.
I think it would be good to seperate what you are doing into a 'prepare' series which simply shuffles code around ready for the actual relocation patches - The compiled code should be identical before and after the 'prepare' patches. If you find some code that can be optimised (consolidating duplicate code across SoCs for example) then do this either immediately before are after the 'prepare' patches (if those optimisations make no difference to the relocation changes, then you can even leave them until after the relocation patches)
After the 'prepare' patches, the relocation changes will be much clearer
Remember, there is nothing wrong with submitting multiple series of patches where one depends on the other, but you need to make the precedence clear in the description. This approach is preferable over interleaving patches which are not, technically, related to the subject of what you are doing in the series. If it gets to the point where you simply must have some interleaving patches, then it is OK to do it within the series, but change the subject of the interleaving patches to make it clear that they are not directly related
Rember, once the patches are applied, the concept of a 'series' will be lost, so the tag at the beginning of the subject must clearly represent what that individual patch is about - Having a 'reloc' tag on a code consolidation patch will not make sense in a years time...
Regards,
Graeme
v2 cover reboard: Introduce generic relocation feature
Hi Graeme,
Quoted 73 lines · Graeme Russ
Hi Simon,
Quoted 39 lines · Simon Glass
Hi Albert,
Quoted 20 lines · Albert ARIBAUD
Hi againLe 11/12/2011 22:30, Simon Glass a ?crit :
Quoted 11 lines
Quoted 9 lines
Actually most of
start.Sis very similar across all its avatars inarch/arm,
and is a good candidate for being generalized. I would prefer a generalization ofstart.Swith the vector table, generic startup sequence prepare for callingboard_init_f, jump toboard_init_rwith a possible stack
switch, exception handlers) , and anything specific moved into the adequate
subdirectory.Quoted 4 lines
Yes I agree. However this is not actually the purpose of this series, which is to head (so far as is possible) towards a generic
board.cfile for all architectures. While I completely agree thatstart.Sis a mess, that is a separate problem!Quoted 6 lines
Indeed, Generalizing
start.Sis a separate problem from generalizingboard.c; and that means your reboard patch series is unaffected whether you move some code intoproc.Sor not. Actually, that move toproc.Sis just a code factorization, unrelated to relocation -- your series can work just as well without it, only it will keep on taking up code size that could be reduced regardless to the way relocation is done.OK but sorry I am still a bit unclear.
Since I need to call from C the assembler function which sets up the stack, invalidates the I-cache and jumps to
board_init_r(), I need this function to be somewhere. Perhaps in the future we might devise a way of doing some of this in C code, or we might change the API. But for now we need it.Quoted 4 lines
Given that we need it, it makes little sense to me to put it in
start.S. It then gets repeated 10 times throughout the code, with every cpu having its own version.[snip]
The 'problem' is that in order to implement the centralisation of the relocation code, you need to do some non-relocation related fix-ups along the way.
I think it would be good to seperate what you are doing into a 'prepare' series which simply shuffles code around ready for the actual relocation patches - The compiled code should be identical before and after the 'prepare' patches. If you find some code that can be optimised (consolidating duplicate code across SoCs for example) then do this either immediately before are after the 'prepare' patches (if those optimisations make no difference to the relocation changes, then you can even leave them until after the relocation patches)
After the 'prepare' patches, the relocation changes will be much clearer
Remember, there is nothing wrong with submitting multiple series of patches where one depends on the other, but you need to make the precedence clear in the description. This approach is preferable over interleaving patches which are not, technically, related to the subject of what you are doing in the series. If it gets to the point where you simply must have some interleaving patches, then it is OK to do it within the series, but change the subject of the interleaving patches to make it clear that they are not directly related
Quoted 4 lines
Rember, once the patches are applied, the concept of a 'series' will be lost, so the tag at the beginning of the subject must clearly represent what that individual patch is about - Having a 'reloc' tag on a code consolidation patch will not make sense in a years time...
Can you please be specific about these non-relocation fix-ups? The last patch of the removes all the relocation code from the various start.S files. Is that what you mean? There is obviously a bit of a problem here, but I just don't see what it is.
Here are the patches with my questions / comments:
reboard: Create reloc.h and include it where needed
- I think this is fine - it was requested by review feedback
reboard: define CONFIG_SYS_SKIP_RELOC for all archs
- This option is intended to deal with architectures which don't yet use the generic relocation method. It is waiting on Albert to say what is actually wanted here, perhaps a separate 'skip-relocation' patch which can be turned on per board (but I thought that was NAKed), or perhaps renaming this option.
reboard: Add generic relocation feature
- this just adds the generic code so I think is ok
reboard: arm: Add processor function library
- this adds the 'jump to board_init_r()' function, which is currently a few instructions at the end of the assembler version of relocate_code(), repeated in each start.S
reboard: arm: Move over to generic relocation
- this turns off CONFIG_SYS_SKIP_RELOC for ARM and makes it use the generic reloc
reboard: arm: Remove unused code in start.S
- this removes the relocate_code() implementation in each start.S, now that this is not needed
Regards,
Simon
Quoted 4 lines
Regards,
Graeme