Skip to contentSkip to conversation

reboard: Introduce generic relocation feature

RFC PATCH New Simon Glass 6 participants 47 messages Nov 21, 2011 – Dec 9, 2011

Subsystems (11)
Arm (32-bit) x86 PowerPC Kbuild +7 more subsystems
lore
Share & tools
lore
#0 lore raw

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 creates a libboard library and implements relocation in it. 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.

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

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 to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. This is tricky mainly due to SPL. I believe that we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

Comments please...

Simon Glass (7):
reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
reboard: Add generic link symbols
reboard: Add generic relocation feature
reboard: arm: Add relocation function
reboard: arm: Add processor function library
reboard: arm: Move over to generic relocation
reboard: arm: Remove unused code in start.S

 Makefile                                    |    1 +
 README                                      |    5 +
 arch/arm/cpu/arm1136/start.S                |  121 ----------------
 arch/arm/cpu/arm1176/start.S                |  202 ---------------------------
 arch/arm/cpu/arm720t/start.S                |  115 ---------------
 arch/arm/cpu/arm920t/start.S                |  123 ----------------
 arch/arm/cpu/arm925t/start.S                |  123 ----------------
 arch/arm/cpu/arm926ejs/start.S              |  130 -----------------
 arch/arm/cpu/arm946es/start.S               |  118 ----------------
 arch/arm/cpu/arm_intcm/start.S              |  123 ----------------
 arch/arm/cpu/armv7/start.S                  |  126 -----------------
 arch/arm/cpu/ixp/start.S                    |  115 ---------------
 arch/arm/cpu/lh7a40x/start.S                |  112 ---------------
 arch/arm/cpu/pxa/start.S                    |  122 ----------------
 arch/arm/cpu/s3c44b0/start.S                |  115 ---------------
 arch/arm/cpu/sa1100/start.S                 |  112 ---------------
 arch/arm/lib/Makefile                       |    5 +
 arch/arm/lib/arch_reloc.c                   |   47 ++++++
 arch/arm/lib/proc.S                         |   35 +++++
 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/Makefile                              |   45 ++++++
 board/reloc.c                               |  101 +++++++++++++
 include/asm-generic/link_symbols.h          |   38 +++++
 include/common.h                            |    2 +-
 include/reloc.h                             |   37 +++++
 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 +
 spl/Makefile                                |    1 +
 41 files changed, 368 insertions(+), 1760 deletions(-)
 create mode 100644 arch/arm/lib/arch_reloc.c
 create mode 100644 arch/arm/lib/proc.S
 create mode 100644 board/Makefile
 create mode 100644 board/reloc.c
 create mode 100644 include/asm-generic/link_symbols.h
 create mode 100644 include/reloc.h
Signature · 1 line
1.7.3.1
#1 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

---
 README                    |    5 +++++
 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, 44 insertions(+), 0 deletions(-)
README +5 -0
index 07f1d11..c600ea1 100644
@@ -2697,6 +2697,11 @@ Configuration Settings:
 	cases. This setting can be used to tune behaviour; see
 	lib/hashtable.c for details.
 
+- CONFIG_SYS_LEGACY_BOARD
+	This selects the legacy architecture-specific board system
+	instead of the cross-architecture board. It is intended to move
+	away from this over time.
+
 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
index 45f9dca..31e9ef9 100644
@@ -33,6 +33,9 @@ endif
 
 PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
 
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
 PF_CPPFLAGS_ARM := $(call cc-option,-marm,)
 
arch/avr32/config.mk +3 -0
index d8e7ebb..6eb00f6 100644
@@ -31,3 +31,6 @@ PLATFORM_RELFLAGS	+= -ffunction-sections -fdata-sections
 LDFLAGS_u-boot		= --gc-sections --relax
 
 LDSCRIPT			= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/blackfin/config.mk +3 -0
index f9d46de..91ddc24 100644
@@ -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
 
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
 LDFLAGS_FINAL += --gc-sections
 LDFLAGS += -m elf32bfin
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
arch/m68k/config.mk +3 -0
index 11ba334..11ad9a5 100644
@@ -29,3 +29,6 @@ PLATFORM_CPPFLAGS += -DCONFIG_M68K -D__M68K__
 PLATFORM_LDFLAGS  += -n
 PLATFORM_RELFLAGS              += -ffunction-sections -fdata-sections
 LDFLAGS_FINAL                  += --gc-sections
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/microblaze/config.mk +3 -0
index abea70b..119a596 100644
@@ -29,3 +29,6 @@ CROSS_COMPILE ?= mb-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
 
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/mips/config.mk +3 -0
index 6ab8acd..8f5305e 100644
@@ -27,6 +27,9 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T mips.lds
 
 PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
 
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
 #
 # From Linux arch/mips/Makefile
 #
arch/nds32/config.mk +3 -0
index c589829..f989053 100644
@@ -33,3 +33,6 @@ PLATFORM_RELFLAGS	+= -gdwarf-2
 PLATFORM_CPPFLAGS	+= -DCONFIG_NDS32 -D__nds32__ -G0 -ffixed-10 -fpie
 
 LDFLAGS_u-boot		= --gc-sections --relax
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/nios2/config.mk +3 -0
index 7b03ed8..0172f70 100644
@@ -31,3 +31,6 @@ PLATFORM_CPPFLAGS += -G0
 
 LDFLAGS_FINAL += --gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/powerpc/config.mk +3 -0
index a307154..e6203dd 100644
@@ -29,6 +29,9 @@ PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections
 PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
 PLATFORM_LDFLAGS  += -n
 
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
 #
 # When cross-compiling on NetBSD, we have to define __PPC__ or else we
 # will pick up a va_list declaration that is incompatible with the
arch/sandbox/config.mk +3 -0
index ab33026..251ccfd 100644
@@ -18,3 +18,6 @@
 # MA 02111-1307 USA
 
 PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/sh/config.mk +3 -0
index 07ff8b9..0c21ef5 100644
@@ -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
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/sparc/config.mk +3 -0
index cae7478..b98a173 100644
@@ -26,3 +26,6 @@ CROSS_COMPILE ?= sparc-elf-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) -T sparc.lds
 
 PLATFORM_CPPFLAGS += -DCONFIG_SPARC -D__sparc__
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/x86/config.mk +3 -0
index fe9083f..3736a68 100644
@@ -41,3 +41,6 @@ PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
 PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions
 
 LDFLAGS_FINAL += --gc-sections -pie
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
Signature · 1 line
1.7.3.1
#2 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

Quoted 2 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? we can do that
easily: add it to include/config_defaults.h. then boards that opt into it will #undef it in their own configs.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/6e213a0b/attachment.pgp>

#3 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

Hi Mike,

Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? ?we can do that
easily: add it to include/config_defaults.h. ?then boards that opt into it will #undef it in their own configs.

Thanks for looking at this.

I see this as an architecture feature - perhaps a rename to something like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving boards over one at a time, or having boards for a particular architecture that still do things the old way - it just increases maintenance and means that my eventual patch to remove arch/xxx/lib/board.c cannot be applied.

My idea for this CONFIG is purely as a temporary measure before boards more over to the generic approach.

Regards,
Simon

Quoted 2 lines

-mike

#4 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

Quoted 18 lines · On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? we can do that easily: add it to include/config_defaults.h. then boards that opt into it will #undef it in their own configs.

Thanks for looking at this.

I see this as an architecture feature - perhaps a rename to something like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving boards over one at a time, or having boards for a particular architecture that still do things the old way - it just increases maintenance and means that my eventual patch to remove arch/xxx/lib/board.c cannot be applied.

Quoted 2 lines

My idea for this CONFIG is purely as a temporary measure before boards more over to the generic approach.

how about we have the reloc code live in lib/reloc/ and be controlled by CONFIG_LEGACY_ARCH_RELOC ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/af622694/attachment.pgp>

#5 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

+omap, samsung, imx maintainers

Hi Mike,

Quoted 19 lines · Mike Frysinger
Quoted 18 lines · On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? ?we can do that easily: add it to include/config_defaults.h. ?then boards that opt into it will #undef it in their own configs.

Thanks for looking at this.

I see this as an architecture feature - perhaps a rename to something like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving boards over one at a time, or having boards for a particular architecture that still do things the old way - it just increases maintenance and means that my eventual patch to remove arch/xxx/lib/board.c cannot be applied.

Quoted 7 lines
Quoted 2 lines

My idea for this CONFIG is purely as a temporary measure before boards more over to the generic approach.

how about we have the reloc code live in lib/reloc/ and be controlled by CONFIG_LEGACY_ARCH_RELOC ?
-mike

Yes I can do that.

My only concern is that if something like SPL needs to keep all the early code at the start of the image. I personally don't like the current method for doing that (would prefer a distinctive .text.early section name) and I don't believe that any SPL implementation actually relocates itself.

Perhaps someone in OMAP / Samsung knows?

Regards,
Simon

#6 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

Quoted 23 lines · On Tuesday 29 November 2011 17:09:19 Simon Glass wrote:
Quoted 22 lines · Mike Frysinger
Quoted 20 lines · On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? we can do that easily: add it to include/config_defaults.h. then boards that opt into it will #undef it in their own configs.

Thanks for looking at this.

I see this as an architecture feature - perhaps a rename to something like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving boards over one at a time, or having boards for a particular architecture that still do things the old way - it just increases maintenance and means that my eventual patch to remove arch/xxx/lib/board.c cannot be applied.

My idea for this CONFIG is purely as a temporary measure before boards more over to the generic approach.

Quoted 8 lines
Quoted 2 lines

how about we have the reloc code live in lib/reloc/ and be controlled by CONFIG_LEGACY_ARCH_RELOC ?

My only concern is that if something like SPL needs to keep all the early code at the start of the image. I personally don't like the current method for doing that (would prefer a distinctive .text.early section name) and I don't believe that any SPL implementation actually relocates itself.

not sure why this matters ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/f792386e/attachment.pgp>

#7 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

Hi Mike,

Quoted 27 lines · Mike Frysinger
Quoted 26 lines · On Tuesday 29 November 2011 17:09:19 Simon Glass wrote:
Quoted 24 lines · Mike Frysinger
Quoted 18 lines · On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? ?we can do that easily: add it to include/config_defaults.h. ?then boards that opt into it will #undef it in their own configs.

Thanks for looking at this.

I see this as an architecture feature - perhaps a rename to something like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving boards over one at a time, or having boards for a particular architecture that still do things the old way - it just increases maintenance and means that my eventual patch to remove arch/xxx/lib/board.c cannot be applied.

Quoted 2 lines

My idea for this CONFIG is purely as a temporary measure before boards more over to the generic approach.

how about we have the reloc code live in lib/reloc/ and be controlled by CONFIG_LEGACY_ARCH_RELOC ?

Quoted 9 lines
Quoted 5 lines

My only concern is that if something like SPL needs to keep all the early code at the start of the image. I personally don't like the current method for doing that (would prefer a distinctive .text.early section name) and I don't believe that any SPL implementation actually relocates itself.

not sure why this matters ?
-mike

Because if they require linking with reloc.o then we will get link failures some boards. There is some ugly stuff in SPL which pulls in particular files from around U-Boot. Any time I split something out of start.S I may break something.

Regards,
Simon

#8 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

Le 30/11/2011 00:40, Simon Glass a ?crit :

Quoted 36 lines

Hi Mike,

Quoted 33 lines · Mike Frysinger
Quoted 31 lines · On Tuesday 29 November 2011 17:09:19 Simon Glass wrote:
Quoted 19 lines · Mike Frysinger
Quoted 18 lines · On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? we can do that easily: add it to include/config_defaults.h. then boards that opt into it will #undef it in their own configs.

Thanks for looking at this.

I see this as an architecture feature - perhaps a rename to something like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving boards over one at a time, or having boards for a particular architecture that still do things the old way - it just increases maintenance and means that my eventual patch to remove arch/xxx/lib/board.c cannot be applied.

Quoted 5 lines
Quoted 2 lines

My idea for this CONFIG is purely as a temporary measure before boards more over to the generic approach.

how about we have the reloc code live in lib/reloc/ and be controlled by CONFIG_LEGACY_ARCH_RELOC ?

My only concern is that if something like SPL needs to keep all the early code at the start of the image. I personally don't like the current method for doing that (would prefer a distinctive .text.early section name) and I don't believe that any SPL implementation actually relocates itself.

Quoted 8 lines
Quoted 3 lines

not sure why this matters ?
-mike

Because if they require linking with reloc.o then we will get link failures some boards. There is some ugly stuff in SPL which pulls in particular files from around U-Boot. Any time I split something out of start.S I may break something.

IIRC, SPL never relocates itself -- the goal of SPL is to get some code in memory that will just enable RAM, move the rest of U-Boot in, and jump to it.

What SPL pulls in is drivers/ functions for console output and access to the RAM and main U-Boot image.

Besides, sometimes making boards all fail until they are fixed is a good way to manage a change. :)

Quoted 2 lines

Regards,
Simon

Amicalement,

Signature · 1 line
Albert.
#9 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

Hi Albert,

Quoted 65 lines · Albert ARIBAUD

Le 30/11/2011 00:40, Simon Glass a ?crit :

Quoted 49 lines

Hi Mike,

Quoted 46 lines · On Tue, Nov 29, 2011 at 3:19 PM, Mike Frysinger<[email protected]> ?wrote:
Quoted 42 lines · On Tuesday 29 November 2011 17:09:19 Simon Glass wrote:
Quoted 26 lines · Mike Frysinger
Quoted 24 lines · On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
Quoted 11 lines · Mike Frysinger
Quoted 3 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? ?we can
do that easily: add it to include/config_defaults.h. ?then boards that opt into it will #undef it in their own configs.

Thanks for looking at this.

I see this as an architecture feature - perhaps a rename to something like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving boards over one at a time, or having boards for a particular architecture that still do things the old way - it just increases maintenance and means that my eventual patch to remove arch/xxx/lib/board.c cannot be applied.

Quoted 7 lines
Quoted 2 lines

My idea for this CONFIG is purely as a temporary measure before boards more over to the generic approach.

how about we have the reloc code live in lib/reloc/ and be controlled by
CONFIG_LEGACY_ARCH_RELOC ?

My only concern is that if something like SPL needs to keep all the early code at the start of the image. I personally don't like the current method for doing that (would prefer a distinctive .text.early section name) and I don't believe that any SPL implementation actually relocates itself.

Quoted 8 lines
Quoted 3 lines

not sure why this matters ?
-mike

Because if they require linking with reloc.o then we will get link failures some boards. There is some ugly stuff in SPL which pulls in particular files from around U-Boot. Any time I split something out of start.S I may break something.

IIRC, SPL never relocates itself -- the goal of SPL is to get some code in memory that will just enable RAM, move the rest of U-Boot in, and jump to it.

Quoted 5 lines

What SPL pulls in is drivers/ functions for console output and access to the RAM and main U-Boot image.

Besides, sometimes making boards all fail until they are fixed is a good way to manage a change. :)

OK it sounds like SPL won't cause problems with this series, good.

Regards,
Simon

Quoted 8 lines
Quoted 3 lines

Regards,
Simon

Amicalement,
--
Albert.

#10 lore raw

RFC PATCH 1/7 reboard: define CONFIG_SYS_LEGACY_BOARD everywhere

In reply to Simon Glass

Simon,

Quoted 32 lines · Simon Glass

+omap, samsung, imx maintainers

Hi Mike,

Quoted 19 lines · Mike Frysinger
Quoted 18 lines · On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
Quoted 7 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:54 Simon Glass wrote:

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

the define says "BOARD", so shouldn't it be in board configs ? we can do that easily: add it to include/config_defaults.h. then boards that opt into it will #undef it in their own configs.

Thanks for looking at this.

I see this as an architecture feature - perhaps a rename to something like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving boards over one at a time, or having boards for a particular architecture that still do things the old way - it just increases maintenance and means that my eventual patch to remove arch/xxx/lib/board.c cannot be applied.

Quoted 7 lines
Quoted 2 lines

My idea for this CONFIG is purely as a temporary measure before boards more over to the generic approach.

how about we have the reloc code live in lib/reloc/ and be controlled by CONFIG_LEGACY_ARCH_RELOC ?
-mike

Quoted 7 lines

Yes I can do that.

My only concern is that if something like SPL needs to keep all the early code at the start of the image. I personally don't like the current method for doing that (would prefer a distinctive .text.early section name) and I don't believe that any SPL implementation actually relocates itself.

OMAP SPL doesn't relocate itself. Neither does it have any restriction on the position of early code in the image.

best regards,
Aneesh

#11 lore raw

RFC PATCH 2/7 reboard: Add generic link symbols

In reply to Simon Glass

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.

---
 include/asm-generic/link_symbols.h |   38 ++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-generic/link_symbols.h
include/asm-generic/link_symbols.h new file +38 -0
new file mode 100644
index 0000000..2ba185b
@@ -0,0 +1,38 @@
+/*
+ * 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 __ASM_GENERIC_LINKSYMBOLS_H
+#define __ASM_GENERIC_LINKSYMBOLS_H
+
+#include <elf.h>
+
+/* Exports from the Linker Script */
+extern uchar __text_start;
+extern uchar _end;
+extern uchar __image_copy_end;
+extern Elf32_Rel __rel_dyn_start[];
+extern Elf32_Rel __rel_dyn_end[];
+extern Elf32_Sym __dynsym_start[];
+extern uchar __bss_start;
+extern uchar __bss_end__;
+extern void _start(void);
+
+#endif
Signature · 1 line
1.7.3.1
#12 lore raw

RFC PATCH 2/7 reboard: Add generic link symbols

Quoted 1 line · On Monday 21 November 2011 18:57:55 Simon Glass wrote:
 include/asm-generic/link_symbols.h |   38

this should be asm-generic/sections.h. might actually want to import the Linux one and then add a section for u-boot specific symbols.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/27e276e7/attachment.pgp>

#13 lore raw

RFC PATCH 2/7 reboard: Add generic link symbols

Hi Mike,

Quoted 6 lines · Mike Frysinger
Quoted 1 line · On Monday 21 November 2011 18:57:55 Simon Glass wrote:

?include/asm-generic/link_symbols.h | ? 38

this should be asm-generic/sections.h. ?might actually want to import the Linux one and then add a section for u-boot specific symbols. -mike

OK I have done that - there are quite a few extra ones that we don't need and some names are different but I suppose that is ok.

Regards,
Simon

#14 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

In reply to Simon Glass

Add a relocation implementation as the first thing in the generic board library. This library is needed by SPL also.

---
 Makefile         |    1 +
 board/Makefile   |   45 ++++++++++++++++++++++++
 board/reloc.c    |  101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/common.h |    2 +-
 include/reloc.h  |   37 ++++++++++++++++++++
 spl/Makefile     |    1 +
 6 files changed, 186 insertions(+), 1 deletions(-)
 create mode 100644 board/Makefile
 create mode 100644 board/reloc.c
 create mode 100644 include/reloc.h
Makefile +1 -0
index fb658f4..d313481 100644
@@ -221,6 +221,7 @@ LIBS  = lib/libgeneric.o
 LIBS += lib/lzma/liblzma.o
 LIBS += lib/lzo/liblzo.o
 LIBS += lib/zlib/libz.o
+LIBS += board/libboard.o
 LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \
 	"board/$(VENDOR)/common/lib$(VENDOR).o"; fi)
 LIBS += $(CPUDIR)/lib$(CPU).o
board/Makefile new file +45 -0

45 lines not on this page · raw message

board/reloc.c new file +101 -0

101 lines not on this page · raw message

include/common.h +1 -1
index 5ca8820..223bf52 100644
@@ -469,7 +469,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 +37 -0
new file mode 100644
index 0000000..7a4f7aa
@@ -0,0 +1,37 @@
+/*
+ * 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
+
+#include <elf.h>
+
+void proc_call_board_init_r(gd_t *new_gd, ulong dest_addr,
+		void (*board_init_r_func)(gd_t *, ulong), ulong dest_addr_sp)
+		__attribute__ ((noreturn));
+
+int arch_elf_relocate_entry(Elf32_Addr *addr, Elf32_Word info,
+			    Elf32_Sym *symtab, ulong reloc_off);
+
+void relocate_code(ulong dest_sp, gd_t *new_gd, ulong dest_addr)
+		__attribute__ ((noreturn));
+#endif
spl/Makefile +1 -0
index 6ac42a2..103f773 100644
@@ -39,6 +39,7 @@ LIBS-y += $(CPUDIR)/lib$(CPU).o
 ifdef SOC
 LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
 endif
+LIBS-y += board/libboard.o
 LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o
 LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
 
Signature · 1 line
1.7.3.1
#15 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Quoted 2 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:
 board/Makefile   |   45
 board/reloc.c    |  101

not to bikeshed, but i don't think we want files in board/. how about board/common/ or board/generic/ instead ?

board/Makefile line 30

Quoted 6 lines
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS	+= reloc.o
+endif

i don't think relocation should be tied "legacy board". not all arches do relocation at all, which means they might never opt in to this aspect.

include/common.h int dcache_status (void); · line 472

Quoted 5 lines
include/common.h +1 -1
 
-void	relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
+#include <reloc.h>

i'd think very few funcs would need this. so maybe we should make the few places include reloc.h explicitly.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/fc74e51a/attachment.pgp>

#16 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Hi Mike,

Quoted 6 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:

?board/Makefile ? | ? 45
?board/reloc.c ? ?| ?101

not to bikeshed, but i don't think we want files in board/. ?how about board/common/ or board/generic/ instead ?

Yes I wasn't sure, let's go with lib/reloc.c unless we hit SPL problems (do we really need lib/reloc/reloc.c?)

Quoted 10 lines

board/Makefile line 30

Quoted 7 lines
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS ? ? ? ?+= reloc.o
+endif

i don't think relocation should be tied "legacy board". ?not all arches do relocation at all, which means they might never opt in to this aspect.

If they don't do reloc then when we move them over we should add a CONFIG for this I think. But would prefer to wait until we have an arch moving over that requires no relocation, before addressing this.

Quoted 11 lines

include/common.h int dcache_status (void); · line 472

Quoted 6 lines
include/common.h +1 -1
 
-void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
+#include <reloc.h>

i'd think very few funcs would need this. ?so maybe we should make the few places include reloc.h explicitly.
-mike

Yes I wanted to do that but was concerned about complaints of including multiple headers in every board.c for this. I really don't like common.h so I will change it.

Regards,
Simon

#17 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Hi Simon,

Quoted 4 lines · Simon Glass

Hi Mike,

Quoted 1 line · Mike Frysinger

On Monday 21 November 2011 18:57:56 Simon Glass wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
 board/Makefile   |   45
 board/reloc.c    |  101

not to bikeshed, but i don't think we want files in board/. how about board/common/ or board/generic/ instead ?

Yes I wasn't sure, let's go with lib/reloc.c unless we hit SPL problems (do we really need lib/reloc/reloc.c?)

Hmmm, I think common/reloc.c may be more appropriate - I think /lib/ is more for externally sourced libraries

Regards,

Graeme

#18 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

In reply to Simon Glass
Quoted 13 lines · On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
Quoted 11 lines · Mike Frysinger

board/Makefile line 30

Quoted 6 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS        += reloc.o
+endif

i don't think relocation should be tied "legacy board". not all arches do relocation at all, which means they might never opt in to this aspect.

Quoted 3 lines

If they don't do reloc then when we move them over we should add a CONFIG for this I think. But would prefer to wait until we have an arch moving over that requires no relocation, before addressing this.

Blackfin does no relocation, so i'd be annoyed to have to carry a define like "LEGACY_BOARD" forever ;)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/1ec49b07/attachment.pgp>

#19 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Hi Mike,

Quoted 14 lines · Mike Frysinger
Quoted 13 lines · On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
Quoted 11 lines · Mike Frysinger

board/Makefile line 30

Quoted 6 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS ? ? ? ?+= reloc.o
+endif

i don't think relocation should be tied "legacy board". ?not all arches do relocation at all, which means they might never opt in to this aspect.

Quoted 8 lines
Quoted 3 lines

If they don't do reloc then when we move them over we should add a CONFIG for this I think. But would prefer to wait until we have an arch moving over that requires no relocation, before addressing this.

Blackfin does no relocation, so i'd be annoyed to have to carry a define like "LEGACY_BOARD" forever ;)
-mike

Would you be happier with CONFIG_ARCH_NO_RELOCATION?

Regards,
Simon

#20 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Hi Simon,

Quoted 21 lines · Simon Glass

Hi Mike,

Quoted 18 lines · Mike Frysinger
Quoted 16 lines · On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
Quoted 11 lines · Mike Frysinger

board/Makefile line 30

Quoted 6 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS ? ? ? ?+= reloc.o
+endif

i don't think relocation should be tied "legacy board". ?not all arches do relocation at all, which means they might never opt in to this aspect.

If they don't do reloc then when we move them over we should add a CONFIG for this I think. But would prefer to wait until we have an arch moving over that requires no relocation, before addressing this.

Quoted 6 lines
Quoted 4 lines

Blackfin does no relocation, so i'd be annoyed to have to carry a define like "LEGACY_BOARD" forever ;)
-mike

Would you be happier with CONFIG_ARCH_NO_RELOCATION?

CONFIG_SYS_NO_RELOC

Regards,

Graeme

#21 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Quoted 20 lines · On Tuesday 29 November 2011 18:49:58 Graeme Russ wrote:
Quoted 19 lines · Simon Glass
Quoted 18 lines · Mike Frysinger
Quoted 16 lines · On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
Quoted 11 lines · Mike Frysinger

board/Makefile line 30

Quoted 6 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS        += reloc.o
+endif

i don't think relocation should be tied "legacy board". not all arches do relocation at all, which means they might never opt in to this aspect.

If they don't do reloc then when we move them over we should add a CONFIG for this I think. But would prefer to wait until we have an arch moving over that requires no relocation, before addressing this.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Blackfin does no relocation, so i'd be annoyed to have to carry a define like "LEGACY_BOARD" forever ;)

Would you be happier with CONFIG_ARCH_NO_RELOCATION?

CONFIG_SYS_NO_RELOC

either is fine by me
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/154e9bee/attachment.pgp>

#22 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Le 30/11/2011 03:58, Mike Frysinger a ?crit :

Quoted 24 lines · On Tuesday 29 November 2011 18:49:58 Graeme Russ wrote:
Quoted 23 lines · Simon Glass
Quoted 22 lines · Mike Frysinger
Quoted 20 lines · On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
Quoted 13 lines · Mike Frysinger
Quoted 11 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:

board/Makefile

Quoted 6 lines
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS        += reloc.o
+endif

i don't think relocation should be tied "legacy board". not all arches do relocation at all, which means they might never opt in to this aspect.

Quoted 3 lines

If they don't do reloc then when we move them over we should add a CONFIG for this I think. But would prefer to wait until we have an arch moving over that requires no relocation, before addressing this.

Blackfin does no relocation, so i'd be annoyed to have to carry a define like "LEGACY_BOARD" forever ;)

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Would you be happier with CONFIG_ARCH_NO_RELOCATION?

CONFIG_SYS_NO_RELOC

either is fine by me
-mike

CONFIG_SYS_SKIP_RELOC clearly states there is some usual step we're skipping, plus we could homogeneize with other config settings that "SKIP" some step.

Amicalement,

Signature · 1 line
Albert.
#23 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Quoted 27 lines · On Wednesday 07 December 2011 02:38:40 Albert ARIBAUD wrote:

Le 30/11/2011 03:58, Mike Frysinger a ?crit :

Quoted 26 lines · On Tuesday 29 November 2011 18:49:58 Graeme Russ wrote:
Quoted 25 lines · Simon Glass
Quoted 23 lines · Mike Frysinger
Quoted 14 lines · On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
Quoted 13 lines · Mike Frysinger
Quoted 11 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:

board/Makefile

Quoted 6 lines
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS        += reloc.o
+endif

i don't think relocation should be tied "legacy board". not all arches do relocation at all, which means they might never opt in to this aspect.

Quoted 6 lines
Quoted 3 lines

If they don't do reloc then when we move them over we should add a CONFIG for this I think. But would prefer to wait until we have an arch moving over that requires no relocation, before addressing this.

Blackfin does no relocation, so i'd be annoyed to have to carry a define like "LEGACY_BOARD" forever ;)

Would you be happier with CONFIG_ARCH_NO_RELOCATION?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

CONFIG_SYS_NO_RELOC

either is fine by me

CONFIG_SYS_SKIP_RELOC clearly states there is some usual step we're skipping, plus we could homogeneize with other config settings that "SKIP" some step.

fine by me as well
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111207/b91978f7/attachment.pgp>

#24 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Hi,

Quoted 30 lines · Mike Frysinger
Quoted 29 lines · On Wednesday 07 December 2011 02:38:40 Albert ARIBAUD wrote:

Le 30/11/2011 03:58, Mike Frysinger a ?crit :

Quoted 28 lines · On Tuesday 29 November 2011 18:49:58 Graeme Russ wrote:
Quoted 26 lines · Simon Glass
Quoted 15 lines · Mike Frysinger
Quoted 14 lines · On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
Quoted 13 lines · Mike Frysinger
Quoted 11 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:

board/Makefile

Quoted 6 lines
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS ? ? ? ?+= reloc.o
+endif

i don't think relocation should be tied "legacy board". ?not all arches do relocation at all, which means they might never opt in to this aspect.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

If they don't do reloc then when we move them over we should add a CONFIG for this I think. But would prefer to wait until we have an arch moving over that requires no relocation, before addressing this.

Blackfin does no relocation, so i'd be annoyed to have to carry a define like "LEGACY_BOARD" forever ;)

Would you be happier with CONFIG_ARCH_NO_RELOCATION?

CONFIG_SYS_NO_RELOC

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

either is fine by me

CONFIG_SYS_SKIP_RELOC clearly states there is some usual step we're skipping, plus we could homogeneize with other config settings that "SKIP" some step.

fine by me as well
-mike

OK, will define that in boards with no relocation. Others (like PowerPC) will end up with an unused relocation function until they switch over. That might cause problems, we will see.

Regards,
Simon

#25 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

In reply to Mike Frysinger

Hi Mike,

Quoted 20 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:

?board/Makefile ? | ? 45
?board/reloc.c ? ?| ?101

not to bikeshed, but i don't think we want files in board/. ?how about board/common/ or board/generic/ instead ?

board/Makefile line 30

Quoted 6 lines
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS ? ? ? ?+= reloc.o
+endif

i don't think relocation should be tied "legacy board". ?not all arches do relocation at all, which means they might never opt in to this aspect.

Quoted 3 lines
include/common.h +0 -0
Quoted 6 lines

include/common.h int dcache_status (void); · line 472

Quoted 2 lines
include/common.h +1 -1
-void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
+#include <reloc.h>

i'd think very few funcs would need this. ?so maybe we should make the few places include reloc.h explicitly.
-mike

I found that 27 files call relocate_code(). Now we can discuss whether the number should be that high, but for now I would prefer to move this out of common.h in a later patch. What do you think?

./nand_spl/board/freescale/p1023rds/nand_boot.c ./nand_spl/board/freescale/p1010rdb/nand_boot.c ./nand_spl/board/freescale/mpc8536ds/nand_boot.c ./nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c ./nand_spl/board/freescale/mpc8569mds/nand_boot.c ./nand_spl/board/freescale/mpc8572ds/nand_boot.c ./nand_spl/board/freescale/p1_p2_rdb/nand_boot.c ./nand_spl/nand_boot_fsl_nfc.c ./arch/mips/lib/board.c ./arch/x86/lib/board.c ./arch/nds32/lib/board.c ./arch/arm/cpu/armv7/omap-common/spl.c ./arch/arm/cpu/arm926ejs/davinci/spl.c ./arch/arm/lib/board.c ./arch/avr32/lib/board.c ./arch/powerpc/lib/board.c ./arch/m68k/lib/board.c ./board/samsung/smdk6400/smdk6400_nand_spl.c ./board/sheldon/simpc8313/simpc8313.c ./board/freescale/mpc8313erdb/mpc8313erdb.c ./board/freescale/mpc8315erdb/mpc8315erdb.c

Regards,
Simon

#26 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Hi Simon,

Quoted 30 lines · Simon Glass

Hi Mike,

Quoted 20 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:

?board/Makefile ? | ? 45
?board/reloc.c ? ?| ?101

not to bikeshed, but i don't think we want files in board/. ?how about board/common/ or board/generic/ instead ?

board/Makefile line 30

Quoted 6 lines
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS ? ? ? ?+= reloc.o
+endif

i don't think relocation should be tied "legacy board". ?not all arches do relocation at all, which means they might never opt in to this aspect.

Quoted 3 lines
include/common.h +0 -0
Quoted 6 lines

include/common.h int dcache_status (void); · line 472

Quoted 2 lines
include/common.h +1 -1
-void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
+#include <reloc.h>

i'd think very few funcs would need this. ?so maybe we should make the few places include reloc.h explicitly.
-mike

Quoted 3 lines

I found that 27 files call relocate_code(). Now we can discuss whether the number should be that high, but for now I would prefer to move this out of common.h in a later patch. What do you think?

27 out of how many source code files? Thousands?

Quite honestly, include/common.h has become a bit of a dumping ground for one-off function definitions that should have been put in a stand-alone header.

common.h is included nearly everywhere - is all this really needed everywhere:

/* Multicore arch functions */
#ifdef CONFIG_MP
int cpu_status(int nr);
int cpu_reset(int nr);
int cpu_disable(int nr);
int cpu_release(int nr, int argc, char * const argv[]); #endif

...

int dpram_init (void);
uint dpram_base(void);
uint dpram_base_align(uint align);
uint dpram_alloc(uint size);
uint dpram_alloc_align(uint size,uint align);

...

#if defined(CONFIG_8260)
int prt_8260_rsr (void);
#elif defined(CONFIG_MPC83xx)
int prt_83xx_rsr (void);
#endif

...

/* $(CPU)/cpu_init.c */
#if defined(CONFIG_8xx) || defined(CONFIG_8260)
void cpu_init_f (volatile immap_t *immr);
#endif

#if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) ||
defined(CONFIG_MCF52x2) ||defined(CONFIG_MPC86xx)

void cpu_init_f (void);
#endif

...

#if defined(CONFIG_IMX)
ulong get_systemPLLCLK(void);
ulong get_FCLK(void);
ulong get_HCLK(void);
ulong get_BCLK(void);
ulong get_PERCLK1(void);
ulong get_PERCLK2(void);
ulong get_PERCLK3(void);
#endif

The list goes on - please, lets stop the rot

Regards,

Graeme

#27 lore raw

RFC PATCH 3/7 reboard: Add generic relocation feature

Hi Graeme,

Quoted 93 lines · Graeme Russ

Hi Simon,

Quoted 30 lines · Simon Glass

Hi Mike,

Quoted 20 lines · Mike Frysinger
Quoted 2 lines · On Monday 21 November 2011 18:57:56 Simon Glass wrote:

?board/Makefile ? | ? 45
?board/reloc.c ? ?| ?101

not to bikeshed, but i don't think we want files in board/. ?how about board/common/ or board/generic/ instead ?

board/Makefile line 30

Quoted 6 lines
board/Makefile new file +3 -0
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS ? ? ? ?+= reloc.o
+endif

i don't think relocation should be tied "legacy board". ?not all arches do relocation at all, which means they might never opt in to this aspect.

Quoted 3 lines
include/common.h +0 -0
Quoted 6 lines

include/common.h int dcache_status (void); · line 472

Quoted 2 lines
include/common.h +1 -1
-void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
+#include <reloc.h>

i'd think very few funcs would need this. ?so maybe we should make the few places include reloc.h explicitly.
-mike

Quoted 3 lines

I found that 27 files call relocate_code(). Now we can discuss whether the number should be that high, but for now I would prefer to move this out of common.h in a later patch. What do you think?

27 out of how many source code files? Thousands?

Quite honestly, include/common.h has become a bit of a dumping ground for one-off function definitions that should have been put in a stand-alone header.

common.h is included nearly everywhere - is all this really needed everywhere:

/* Multicore arch functions */
#ifdef CONFIG_MP
int cpu_status(int nr);
int cpu_reset(int nr);
int cpu_disable(int nr);
int cpu_release(int nr, int argc, char * const argv[]); #endif

...

int ? ? dpram_init (void);
uint ? ?dpram_base(void);
uint ? ?dpram_base_align(uint align);
uint ? ?dpram_alloc(uint size);
uint ? ?dpram_alloc_align(uint size,uint align);

...

#if defined(CONFIG_8260)
int ? ? prt_8260_rsr ?(void);
#elif defined(CONFIG_MPC83xx)
int ? ? prt_83xx_rsr ?(void);
#endif

...

/* $(CPU)/cpu_init.c */
#if defined(CONFIG_8xx) || defined(CONFIG_8260)
void ? ?cpu_init_f ? ?(volatile immap_t *immr);
#endif

#if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) ||
defined(CONFIG_MCF52x2) ||defined(CONFIG_MPC86xx)

void ? ?cpu_init_f ? ?(void);
#endif

...

#if defined(CONFIG_IMX)
ulong get_systemPLLCLK(void);
ulong get_FCLK(void);
ulong get_HCLK(void);
ulong get_BCLK(void);
ulong get_PERCLK1(void);
ulong get_PERCLK2(void);
ulong get_PERCLK3(void);
#endif

Quoted 1 line

The list goes on - please, lets stop the rot

You are preaching to the choir...

OK I will add an initial patch to the series to clean this up.

Regards,
Simon

Quoted 4 lines

Regards,

Graeme

#28 lore raw

RFC PATCH 4/7 reboard: arm: Add relocation function

In reply to Simon Glass

Add a function to process a single ELF relocation.

---
 arch/arm/lib/Makefile     |    4 +++
 arch/arm/lib/arch_reloc.c |   47 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/lib/arch_reloc.c
arch/arm/lib/Makefile +4 -0
index 300c8fa..ca2802a 100644
@@ -48,6 +48,10 @@ SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o
 SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 endif
 
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS-y += arch_reloc.o
+endif
+
 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/arch_reloc.c new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#29 lore raw

RFC PATCH 5/7 reboard: arm: Add processor function library

In reply to Simon Glass

Add a library to hold ARM assembler code which is generic across all ARM CPUs.

---
 arch/arm/lib/Makefile |    1 +
 arch/arm/lib/proc.S   |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/lib/proc.S
arch/arm/lib/Makefile +1 -0
index ca2802a..27749dc 100644
@@ -50,6 +50,7 @@ endif
 
 ifndef CONFIG_SYS_LEGACY_BOARD
 COBJS-y += arch_reloc.o
+SOBJS-y += proc.o
 endif
 
 SRCS	:= $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \
arch/arm/lib/proc.S new file +35 -0
new file mode 100644
index 0000000..99a2944
@@ -0,0 +1,35 @@
+/*
+ * 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:
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
Signature · 1 line
1.7.3.1
#30 lore raw

RFC PATCH 5/7 reboard: arm: Add processor function library

Quoted 2 lines · On Monday 21 November 2011 18:57:58 Simon Glass wrote:

+.globl proc_call_board_init_r
+proc_call_board_init_r:

ENTRY(proc_call_board_init_r)

arch/arm/lib/proc.S line 35

Quoted 3 lines
arch/arm/lib/proc.S new file +3 -0
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2

then add ENDPROC(proc_call_board_init_r) here
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/04015bbc/attachment.pgp>

#31 lore raw

RFC PATCH 5/7 reboard: arm: Add processor function library

In reply to Simon Glass

Hi Simon,

Le 22/11/2011 00:57, Simon Glass a ?crit :

Quoted 53 lines

Add a library to hold ARM assembler code which is generic across all ARM CPUs.

---
  arch/arm/lib/Makefile |    1 +
  arch/arm/lib/proc.S   |   35 +++++++++++++++++++++++++++++++++++
  2 files changed, 36 insertions(+), 0 deletions(-)

create mode 100644 arch/arm/lib/proc.S

arch/arm/lib/Makefile +1 -0
index ca2802a..27749dc 100644
@@ -50,6 +50,7 @@ endif
 
  ifndef CONFIG_SYS_LEGACY_BOARD
  COBJS-y += arch_reloc.o
+SOBJS-y += proc.o
  endif
 
  SRCS	:= $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \
arch/arm/lib/proc.S new file +25 -0
new file mode 100644
index 0000000..99a2944
@@ -0,0 +1,35 @@
+/*
+ * 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
+ *

arch/arm/lib/proc.S line 35

Quoted 10 lines
arch/arm/lib/proc.S new file +10 -0
+ * @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:
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2

What do we gain from this patch exactly?

Amicalement,

Signature · 1 line
Albert.
#32 lore raw

RFC PATCH 5/7 reboard: arm: Add processor function library

Hi Albert,

Quoted 62 lines · Albert ARIBAUD

Hi Simon,

Le 22/11/2011 00:57, Simon Glass a ?crit :

Quoted 58 lines

Add a library to hold ARM assembler code which is generic across all ARM CPUs.

---
?arch/arm/lib/Makefile | ? ?1 +
?arch/arm/lib/proc.S ? | ? 35 +++++++++++++++++++++++++++++++++++ ?2 files changed, 36 insertions(+), 0 deletions(-) ?create mode 100644 arch/arm/lib/proc.S

arch/arm/lib/Makefile +0 -0
index ca2802a..27749dc 100644
@@ -50,6 +50,7 @@ endif
 

?ifndef CONFIG_SYS_LEGACY_BOARD
?COBJS-y += arch_reloc.o
+SOBJS-y += proc.o
?endif

?SRCS ?:= $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \

arch/arm/lib/proc.S new file +30 -0
new file mode 100644
index 0000000..99a2944
@@ -0,0 +1,35 @@
+/*
+ * 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
+ */
Quoted 8 lines

arch/arm/lib/proc.S line 35

Quoted 5 lines
arch/arm/lib/proc.S new file +5 -0
+.globl proc_call_board_init_r
+proc_call_board_init_r:
+ ? ? ? mov ? ? sp, r3
+ ? ? ? /* jump to it ... */
+ ? ? ? mov ? ? pc, r2

What do we gain from this patch exactly?

The idea is to create a library to hold ARM assembler code which is generic across all (or even most) ARM CPUs. So far it is just relocation, but I feel that exception handling could move here too eventually.

IMO start.S is a bad place for this sort of thing - it is private to each cpu type so people tend to copy and paste large tracts of code and it doesn't feel right to call back into your startup code later to do things.

So I suggest a proc.S (or some other name) with processor-level functions which are generic across ARM. We can then move this code from all the little start.S files into one place, and maintain it more easily.

Yes this is a trivial wee patch, but it's good to start the discussion with something.

Regards,
Simon

Quoted 4 lines

Amicalement,
--
Albert.

#33 lore raw

RFC PATCH 6/7 reboard: arm: Move over to generic relocation

In reply to Simon Glass

Switch ARM over to generic relocation - unfortunately a few boards need to be modified to make this work. We rename the relocate_code() function here so that the existing start.S implementations are still used for now. The next commit does the actual switch.

---
 arch/arm/config.mk                          |    3 ---
 board/reloc.c                               |    2 +-
 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, 17 insertions(+), 6 deletions(-)
arch/arm/config.mk +0 -3
index 31e9ef9..45f9dca 100644
@@ -33,9 +33,6 @@ endif
 
 PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
 
-# Move to unified board system later
-CONFIG_SYS_LEGACY_BOARD := y
-
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
 PF_CPPFLAGS_ARM := $(call cc-option,-marm,)
 
board/reloc.c +1 -1
index abd9c0b..edbeabb 100644
@@ -87,7 +87,7 @@ static int reloc_elf(void)
 	return 0;
 }
 
-void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
 {
 	reloc_make_copy();
 	reloc_elf();
nand_spl/board/freescale/mx31pdk/Makefile +7 -1
index 87784d2..3e858b8 100644
@@ -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)/board/%.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
index d2b08f6..2273e9b 100644
@@ -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
index 0336346..5063c06 100644
@@ -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)/board/%.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
index d2b08f6..2273e9b 100644
@@ -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
#34 lore raw

RFC PATCH 6/7 reboard: arm: Move over to generic relocation

board/reloc.c static int reloc_elf(void) · line 90

Quoted 5 lines · On Monday 21 November 2011 18:57:59 Simon Glass wrote:
board/reloc.c +1 -1
 
-void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)

shouldn't this be squashed into the patch that added this func ?

nand_spl/board/freescale/mx31pdk/Makefile $(obj)%.o: $(SRCTREE)/board/freescale/mx31pdk/%.S · line 57

Quoted 8 lines
nand_spl/board/freescale/mx31pdk/Makefile +5 -0
 
+$(obj)%.o:	$(SRCTREE)/board/%.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)%.o:	$(SRCTREE)/arch/arm/lib/%.S
+	$(CC) $(AFLAGS) -c -o $@ $<

ugh. is this the SOP for SPL or something ? this is awful :(.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/a36ad23a/attachment.pgp>

#35 lore raw

RFC PATCH 6/7 reboard: arm: Move over to generic relocation

Hi Mike,

Quoted 8 lines · Mike Frysinger

board/reloc.c static int reloc_elf(void) · line 90

Quoted 5 lines · On Monday 21 November 2011 18:57:59 Simon Glass wrote:
board/reloc.c +1 -1
 
-void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)

shouldn't this be squashed into the patch that added this func ?

Yes I'm going with the weak function idea. We can remove it when all archs are moved over.

Quoted 11 lines

nand_spl/board/freescale/mx31pdk/Makefile

Quoted 9 lines
nand_spl/board/freescale/mx31pdk/Makefile +5 -0
 
+$(obj)%.o: ? $(SRCTREE)/board/%.c
+ ? ? $(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)%.o: ? $(SRCTREE)/arch/arm/lib/%.S
+ ? ? $(CC) $(AFLAGS) -c -o $@ $<

ugh. ?is this the SOP for SPL or something ? ?this is awful :(.

Yes, SPL. It makes me very sad too. The worse alternative is to break all boards that don't use the new SPL framework.

Regards,
Simon

Quoted 1 line

-mike

#36 lore raw

RFC PATCH 7/7 reboard: arm: Remove unused code in start.S

In reply to Simon Glass

Now that we are using the generic relocation framework, we don't need this code. Once it is removed, we can change reloc.c's relocate_code() function back to its correct name.

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?

---
 arch/arm/cpu/arm1136/start.S   |  121 ------------------------
 arch/arm/cpu/arm1176/start.S   |  202 ----------------------------------------
 arch/arm/cpu/arm720t/start.S   |  115 -----------------------
 arch/arm/cpu/arm920t/start.S   |  123 ------------------------
 arch/arm/cpu/arm925t/start.S   |  123 ------------------------
 arch/arm/cpu/arm926ejs/start.S |  130 --------------------------
 arch/arm/cpu/arm946es/start.S  |  118 -----------------------
 arch/arm/cpu/arm_intcm/start.S |  123 ------------------------
 arch/arm/cpu/armv7/start.S     |  126 -------------------------
 arch/arm/cpu/ixp/start.S       |  115 -----------------------
 arch/arm/cpu/lh7a40x/start.S   |  112 ----------------------
 arch/arm/cpu/pxa/start.S       |  122 ------------------------
 arch/arm/cpu/s3c44b0/start.S   |  115 -----------------------
 arch/arm/cpu/sa1100/start.S    |  112 ----------------------
 board/reloc.c                  |    2 +-
 15 files changed, 1 insertions(+), 1758 deletions(-)
arch/arm/cpu/arm1136/start.S +0 -121
index c0db96c..d69aa5d 100644
@@ -169,127 +169,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 +0 -202

208 lines not on this page · raw message

arch/arm/cpu/arm720t/start.S +0 -115

121 lines not on this page · raw message

arch/arm/cpu/arm920t/start.S +0 -123

129 lines not on this page · raw message

arch/arm/cpu/arm925t/start.S +0 -123

129 lines not on this page · raw message

arch/arm/cpu/arm926ejs/start.S +0 -130

136 lines not on this page · raw message

arch/arm/cpu/arm946es/start.S +0 -118

124 lines not on this page · raw message

arch/arm/cpu/arm_intcm/start.S +0 -123

129 lines not on this page · raw message

arch/arm/cpu/armv7/start.S +0 -126

132 lines not on this page · raw message

arch/arm/cpu/ixp/start.S +0 -115

121 lines not on this page · raw message

arch/arm/cpu/lh7a40x/start.S +0 -112

118 lines not on this page · raw message

arch/arm/cpu/pxa/start.S +0 -122

128 lines not on this page · raw message

arch/arm/cpu/s3c44b0/start.S +0 -115

121 lines not on this page · raw message

arch/arm/cpu/sa1100/start.S +0 -112

118 lines not on this page · raw message

board/reloc.c +1 -1
index edbeabb..abd9c0b 100644
@@ -87,7 +87,7 @@ static int reloc_elf(void)
 	return 0;
 }
 
-void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
 {
 	reloc_make_copy();
 	reloc_elf();
Signature · 1 line
1.7.3.1
#37 lore raw

RFC PATCH 7/7 reboard: arm: Remove unused code in start.S

board/reloc.c static int reloc_elf(void) · line 90

Quoted 5 lines · On Monday 21 November 2011 18:58:00 Simon Glass wrote:
board/reloc.c +1 -1
 
-void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)

this is too fragile. we can't have every arch transition the way you did with arm (otherwise arches that have transitioned will break in between). declare this func weak and don't rename it. then there should be no migration issue. -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/4f1806d9/attachment.pgp>

#38 lore raw

RFC PATCH 7/7 reboard: arm: Remove unused code in start.S

Hi Mike,

Quoted 11 lines · Mike Frysinger

board/reloc.c static int reloc_elf(void) · line 90

Quoted 5 lines · On Monday 21 November 2011 18:58:00 Simon Glass wrote:
board/reloc.c +1 -1
 
-void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)

this is too fragile. ?we can't have every arch transition the way you did with arm (otherwise arches that have transitioned will break in between). ?declare this func weak and don't rename it. ?then there should be no migration issue. -mike

Yes I will do that, thanks. We can always remove it later when archs have all moved over.

Regards,
Simon

#39 lore raw

cover reboard: Introduce generic relocation feature

In reply to Simon Glass
Quoted 31 lines · Simon Glass

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series creates a libboard library and implements relocation in it. 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.

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

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 to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. ?This is tricky mainly due to SPL. I believe that we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

Quoted 4 lines

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

Comments please...

Seems like a good idea. Got some size's before and after? Maybe some boot times too (as you mention 2000-odd function calls during relocation) ?

Signature · 1 line
Tom
#40 lore raw

cover reboard: Introduce generic relocation feature

Hi Tom,

Quoted 35 lines · Tom Rini
Quoted 34 lines · Simon Glass

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series creates a libboard library and implements relocation in it. 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.

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

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 to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. ?This is tricky mainly due to SPL. I believe that we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

Quoted 8 lines
Quoted 1 line

Comments please...

Seems like a good idea. ?Got some size's before and after? ?Maybe some boot times too (as you mention 2000-odd function calls during relocation) ?

--
Tom

Yes I have this info - will package it up tomorrow along with a new series to deal with review comments.

Regards,
Simon

#41 lore raw

cover reboard: Introduce generic relocation feature

Hi Simon

Sorry for the late review on this - I've only just now had a good chance to look at it...

Quoted 19 lines · Simon Glass

Hi Tom,

Quoted 16 lines · Tom Rini
Quoted 15 lines · Simon Glass

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series creates a libboard library and implements relocation in it. 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.

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

Ugh, that overhead is a killer - The relocation can be done entirely in a tight loop with a switch statement in your reloc_elf() function. But I think reloc_elf() should be weak - x86 relocation can be done in a few lines of assembler which is smaller and faster than a C implementation will ever be

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

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 to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. This is tricky mainly due to SPL. I believe that we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

Comments please...

The whole sequence of the series seems a little bit 'random' to me - I think patches 2 and 3 can be squahed and the dead code removal in patch 7 should be done in the same patch(es) that create the dead code.

It looks like reloc_make_copy(), reloc_clear_bss() and reloc_elf() have been poached from x86 - The copy and clear loops are quite inefficient. I have patches at home which change these to use memcpy and memset

Quoted 10 lines
Quoted 7 lines

Seems like a good idea. Got some size's before and after? Maybe some boot times too (as you mention 2000-odd function calls during relocation) ?

--
Tom

Yes I have this info - will package it up tomorrow along with a new series to deal with review comments.

As far as I understand it, the long-term plan is to unify the board init sequence across all architectures. I can see three approaches:

1) Tweak each arch until they are all the same and then 'throw the switch'
2) Pick one or two arches and 'throw the switch' on them and migrate the others later
3) Pull out common bits and pieced and deal with the left-overs later

It looks like you've opted for number 3. The problem I see in this approach is that you are relying on the other arches to follow your lead which is, at best, a 50/50 bet.

Now I look at board_init_f() and board_init_r() in ARM and x86 and think 'why on earth isn't most of than in the init loops?'. The boot sequence for ARM and x86 should be reducible to (all arches are generally pretty close to this, so it should not introduce too much pain when they decide to switch)

- Low level init (reset vector etc)
- Setup temporary stack and gd storage (typically in CPU cache)
+ init_f loop <-- SDRAM initialised
- Move gd to RAM
- Setup new stack in SDRAM
- Turn on caching (cannot be done while gd and stack in cache!!!)
+ Calculate relocation address
+ Copy to RAM
+ Do relocation fixups
+ Clear BSS
- Jump to RAM
+ init_r loop
+ main_loop()

+ = common code
- = arch, SoC, or board specific

Note: Typically the boot sequence currently has 'Turn on caching' after jump to RAM - I have patches in the works which change this for x86

So my vote would be #2 - Unify the ARM and x86 and bring any code that can be inside the init loops in and then switch both over to a generic init implementation. Other arches can be switched later

Regards,

Graeme

#42 lore raw

cover reboard: Introduce generic relocation feature

Hi Graeme,

Quoted 5 lines · Graeme Russ

Hi Simon

Sorry for the late review on this - I've only just now had a good chance to look at it...

Thanks for the comments.

Quoted 21 lines · Simon Glass
Quoted 19 lines

Hi Tom,

Quoted 16 lines · Tom Rini
Quoted 15 lines · Simon Glass

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series creates a libboard library and implements relocation in it. 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.

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

Quoted 5 lines

Ugh, that overhead is a killer - The relocation can be done entirely in a tight loop with a switch statement in your reloc_elf() function. But I think reloc_elf() should be weak - x86 relocation can be done in a few lines of assembler which is smaller and faster than a C implementation will ever be

I will benchmark it tomorrow. If we move the for loop into the architecture-specific code then it goes away. Just seemed to me that the less duplicated code we have the better. We could use an inline function but I'm not keen on that.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

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 to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. ?This is tricky mainly due to SPL. I believe that we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

Comments please...

The whole sequence of the series seems a little bit 'random' to me - I think patches 2 and 3 can be squahed and the dead code removal in patch 7 should be done in the same patch(es) that create the dead code.

Yes I can clean this up.

Quoted 3 lines

It looks like reloc_make_copy(), reloc_clear_bss() and reloc_elf() have been poached from x86 - The copy and clear loops are quite inefficient. I have patches at home which change these to use memcpy and memset

Yes they have - in fact I have a series here which unifies board.c completely for ARM and x86. But I need to take this in baby steps as I said.

Quoted 15 lines
Quoted 11 lines
Quoted 8 lines

Seems like a good idea. ?Got some size's before and after? ?Maybe some boot times too (as you mention 2000-odd function calls during relocation) ?

--
Tom

Yes I have this info - will package it up tomorrow along with a new series to deal with review comments.

As far as I understand it, the long-term plan is to unify the board init sequence across all architectures. I can see three approaches:

Quoted 8 lines

?1) Tweak each arch until they are all the same and then 'throw the switch' ?2) Pick one or two arches and 'throw the switch' on them and migrate the ? ?others later
?3) Pull out common bits and pieced and deal with the left-overs later

It looks like you've opted for number 3. The problem I see in this approach is that you are relying on the other arches to follow your lead which is, at best, a 50/50 bet.

Sort of. Actually I have gone for option 2. But rather than send a series which switches over ARM and then x86 (about 40 patches) I have decided to do it in steps. Relocation is the first step.

Quoted 6 lines

Now I look at board_init_f() and board_init_r() in ARM and x86 and think 'why on earth isn't most of than in the init loops?'. The boot sequence for ARM and x86 should be reducible to (all arches are generally pretty close to this, so it should not introduce too much pain when they decide to switch)

Yes my generic board.c consists of a couple of init loops. I can email the patch if you like but it is not ready for the mailing list.

Quoted 18 lines

?- Low level init (reset vector etc)
?- Setup temporary stack and gd storage (typically in CPU cache) ?+ init_f loop <-- SDRAM initialised
?- Move gd to RAM
?- Setup new stack in SDRAM
?- Turn on caching (cannot be done while gd and stack in cache!!!) ?+ Calculate relocation address
?+ Copy to RAM
?+ Do relocation fixups
?+ Clear BSS
?- Jump to RAM
?+ init_r loop
?+ main_loop()

+ = common code
- = arch, SoC, or board specific

Quoted 6 lines

Note: Typically the boot sequence currently has 'Turn on caching' after jump to RAM - I have patches in the works which change this for x86

So my vote would be #2 - Unify the ARM and x86 and bring any code that can be inside the init loops in and then switch both over to a generic init implementation. Other arches can be switched later

Agreed, but I can't send a series that big, so I am doing it in stages.

Regards,
Simon

Quoted 4 lines

Regards,

Graeme

#43 lore raw

cover reboard: Introduce generic relocation feature

Hi Simon,

Quoted 38 lines · Simon Glass

Hi Graeme,

Quoted 5 lines · Graeme Russ

Hi Simon

Sorry for the late review on this - I've only just now had a good chance to look at it...

Thanks for the comments.

Quoted 21 lines · Simon Glass
Quoted 19 lines

Hi Tom,

Quoted 16 lines · Tom Rini
Quoted 15 lines · Simon Glass

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series creates a libboard library and implements relocation in it. 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.

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

Quoted 5 lines

Ugh, that overhead is a killer - The relocation can be done entirely in a tight loop with a switch statement in your reloc_elf() function. But I think reloc_elf() should be weak - x86 relocation can be done in a few lines of assembler which is smaller and faster than a C implementation will ever be

Quoted 4 lines

I will benchmark it tomorrow. If we move the for loop into the architecture-specific code then it goes away. Just seemed to me that the less duplicated code we have the better. We could use an inline function but I'm not keen on that.

This may be one case were performance outweighs the desire to be generic. The nice thing is we can provide a generic function which will work for all arches (albiet a little big and slow) - This will help when switching an arch over as there is, at least, a default implementation much like all the string functions (off topic, but why aren't they weak instead of #defined)

Quoted 54 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

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 to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. This is tricky mainly due to SPL. I believe that we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

Comments please...

The whole sequence of the series seems a little bit 'random' to me - I think patches 2 and 3 can be squahed and the dead code removal in patch 7 should be done in the same patch(es) that create the dead code.

Yes I can clean this up.

Quoted 3 lines

It looks like reloc_make_copy(), reloc_clear_bss() and reloc_elf() have been poached from x86 - The copy and clear loops are quite inefficient. I have patches at home which change these to use memcpy and memset

Yes they have - in fact I have a series here which unifies board.c completely for ARM and x86. But I need to take this in baby steps as I said.

Quoted 20 lines
Quoted 11 lines
Quoted 8 lines

Seems like a good idea. Got some size's before and after? Maybe some boot times too (as you mention 2000-odd function calls during relocation) ?

--
Tom

Yes I have this info - will package it up tomorrow along with a new series to deal with review comments.

As far as I understand it, the long-term plan is to unify the board init sequence across all architectures. I can see three approaches:

1) Tweak each arch until they are all the same and then 'throw the switch'
2) Pick one or two arches and 'throw the switch' on them and migrate the others later
3) Pull out common bits and pieced and deal with the left-overs later

Quoted 7 lines
Quoted 3 lines

It looks like you've opted for number 3. The problem I see in this approach is that you are relying on the other arches to follow your lead which is, at best, a 50/50 bet.

Sort of. Actually I have gone for option 2. But rather than send a series which switches over ARM and then x86 (about 40 patches) I have decided to do it in steps. Relocation is the first step.

OK, sounds like a plan

Quoted 8 lines
Quoted 5 lines

Now I look at board_init_f() and board_init_r() in ARM and x86 and think 'why on earth isn't most of than in the init loops?'. The boot sequence for ARM and x86 should be reducible to (all arches are generally pretty close to this, so it should not introduce too much pain when they decide to switch)

Yes my generic board.c consists of a couple of init loops. I can email the patch if you like but it is not ready for the mailing list.

Hmm, I don't think I have the time right now

Quoted 17 lines
Quoted 17 lines

- Low level init (reset vector etc)
- Setup temporary stack and gd storage (typically in CPU cache)
+ init_f loop <-- SDRAM initialised
- Move gd to RAM
- Setup new stack in SDRAM
- Turn on caching (cannot be done while gd and stack in cache!!!)
+ Calculate relocation address
+ Copy to RAM
+ Do relocation fixups
+ Clear BSS
- Jump to RAM
+ init_r loop
+ main_loop()

+ = common code
- = arch, SoC, or board specific

Quoted 8 lines
Quoted 6 lines

Note: Typically the boot sequence currently has 'Turn on caching' after jump to RAM - I have patches in the works which change this for x86

So my vote would be #2 - Unify the ARM and x86 and bring any code that can be inside the init loops in and then switch both over to a generic init implementation. Other arches can be switched later

Agreed, but I can't send a series that big, so I am doing it in stages.

Excellent - I don't have a huge amoun of spare time, but if you let me know what you need, I can probably give x86 a little prod here and there to align it with what you are doing. I already have a few patches, and Gabe has been doing a bit as well in order to make the coreboot port integrate more seamlessly.

Regards,

Graeme

#44 lore raw

cover reboard: Introduce generic relocation feature

In reply to Tom Rini

Hi Tomi,

Quoted 32 lines · Tom Rini
Quoted 31 lines · Simon Glass

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series creates a libboard library and implements relocation in it. 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.

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

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 to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. ?This is tricky mainly due to SPL. I believe that we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

Quoted 8 lines
Quoted 4 lines

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

Comments please...

Seems like a good idea. ?Got some size's before and after? ?Maybe some boot times too (as you mention 2000-odd function calls during relocation) ?

For my system it is currently 500us slower on a 320KB U-Boot binary (so adding 0.5ms to a 95ms pre-relocation stage), It is currently 350 bytes larger.

I will see what I can do about the code size, and I expect the performance penalty will reduce also, although it is already small.

Regards,
Simon

Quoted 3 lines

--
Tom

#45 lore raw

cover reboard: Introduce generic relocation feature

In reply to Simon Glass

Hi Simon,

Le 22/11/2011 00:57, Simon Glass a ?crit :

Quoted 9 lines

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series creates a libboard library and implements relocation in it. 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.

Agreed.

Quoted 5 lines

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

NAK -- a generic relocation function should be not be in board/, it should be in lib/

Quoted 4 lines

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.

As commented in detail, I am not sure creating a function for three asm instructions is worthwhile. The overhead for calling the code might be bigger than the body of the function. Did you compare with inline functions with asm statements and/or intrinsics?

Quoted 5 lines

It may be useful for other architectures to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. This is tricky mainly due to SPL.

Can you develop what the issue is with SPL exactly?

Quoted 8 lines

I believe that
we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

This would not cause an error, but Wolfgang would have to "OK' the post, which is a good thing if many people are involved. :)

Quoted 1 line

Comments please...

Generic comment is that the patch is not about generic *board*. It is about generic *relocation*, which is not a thing of boards IMO: it is not related to peripheral or HW configuration, and is not actually memory-mapped related.

Other than that, as stated in the detailed answers, we need to keep the relocation code as efficient as possible. As happy as I am to see the ELF relocation code rewritten in C for easy understanding and maintenance, I would not want it done at the expense of speed or overall architecture soundness. So:

- the C relocation code (both the generic function and the ELF specific code) are neither board-related nor ARM-specific, so it has no reason to reside in board/ or arch/arm. My first reflex was lib/, but indeed common/ might be a better place.

- the relocation function should be as efficient as possible. Compared numbers between 'before' and 'after' should also be provided -- I do not necessarily expect the same or better performance, but we need to assess what the performance issue is.

- I would prefer each patch to be as self-contained as possible -- 'preparatory' patches I don't like much. For instance, to relace ASM relocation with C relocation, I would want a single patch introducing the C code and removing the ASM code or moving it out of the way.

- I am not sure why the code should be "early" or, more precisely, should be specifically located in the linker file: any code in there is accessible at any time, and the only special case is for _start because we want it to be first in placement, not in time. Can you clarify this 'early' issue?

- indeed I would prefer a weak symbol for the relocation function. This would allow a given config to easily override the generic C code if needed.

Amicalement,

Signature · 1 line
Albert.
#46 lore raw

cover reboard: Introduce generic relocation feature

Hi Albert,

Quoted 25 lines · Albert ARIBAUD

Hi Simon,

Le 22/11/2011 00:57, Simon Glass a ?crit :

Quoted 9 lines

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series creates a libboard library and implements relocation in it. 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.

Agreed.

Quoted 5 lines

This series establishes a new libboard library in the board/ subdir and puts some relocation code in it. Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. If there is concern about calling a function for all 2000-odd relocations then I can change this.

Quoted 2 lines

NAK -- a generic relocation function should be not be in board/, it should be in lib/

Well based on your other comments I have gone with common/ for now.

Quoted 8 lines
Quoted 6 lines

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.

Quoted 4 lines

As commented in detail, I am not sure creating a function for three asm instructions is worthwhile. The overhead for calling the code might be bigger than the body of the function. Did you compare with inline functions with asm statements and/or intrinsics?

Well it still needs the I$ stuff and other archs may need more. It could be an inline function, but what would be the benefit? No time or code size saving I think.

Quoted 10 lines
Quoted 7 lines

It may be useful for other architectures to have a similar file.

This series moves ARM over to use this framework. Overall this means that two new files are required 'early' in boot: board/reloc.c and arch/arm/lib/proc.S. ?This is tricky mainly due to SPL.

Can you develop what the issue is with SPL exactly?

Well it is just that SPL brings in source files from around U-Boot and builds them into an image. If we add a new object file which is needed by SPL then we may need to change all those Makefiles. I don't think that applies to relocation luckily. We will hit this issue anytime we move code out of start.S.

Quoted 8 lines
Quoted 8 lines

I believe that
we may need to adjust link scripts to put these two files early in the link scripts also. But I am not sure about this and can't actually find a problem as yet. I would much prefer to solve this with a new section name like .text.early if we can.

Quoted 6 lines
Quoted 2 lines

(I should really cc all arch maintainers but I think in that case I get an error from the list server. Not sure what the limit is.)

This would not cause an error, but Wolfgang would have to "OK' the post, which is a good thing if many people are involved. :)

OK, well I may try that with the next revision.

Quoted 8 lines
Quoted 2 lines

Comments please...

Generic comment is that the patch is not about generic *board*. It is about generic *relocation*, which is not a thing of boards IMO: it is not related to peripheral or HW configuration, and is not actually memory-mapped related.

Well it is the first thing I have chosen to deal with on the path to a generic board.c. Relocation is a large part of what arch/xxx/lib/board.c currently does. And after all I am actually moving it out of board.c.

Quoted 11 lines

Other than that, as stated in the detailed answers, we need to keep the relocation code as efficient as possible. As happy as I am to see the ELF relocation code rewritten in C for easy understanding and maintenance, I would not want it done at the expense of speed or overall architecture soundness. So:

- the C relocation code (both the generic function and the ELF specific code) are neither board-related nor ARM-specific, so it has no reason to reside in board/ or arch/arm. My first reflex was lib/, but indeed common/ might be a better place.

ok

Quoted 5 lines

- the relocation function should be as efficient as possible. Compared numbers between 'before' and 'after' should also be provided -- I do not necessarily expect the same or better performance, but we need to assess what the performance issue is.

I sent some numbers, but hope to improve on them.

Quoted 5 lines

- I would prefer each patch to be as self-contained as possible -- 'preparatory' patches I don't like much. For instance, to relace ASM relocation with C relocation, I would want a single patch introducing the C code and removing the ASM code or moving it out of the way.

Well that's a bit tricky unless you want be to replace the code in start.S to call my proc.S function, just before I delete the code in start.S!

Quoted 5 lines

- I am not sure why the code should be "early" or, more precisely, should be specifically located in the linker file: any code in there is accessible at any time, and the only special case is for _start because we want it to be first in placement, not in time. Can you clarify this 'early' issue?

I was referring to SPL, but I think we have established that it shouldn't matter.

Quoted 3 lines

- indeed I would prefer a weak symbol for the relocation function. This would allow a given config to easily override the generic C code if needed.

Ok.

Quoted 4 lines

Amicalement,
--
Albert.

Regards,
Simon