Skip to contentSkip to conversation

Introduce generic relocation feature

PATCH Superseded Simon Glass 8 participants 49 messages Feb 21, 2012 – Mar 11, 2012 1 message not in the archive

Subsystems (12)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Introduce generic relocation feature

(This series has trivial conflicts with the generic board series in the arch/xxx/config.mk additions and also in that they both add include/linux/sections.h. I original had this series first in my list, but the generic board series now also applies directly to master, so I will leave this one as is until I know what ordering is required.)

This is the second patch series aiming to unify the various board.c files in each architecture into a single one. This series implements a generic relocation feature, which is the bridge between board_init_f() and board_init_r(). It then moves ARM over to use this framework, as an example.

On ARM the relocation code is duplicated for each CPU yet it is the same. We can bring this up to the arch level. But since (I believe) Elf relocation is basically the same process for all archs, there is no reason not to bring it up to the generic level.

Each architecture which uses this framework needs to provide a function called arch_elf_relocate_entry() which processes a single relocation entry. This is a static inline function to reduce code size overhead.

For ARM, a new arch/arm/lib/proc.S file is created, which holds generic ARM assembler code (things that cannot be written in C and are common functions used by all ARM CPUs). This helps reduce duplication. Interrupt handling code and perhaps even some startup code can move there later.

It may be useful for other architectures with a lot of different CPUs to have a similar file.

Code size on my ARMv7 system increases by 54 bytes with generic relocation. This overhead is mostly just literal pool access and setting up to call the relocated U-Boot at the end.

On my system, execution time increases from 10.8ms to 15.6ms due to the less efficient C implementations of the copy and zero loops. If execution time is of concern, you can define CONFIG_USE_ARCH_MEMSET and CONFIG_USE_ARCH_MEMCPY to reduce it. For me this reduces relocation time to 5.4ms, i.e. twice as fast as the old system.

To address the build failure in tx25 I have split out the memset()/memcpy() functions into their own file. I believe this is somewhat justified by the fact that they are now used for relocation, independently of what other part of U-Boot may or may not use the string functions. The problem with linking with the whole string.o object file is that the code size is too large for highly-constrained SPL builds which don't have -ffunction-sections defined.

Changes in v2:
- Add README file for relocation
- Add function comments
- Import asm-generic/sections.h from Linux and add U-Boot extras
- Make relocation symbols global so we can use them outside start.S
- Move reloc.c into common/
- Squash generic link symbols patch into generic relocation patch
- Use CONFIG_SYS_SKIP_RELOC instead of CONFIG_SYS_LEGACY_BOARD
- Use an inline relocation function to reduce code size
- Use memset, memcpy instead of inline code

Changes in v3:
- Rebase to master
- Remove the 'reloc' tag from each commit

Changes in v4:
- Add new patch to fix davinci build warnings
- Add new patch to fix smdk6400 with generic relocation
- Add new patch to separate out memcpy(), memset()
- Capital D on Define of CONFIG_SYS_SKIP_RELOC commit message
- Put start_call_board_init_r() into each start.S, sadly
- Rebase to master, also bring in ARM master
- Remove proc.S file from Makefiles
- Split out board changes into separate patches
- Split out change to move relocation symbols to top of start.S files
- Split out hawkboard changes into new patch
- Split out mx31pdk changes into new patch
- Split out start_call_board_init_r() addition into new patch
- Split out tx25 changes into new patch
- Update start.S pruning to fit with early patches
- Use renamed start_call_board_init_r() function

Simon Glass (13):
Define CONFIG_SYS_SKIP_RELOC for all archs
Add generic relocation feature
arm: Export and promote relocation symbols
arm: Add start_call_board_init_r() to each start.S Move memcpy(), memset() into new lib/membasic.c
arm: Add explicit __image_copy_end symbol for ARM926EJ-S
davinci: Use correct #ifdef around gdata/bdata
tx25: Modify to work with generic relocation
hawkboard: Modify to work with generic relocation
mx31pdk: Modify to work with generic relocation
smdk6400: Modify to work with generic relocation
arm: Move over to generic relocation
arm: Remove unused code in start.S

 README                                      |    4 +
 arch/arm/cpu/arm1136/start.S                |  142 +++--------------
 arch/arm/cpu/arm1176/start.S                |  221 +++-----------------------
 arch/arm/cpu/arm720t/start.S                |  136 +++-------------
 arch/arm/cpu/arm920t/start.S                |  144 +++--------------
 arch/arm/cpu/arm925t/start.S                |  144 +++--------------
 arch/arm/cpu/arm926ejs/davinci/spl.c        |    2 +
 arch/arm/cpu/arm926ejs/start.S              |  157 ++++---------------
 arch/arm/cpu/arm926ejs/u-boot.lds           |    2 +
 arch/arm/cpu/arm946es/start.S               |  139 +++--------------
 arch/arm/cpu/arm_intcm/start.S              |  144 +++--------------
 arch/arm/cpu/armv7/start.S                  |  142 +++--------------
 arch/arm/cpu/ixp/start.S                    |  136 +++-------------
 arch/arm/cpu/lh7a40x/start.S                |  133 +++-------------
 arch/arm/cpu/pxa/start.S                    |  147 +++---------------
 arch/arm/cpu/s3c44b0/start.S                |  136 +++-------------
 arch/arm/cpu/sa1100/start.S                 |  133 +++-------------
 arch/arm/include/asm/reloc.h                |   56 +++++++
 arch/avr32/config.mk                        |    3 +
 arch/blackfin/config.mk                     |    3 +
 arch/m68k/config.mk                         |    3 +
 arch/microblaze/config.mk                   |    3 +
 arch/mips/config.mk                         |    3 +
 arch/nds32/config.mk                        |    3 +
 arch/nios2/config.mk                        |    3 +
 arch/powerpc/config.mk                      |    3 +
 arch/sandbox/config.mk                      |    3 +
 arch/sh/config.mk                           |    3 +
 arch/sparc/config.mk                        |    3 +
 arch/x86/config.mk                          |    3 +
 board/davinci/da8xxevm/u-boot-spl-hawk.lds  |    1 +
 common/Makefile                             |    4 +
 common/reloc.c                              |  121 +++++++++++++++
 doc/README.relocation                       |   87 +++++++++++
 include/asm-generic/sections.h              |   92 +++++++++++
 include/configs/hawkboard.h                 |    2 +
 include/configs/tx25.h                      |    2 +
 include/reloc.h                             |   17 ++-
 lib/Makefile                                |    1 +
 lib/membasic.c                              |  103 +++++++++++++
 lib/string.c                                |   71 ---------
 nand_spl/board/freescale/mx31pdk/Makefile   |    6 +
 nand_spl/board/freescale/mx31pdk/u-boot.lds |    1 +
 nand_spl/board/karo/tx25/Makefile           |   11 ++-
 nand_spl/board/karo/tx25/u-boot.lds         |    1 +
 nand_spl/board/samsung/smdk6400/Makefile    |   11 ++
 46 files changed, 924 insertions(+), 1761 deletions(-)
 create mode 100644 arch/arm/include/asm/reloc.h
 create mode 100644 common/reloc.c
 create mode 100644 doc/README.relocation
 create mode 100644 include/asm-generic/sections.h
 create mode 100644 lib/membasic.c
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH v4 1/13 Define CONFIG_SYS_SKIP_RELOC for all archs

We are introducing a new generic relocation features and we want this to be the default. So we need to opt all architectures out first. Some may never have relocation, but those that do will eventually move over to this generic relocation framework.

This is part of the unified board effort, but since we are only dealing with relocation in this series, CONFIG_SYS_SKIP_RELOC is more appropriate than CONFIG_SYS_LEGACY_BOARD.

---
Changes in v2:
- Use CONFIG_SYS_SKIP_RELOC instead of CONFIG_SYS_LEGACY_BOARD

Changes in v4:
- Capital D on Define of CONFIG_SYS_SKIP_RELOC commit message

 README                    |    4 ++++
 arch/arm/config.mk        |    3 +++
 arch/avr32/config.mk      |    3 +++
 arch/blackfin/config.mk   |    3 +++
 arch/m68k/config.mk       |    3 +++
 arch/microblaze/config.mk |    3 +++
 arch/mips/config.mk       |    3 +++
 arch/nds32/config.mk      |    3 +++
 arch/nios2/config.mk      |    3 +++
 arch/powerpc/config.mk    |    3 +++
 arch/sandbox/config.mk    |    3 +++
 arch/sh/config.mk         |    3 +++
 arch/sparc/config.mk      |    3 +++
 arch/x86/config.mk        |    3 +++
 14 files changed, 43 insertions(+), 0 deletions(-)
README +4 -0
index 8964672..cbec491 100644
@@ -2770,6 +2770,10 @@ Configuration Settings:
 	cases. This setting can be used to tune behaviour; see
 	lib/hashtable.c for details.
 
+- CONFIG_SYS_SKIP_RELOC
+	This makes U-Boot skip relocation for those architectures which
+	don't support it. It is normally defined in arch/xxx/config.mk
+
 The following definitions that deal with the placement and management
 of environment data (variable area); in general, we support the
 following configurations:
arch/arm/config.mk +3 -0
index 45f9dca..f47d4f7 100644
@@ -81,3 +81,6 @@ endif
 ifndef CONFIG_NAND_SPL
 LDFLAGS_u-boot += -pie
 endif
+
+# We use legacy relocation for now
+CONFIG_SYS_SKIP_RELOC := y
arch/avr32/config.mk +3 -0
index d8e7ebb..1995983 100644
@@ -31,3 +31,6 @@ PLATFORM_RELFLAGS	+= -ffunction-sections -fdata-sections
 LDFLAGS_u-boot		= --gc-sections --relax
 
 LDSCRIPT			= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+# We use legacy relocation for now
+CONFIG_SYS_SKIP_RELOC := y
arch/blackfin/config.mk +3 -0
index 3595aa2..56047c8 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
 
+# Blackfin does not do relocation
+CONFIG_SYS_SKIP_RELOC := y
+
 LDFLAGS_FINAL += --gc-sections
 LDFLAGS += -m elf32bfin
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
arch/m68k/config.mk +3 -0
index 11ba334..52bfc81 100644
@@ -29,3 +29,6 @@ PLATFORM_CPPFLAGS += -DCONFIG_M68K -D__M68K__
 PLATFORM_LDFLAGS  += -n
 PLATFORM_RELFLAGS              += -ffunction-sections -fdata-sections
 LDFLAGS_FINAL                  += --gc-sections
+
+# We use legacy relocation for now
+CONFIG_SYS_SKIP_RELOC := y
arch/microblaze/config.mk +3 -0
index abea70b..7645f2e 100644
@@ -29,3 +29,6 @@ CROSS_COMPILE ?= mb-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
 
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
+
+# Microblaze does not do relocation
+CONFIG_SYS_SKIP_RELOC := y
arch/mips/config.mk +3 -0
index 6ab8acd..832b93f 100644
@@ -52,3 +52,6 @@ PLATFORM_CPPFLAGS		+= -msoft-float
 PLATFORM_LDFLAGS		+= -G 0 -static -n -nostdlib
 PLATFORM_RELFLAGS		+= -ffunction-sections -fdata-sections
 LDFLAGS_FINAL			+= --gc-sections
+
+# We use legacy relocation for now
+CONFIG_SYS_SKIP_RELOC := y
arch/nds32/config.mk +3 -0
index c589829..4a4499b 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
+
+# We use legacy relocation for now
+CONFIG_SYS_SKIP_RELOC := y
arch/nios2/config.mk +3 -0
index 7b03ed8..cde7f82 100644
@@ -31,3 +31,6 @@ PLATFORM_CPPFLAGS += -G0
 
 LDFLAGS_FINAL += --gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+
+# NIOS2 does not do relocation
+CONFIG_SYS_SKIP_RELOC := y
arch/powerpc/config.mk +3 -0
index a307154..eba562f 100644
@@ -42,3 +42,6 @@ endif
 ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
 PLATFORM_CPPFLAGS+= -D__PPC__
 endif
+
+# We use legacy relocation for now
+CONFIG_SYS_SKIP_RELOC := y
arch/sandbox/config.mk +3 -0
index 2ec1bb7..d71326f 100644
@@ -19,3 +19,6 @@
 
 PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__
 PLATFORM_LIBS += -lrt
+
+# Sandbox does not do relocation
+CONFIG_SYS_SKIP_RELOC := y
arch/sh/config.mk +3 -0
index 07ff8b9..48a7b37 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
+
+# SH does not do relocation
+CONFIG_SYS_SKIP_RELOC := y
arch/sparc/config.mk +3 -0
index cae7478..032659c 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__
+
+# Sparc does not do relocation
+CONFIG_SYS_SKIP_RELOC := y
arch/x86/config.mk +3 -0
index 23cacff..11f3d18 100644
@@ -48,3 +48,6 @@ NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
 PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC))
 
 export USE_PRIVATE_LIBGCC=$(shell dirname $(PREFIXED_LIBGCC))
+
+# We use legacy relocation for now
+CONFIG_SYS_SKIP_RELOC := y
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH v4 1/13 Define CONFIG_SYS_SKIP_RELOC for all archs

Quoted 6 lines · On Monday 20 February 2012 20:32:43 Simon Glass wrote:
 README                    |    4 ++++
 arch/arm/config.mk        |    3 +++
 arch/avr32/config.mk      |    3 +++
 arch/blackfin/config.mk   |    3 +++
 arch/m68k/config.mk       |    3 +++
 arch/microblaze/config.mk |    3 +++
Quoted 8 lines
 arch/mips/config.mk       |    3 +++
 arch/nds32/config.mk      |    3 +++
 arch/nios2/config.mk      |    3 +++
 arch/powerpc/config.mk    |    3 +++
 arch/sandbox/config.mk    |    3 +++
 arch/sh/config.mk         |    3 +++
 arch/sparc/config.mk      |    3 +++
 arch/x86/config.mk        |    3 +++

why config.mk and not asm/config.h ?
-mike
-------------- 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/20120306/0382daf4/attachment.pgp>

#3 lore raw

PATCH v4 1/13 Define CONFIG_SYS_SKIP_RELOC for all archs

Hi Mike,

Quoted 16 lines · Mike Frysinger
Quoted 6 lines · On Monday 20 February 2012 20:32:43 Simon Glass wrote:
?README ? ? ? ? ? ? ? ? ? ?| ? ?4 ++++
?arch/arm/config.mk ? ? ? ?| ? ?3 +++
?arch/avr32/config.mk ? ? ?| ? ?3 +++
?arch/blackfin/config.mk ? | ? ?3 +++
?arch/m68k/config.mk ? ? ? | ? ?3 +++
?arch/microblaze/config.mk | ? ?3 +++
Quoted 8 lines
?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 +++
Quoted 1 line

why config.mk and not asm/config.h ?

Actually I think it would be better in asm/config.h. I hope that most of these will be removed in time. I will update the patch.

Regards,
Simon

Quoted 1 line

-mike

#4 lore raw

PATCH v4 2/13 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.

We create a separate header file for link symbols defined by the link scripts. It is helpful to have these all in one place and try to make them common across architectures. Since Linux already has a similar file, we bring this in even though many of the symbols there are not relevant to us.

The __relocate_code() function is what we expect all architectures which support relocation will use eventually. For now, they all override this with their own version.

Note: The conflict with the generic board series is that the file include/asm-generic/sections.h is created in both. This should be easy to resolve once we know the order in which these series will be applied.

---
Changes in v2:
- Add README file for relocation
- Add function comments
- Import asm-generic/sections.h from Linux and add U-Boot extras
- Move reloc.c into common/
- Squash generic link symbols patch into generic relocation patch
- Use memset, memcpy instead of inline code

Changes in v4:
- Use renamed start_call_board_init_r() function

 common/Makefile                |    4 +
 common/reloc.c                 |  121 ++++++++++++++++++++++++++++++++++++++++
 doc/README.relocation          |   87 ++++++++++++++++++++++++++++
 include/asm-generic/sections.h |   92 ++++++++++++++++++++++++++++++
 include/reloc.h                |   17 +++++-
 5 files changed, 320 insertions(+), 1 deletions(-)
 create mode 100644 common/reloc.c
 create mode 100644 doc/README.relocation
 create mode 100644 include/asm-generic/sections.h
common/Makefile +4 -0
index 2d9ae8c..3801c28 100644
@@ -189,6 +189,10 @@ COBJS-y += dlmalloc.o
 COBJS-y += memsize.o
 COBJS-y += stdio.o
 
+ifndef CONFIG_SYS_SKIP_RELOC
+COBJS-y += reloc.o
+endif
+
 
 COBJS	:= $(sort $(COBJS-y))
 XCOBJS	:= $(sort $(XCOBJS-y))
common/reloc.c new file +121 -0

121 lines not on this page · raw message

doc/README.relocation new file +87 -0

87 lines not on this page · raw message

include/asm-generic/sections.h new file +92 -0

92 lines not on this page · raw message

include/reloc.h +16 -1
index 3dc7b85..2a8778e 100644
@@ -23,12 +23,27 @@
 #ifndef __RELOC_H
 #define __RELOC_H
 
+/* This is the prototype for the post-relocation init function */
+typedef void (*board_init_r_func)(gd_t *, ulong);
+
+/**
+ * Call the relocated U-Boot. This is the last thing that is done after
+ * relocation. This function does not return.
+ *
+ * @param new_gd		Pointer to the relocated global data
+ * @param dest_addr		Base code address of relocated U-Boot
+ * @param board_init_r_func	Pointer to relocated function to call
+ */
+void start_call_board_init_r(gd_t *new_gd, ulong dest_addr,
+		board_init_r_func board_init_r, ulong dest_addr_sp)
+		__attribute__ ((noreturn));
+
 /**
  * Relocate U-Boot and jump to the relocated coded
  *
  * This copies U-Boot to a new location, zeroes the BSS, sets up a new stack
  * and jumps to board_init_r() in the relocated code using the
- * proc_call_board_init_r() function. It does not return.
+ * start_call_board_init_r() function. It does not return.
  *
  * @param dest_sp	New stack pointer to use
  * @param new_gd	Pointer to the relocated global data
Signature · 1 line
1.7.7.3
#5 lore raw

PATCH v4 2/13 Add generic relocation feature

Hi Simon,

Le 21/02/2012 02:32, Simon Glass a ?crit :

Quoted 3 lines

The __relocate_code() function is what we expect all architectures which support relocation will use eventually. For now, they all override this with their own version.

Why the double underscore?

Amicalement,

Signature · 1 line
Albert.
#6 lore raw

PATCH v4 2/13 Add generic relocation feature

Hi Albert,

Quoted 11 lines · Albert ARIBAUD

Hi Simon,

Le 21/02/2012 02:32, Simon Glass a ?crit :

Quoted 3 lines

The __relocate_code() function is what we expect all architectures which support relocation will use eventually. For now, they all override this with their own version.

Why the double underscore?

It is a default implementation of relocate_code() - a weak function alias. It seems that this is the naming convention used in U-Boot for this, but I'm not sure why.

Quoted 4 lines

Amicalement,
--
Albert.

Regards,
Simon

#7 lore raw

PATCH v4 3/13 arm: Export and promote relocation symbols

In reply to Simon Glass

These symbols are currently part-way through each file. Most have the same code, but there are small variations.

We move all these relocation symbols to the start next to the other exported symbols, and export them so we can use them in generic relocation code.

---
Changes in v4:
- Split out change to move relocation symbols to top of start.S files

 arch/arm/cpu/arm1136/start.S   |   19 ++++++++++++-------
 arch/arm/cpu/arm1176/start.S   |   19 ++++++++++++-------
 arch/arm/cpu/arm720t/start.S   |   19 ++++++++++++-------
 arch/arm/cpu/arm920t/start.S   |   19 ++++++++++++-------
 arch/arm/cpu/arm925t/start.S   |   19 ++++++++++++-------
 arch/arm/cpu/arm926ejs/start.S |   19 ++++++++++++-------
 arch/arm/cpu/arm946es/start.S  |   19 ++++++++++++-------
 arch/arm/cpu/arm_intcm/start.S |   19 ++++++++++++-------
 arch/arm/cpu/armv7/start.S     |   20 ++++++++++++++------
 arch/arm/cpu/ixp/start.S       |   19 ++++++++++++-------
 arch/arm/cpu/lh7a40x/start.S   |   19 ++++++++++++-------
 arch/arm/cpu/pxa/start.S       |   18 ++++++++++++------
 arch/arm/cpu/s3c44b0/start.S   |   19 ++++++++++++-------
 arch/arm/cpu/sa1100/start.S    |   19 ++++++++++++-------
 14 files changed, 170 insertions(+), 96 deletions(-)
arch/arm/cpu/arm1136/start.S +12 -7
index c0db96c..28e059e 100644
@@ -108,6 +108,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -283,13 +295,6 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/arm1176/start.S +12 -7
index 848144a..0c749b4 100644
@@ -127,6 +127,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 /* IRQ stack memory (calculated at run-time) + 8 bytes */
 .globl IRQ_STACK_START_IN
 IRQ_STACK_START_IN:
@@ -385,13 +397,6 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 #ifdef CONFIG_ENABLE_MMU
 _mmu_table_base:
 	.word mmu_table
arch/arm/cpu/arm720t/start.S +12 -7
index 540e3c2..80814d6 100644
@@ -97,6 +97,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -254,13 +266,6 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/arm920t/start.S +12 -7
index 8c5612c..57b2b59 100644
@@ -93,6 +93,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -305,13 +317,6 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/arm925t/start.S +12 -7
index dbb93ef..5dafc11 100644
@@ -103,6 +103,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -299,13 +311,6 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/arm926ejs/start.S +12 -7
index 6f05f1a..6b8fdc5 100644
@@ -160,6 +160,18 @@ _end:
 	.word __bss_end__
 #endif
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -338,13 +350,6 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/arm946es/start.S +12 -7
index 89ba558..448979f 100644
@@ -109,6 +109,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -265,13 +277,6 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/arm_intcm/start.S +12 -7
index 2033b36..7a9dbd1 100644
@@ -105,6 +105,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -266,13 +278,6 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/armv7/start.S +14 -6
index ef08a55..8a616fa 100644
@@ -101,6 +101,20 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+#ifndef CONFIG_SPL_BUILD
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+#endif
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -236,12 +250,6 @@ fixnext:
 	cmp	r2, r3
 	blo	fixloop
 	b	clear_bss
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
 
 #endif	/* #ifndef CONFIG_SPL_BUILD */
 
arch/arm/cpu/ixp/start.S +12 -7
index cb32121..68d8029 100644
@@ -118,6 +118,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -360,13 +372,6 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /****************************************************************************/
 /*									    */
 /* Interrupt handling							    */
arch/arm/cpu/lh7a40x/start.S +12 -7
index 62de8b8..3274f43 100644
@@ -93,6 +93,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -268,13 +280,6 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/pxa/start.S +12 -6
index ba0de8f..9de1a4a 100644
@@ -126,6 +126,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -290,12 +302,6 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
 #endif
 /*
  *************************************************************************
arch/arm/cpu/s3c44b0/start.S +12 -7
index a29d5b4..ffb3ebf 100644
@@ -84,6 +84,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -243,13 +255,6 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
arch/arm/cpu/sa1100/start.S +12 -7
index 92546d8..168b11f 100644
@@ -94,6 +94,18 @@ _bss_end_ofs:
 _end_ofs:
 	.word _end - _start
 
+.globl _rel_dyn_start_ofs
+_rel_dyn_start_ofs:
+	.word __rel_dyn_start - _start
+
+.globl _rel_dyn_end_ofs
+_rel_dyn_end_ofs:
+	.word __rel_dyn_end - _start
+
+.globl _dynsym_start_ofs
+_dynsym_start_ofs:
+	.word __dynsym_start - _start
+
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
 .globl IRQ_STACK_START
@@ -244,13 +256,6 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
-_rel_dyn_start_ofs:
-	.word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
-	.word __rel_dyn_end - _start
-_dynsym_start_ofs:
-	.word __dynsym_start - _start
-
 /*
  *************************************************************************
  *
Signature · 1 line
1.7.7.3
#8 lore raw

PATCH v4 4/13 arm: Add start_call_board_init_r() to each start.S

In reply to Simon Glass

We don't want this in a common file, or at least not yet, so add this function to every start.S individually. The existing code tacked on the end of a long relocation function and does not suit our needs since it doesn't allow the address of board_init_r() to be passed in and cannot be called from C since it expects values in registers r4 and above.

---
Changes in v4:
- Put start_call_board_init_r() into each start.S, sadly
- Split out start_call_board_init_r() addition into new patch

 arch/arm/cpu/arm1136/start.S   |   19 +++++++++++++++++++
 arch/arm/cpu/arm1176/start.S   |   19 +++++++++++++++++++
 arch/arm/cpu/arm720t/start.S   |   19 +++++++++++++++++++
 arch/arm/cpu/arm920t/start.S   |   19 +++++++++++++++++++
 arch/arm/cpu/arm925t/start.S   |   19 +++++++++++++++++++
 arch/arm/cpu/arm926ejs/start.S |   19 +++++++++++++++++++
 arch/arm/cpu/arm946es/start.S  |   19 +++++++++++++++++++
 arch/arm/cpu/arm_intcm/start.S |   19 +++++++++++++++++++
 arch/arm/cpu/armv7/start.S     |   19 +++++++++++++++++++
 arch/arm/cpu/ixp/start.S       |   19 +++++++++++++++++++
 arch/arm/cpu/lh7a40x/start.S   |   19 +++++++++++++++++++
 arch/arm/cpu/pxa/start.S       |   20 ++++++++++++++++++++
 arch/arm/cpu/s3c44b0/start.S   |   19 +++++++++++++++++++
 arch/arm/cpu/sa1100/start.S    |   19 +++++++++++++++++++
 14 files changed, 267 insertions(+), 0 deletions(-)
arch/arm/cpu/arm1136/start.S +19 -0
index 28e059e..e74d5f9 100644
@@ -295,6 +295,25 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/arm1176/start.S +19 -0
index 0c749b4..7fc6a18 100644
@@ -397,6 +397,25 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 #ifdef CONFIG_ENABLE_MMU
 _mmu_table_base:
 	.word mmu_table
arch/arm/cpu/arm720t/start.S +19 -0
index 80814d6..cdbe751 100644
@@ -266,6 +266,25 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/arm920t/start.S +19 -0
index 57b2b59..3257df6 100644
@@ -317,6 +317,25 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/arm925t/start.S +19 -0
index 5dafc11..b9181bf 100644
@@ -311,6 +311,25 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/arm926ejs/start.S +19 -0
index 6b8fdc5..2c8ff81 100644
@@ -350,6 +350,25 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/arm946es/start.S +19 -0
index 448979f..469a141 100644
@@ -277,6 +277,25 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/arm_intcm/start.S +19 -0
index 7a9dbd1..0e469e9 100644
@@ -278,6 +278,25 @@ _board_init_r_ofs:
 	.word board_init_r - _start
 #endif
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/armv7/start.S +19 -0
index 8a616fa..5581387 100644
@@ -298,6 +298,25 @@ jump_2_ram:
 _board_init_r_ofs:
 	.word board_init_r - _start
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*************************************************************************
  *
  * cpu_init_cp15
arch/arm/cpu/ixp/start.S +19 -0
index 68d8029..f00ad38 100644
@@ -372,6 +372,25 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /****************************************************************************/
 /*									    */
 /* Interrupt handling							    */
arch/arm/cpu/lh7a40x/start.S +19 -0
index 3274f43..48b8639 100644
@@ -280,6 +280,25 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/pxa/start.S +20 -0
index 9de1a4a..30f15b6 100644
@@ -303,6 +303,26 @@ _board_init_r_ofs:
 #endif
 
 #endif
+
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/s3c44b0/start.S +19 -0
index ffb3ebf..f470f10 100644
@@ -255,6 +255,25 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
arch/arm/cpu/sa1100/start.S +19 -0
index 168b11f..fce6f87 100644
@@ -256,6 +256,25 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 _board_init_r_ofs:
 	.word board_init_r - _start
 
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:
+#ifndef CONFIG_SYS_ICACHE_OFF
+	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
+	mcr     p15, 0, r0, c7, c10, 4	@ DSB
+	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+#endif
+	mov	sp, r3
+	/* jump to it ... */
+	mov	pc, r2
+
 /*
  *************************************************************************
  *
Signature · 1 line
1.7.7.3
#9 lore raw

PATCH v4 4/13 arm: Add start_call_board_init_r() to each start.S

Hi Simon,

Le 21/02/2012 02:32, Simon Glass a ?crit :

Quoted 6 lines

We don't want this in a common file, or at least not yet, so add this function to every start.S individually. The existing code tacked on the end of a long relocation function and does not suit our needs since it doesn't allow the address of board_init_r() to be passed in and cannot be called from C since it expects values in registers r4 and above.

It is not really an addition, as every start.S file involved already has this sequence at the end of its relocate_code routine.

Quoted 27 lines

---
Changes in v4:
- Put start_call_board_init_r() into each start.S, sadly
- Split out start_call_board_init_r() addition into new patch

  arch/arm/cpu/arm1136/start.S   |   19 +++++++++++++++++++
  arch/arm/cpu/arm1176/start.S   |   19 +++++++++++++++++++
  arch/arm/cpu/arm720t/start.S   |   19 +++++++++++++++++++
  arch/arm/cpu/arm920t/start.S   |   19 +++++++++++++++++++
  arch/arm/cpu/arm925t/start.S   |   19 +++++++++++++++++++
  arch/arm/cpu/arm926ejs/start.S |   19 +++++++++++++++++++
  arch/arm/cpu/arm946es/start.S  |   19 +++++++++++++++++++
  arch/arm/cpu/arm_intcm/start.S |   19 +++++++++++++++++++
  arch/arm/cpu/armv7/start.S     |   19 +++++++++++++++++++
  arch/arm/cpu/ixp/start.S       |   19 +++++++++++++++++++
  arch/arm/cpu/lh7a40x/start.S   |   19 +++++++++++++++++++
  arch/arm/cpu/pxa/start.S       |   20 ++++++++++++++++++++
  arch/arm/cpu/s3c44b0/start.S   |   19 +++++++++++++++++++
  arch/arm/cpu/sa1100/start.S    |   19 +++++++++++++++++++
  14 files changed, 267 insertions(+), 0 deletions(-)
arch/arm/cpu/arm1136/start.S +0 -0
index 28e059e..e74d5f9 100644

arch/arm/cpu/arm1136/start.S _board_init_r_ofs: · line 298

Quoted 4 lines
arch/arm/cpu/arm1136/start.S +1 -0
@@ -295,6 +295,25 @@ _board_init_r_ofs:
  	.word board_init_r - _start
  #endif
 
+/**

Do we agree to Doxygen annotations in U-Boot?

arch/arm/cpu/arm1136/start.S _board_init_r_ofs: · line 307

Quoted 9 lines
arch/arm/cpu/arm1136/start.S +9 -0
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd	Pointer to global data
+ * @param dest_addr	Destination address from global data
+ * @param func	Address of board_init_r function (relocated)
+ * @param sp	New stack pointer
+ */
+.globl start_call_board_init_r
+start_call_board_init_r:

Why "start_call_board_init_r"? "start_" may mislead readers into thinking we're starting something there and finishing it elsewhere, and "call_board_init_r" doesn't tell we're switching stacks etc.

I suggest "pivot_to_board_init_r", in analogy with Linux 'pivot_root'. Other suggestions are welcome.

Better yet, we could avoid this new function altogether and make start.S much cleaner by rewriting the startup sequence as:

1. start.S sets up the initial stack
2. start.S calls C function board_init_f
3. board_init_f allocates initial GD and stores final stack, final GD, and final base address within initial GD, then returns normally
4. start.S sets up the final stack and final GD
4. start.S calls C function relocate_code using relevant GD fields as its arguments
5. relocate_code returns normally
6. start.S calls either nand_boot or board_init_r()

This way all the logic would be in start.S and board_init_f(), relocate_code() and board_init_r() would be simple and independent functions.

Amicalement,

Signature · 1 line
Albert.
#10 lore raw

PATCH v4 4/13 arm: Add start_call_board_init_r() to each start.S

Hi Albert,

Quoted 46 lines · Albert ARIBAUD

Hi Simon,

Le 21/02/2012 02:32, Simon Glass a ?crit :

Quoted 6 lines

We don't want this in a common file, or at least not yet, so add this function to every start.S individually. The existing code tacked on the end of a long relocation function and does not suit our needs since it doesn't allow the address of board_init_r() to be passed in and cannot be called from C since it expects values in registers r4 and above.

It is not really an addition, as every start.S file involved already has this sequence at the end of its relocate_code routine.

Quoted 30 lines

---
Changes in v4:
- Put start_call_board_init_r() into each start.S, sadly
- Split out start_call_board_init_r() addition into new patch

?arch/arm/cpu/arm1136/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm1176/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm720t/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm920t/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm925t/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm926ejs/start.S | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm946es/start.S ?| ? 19 +++++++++++++++++++
?arch/arm/cpu/arm_intcm/start.S | ? 19 +++++++++++++++++++
?arch/arm/cpu/armv7/start.S ? ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/ixp/start.S ? ? ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/lh7a40x/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/pxa/start.S ? ? ? | ? 20 ++++++++++++++++++++
?arch/arm/cpu/s3c44b0/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/sa1100/start.S ? ?| ? 19 +++++++++++++++++++

?14 files changed, 267 insertions(+), 0 deletions(-)

arch/arm/cpu/arm1136/start.S +0 -0
index 28e059e..e74d5f9 100644
@@ -295,6 +295,25 @@ _board_init_r_ofs:

? ? ? ?.word board_init_r - _start
?#endif

Quoted 4 lines
Quoted 1 line

+/**

Do we agree to Doxygen annotations in U-Boot?

I hope so, it makes things easy to read for those with editors that support it.

Quoted 13 lines
Quoted 11 lines

+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd ? Pointer to global data
+ * @param dest_addr ? ?Destination address from global data
+ * @param func Address of board_init_r function (relocated)
+ * @param sp ? New stack pointer
+ */
+.globl start_call_board_init_r +start_call_board_init_r:

Quoted 6 lines

Why "start_call_board_init_r"? "start_" may mislead readers into thinking we're starting something there and finishing it elsewhere, and "call_board_init_r" doesn't tell we're switching stacks etc.

I suggest "pivot_to_board_init_r", in analogy with Linux 'pivot_root'. Other suggestions are welcome.

OK I will go with pivot_to_board_init_r.

Quoted 14 lines

Better yet, we could avoid this new function altogether and make start.S much cleaner by rewriting the startup sequence as:

1. start.S sets up the initial stack
2. start.S calls C function board_init_f
3. board_init_f allocates initial GD and stores final stack, final GD, ? and final base address within initial GD, then returns normally
4. start.S sets up the final stack and final GD
4. start.S calls C function relocate_code using relevant GD fields ? as its arguments
5. relocate_code returns normally
6. start.S calls either nand_boot or board_init_r()

Quoted 3 lines

This way all the logic would be in start.S and board_init_f(), relocate_code() and board_init_r() would be simple and independent functions.

Please see the generic relocation effort which I think is a better place to put this. If you like I can revisit this once we have that sorted out.

Quoted 4 lines

Amicalement,
--
Albert.

Regards,
Simon

#11 lore raw

PATCH v4 4/13 arm: Add start_call_board_init_r() to each start.S

Hi Albert,

Quoted 70 lines · Simon Glass

Hi Albert,

Quoted 46 lines · Albert ARIBAUD

Hi Simon,

Le 21/02/2012 02:32, Simon Glass a ?crit :

Quoted 6 lines

We don't want this in a common file, or at least not yet, so add this function to every start.S individually. The existing code tacked on the end of a long relocation function and does not suit our needs since it doesn't allow the address of board_init_r() to be passed in and cannot be called from C since it expects values in registers r4 and above.

It is not really an addition, as every start.S file involved already has this sequence at the end of its relocate_code routine.

Quoted 30 lines

---
Changes in v4:
- Put start_call_board_init_r() into each start.S, sadly
- Split out start_call_board_init_r() addition into new patch

?arch/arm/cpu/arm1136/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm1176/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm720t/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm920t/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm925t/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm926ejs/start.S | ? 19 +++++++++++++++++++
?arch/arm/cpu/arm946es/start.S ?| ? 19 +++++++++++++++++++
?arch/arm/cpu/arm_intcm/start.S | ? 19 +++++++++++++++++++
?arch/arm/cpu/armv7/start.S ? ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/ixp/start.S ? ? ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/lh7a40x/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/pxa/start.S ? ? ? | ? 20 ++++++++++++++++++++
?arch/arm/cpu/s3c44b0/start.S ? | ? 19 +++++++++++++++++++
?arch/arm/cpu/sa1100/start.S ? ?| ? 19 +++++++++++++++++++

?14 files changed, 267 insertions(+), 0 deletions(-)

arch/arm/cpu/arm1136/start.S +0 -0
index 28e059e..e74d5f9 100644
@@ -295,6 +295,25 @@ _board_init_r_ofs:

? ? ? ?.word board_init_r - _start
?#endif

Quoted 4 lines
Quoted 1 line

+/**

Do we agree to Doxygen annotations in U-Boot?

I hope so, it makes things easy to read for those with editors that support it.

Quoted 13 lines
Quoted 11 lines

+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd ? Pointer to global data
+ * @param dest_addr ? ?Destination address from global data
+ * @param func Address of board_init_r function (relocated)
+ * @param sp ? New stack pointer
+ */
+.globl start_call_board_init_r +start_call_board_init_r:

Quoted 8 lines
Quoted 6 lines

Why "start_call_board_init_r"? "start_" may mislead readers into thinking we're starting something there and finishing it elsewhere, and "call_board_init_r" doesn't tell we're switching stacks etc.

I suggest "pivot_to_board_init_r", in analogy with Linux 'pivot_root'. Other suggestions are welcome.

OK I will go with pivot_to_board_init_r.

I have updated two of the patches to v5 to deal with this change.

Quoted 15 lines
Quoted 15 lines

Better yet, we could avoid this new function altogether and make start.S much cleaner by rewriting the startup sequence as:

1. start.S sets up the initial stack
2. start.S calls C function board_init_f
3. board_init_f allocates initial GD and stores final stack, final GD, ? and final base address within initial GD, then returns normally
4. start.S sets up the final stack and final GD
4. start.S calls C function relocate_code using relevant GD fields ? as its arguments
5. relocate_code returns normally
6. start.S calls either nand_boot or board_init_r()

Quoted 7 lines
Quoted 3 lines

This way all the logic would be in start.S and board_init_f(), relocate_code() and board_init_r() would be simple and independent functions.

Please see the generic relocation effort which I think is a better place to put this. If you like I can revisit this once we have that sorted out.

Sorry I meant the generic board init series. Once we have generic board init and generic relocation then everything becomes common. Then it might be easier to change the function signature of board_init_f() or board_init_r() if we want to.

One more point - as Graeme points out it would be nice to turn on the dcache earlier. Another thing to look at under generic board init I think.

Quoted 2 lines
Quoted 2 lines

Regards,
Simon

#12 lore raw

PATCH v4 5/13 Move memcpy(), memset() into new lib/membasic.c

In reply to Simon Glass

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.

Also tidy up the checkpatch warnings and function comments at the same time.

I considered splitting these into two separate files, but I think that is overkill. The justification is that these two functions are needed regardless of what the 'user' code in U-Boot does, just to support relocation.

---
Changes in v4:
- Add new patch to separate out memcpy(), memset()

 lib/Makefile   |    1 +
 lib/membasic.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/string.c   |   71 --------------------------------------
 3 files changed, 104 insertions(+), 71 deletions(-)
 create mode 100644 lib/membasic.c
lib/Makefile +1 -0
index e6e6ec6..0480824 100644
@@ -57,6 +57,7 @@ endif
 
 COBJS-y += ctype.o
 COBJS-y += div64.o
+COBJS-y += membasic.o
 COBJS-y += string.o
 COBJS-y += time.o
 COBJS-$(CONFIG_BOOTP_PXE) += uuid.o
lib/membasic.c new file +103 -0

103 lines not on this page · raw message

lib/string.c +0 -71

83 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#13 lore raw

PATCH v4 5/13 Move memcpy(), memset() into new lib/membasic.c

Quoted 3 lines · On Monday 20 February 2012 20:32:47 Simon Glass wrote:

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.

seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do. -mike
-------------- 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/20120306/96aa497c/attachment.pgp>

#14 lore raw

PATCH v4 5/13 Move memcpy(), memset() into new lib/membasic.c

Hi Mike,

Quoted 7 lines · Mike Frysinger
Quoted 3 lines · On Monday 20 February 2012 20:32:47 Simon Glass wrote:

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.

seems like fixing -f{data,function}-sections would be a more useful goal. ?i don't know why arm doesn't support this today ... it's fairly easy to do.

I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.

IXP does enable it, but not ARM in general. Most archs use function-sections although not all. Perhaps there are some boards which don't work with this flag?

Albert do you know?

Regards,
Simon

Quoted 1 line

-mike

#15 lore raw

PATCH v4 5/13 Move memcpy(), memset() into new lib/membasic.c

Quoted 10 lines · On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
Quoted 8 lines · Mike Frysinger
Quoted 3 lines · On Monday 20 February 2012 20:32:47 Simon Glass wrote:

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.

seems like fixing -f{data,function}-sections would be a more useful goal.
i don't know why arm doesn't support this today ... it's fairly easy to
do.

Quoted 5 lines

I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.

if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". plus, fixing this yields general improvements in anti-bloat for everyone.

function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.
-mike
-------------- 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/20120306/180a8acf/attachment.pgp>

#16 lore raw

PATCH v4 5/13 Move memcpy(), memset() into new lib/membasic.c

Hi Mike,

Quoted 17 lines · Mike Frysinger
Quoted 10 lines · On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
Quoted 8 lines · Mike Frysinger
Quoted 3 lines · On Monday 20 February 2012 20:32:47 Simon Glass wrote:

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.

seems like fixing -f{data,function}-sections would be a more useful goal. ?i don't know why arm doesn't support this today ... it's fairly easy to do.

Quoted 5 lines

I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.

Quoted 8 lines

if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". ?plus, fixing this yields general improvements in anti-bloat for everyone.

function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.

While I agree with you, I am not sure that I can enable that for ARM this late in the game.

If I enable -ffunction-sections for the tx25 spl build, I get:

$ make clean && make tx25_config && make -j20 -s
Configuring for tx25 board...
Generating include/generated/asm-offsets.h
string.o: In function `skip_spaces':
/home/sjg/trunk/src/third_party/u-boot/files/lib/string.c:229:
undefined reference to `_ctype'
string.o: In function `strim':
/home/sjg/trunk/src/third_party/u-boot/files/lib/string.c:255:
undefined reference to `_ctype'
string.o: In function `strdup':
/home/sjg/trunk/src/third_party/u-boot/files/lib/string.c:292:
undefined reference to `malloc'
make[1]: *** [/home/sjg/trunk/src/third_party/u-boot/files/nand_spl/u-boot-spl]
Error 1
make: *** [nand_spl] Error 2
make: *** Waiting for unfinished jobs....

The string.c library is using malloc() and ctype calls which are not in the build. If I add them to the build (and divide and various other things that aren't really needed) and enable -ffunction-sections I get a complete build but the result is a bit over 8KB instead of the original 2KB. The build does complete, though. Maybe just building is good enough for now, and we can deal any breakage next time?

Now I'm not sure if the tx25 can in fact deal with this, but it seems risky at this stage.

So in summary I wonder whether we should run with this simple split patch for now, and deal with moving ARM to -ffunction-sections in the next merge window, assuming Albert is keen on that idea? Alternatively I can update the tx25 patch (and perhaps1-2 others) to remove the need for this patch, with the possibility that these few boards will build but night not actually work.

Hmmm.

Regards,
Simon

Quoted 1 line

-mike

#17 lore raw

PATCH v4 5/13 Move memcpy(), memset() into new lib/membasic.c

In reply to Mike Frysinger

Hi Mike,

Quoted 17 lines · Mike Frysinger
Quoted 10 lines · On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
Quoted 8 lines · Mike Frysinger
Quoted 3 lines · On Monday 20 February 2012 20:32:47 Simon Glass wrote:

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.

seems like fixing -f{data,function}-sections would be a more useful goal. ?i don't know why arm doesn't support this today ... it's fairly easy to do.

Quoted 5 lines

I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.

Quoted 8 lines

if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". ?plus, fixing this yields general improvements in anti-bloat for everyone.

function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.

Can't the entry point be forced to be at the start of the u-boot image by putting that function in a dedicated section and specifying that section as the first in the linker script?

This has always bothered me:

#########################################################################
# U-Boot objects....order is important (i.e. start must be first)

OBJS = $(CPUDIR)/start.o
ifeq ($(CPU),x86)
OBJS += $(CPUDIR)/start16.o
OBJS += $(CPUDIR)/resetvec.o
endif
ifeq ($(CPU),ppc4xx)
OBJS += $(CPUDIR)/resetvec.o
endif
ifeq ($(CPU),mpc85xx)
OBJS += $(CPUDIR)/resetvec.o
endif

I've been meaning to get rid of this for x86 as I believe this can be adequately handled by putting the code in relevant sections and locating the sections at the correct location using the linker script.

For x86 there are only two requirements:
- The first byte of resetvec.o sits 16 bytes from the end of flash
- The first byte of start.o is the first byte of the core u-boot image (there is other cruft above it in the flash like an embedded kernel image)

Regards,

Graeme

#18 lore raw

PATCH v4 5/13 Move memcpy(), memset() into new lib/membasic.c

Hi Graeme,

Quoted 54 lines · Graeme Russ

Hi Mike,

Quoted 17 lines · Mike Frysinger
Quoted 10 lines · On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
Quoted 8 lines · Mike Frysinger
Quoted 3 lines · On Monday 20 February 2012 20:32:47 Simon Glass wrote:

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.

seems like fixing -f{data,function}-sections would be a more useful goal. ?i don't know why arm doesn't support this today ... it's fairly easy to do.

Quoted 5 lines

I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.

Quoted 8 lines

if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". ?plus, fixing this yields general improvements in anti-bloat for everyone.

function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.

Can't the entry point be forced to be at the start of the u-boot image by putting that function in a dedicated section and specifying that section as the first in the linker script?

This has always bothered me:

#########################################################################
# U-Boot objects....order is important (i.e. start must be first)

OBJS ?= $(CPUDIR)/start.o
ifeq ($(CPU),x86)
OBJS += $(CPUDIR)/start16.o
OBJS += $(CPUDIR)/resetvec.o
endif
ifeq ($(CPU),ppc4xx)
OBJS += $(CPUDIR)/resetvec.o
endif
ifeq ($(CPU),mpc85xx)
OBJS += $(CPUDIR)/resetvec.o
endif

I've been meaning to get rid of this for x86 as I believe this can be adequately handled by putting the code in relevant sections and locating the sections at the correct location using the linker script.

Quoted 6 lines

For x86 there are only two requirements:
?- The first byte of resetvec.o sits 16 bytes from the end of flash ?- The first byte of start.o is the first byte of the core u-boot image ? (there is other cruft above it in the flash like an embedded kernel ? ?image)

Yes I don't think the order is important now as we have a link script as you say.

Quoted 3 lines

Regards,

Graeme

#19 lore raw

PATCH v4 5/13 Move memcpy(), memset() into new lib/membasic.c

In reply to Graeme Russ
Quoted 23 lines · On Wednesday 07 March 2012 00:50:15 Graeme Russ wrote:
Quoted 22 lines · Mike Frysinger
Quoted 11 lines · On Tuesday 06 March 2012 01:34:24 Simon Glass wrote:
Quoted 9 lines · Mike Frysinger
Quoted 4 lines · On Monday 20 February 2012 20:32:47 Simon Glass wrote:

These basic functions are needed by relocation. To avoid bringing in all string.c functions (and the resulting code bloat for architectures where -ffunction-sections is not used), move these into their own file.

seems like fixing -f{data,function}-sections would be a more useful goal. i don't know why arm doesn't support this today ... it's fairly easy to do.

Quoted 5 lines

I did enable it for Tegra at one point with no ill effects except for breaking warmboot, which relied on function ordering. I notice the no-toplevel-reorder flag on x86 but not with ARM. But I assumed there must be some reason it is not used and thought this patch safer, since it is just a minor tweak on a series that has has some review.

if we keep assuming that, then it'll never get fixed, and we'll sit on a steady stream of "small safe patches". plus, fixing this yields general improvements in anti-bloat for everyone.

Quoted 8 lines
Quoted 4 lines

function ordering sounds like something that should be imposed at the linker level ... for Blackfin, all i had to care about was the entry point was at the start of the .text, although warmbooting is fairly low level magic, and i handle that in the SPL-like core.

Can't the entry point be forced to be at the start of the u-boot image by putting that function in a dedicated section and specifying that section as the first in the linker script?

yes ... that's what Blackfin does:
...
ENTRY(_start)
SECTIONS

{  
    .text.pre :
    {
        arch/blackfin/cpu/start.o (.text .text.*)

...
-mike
-------------- 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/20120311/7206a6f7/attachment.pgp>

#20 lore raw

PATCH v4 6/13 arm: Add explicit __image_copy_end symbol for ARM926EJ-S

In reply to Simon Glass

The start of the BSS is normally the end of the region in the image that must be copied for relocation to work. But for SPL this is apparently not always true, and ARMv7 has an explicit __image_copy_end symbol for this. Add this new symbol to ARM926EJ-S to support SPL under generic relocation.

---

 arch/arm/cpu/arm926ejs/start.S    |    4 ++++
 arch/arm/cpu/arm926ejs/u-boot.lds |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)
arch/arm/cpu/arm926ejs/start.S +4 -0
index 2c8ff81..ecb44f1 100644
@@ -146,6 +146,10 @@ _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global _image_copy_end_ofs
+_image_copy_end_ofs:
+        .word   __image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
arch/arm/cpu/arm926ejs/u-boot.lds +2 -0
index 1480e0c..069cd1b 100644
@@ -52,6 +52,8 @@ SECTIONS
 
 	. = ALIGN(4);
 
+        __image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
Signature · 1 line
1.7.7.3
#21 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

In reply to Simon Glass

This fixes the following warnings in an SPL build when libcommon is in use:

spl.c:37: warning: 'gdata' defined but not used
spl.c:38: warning: 'bdata' defined but not used

---
Changes in v4:
- Add new patch to fix davinci build warnings

 arch/arm/cpu/arm926ejs/davinci/spl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/cpu/arm926ejs/davinci/spl.c +2 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 
+#ifdef CONFIG_SPL_SPI_LOAD
 DECLARE_GLOBAL_DATA_PTR;
 /* Define global data structure pointer to it*/
 static gd_t gdata __attribute__ ((section(".data")));
 static bd_t bdata __attribute__ ((section(".data")));
+#endif
 
 #else
 
Signature · 1 line
1.7.7.3
#22 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

Quoted 7 lines · Simon Glass

This fixes the following warnings in an SPL build when libcommon is in use:

spl.c:37: warning: 'gdata' defined but not used
spl.c:38: warning: 'bdata' defined but not used

Signature · 1 line
Tom
#23 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

In reply to Simon Glass

hi Simon,

Quoted 19 lines · Simon Glass

This fixes the following warnings in an SPL build when libcommon is in use:

spl.c:37: warning: 'gdata' defined but not used
spl.c:38: warning: 'bdata' defined but not used

---
Changes in v4:
- Add new patch to fix davinci build warnings

 arch/arm/cpu/arm926ejs/davinci/spl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644

arch/arm/cpu/arm926ejs/davinci/spl.c line 40

Quoted 9 lines
arch/arm/cpu/arm926ejs/davinci/spl.c +2 -0
@@ -32,10 +32,12 @@
 
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 
+#ifdef CONFIG_SPL_SPI_LOAD
 DECLARE_GLOBAL_DATA_PTR;
 /* Define global data structure pointer to it*/
 static gd_t gdata __attribute__ ((section(".data")));
 static bd_t bdata __attribute__ ((section(".data")));
+#endif

Can you specify which boards you get this warning for. With your patch to add libcommon to hawkboard's spl image, this is now also needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

-sughosh

#24 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

Hi Sughosh,

Quoted 25 lines · Sughosh Ganu

hi Simon,

Quoted 22 lines · Simon Glass

This fixes the following warnings in an SPL build when libcommon is in use:

spl.c:37: warning: 'gdata' defined but not used
spl.c:38: warning: 'bdata' defined but not used

---
Changes in v4:
- Add new patch to fix davinci build warnings

?arch/arm/cpu/arm926ejs/davinci/spl.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 

?#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT

Quoted 10 lines
Quoted 6 lines

+#ifdef CONFIG_SPL_SPI_LOAD ?DECLARE_GLOBAL_DATA_PTR;
?/* Define global data structure pointer to it*/ ?static gd_t gdata __attribute__ ((section(".data"))); ?static bd_t bdata __attribute__ ((section(".data"))); +#endif

?Can you specify which boards you get this warning for. With your ?patch to add libcommon to hawkboard's spl image, this is now also ?needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Perhaps it is any davinci board, with SPI? I don't have any of these - I was just fixing what I thought was a minor #ifdef bug in the code.

Regards,
Simon

Quoted 2 lines

-sughosh

#25 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

hi Simon,

Quoted 39 lines · Simon Glass

Hi Sughosh,

Quoted 25 lines · Sughosh Ganu

hi Simon,

Quoted 22 lines · Simon Glass

This fixes the following warnings in an SPL build when libcommon is in use:

spl.c:37: warning: 'gdata' defined but not used
spl.c:38: warning: 'bdata' defined but not used

---
Changes in v4:
- Add new patch to fix davinci build warnings

?arch/arm/cpu/arm926ejs/davinci/spl.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 

?#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT

Quoted 10 lines
Quoted 6 lines

+#ifdef CONFIG_SPL_SPI_LOAD ?DECLARE_GLOBAL_DATA_PTR;
?/* Define global data structure pointer to it*/ ?static gd_t gdata __attribute__ ((section(".data"))); ?static bd_t bdata __attribute__ ((section(".data"))); +#endif

?Can you specify which boards you get this warning for. With your ?patch to add libcommon to hawkboard's spl image, this is now also ?needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Quoted 2 lines

Perhaps it is any davinci board, with SPI? I don't have any of these - I was just fixing what I thought was a minor #ifdef bug in the code.

I checked the configs for all the davinci boards, and cam_enc_4xx, da850* and hawkboard use spl. Out of these the da850* use a spi flash, while cam_enc_4xx and hawkboard both use a nand. So we should not be using the CONFIG_SPL_SPI_LOAD check to exclude the gdata and bdata objects -- these are now needed after adding the libcommon support to the hawkboard.

Also, the cam_enc_4xx board which uses a spl does not have CONFIG_SPL_LIBCOMMON_SUPPORT and CONFIG_SPL_LIBGENERIC_SUPPORT defined and this patchset does not add these defines for the board. Was adding these defines for the board missed out. If so, then this patch would no longer be needed.

-sughosh

#26 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

Hi,

Quoted 29 lines · Sughosh Ganu

hi Simon,

Quoted 26 lines · Simon Glass

Hi Sughosh,

Quoted 23 lines · Sughosh Ganu

hi Simon,

Quoted 20 lines · Simon Glass

This fixes the following warnings in an SPL build when libcommon is in use:

spl.c:37: warning: 'gdata' defined but not used
spl.c:38: warning: 'bdata' defined but not used

---
Changes in v4:
- Add new patch to fix davinci build warnings

?arch/arm/cpu/arm926ejs/davinci/spl.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

?#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT

+#ifdef CONFIG_SPL_SPI_LOAD ?DECLARE_GLOBAL_DATA_PTR;
?/* Define global data structure pointer to it*/ ?static gd_t gdata __attribute__ ((section(".data"))); ?static bd_t bdata __attribute__ ((section(".data"))); +#endif

In arch/arm/cpu/arm926ejs/davinci/spl.c gdata and bdata are used for serial_init() to allow output to the console from the SPL. However, this is only the case when LIBCOMMON is used. LIBCOMMON is required for booting from SPI, but not for booting from NAND. Up to now davinci boards that boot from NAND with SPL did not use LIBCOMMON but used the puts and putc functions defined in spl.c for console output.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

?Can you specify which boards you get this warning for. With your ?patch to add libcommon to hawkboard's spl image, this is now also ?needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)

However, the patch fixes the warning, but now we use putc and puts from LIBCOMMON without initializing them. Thus it breaks the console output of the hawkboard SPL.

So the correct solution would be to keep the ifdefs around the definition of gdata and bdata as they are, but change board_init_f() like this:

void board_init_r(gd_t *id, ulong dummy)
{

#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
        mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN,
                        CONFIG_SYS_MALLOC_LEN);

        gd = &gdata;
        gd->bd = &bdata;
        gd->flags |= GD_FLG_RELOC;
        gd->baudrate = CONFIG_BAUDRATE;
        serial_init();          /* serial communications setup */
        gd->have_console = 1;
#endif
#ifdef CONFIG_SPL_NAND_LOAD
        nand_init();
        puts("Nand boot...\n");
        nand_boot();
#endif
#ifdef CONFIG_SPL_SPI_LOAD
        puts("SPI boot...\n");
        spi_boot();

#endif
}

Regards, Christian

#27 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

hi Christian,

Quoted 3 lines · Christian Riesch

Hi,

On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu <[email protected]> wrote:

<snip>

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

?arch/arm/cpu/arm926ejs/davinci/spl.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 

?#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT

+#ifdef CONFIG_SPL_SPI_LOAD ?DECLARE_GLOBAL_DATA_PTR;
?/* Define global data structure pointer to it*/ ?static gd_t gdata __attribute__ ((section(".data"))); ?static bd_t bdata __attribute__ ((section(".data"))); +#endif

<snip>

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

?Can you specify which boards you get this warning for. With your ?patch to add libcommon to hawkboard's spl image, this is now also ?needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)

LIBCOMMON is now needed as the generic relocation based functions are part of the libcommon.o, which are being enabled in the same patchset for all arm boards. So if i understand correct, all arm board based spl's now need libcommon and libgeneric.

The only thing i see is that libcommon and libgeneric are not defined for cam_enc_4xx board which uses spl, and this patchset does not add it either. Not sure whether it got missed.

Quoted 7 lines

However, the patch fixes the warning, but now we use putc and puts from LIBCOMMON without initializing them. Thus it breaks the console output of the hawkboard SPL.

So the correct solution would be to keep the ifdefs around the definition of gdata and bdata as they are, but change board_init_f() like this:

I have a patch for this, which i will send today. There is only one question i have though.

Quoted 6 lines

void board_init_r(gd_t *id, ulong dummy)
{
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN,
CONFIG_SYS_MALLOC_LEN);

Can you please explain why we need the mem_malloc_init. I did not include this, and spl boots up just fine on my board.

-sughosh

#28 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

Hi Sughosh,

Quoted 39 lines · Sughosh Ganu

hi Christian,

Quoted 3 lines · Christian Riesch

Hi,

On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu <[email protected]> wrote:

<snip>

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

?arch/arm/cpu/arm926ejs/davinci/spl.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 

?#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT

+#ifdef CONFIG_SPL_SPI_LOAD ?DECLARE_GLOBAL_DATA_PTR;
?/* Define global data structure pointer to it*/ ?static gd_t gdata __attribute__ ((section(".data"))); ?static bd_t bdata __attribute__ ((section(".data"))); +#endif

<snip>

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

?Can you specify which boards you get this warning for. With your ?patch to add libcommon to hawkboard's spl image, this is now also ?needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)

Quoted 8 lines

?LIBCOMMON is now needed as the generic relocation based functions ?are part of the libcommon.o, which are being enabled in the same ?patchset for all arm boards. So if i understand correct, all arm ?board based spl's now need libcommon and libgeneric.

?The only thing i see is that libcommon and libgeneric are not ?defined for cam_enc_4xx board which uses spl, and this patchset does ?not add it either. Not sure whether it got missed.

When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?

However, I we can make all davinci boards use LIBCOMMON, we can remove the putc/puts functions from spl.c.

Quoted 12 lines
Quoted 7 lines

However, the patch fixes the warning, but now we use putc and puts from LIBCOMMON without initializing them. Thus it breaks the console output of the hawkboard SPL.

So the correct solution would be to keep the ifdefs around the definition of gdata and bdata as they are, but change board_init_f() like this:

?I have a patch for this, which i will send today. There is only one ?question i have though.

Quoted 1 line
Quoted 9 lines
Quoted 5 lines

void board_init_r(gd_t *id, ulong dummy)
{
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
? ? ? ? mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_MALLOC_LEN);

?Can you please explain why we need the mem_malloc_init. I did not ?include this, and spl boots up just fine on my board.

malloc is required for the SPI code only, so you could also put it within #ifdef CONFIG_SPL_SPI_LOAD

Regards, Christian

#29 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

hi Christian,

Quoted 51 lines · Christian Riesch

Hi Sughosh,

Quoted 39 lines · Sughosh Ganu

hi Christian,

Quoted 3 lines · Christian Riesch

Hi,

On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu <[email protected]> wrote:

<snip>

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

?arch/arm/cpu/arm926ejs/davinci/spl.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 

?#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT

+#ifdef CONFIG_SPL_SPI_LOAD ?DECLARE_GLOBAL_DATA_PTR;
?/* Define global data structure pointer to it*/ ?static gd_t gdata __attribute__ ((section(".data"))); ?static bd_t bdata __attribute__ ((section(".data"))); +#endif

<snip>

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

?Can you specify which boards you get this warning for. With your ?patch to add libcommon to hawkboard's spl image, this is now also ?needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)

Quoted 8 lines

?LIBCOMMON is now needed as the generic relocation based functions ?are part of the libcommon.o, which are being enabled in the same ?patchset for all arm boards. So if i understand correct, all arm ?board based spl's now need libcommon and libgeneric.

?The only thing i see is that libcommon and libgeneric are not ?defined for cam_enc_4xx board which uses spl, and this patchset does ?not add it either. Not sure whether it got missed.

Quoted 6 lines

When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?

That is exactly what i reported in one of the threads in response to addition of libcommon and libgeneric to the hawkboard's spl. In fact, this might cause problems on quite a few boards with spl size restrictions. I am not sure, whether the generic relocation feature should be turned on by default on all boards or should be a config option -- at least for the spl builds. Another option would be to move it to a place where it is not needed to compile in the entire libcommon/libgeneric support that is not needed for the generic relocation code. I think that would help us keep the generic relocation without the size bloat that we see right now.

http://lists.denx.de/pipermail/u-boot/2012-February/118567.html

<snip>

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

void board_init_r(gd_t *id, ulong dummy)
{
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
? ? ? ? mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_MALLOC_LEN);

Quoted 6 lines
Quoted 3 lines

?Can you please explain why we need the mem_malloc_init. I did not ?include this, and spl boots up just fine on my board.

malloc is required for the SPI code only, so you could also put it within #ifdef CONFIG_SPL_SPI_LOAD

Ok, i will move the common changes to a static function, and call it from both the nand and spi load cases. Or, should i wait till a consensus is drawn on whether to enable this feature for spl images also. In case this is not needed for spl, then we don't need this change.

-sughosh

#30 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

Le 27/02/2012 13:02, Sughosh Ganu a ?crit :

Quoted 18 lines
Quoted 6 lines

When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?

That is exactly what i reported in one of the threads in response to addition of libcommon and libgeneric to the hawkboard's spl. In fact, this might cause problems on quite a few boards with spl size restrictions. I am not sure, whether the generic relocation feature should be turned on by default on all boards or should be a config option -- at least for the spl builds. Another option would be to move it to a place where it is not needed to compile in the entire libcommon/libgeneric support that is not needed for the generic relocation code. I think that would help us keep the generic relocation without the size bloat that we see right now.

Quoted 1 line
   http://lists.denx.de/pipermail/u-boot/2012-February/118567.html

Sorry for appearing dumb, but can someone explain to me how SPL relates to relocation in the first place? I thought SPL was meant to be a preloader for the full(er) U-boot, small enough to be loaded by some SoCs' ROM code and possibly even to fit in SRAM. Why does it need relocation? And if it does not, how come it is affected by a rework of the relocation feature? I really would like a heads-up on this.

Amicalement,

Signature · 1 line
Albert.
#31 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

Quoted 20 lines · Albert ARIBAUD

Le 27/02/2012 13:02, Sughosh Ganu a ?crit :

Quoted 18 lines
Quoted 6 lines

When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?

That is exactly what i reported in one of the threads in response to addition of libcommon and libgeneric to the hawkboard's spl. In fact, this might cause problems on quite a few boards with spl size restrictions. I am not sure, whether the generic relocation feature should be turned on by default on all boards or should be a config option -- at least for the spl builds. Another option would be to move it to a place where it is not needed to compile in the entire libcommon/libgeneric support that is not needed for the generic relocation code. I think that would help us keep the generic relocation without the size bloat that we see right now.

Quoted 8 lines
Quoted 1 line
   http://lists.denx.de/pipermail/u-boot/2012-February/118567.html

Sorry for appearing dumb, but can someone explain to me how SPL relates to relocation in the first place? I thought SPL was meant to be a preloader for the full(er) U-boot, small enough to be loaded by some SoCs' ROM code and possibly even to fit in SRAM. Why does it need relocation? And if it does not, how come it is affected by a rework of the relocation feature? I really would like a heads-up on this.

SPL may need relocation to vacate a buffer that will be used for further I/O, such as on Freescale PPC (NAND boot execution begins in the NAND controller's SRAM), or possibly to allow the memory map to be transformed to what the final image is going to expect, etc.

Even in cases where the SPL text itself doesn't really need to move, you may need some other things that typically happen along with relocation, such as moving the stack to a larger memory after that memory is initialized, zeroing BSS, etc.

-Scott

#32 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

In reply to Sughosh Ganu

Hi,

Quoted 60 lines · Sughosh Ganu

hi Christian,

Quoted 57 lines · Christian Riesch

Hi Sughosh,

Quoted 39 lines · Sughosh Ganu

hi Christian,

Quoted 3 lines · Christian Riesch

Hi,

On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu <[email protected]> wrote:

<snip>

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

?arch/arm/cpu/arm926ejs/davinci/spl.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 

?#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT

+#ifdef CONFIG_SPL_SPI_LOAD ?DECLARE_GLOBAL_DATA_PTR;
?/* Define global data structure pointer to it*/ ?static gd_t gdata __attribute__ ((section(".data"))); ?static bd_t bdata __attribute__ ((section(".data"))); +#endif

<snip>

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

?Can you specify which boards you get this warning for. With your ?patch to add libcommon to hawkboard's spl image, this is now also ?needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)

Quoted 8 lines

?LIBCOMMON is now needed as the generic relocation based functions ?are part of the libcommon.o, which are being enabled in the same ?patchset for all arm boards. So if i understand correct, all arm ?board based spl's now need libcommon and libgeneric.

?The only thing i see is that libcommon and libgeneric are not ?defined for cam_enc_4xx board which uses spl, and this patchset does ?not add it either. Not sure whether it got missed.

When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?

If it pushes it over 16KB, although it's not clear that it will. So far I haven't seen this and I would hope that builds would fail in this case (normally I got a 'cannot move program counter backwards' error).

But clearly putting this code in spl.c is a bit ugly because it hard-codes the driver and duplicates code in common/console.c:

void putc(char c)

{
	if (c == '\n')
		NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');

	NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
}

Can someone please check what is the maximum SPL size on one of these boards? Generic relocation increases the spl from 5.9KB to 10KB. Is there an 8KB limit?

One option if this really is a problem is to move common/reloc.c to lib/reloc.c, although there isn't really a huge amount of justification for that given that it is U-Boot code. Perhaps we could claim that it is a relocation library and not U-Boot-specific?

Quoted 12 lines

?That is exactly what i reported in one of the threads in response to ?addition of libcommon and libgeneric to the hawkboard's spl. In ?fact, this might cause problems on quite a few boards with spl size ?restrictions. I am not sure, whether the generic relocation feature ?should be turned on by default on all boards or should be a config ?option -- at least for the spl builds. Another option would be to ?move it to a place where it is not needed to compile in the entire ?libcommon/libgeneric support that is not needed for the generic ?relocation code. I think that would help us keep the generic ?relocation without the size bloat that we see right now.

Quoted 1 line

?http://lists.denx.de/pipermail/u-boot/2012-February/118567.html

Well it would be nice to find out what the limit is. I might be able to squeeze it a bit more even in common. But failing that the putc() hack and lib/ might be the most expedient solution at this stage.

Quoted 13 lines

<snip>

Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

void board_init_r(gd_t *id, ulong dummy)
{
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
? ? ? ? mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_MALLOC_LEN);

?Can you please explain why we need the mem_malloc_init. I did not ?include this, and spl boots up just fine on my board.

Quoted 8 lines
Quoted 2 lines

malloc is required for the SPI code only, so you could also put it within #ifdef CONFIG_SPL_SPI_LOAD

?Ok, i will move the common changes to a static function, and call ?it from both the nand and spi load cases. Or, should i wait till a ?consensus is drawn on whether to enable this feature for spl images ?also. In case this is not needed for spl, then we don't need this ?change.

My series removes the old relocation code, so it really does need to work for SPL also. I have put a bit of effort in here to tidy this up and I don't think it is hard to resolve this last problem.

I will investigate this a bit more and then suggest a solution.

Regards,
Simon

Quoted 2 lines

-sughosh

#33 lore raw

PATCH v4 7/13 davinci: Use correct #ifdef around gdata/bdata

Hi,

Quoted 129 lines · Simon Glass

Hi,

Quoted 60 lines · Sughosh Ganu

hi Christian,

Quoted 57 lines · Christian Riesch

Hi Sughosh,

Quoted 39 lines · Sughosh Ganu

hi Christian,

Quoted 3 lines · Christian Riesch

Hi,

On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu <[email protected]> wrote:

<snip>

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

?arch/arm/cpu/arm926ejs/davinci/spl.c | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

arch/arm/cpu/arm926ejs/davinci/spl.c +0 -0
index b1eff26..2861907 100644
@@ -32,10 +32,12 @@
 

?#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT

+#ifdef CONFIG_SPL_SPI_LOAD ?DECLARE_GLOBAL_DATA_PTR;
?/* Define global data structure pointer to it*/ ?static gd_t gdata __attribute__ ((section(".data"))); ?static bd_t bdata __attribute__ ((section(".data"))); +#endif

<snip>

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

?Can you specify which boards you get this warning for. With your ?patch to add libcommon to hawkboard's spl image, this is now also ?needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Simon's patch is for the hawkboard, since due to another patch in his patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did not check the rest of your patchset, why do you need LIBCOMMON on the hawkboard at all?)

Quoted 8 lines

?LIBCOMMON is now needed as the generic relocation based functions ?are part of the libcommon.o, which are being enabled in the same ?patchset for all arm boards. So if i understand correct, all arm ?board based spl's now need libcommon and libgeneric.

?The only thing i see is that libcommon and libgeneric are not ?defined for cam_enc_4xx board which uses spl, and this patchset does ?not add it either. Not sure whether it got missed.

When I asked Heiko Schocher a few month ago why he defined putc and puts in arch/arm/cpu/arm926ejs/davinci/spl.c he replied that he could not use LIBCOMMON due to size limitations for the SPL. So I guess that this board will not be able to use the generic relocation functions, unless the SPL is smaller than 16kB, right? Simon's patchset will break this board then, right?

If it pushes it over 16KB, although it's not clear that it will. So far I haven't seen this and I would hope that builds would fail in this case (normally I got a 'cannot move program counter backwards' error).

But clearly putting this code in spl.c is a bit ugly because it hard-codes the driver and duplicates code in common/console.c:

void putc(char c)
{
? ? ? ?if (c == '\n')
? ? ? ? ? ? ? ?NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');

? ? ? ?NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c); }

Can someone please check what is the maximum SPL size on one of these boards? Generic relocation increases the spl from 5.9KB to 10KB. Is there an 8KB limit?

One option if this really is a problem is to move common/reloc.c to lib/reloc.c, although there isn't really a huge amount of justification for that given that it is U-Boot code. Perhaps we could claim that it is a relocation library and not U-Boot-specific?

Quoted 12 lines

?That is exactly what i reported in one of the threads in response to ?addition of libcommon and libgeneric to the hawkboard's spl. In ?fact, this might cause problems on quite a few boards with spl size ?restrictions. I am not sure, whether the generic relocation feature ?should be turned on by default on all boards or should be a config ?option -- at least for the spl builds. Another option would be to ?move it to a place where it is not needed to compile in the entire ?libcommon/libgeneric support that is not needed for the generic ?relocation code. I think that would help us keep the generic ?relocation without the size bloat that we see right now.

Quoted 1 line

?http://lists.denx.de/pipermail/u-boot/2012-February/118567.html

Well it would be nice to find out what the limit is. I might be able to squeeze it a bit more even in common. But failing that the putc() hack and lib/ might be the most expedient solution at this stage.

Quoted 13 lines

<snip>

Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

void board_init_r(gd_t *id, ulong dummy)
{
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
? ? ? ? mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, ? ? ? ? ? ? ? ? ? ? ? ? CONFIG_SYS_MALLOC_LEN);

?Can you please explain why we need the mem_malloc_init. I did not ?include this, and spl boots up just fine on my board.

Quoted 8 lines
Quoted 2 lines

malloc is required for the SPI code only, so you could also put it within #ifdef CONFIG_SPL_SPI_LOAD

?Ok, i will move the common changes to a static function, and call ?it from both the nand and spi load cases. Or, should i wait till a ?consensus is drawn on whether to enable this feature for spl images ?also. In case this is not needed for spl, then we don't need this ?change.

Quoted 5 lines

My series removes the old relocation code, so it really does need to work for SPL also. I have put a bit of effort in here to tidy this up and I don't think it is hard to resolve this last problem.

I will investigate this a bit more and then suggest a solution.

Actually further to this it seems that it is just that raise() is calling printf(). Seems like we can punt this unless anyone has objections. Alternatively we could use puts() and just print a general message. I will send a patch.

Regards,
Simon

Quoted 6 lines

Regards,
Simon

Quoted 2 lines

-sughosh

#34 lore raw

PATCH v4 8/13 tx25: Modify to work with generic relocation

In reply to Simon Glass

Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.

---
Changes in v4:
- Split out tx25 changes into new patch

 include/configs/tx25.h              |    2 ++
 nand_spl/board/karo/tx25/Makefile   |   11 ++++++++++-
 nand_spl/board/karo/tx25/u-boot.lds |    1 +
 3 files changed, 13 insertions(+), 1 deletions(-)
include/configs/tx25.h +2 -0
index 87bd8a6..115d810 100644
@@ -58,6 +58,8 @@
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #endif
 
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+
 #define CONFIG_DISPLAY_CPUINFO
 
 #define CONFIG_CMDLINE_TAG			/* enable passing of ATAGs */
nand_spl/board/karo/tx25/Makefile +10 -1
index 0336346..c253d42 100644
@@ -33,7 +33,10 @@ AFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
 CFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
 
 SOBJS	= start.o lowlevel_init.o
-COBJS	= nand_boot_fsl_nfc.o
+COBJS	= nand_boot_fsl_nfc.o membasic.o
+ifndef CONFIG_SYS_SKIP_RELOC
+COBJS	+= reloc.o
+endif
 
 SRCS	:= $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c
 SRCS	+= $(SRCTREE)/arch/arm/cpu/arm926ejs/start.S
@@ -71,6 +74,12 @@ $(obj)%.o:	$(SRCTREE)/board/karo/tx25/%.S
 $(obj)%.o:	$(SRCTREE)/nand_spl/%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
 
+$(obj)%.o:	$(SRCTREE)/common/%.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)%.o:	$(SRCTREE)/lib/%.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
 # defines $(obj).depend target
 include $(SRCTREE)/rules.mk
 
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.7.3
#35 lore raw

PATCH v4 9/13 hawkboard: Modify to work with generic relocation

In reply to Simon Glass

Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.

---
Changes in v4:
- Split out hawkboard changes into new patch

 board/davinci/da8xxevm/u-boot-spl-hawk.lds |    1 +
 include/configs/hawkboard.h                |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/u-boot-spl-hawk.lds +1 -0
index b3a41af..4bbfa3d 100644
@@ -58,6 +58,7 @@ SECTIONS
 	}
 
 	. = ALIGN(4);
+        __image_copy_end = .;
 	__rel_dyn_start = .;
 	__rel_dyn_end = .;
 	__dynsym_start = .;
include/configs/hawkboard.h +2 -0
index 50a1c17..85a955b 100644
@@ -63,6 +63,8 @@
 #define CONFIG_SPL_NAND_SIMPLE
 #define CONFIG_SPL_NAND_LOAD
 #define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
 #define CONFIG_SPL_LDSCRIPT		"board/$(BOARDDIR)/u-boot-spl-hawk.lds"
 #define CONFIG_SPL_TEXT_BASE		0xc1080000
 #define CONFIG_SPL_STACK		CONFIG_SYS_INIT_SP_ADDR
Signature · 1 line
1.7.7.3
#37 lore raw

PATCH v4 9/13 hawkboard: Modify to work with generic relocation

In reply to Simon Glass

hi Simon,

Quoted 11 lines · Simon Glass

Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.

---
Changes in v4:
- Split out hawkboard changes into new patch

 board/davinci/da8xxevm/u-boot-spl-hawk.lds |    1 +
 include/configs/hawkboard.h                |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

I have tested these changes on the hawkboard. It requires setting up of the gd and bd pointers in the spl for this to work with the libcommon changes, which were not needed up until now in my spl. I will send a patch to fix this. Will also test the rest of your patchset on the board during the weekend.

Btw, i had quite a substantial increase in the spl image size with these additions with a 4.5 based toolchain(will provide exact toolchain details and size difference tonight). Building with a 4.6 based toolchain got the size increase down by quite a bit. Although i don't have any size restrictions with spl on my board, this could be a problem on boards which have these restrictions with toolchains before 4.6.

-sughosh

#38 lore raw

PATCH v4 9/13 hawkboard: Modify to work with generic relocation

Quoted 15 lines · Sughosh Ganu

hi Simon,

Quoted 11 lines · Simon Glass

Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.

---
Changes in v4:
- Split out hawkboard changes into new patch

 board/davinci/da8xxevm/u-boot-spl-hawk.lds |    1 +
 include/configs/hawkboard.h                |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

<snip>

Quoted 8 lines

Btw, i had quite a substantial increase in the spl image size with these additions with a 4.5 based toolchain(will provide exact toolchain details and size difference tonight). Building with a 4.6 based toolchain got the size increase down by quite a bit. Although i don't have any size restrictions with spl on my board, this could be a problem on boards which have these restrictions with toolchains before 4.6.

gcc(arm-none-linux-gnueabi) -- 4.5.2
binutils -- 2.20

spl size without this patch

   text       data        bss        dec        hex    filename
   5208        620        464       6292       1894    spl/u-boot-spl

spl size with this patch

   text       data        bss        dec        hex    filename
   8897        620        476       9993       2709    spl/u-boot-spl

gcc(arm-none-eabi) -- 4.6.2
binutils -- 2.21

spl size without this patch
text data bss dec hex filename
4692 620 464 5776 1690 spl/u-boot-spl

spl size with this patch
text data bss dec hex filename
4812 620 476 5908 1714 spl/u-boot-spl

-sughosh

#39 lore raw

PATCH v4 9/13 hawkboard: Modify to work with generic relocation

Hi,

Quoted 50 lines · Sughosh Ganu
Quoted 15 lines · Sughosh Ganu

hi Simon,

Quoted 11 lines · Simon Glass

Add use of common/ and lib/ libraries for the SPL stage, and add the new link symbol required for generic relocation.

---
Changes in v4:
- Split out hawkboard changes into new patch

?board/davinci/da8xxevm/u-boot-spl-hawk.lds | ? ?1 + ?include/configs/hawkboard.h ? ? ? ? ? ? ? ?| ? ?2 ++ ?2 files changed, 3 insertions(+), 0 deletions(-)

<snip>

Quoted 8 lines

?Btw, i had quite a substantial increase in the spl image size with ?these additions with a 4.5 based toolchain(will provide exact ?toolchain details and size difference tonight). Building with a 4.6 ?based toolchain got the size increase down by quite a bit. Although i ?don't have any size restrictions with spl on my board, this could be ?a problem on boards which have these restrictions with toolchains ?before 4.6.

gcc(arm-none-linux-gnueabi) -- 4.5.2
binutils -- 2.20

spl size without this patch
?? text??? ?? data??? ??? bss??? ??? dec??? ??? hex??? filename ?? 5208??? ??? 620??? ??? 464??? ?? 6292??? ?? 1894??? spl/u-boot-spl

spl size with this patch
?? text??? ?? data??? ??? bss??? ??? dec??? ??? hex??? filename ?? 8897??? ??? 620??? ??? 476??? ?? 9993??? ?? 2709??? spl/u-boot-spl

gcc(arm-none-eabi) -- 4.6.2
binutils -- 2.21

spl size without this patch
?? text??? ?? data??? ??? bss??? ??? dec??? ??? hex??? filename ?? 4692 ?? ??? 620??? ??? 464???? 5776 ?? ? 1690 ?? spl/u-boot-spl

Quoted 5 lines

spl size with this patch
?? text??? ?? data??? ??? bss??? ??? dec??? ??? hex??? filename ?? 4812 ?? ??? 620??? ? 476 ????? 5908 ?? ? 1714 ?? spl/u-boot-spl

-sughosh

Thanks for looking at this.

I'm not sure why it doesn't happen with your 4.6.2 compiler. With my 4.6.0 I do see the size increase.

It seems to be due to vsprintf:

text data bss dec hex filename
4011 0 22 4033 fc1 spl/lib/vsprintf.o

I wonder if it is a call to printf that the older compiler is failing to optimize out?

Regards,
Simon

#40 lore raw

PATCH v4 10/13 mx31pdk: Modify to work with generic relocation

In reply to Simon Glass

This adds a link symbol and updates the board Makefile so that it's SPL implementation will work with generic relocation.

---
Changes in v4:
- Split out mx31pdk changes into new patch

 nand_spl/board/freescale/mx31pdk/Makefile   |    6 ++++++
 nand_spl/board/freescale/mx31pdk/u-boot.lds |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)
nand_spl/board/freescale/mx31pdk/Makefile +6 -0
index 87784d2..4598206 100644
@@ -13,6 +13,9 @@ CFLAGS	+= -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
 
 SOBJS	= start.o lowlevel_init.o
 COBJS	= nand_boot_fsl_nfc.o
+ifndef CONFIG_SYS_SKIP_RELOC
+COBJS	+= reloc.o
+endif
 
 SRCS	:= $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c
 SRCS	+= $(SRCTREE)/arch/arm/cpu/arm1136/start.S
@@ -50,6 +53,9 @@ $(obj)%.o:	$(SRCTREE)/board/freescale/mx31pdk/%.S
 $(obj)%.o:	$(SRCTREE)/nand_spl/%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
 
+$(obj)%.o:	$(SRCTREE)/common/%.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
 # defines $(obj).depend target
 include $(SRCTREE)/rules.mk
 
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 = .;
Signature · 1 line
1.7.7.3
#41 lore raw

PATCH v4 11/13 smdk6400: Modify to work with generic relocation

In reply to Simon Glass

This seems to use an old SPL framework, or at least it is ugly enough that I hope it is old. Add symlinks for the new files required by generic relocation.

---
Changes in v4:
- Add new patch to fix smdk6400 with generic relocation

 nand_spl/board/samsung/smdk6400/Makefile |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
nand_spl/board/samsung/smdk6400/Makefile +11 -0
index c9e75ba..c79e12b 100644
@@ -39,6 +39,9 @@ CFLAGS	+= -DCONFIG_NAND_SPL -ffunction-sections
 
 SOBJS	= start.o cpu_init.o lowlevel_init.o
 COBJS	= nand_boot.o nand_ecc.o s3c64xx.o smdk6400_nand_spl.o nand_base.o
+ifndef CONFIG_SYS_SKIP_RELOC
+COBJS	+= reloc.o membasic.o
+endif
 
 SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
@@ -101,6 +104,14 @@ $(obj)smdk6400_nand_spl.c:
 $(obj)nand_base.c:
 	@rm -f $@
 	@ln -s $(TOPDIR)/drivers/mtd/nand/nand_base.c $@
+
+$(obj)reloc.c:
+	@rm -f $@
+	@ln -s $(TOPDIR)/common/reloc.c $@
+
+$(obj)membasic.c:
+	@rm -f $@
+	@ln -s $(TOPDIR)/lib/membasic.c $@
 #########################################################################
 
 $(obj)%.o:	$(obj)%.S
Signature · 1 line
1.7.7.3
#42 lore raw

PATCH v4 12/13 arm: Move over to generic relocation

In reply to Simon Glass

Add a function to process a single ELF relocation and switch ARM over to use generic relocation.

---
Changes in v2:
- Use an inline relocation function to reduce code size

Changes in v4:
- Remove proc.S file from Makefiles
- Split out board changes into separate patches

 arch/arm/config.mk           |    3 --
 arch/arm/include/asm/reloc.h |   56 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/reloc.h
arch/arm/config.mk +0 -3
index f47d4f7..45f9dca 100644
@@ -81,6 +81,3 @@ endif
 ifndef CONFIG_NAND_SPL
 LDFLAGS_u-boot += -pie
 endif
-
-# We use legacy relocation for now
-CONFIG_SYS_SKIP_RELOC := y
arch/arm/include/asm/reloc.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#43 lore raw

PATCH v4 13/13 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.

Note: Here we lose the ARM1176's enable_mmu code. This seems to duplicate code already in U-Boot now. Can anyone comment on this?

---
Changes in v2:
- Make relocation symbols global so we can use them outside start.S

Changes in v3:
- Rebase to master
- Remove the 'reloc' tag from each commit

Changes in v4:
- Rebase to master, also bring in ARM master
- Update start.S pruning to fit with early patches

 arch/arm/cpu/arm1136/start.S   |  114 -----------------------
 arch/arm/cpu/arm1176/start.S   |  193 ----------------------------------------
 arch/arm/cpu/arm720t/start.S   |  108 ----------------------
 arch/arm/cpu/arm920t/start.S   |  116 ------------------------
 arch/arm/cpu/arm925t/start.S   |  116 ------------------------
 arch/arm/cpu/arm926ejs/start.S |  125 --------------------------
 arch/arm/cpu/arm946es/start.S  |  111 -----------------------
 arch/arm/cpu/arm_intcm/start.S |  116 ------------------------
 arch/arm/cpu/armv7/start.S     |  121 -------------------------
 arch/arm/cpu/ixp/start.S       |  108 ----------------------
 arch/arm/cpu/lh7a40x/start.S   |  105 ----------------------
 arch/arm/cpu/pxa/start.S       |  121 -------------------------
 arch/arm/cpu/s3c44b0/start.S   |  108 ----------------------
 arch/arm/cpu/sa1100/start.S    |  105 ----------------------
 14 files changed, 0 insertions(+), 1667 deletions(-)
arch/arm/cpu/arm1136/start.S +0 -114
index e74d5f9..06c91dd 100644
@@ -181,120 +181,6 @@ call_board_init_f:
 
 	bl	board_init_f
 
-/*------------------------------------------------------------------------------*/
-
-/*
- * void relocate_code (addr_sp, gd, addr_moni)
- *
- * This "function" does not return, instead it continues in RAM
- * after relocating the monitor code.
- *
- */
-	.globl	relocate_code
-relocate_code:
-	mov	r4, r0	/* save addr_sp */
-	mov	r5, r1	/* save addr of gd */
-	mov	r6, r2	/* save addr of destination */
-
-	/* Set up the stack						    */
-stack_setup:
-	mov	sp, r4
-
-	adr	r0, _start
-	cmp	r0, r6
-	beq	clear_bss		/* skip relocation */
-	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
-	add	r2, r0, r3		/* r2 <- source end address	    */
-
-copy_loop:
-	ldmia	r0!, {r9-r10}		/* copy from source address [r0]    */
-	stmia	r1!, {r9-r10}		/* copy to   target address [r1]    */
-	cmp	r0, r2			/* until source end address [r2]    */
-	blo	copy_loop
-
-#ifndef CONFIG_SPL_BUILD
-	/*
-	 * fix .rel.dyn relocations
-	 */
-	ldr	r0, _TEXT_BASE		/* r0 <- Text base */
-	sub	r9, r6, r0		/* r9 <- relocation offset */
-	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */
-	add	r10, r10, r0		/* r10 <- sym table in FLASH */
-	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */
-	add	r2, r2, r0		/* r2 <- rel dyn start in FLASH */
-	ldr	r3, _rel_dyn_end_ofs	/* r3 <- rel dyn end ofs */
-	add	r3, r3, r0		/* r3 <- rel dyn end in FLASH */
-fixloop:
-	ldr	r0, [r2]		/* r0 <- location to fix up, IN FLASH! */
-	add	r0, r0, r9		/* r0 <- location to fix up in RAM */
-	ldr	r1, [r2, #4]
-	and	r7, r1, #0xff
-	cmp	r7, #23			/* relative fixup? */
-	beq	fixrel
-	cmp	r7, #2			/* absolute fixup? */
-	beq	fixabs
-	/* ignore unknown type of fixup */
-	b	fixnext
-fixabs:
-	/* absolute fix: set location to (offset) symbol value */
-	mov	r1, r1, LSR #4		/* r1 <- symbol index in .dynsym */
-	add	r1, r10, r1		/* r1 <- address of symbol in table */
-	ldr	r1, [r1, #4]		/* r1 <- symbol value */
-	add	r1, r1, r9		/* r1 <- relocated sym addr */
-	b	fixnext
-fixrel:
-	/* relative fix: increase location by offset */
-	ldr	r1, [r0]
-	add	r1, r1, r9
-fixnext:
-	str	r1, [r0]
-	add	r2, r2, #8		/* each rel.dyn entry is 8 bytes */
-	cmp	r2, r3
-	blo	fixloop
-#endif
-
-clear_bss:
-#ifndef CONFIG_SPL_BUILD
-	ldr	r0, _bss_start_ofs
-	ldr	r1, _bss_end_ofs
-	mov	r4, r6			/* reloc addr */
-	add	r0, r0, r4
-	add	r1, r1, r4
-	mov	r2, #0x00000000		/* clear			    */
-
-clbss_l:str	r2, [r0]		/* clear loop...		    */
-	add	r0, r0, #4
-	cmp	r0, r1
-	bne	clbss_l
-#endif	/* #ifndef CONFIG_SPL_BUILD */
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
-#ifdef CONFIG_NAND_SPL
-	ldr     r0, _nand_boot_ofs
-	mov	pc, r0
-
-_nand_boot_ofs:
-	.word nand_boot
-#else
-jump_2_ram:
-	ldr	r0, _board_init_r_ofs
-	ldr     r1, _TEXT_BASE
-	add	lr, r0, r1
-	add	lr, lr, r9
-	/* setup parameters for board_init_r */
-	mov	r0, r5		/* gd_t */
-	mov	r1, r6		/* dest_addr */
-	/* jump to it ... */
-	mov	pc, lr
-
-_board_init_r_ofs:
-	.word board_init_r - _start
-#endif
-
 /**
  * Jump to board_init_r with a new stack pointer
  *
arch/arm/cpu/arm1176/start.S +0 -193

206 lines not on this page · raw message

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

114 lines not on this page · raw message

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

122 lines not on this page · raw message

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

122 lines not on this page · raw message

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

131 lines not on this page · raw message

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

117 lines not on this page · raw message

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

122 lines not on this page · raw message

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

127 lines not on this page · raw message

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

114 lines not on this page · raw message

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

111 lines not on this page · raw message

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

127 lines not on this page · raw message

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

114 lines not on this page · raw message

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

111 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#44 lore raw

v4 cover Introduce generic relocation feature

In reply to Simon Glass

Hi Simon,

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

Amicalement,

Signature · 1 line
Albert.
#45 lore raw

v4 cover Introduce generic relocation feature

Hi Albert,

Quoted 5 lines · Albert ARIBAUD

Hi Simon,

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

Well the current relocation code is all in assembler and I don't believe it uses the stack at all. It does set up the stack pointer at the beginning if that's what you mean.

Yes this series uses the initial stack for all processing until it reaches board_init_r().

Quoted 4 lines

Amicalement,
--
Albert.

Regards,
Simon

#46 lore raw

v4 cover Introduce generic relocation feature

Hi Simon, Albert.

Quoted 10 lines · Simon Glass

Hi Albert,

Quoted 5 lines · Albert ARIBAUD

Hi Simon,

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

Quoted 6 lines

Well the current relocation code is all in assembler and I don't believe it uses the stack at all. It does set up the stack pointer at the beginning if that's what you mean.

Yes this series uses the initial stack for all processing until it reaches board_init_r().

<broken record>

See what x86 does - Code copy and relocation in C using final stack and full cache enabled...

</broken record> :)

Regards,

Graeme

#47 lore raw

v4 cover Introduce generic relocation feature

Hi Graeme,

Quoted 20 lines · Graeme Russ

Hi Simon, Albert.

Quoted 10 lines · Simon Glass

Hi Albert,

Quoted 5 lines · Albert ARIBAUD

Hi Simon,

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

Quoted 6 lines

Well the current relocation code is all in assembler and I don't believe it uses the stack at all. It does set up the stack pointer at the beginning if that's what you mean.

Yes this series uses the initial stack for all processing until it reaches board_init_r().

Quoted 6 lines

<broken record>

See what x86 does - Code copy and relocation in C using final stack and full cache enabled...

</broken record> :)

Heading there, but we can't enable dcache prior to relocation on ARM yet. Generic relocation gives me something to work with that isn't just for one architecture,

Regards,
Simon

Quoted 4 lines

Regards,

Graeme

A message that is not in the archive (sent off-list or not yet received): [email protected]

#49 lore raw

v4 cover Introduce generic relocation feature

Hi Albert,

Quoted 42 lines · Albert ARIBAUD

Hi Simon,

Le 21/02/2012 21:16, Simon Glass a ?crit :

Quoted 38 lines

Hi Graeme,

Quoted 32 lines · On Tue, Feb 21, 2012 at 12:10 PM, Graeme Russ<[email protected]> ?wrote:

Hi Simon, Albert.

Quoted 14 lines · Simon Glass

Hi Albert,

Quoted 7 lines · On Tue, Feb 21, 2012 at 11:40 AM, Albert ARIBAUD <[email protected]>…

Hi Simon,

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

Quoted 6 lines

Well the current relocation code is all in assembler and I don't believe it uses the stack at all. It does set up the stack pointer at the beginning if that's what you mean.

Yes this series uses the initial stack for all processing until it reaches board_init_r().

<broken record>

See what x86 does - Code copy and relocation in C using final stack and full cache enabled...

</broken record> ?:)

Quoted 7 lines
Quoted 3 lines

Heading there, but we can't enable dcache prior to relocation on ARM yet. Generic relocation gives me something to work with that isn't just for one architecture,

I'm not sure what is the relation between stack and caches exactly -- nor why we could not have caches enabled before relocation, for that matter.

Well here are my thoughts...

To enable the dcache on ARM we need an MMU page table. The position of this table is calculated in board_init_f() and it is set up by the dcache_enable in board_init_r().

The stack and caches are only related in the sense that they both need DRAM to be ready. So in principle I don't see any reason why we cannot enable the dcache during board_init_f().

What I suggested is that we tackle this once the generic board series goes in. I am happy to do this work. That way we only need to do one framework and all the archs can use it.

Regards,
Simon

Quoted 3 lines

Amicalement,
--
Albert.