* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
@ 2011-11-21 23:57 Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere Simon Glass
` (8 more replies)
0 siblings, 9 replies; 47+ messages in thread
From: Simon Glass @ 2011-11-21 23:57 UTC (permalink / raw)
To: u-boot
This is the second patch series aiming to unify the various board.c files
in each architecture into a single one. This series creates a libboard
library and implements relocation in it. It then moves ARM over to use
this framework, as an example.
On ARM the relocation code is duplicated for each CPU yet it
is the same. We can bring this up to the arch level. But since (I believe)
Elf relocation is basically the same process for all archs, there is no
reason not to bring it up to the generic level.
This series establishes a new libboard library in the board/ subdir and
puts some relocation code in it. Each architecture which uses this
framework needs to provide a function called arch_elf_relocate_entry()
which processes a single relocation entry. If there is concern about
calling a function for all 2000-odd relocations then I can change this.
For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
ARM assembler code (things that cannot be written in C and are common
functions used by all ARM CPUs). This helps reduce duplication. Interrupt
handling code and perhaps even some startup code can move there later.
It may be useful for other architectures to have a similar file.
This series moves ARM over to use this framework. Overall this means that
two new files are required 'early' in boot: board/reloc.c and
arch/arm/lib/proc.S. This is tricky mainly due to SPL. I believe that
we may need to adjust link scripts to put these two files early in the
link scripts also. But I am not sure about this and can't actually find
a problem as yet. I would much prefer to solve this with a new section
name like .text.early if we can.
(I should really cc all arch maintainers but I think in that case I get
an error from the list server. Not sure what the limit is.)
Comments please...
Simon Glass (7):
reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
reboard: Add generic link symbols
reboard: Add generic relocation feature
reboard: arm: Add relocation function
reboard: arm: Add processor function library
reboard: arm: Move over to generic relocation
reboard: arm: Remove unused code in start.S
Makefile | 1 +
README | 5 +
arch/arm/cpu/arm1136/start.S | 121 ----------------
arch/arm/cpu/arm1176/start.S | 202 ---------------------------
arch/arm/cpu/arm720t/start.S | 115 ---------------
arch/arm/cpu/arm920t/start.S | 123 ----------------
arch/arm/cpu/arm925t/start.S | 123 ----------------
arch/arm/cpu/arm926ejs/start.S | 130 -----------------
arch/arm/cpu/arm946es/start.S | 118 ----------------
arch/arm/cpu/arm_intcm/start.S | 123 ----------------
arch/arm/cpu/armv7/start.S | 126 -----------------
arch/arm/cpu/ixp/start.S | 115 ---------------
arch/arm/cpu/lh7a40x/start.S | 112 ---------------
arch/arm/cpu/pxa/start.S | 122 ----------------
arch/arm/cpu/s3c44b0/start.S | 115 ---------------
arch/arm/cpu/sa1100/start.S | 112 ---------------
arch/arm/lib/Makefile | 5 +
arch/arm/lib/arch_reloc.c | 47 ++++++
arch/arm/lib/proc.S | 35 +++++
arch/avr32/config.mk | 3 +
arch/blackfin/config.mk | 3 +
arch/m68k/config.mk | 3 +
arch/microblaze/config.mk | 3 +
arch/mips/config.mk | 3 +
arch/nds32/config.mk | 3 +
arch/nios2/config.mk | 3 +
arch/powerpc/config.mk | 3 +
arch/sandbox/config.mk | 3 +
arch/sh/config.mk | 3 +
arch/sparc/config.mk | 3 +
arch/x86/config.mk | 3 +
board/Makefile | 45 ++++++
board/reloc.c | 101 +++++++++++++
include/asm-generic/link_symbols.h | 38 +++++
include/common.h | 2 +-
include/reloc.h | 37 +++++
nand_spl/board/freescale/mx31pdk/Makefile | 8 +-
nand_spl/board/freescale/mx31pdk/u-boot.lds | 1 +
nand_spl/board/karo/tx25/Makefile | 8 +-
nand_spl/board/karo/tx25/u-boot.lds | 1 +
spl/Makefile | 1 +
41 files changed, 368 insertions(+), 1760 deletions(-)
create mode 100644 arch/arm/lib/arch_reloc.c
create mode 100644 arch/arm/lib/proc.S
create mode 100644 board/Makefile
create mode 100644 board/reloc.c
create mode 100644 include/asm-generic/link_symbols.h
create mode 100644 include/reloc.h
--
1.7.3.1
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
@ 2011-11-21 23:57 ` Simon Glass
2011-11-29 3:11 ` Mike Frysinger
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 2/7] reboard: Add generic link symbols Simon Glass
` (7 subsequent siblings)
8 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-11-21 23:57 UTC (permalink / raw)
To: u-boot
We are introducing a new unified board setup and we want this to
be the default. So we need to opt all architectures out first.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
README | 5 +++++
arch/arm/config.mk | 3 +++
arch/avr32/config.mk | 3 +++
arch/blackfin/config.mk | 3 +++
arch/m68k/config.mk | 3 +++
arch/microblaze/config.mk | 3 +++
arch/mips/config.mk | 3 +++
arch/nds32/config.mk | 3 +++
arch/nios2/config.mk | 3 +++
arch/powerpc/config.mk | 3 +++
arch/sandbox/config.mk | 3 +++
arch/sh/config.mk | 3 +++
arch/sparc/config.mk | 3 +++
arch/x86/config.mk | 3 +++
14 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/README b/README
index 07f1d11..c600ea1 100644
--- a/README
+++ b/README
@@ -2697,6 +2697,11 @@ Configuration Settings:
cases. This setting can be used to tune behaviour; see
lib/hashtable.c for details.
+- CONFIG_SYS_LEGACY_BOARD
+ This selects the legacy architecture-specific board system
+ instead of the cross-architecture board. It is intended to move
+ away from this over time.
+
The following definitions that deal with the placement and management
of environment data (variable area); in general, we support the
following configurations:
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 45f9dca..31e9ef9 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -33,6 +33,9 @@ endif
PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
PF_CPPFLAGS_ARM := $(call cc-option,-marm,)
diff --git a/arch/avr32/config.mk b/arch/avr32/config.mk
index d8e7ebb..6eb00f6 100644
--- a/arch/avr32/config.mk
+++ b/arch/avr32/config.mk
@@ -31,3 +31,6 @@ PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
LDFLAGS_u-boot = --gc-sections --relax
LDSCRIPT = $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
diff --git a/arch/blackfin/config.mk b/arch/blackfin/config.mk
index f9d46de..91ddc24 100644
--- a/arch/blackfin/config.mk
+++ b/arch/blackfin/config.mk
@@ -37,6 +37,9 @@ CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE)))
PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic
PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
LDFLAGS_FINAL += --gc-sections
LDFLAGS += -m elf32bfin
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
diff --git a/arch/m68k/config.mk b/arch/m68k/config.mk
index 11ba334..11ad9a5 100644
--- a/arch/m68k/config.mk
+++ b/arch/m68k/config.mk
@@ -29,3 +29,6 @@ PLATFORM_CPPFLAGS += -DCONFIG_M68K -D__M68K__
PLATFORM_LDFLAGS += -n
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
LDFLAGS_FINAL += --gc-sections
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk
index abea70b..119a596 100644
--- a/arch/microblaze/config.mk
+++ b/arch/microblaze/config.mk
@@ -29,3 +29,6 @@ CROSS_COMPILE ?= mb-
CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
diff --git a/arch/mips/config.mk b/arch/mips/config.mk
index 6ab8acd..8f5305e 100644
--- a/arch/mips/config.mk
+++ b/arch/mips/config.mk
@@ -27,6 +27,9 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T mips.lds
PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
#
# From Linux arch/mips/Makefile
#
diff --git a/arch/nds32/config.mk b/arch/nds32/config.mk
index c589829..f989053 100644
--- a/arch/nds32/config.mk
+++ b/arch/nds32/config.mk
@@ -33,3 +33,6 @@ PLATFORM_RELFLAGS += -gdwarf-2
PLATFORM_CPPFLAGS += -DCONFIG_NDS32 -D__nds32__ -G0 -ffixed-10 -fpie
LDFLAGS_u-boot = --gc-sections --relax
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk
index 7b03ed8..0172f70 100644
--- a/arch/nios2/config.mk
+++ b/arch/nios2/config.mk
@@ -31,3 +31,6 @@ PLATFORM_CPPFLAGS += -G0
LDFLAGS_FINAL += --gc-sections
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk
index a307154..e6203dd 100644
--- a/arch/powerpc/config.mk
+++ b/arch/powerpc/config.mk
@@ -29,6 +29,9 @@ PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections
PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
PLATFORM_LDFLAGS += -n
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
#
# When cross-compiling on NetBSD, we have to define __PPC__ or else we
# will pick up a va_list declaration that is incompatible with the
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index ab33026..251ccfd 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -18,3 +18,6 @@
# MA 02111-1307 USA
PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
diff --git a/arch/sh/config.mk b/arch/sh/config.mk
index 07ff8b9..0c21ef5 100644
--- a/arch/sh/config.mk
+++ b/arch/sh/config.mk
@@ -31,3 +31,6 @@ endif
PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__
PLATFORM_LDFLAGS += -e $(CONFIG_SYS_TEXT_BASE) --defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE)
LDFLAGS_FINAL = --gc-sections
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
diff --git a/arch/sparc/config.mk b/arch/sparc/config.mk
index cae7478..b98a173 100644
--- a/arch/sparc/config.mk
+++ b/arch/sparc/config.mk
@@ -26,3 +26,6 @@ CROSS_COMPILE ?= sparc-elf-
CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) -T sparc.lds
PLATFORM_CPPFLAGS += -DCONFIG_SPARC -D__sparc__
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index fe9083f..3736a68 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -41,3 +41,6 @@ PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions
LDFLAGS_FINAL += --gc-sections -pie
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
--
1.7.3.1
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 2/7] reboard: Add generic link symbols
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere Simon Glass
@ 2011-11-21 23:57 ` Simon Glass
2011-11-29 2:59 ` Mike Frysinger
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature Simon Glass
` (6 subsequent siblings)
8 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-11-21 23:57 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
include/asm-generic/link_symbols.h | 38 ++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
create mode 100644 include/asm-generic/link_symbols.h
diff --git a/include/asm-generic/link_symbols.h b/include/asm-generic/link_symbols.h
new file mode 100644
index 0000000..2ba185b
--- /dev/null
+++ b/include/asm-generic/link_symbols.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_GENERIC_LINKSYMBOLS_H
+#define __ASM_GENERIC_LINKSYMBOLS_H
+
+#include <elf.h>
+
+/* Exports from the Linker Script */
+extern uchar __text_start;
+extern uchar _end;
+extern uchar __image_copy_end;
+extern Elf32_Rel __rel_dyn_start[];
+extern Elf32_Rel __rel_dyn_end[];
+extern Elf32_Sym __dynsym_start[];
+extern uchar __bss_start;
+extern uchar __bss_end__;
+extern void _start(void);
+
+#endif
--
1.7.3.1
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 2/7] reboard: Add generic link symbols Simon Glass
@ 2011-11-21 23:57 ` Simon Glass
2011-11-29 3:07 ` Mike Frysinger
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 4/7] reboard: arm: Add relocation function Simon Glass
` (5 subsequent siblings)
8 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-11-21 23:57 UTC (permalink / raw)
To: u-boot
Add a relocation implementation as the first thing in the generic board
library. This library is needed by SPL also.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Makefile | 1 +
board/Makefile | 45 ++++++++++++++++++++++++
board/reloc.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/common.h | 2 +-
include/reloc.h | 37 ++++++++++++++++++++
spl/Makefile | 1 +
6 files changed, 186 insertions(+), 1 deletions(-)
create mode 100644 board/Makefile
create mode 100644 board/reloc.c
create mode 100644 include/reloc.h
diff --git a/Makefile b/Makefile
index fb658f4..d313481 100644
--- a/Makefile
+++ b/Makefile
@@ -221,6 +221,7 @@ LIBS = lib/libgeneric.o
LIBS += lib/lzma/liblzma.o
LIBS += lib/lzo/liblzo.o
LIBS += lib/zlib/libz.o
+LIBS += board/libboard.o
LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \
"board/$(VENDOR)/common/lib$(VENDOR).o"; fi)
LIBS += $(CPUDIR)/lib$(CPU).o
diff --git a/board/Makefile b/board/Makefile
new file mode 100644
index 0000000..e7f8b17
--- /dev/null
+++ b/board/Makefile
@@ -0,0 +1,45 @@
+#
+# (C) Copyright 2002-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = $(obj)libboard.o
+
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS += reloc.o
+endif
+
+SRCS := $(COBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS))
+
+$(LIB): $(obj).depend $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/reloc.c b/board/reloc.c
new file mode 100644
index 0000000..abd9c0b
--- /dev/null
+++ b/board/reloc.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm-generic/link_symbols.h>
+#include <reloc.h>
+#include <nand.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int reloc_make_copy(void)
+{
+ ulong *dst_addr = (ulong *)gd->relocaddr;
+
+ /* TODO: __text_start would be better when we have it */
+ ulong *src_addr = (ulong *)_start;
+ /* TODO: switch over to __image_copy_end when we can */
+#ifdef CONFIG_SPL_BUILD
+ ulong *end_addr = (ulong *)&__image_copy_end;
+#else
+ ulong *end_addr = (ulong *)&__rel_dyn_start;
+#endif
+
+ if (dst_addr != src_addr) {
+ while (src_addr < end_addr)
+ *dst_addr++ = *src_addr++;
+ }
+ return 0;
+}
+
+static int reloc_clear_bss(void)
+{
+ ulong *dst_addr = (ulong *)&__bss_start;
+
+ /* TODO: change to __bss_end */
+ ulong *end_addr = (ulong *)&__bss_end__;
+
+#ifndef CONFIG_SPL_BUILD
+ /* No relocation for SPL */
+ dst_addr += gd->reloc_off / sizeof(ulong);
+ end_addr += gd->reloc_off / sizeof(ulong);
+#endif
+
+ while (dst_addr < end_addr)
+ *dst_addr++ = 0;
+
+ return 0;
+}
+
+static int reloc_elf(void)
+{
+#ifndef CONFIG_SPL_BUILD
+ const Elf32_Rel *ptr;
+ Elf32_Addr *addr;
+
+ /* scan the relocation table for relevant entries */
+ for (ptr = __rel_dyn_start; ptr < __rel_dyn_end; ptr++) {
+ /* CONFIG_TEXT_BASE on x86 */
+ if (ptr->r_offset < CONFIG_SYS_TEXT_BASE)
+ continue;
+
+ addr = (Elf32_Addr *)(ptr->r_offset + gd->reloc_off);
+ if (arch_elf_relocate_entry(addr, ptr->r_info, __dynsym_start,
+ gd->reloc_off))
+ return -1;
+ }
+#endif
+ return 0;
+}
+
+void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+{
+ reloc_make_copy();
+ reloc_elf();
+ reloc_clear_bss();
+ /* TODO: tidy this up */
+#ifdef CONFIG_NAND_SPL
+ nand_boot();
+#else
+ proc_call_board_init_r(new_gd, dest_addr, board_init_r, dest_addr_sp);
+#endif
+}
diff --git a/include/common.h b/include/common.h
index 5ca8820..223bf52 100644
--- a/include/common.h
+++ b/include/common.h
@@ -469,7 +469,7 @@ int dcache_status (void);
void dcache_enable (void);
void dcache_disable(void);
void mmu_disable(void);
-void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
+#include <reloc.h>
ulong get_endaddr (void);
void trap_init (ulong);
#if defined (CONFIG_4xx) || \
diff --git a/include/reloc.h b/include/reloc.h
new file mode 100644
index 0000000..7a4f7aa
--- /dev/null
+++ b/include/reloc.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __RELOC_H
+#define __RELOC_H
+
+#include <elf.h>
+
+void proc_call_board_init_r(gd_t *new_gd, ulong dest_addr,
+ void (*board_init_r_func)(gd_t *, ulong), ulong dest_addr_sp)
+ __attribute__ ((noreturn));
+
+int arch_elf_relocate_entry(Elf32_Addr *addr, Elf32_Word info,
+ Elf32_Sym *symtab, ulong reloc_off);
+
+void relocate_code(ulong dest_sp, gd_t *new_gd, ulong dest_addr)
+ __attribute__ ((noreturn));
+#endif
diff --git a/spl/Makefile b/spl/Makefile
index 6ac42a2..103f773 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -39,6 +39,7 @@ LIBS-y += $(CPUDIR)/lib$(CPU).o
ifdef SOC
LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
endif
+LIBS-y += board/libboard.o
LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o
LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
--
1.7.3.1
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 4/7] reboard: arm: Add relocation function
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
` (2 preceding siblings ...)
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature Simon Glass
@ 2011-11-21 23:57 ` Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library Simon Glass
` (4 subsequent siblings)
8 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-11-21 23:57 UTC (permalink / raw)
To: u-boot
Add a function to process a single ELF relocation.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
arch/arm/lib/Makefile | 4 +++
arch/arm/lib/arch_reloc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/lib/arch_reloc.c
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 300c8fa..ca2802a 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -48,6 +48,10 @@ SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o
SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
endif
+ifndef CONFIG_SYS_LEGACY_BOARD
+COBJS-y += arch_reloc.o
+endif
+
SRCS := $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \
$(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
diff --git a/arch/arm/lib/arch_reloc.c b/arch/arm/lib/arch_reloc.c
new file mode 100644
index 0000000..80cf5a0
--- /dev/null
+++ b/arch/arm/lib/arch_reloc.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <elf.h>
+
+int arch_elf_relocate_entry(Elf32_Addr *addr, Elf32_Word info,
+ Elf32_Sym *symtab, ulong reloc_off)
+{
+ int sym;
+
+ switch (ELF32_R_TYPE(info)) {
+ /* relative fix: increase location by offset */
+ case 23: /* TODO: add R_ARM_... defines to elf.h */
+ *addr += reloc_off;
+ break;
+
+ /* absolute fix: set location to (offset) symbol value */
+ case 2:
+ sym = ELF32_R_SYM(info);
+ *addr = symtab[sym].st_value + reloc_off;
+ break;
+
+ default:
+ debug("*** Invalid relocation\n");
+ return -1;
+ }
+ return 0;
+}
--
1.7.3.1
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
` (3 preceding siblings ...)
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 4/7] reboard: arm: Add relocation function Simon Glass
@ 2011-11-21 23:57 ` Simon Glass
2011-11-29 3:12 ` Mike Frysinger
2011-12-07 7:44 ` Albert ARIBAUD
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 6/7] reboard: arm: Move over to generic relocation Simon Glass
` (3 subsequent siblings)
8 siblings, 2 replies; 47+ messages in thread
From: Simon Glass @ 2011-11-21 23:57 UTC (permalink / raw)
To: u-boot
Add a library to hold ARM assembler code which is generic across all
ARM CPUs.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
arch/arm/lib/Makefile | 1 +
arch/arm/lib/proc.S | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/lib/proc.S
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index ca2802a..27749dc 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -50,6 +50,7 @@ endif
ifndef CONFIG_SYS_LEGACY_BOARD
COBJS-y += arch_reloc.o
+SOBJS-y += proc.o
endif
SRCS := $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \
diff --git a/arch/arm/lib/proc.S b/arch/arm/lib/proc.S
new file mode 100644
index 0000000..99a2944
--- /dev/null
+++ b/arch/arm/lib/proc.S
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+/**
+ * Jump to board_init_r with a new stack pointer
+ *
+ * @param gd Pointer to global data
+ * @param dest_addr Destination address from global data
+ * @param func Address of board_init_r function (relocated)
+ * @param sp New stack pointer
+ */
+.globl proc_call_board_init_r
+proc_call_board_init_r:
+ mov sp, r3
+ /* jump to it ... */
+ mov pc, r2
--
1.7.3.1
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 6/7] reboard: arm: Move over to generic relocation
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
` (4 preceding siblings ...)
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library Simon Glass
@ 2011-11-21 23:57 ` Simon Glass
2011-11-29 3:14 ` Mike Frysinger
2011-11-21 23:58 ` [U-Boot] [RFC PATCH 7/7] reboard: arm: Remove unused code in start.S Simon Glass
` (2 subsequent siblings)
8 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-11-21 23:57 UTC (permalink / raw)
To: u-boot
Switch ARM over to generic relocation - unfortunately a few boards need
to be modified to make this work. We rename the relocate_code() function
here so that the existing start.S implementations are still used for now.
The next commit does the actual switch.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
arch/arm/config.mk | 3 ---
board/reloc.c | 2 +-
nand_spl/board/freescale/mx31pdk/Makefile | 8 +++++++-
nand_spl/board/freescale/mx31pdk/u-boot.lds | 1 +
nand_spl/board/karo/tx25/Makefile | 8 +++++++-
nand_spl/board/karo/tx25/u-boot.lds | 1 +
6 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 31e9ef9..45f9dca 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -33,9 +33,6 @@ endif
PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
-# Move to unified board system later
-CONFIG_SYS_LEGACY_BOARD := y
-
# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
PF_CPPFLAGS_ARM := $(call cc-option,-marm,)
diff --git a/board/reloc.c b/board/reloc.c
index abd9c0b..edbeabb 100644
--- a/board/reloc.c
+++ b/board/reloc.c
@@ -87,7 +87,7 @@ static int reloc_elf(void)
return 0;
}
-void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
{
reloc_make_copy();
reloc_elf();
diff --git a/nand_spl/board/freescale/mx31pdk/Makefile b/nand_spl/board/freescale/mx31pdk/Makefile
index 87784d2..3e858b8 100644
--- a/nand_spl/board/freescale/mx31pdk/Makefile
+++ b/nand_spl/board/freescale/mx31pdk/Makefile
@@ -11,7 +11,7 @@ LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
AFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
-SOBJS = start.o lowlevel_init.o
+SOBJS = start.o lowlevel_init.o proc.o reloc.o
COBJS = nand_boot_fsl_nfc.o
SRCS := $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c
@@ -50,6 +50,12 @@ $(obj)%.o: $(SRCTREE)/board/freescale/mx31pdk/%.S
$(obj)%.o: $(SRCTREE)/nand_spl/%.c
$(CC) $(CFLAGS) -c -o $@ $<
+$(obj)%.o: $(SRCTREE)/board/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)%.o: $(SRCTREE)/arch/arm/lib/%.S
+ $(CC) $(AFLAGS) -c -o $@ $<
+
# defines $(obj).depend target
include $(SRCTREE)/rules.mk
diff --git a/nand_spl/board/freescale/mx31pdk/u-boot.lds b/nand_spl/board/freescale/mx31pdk/u-boot.lds
index d2b08f6..2273e9b 100644
--- a/nand_spl/board/freescale/mx31pdk/u-boot.lds
+++ b/nand_spl/board/freescale/mx31pdk/u-boot.lds
@@ -51,6 +51,7 @@ SECTIONS
__u_boot_cmd_end = .;
. = ALIGN(4);
+ __image_copy_end = .;
.rel.dyn : {
__rel_dyn_start = .;
diff --git a/nand_spl/board/karo/tx25/Makefile b/nand_spl/board/karo/tx25/Makefile
index 0336346..5063c06 100644
--- a/nand_spl/board/karo/tx25/Makefile
+++ b/nand_spl/board/karo/tx25/Makefile
@@ -32,7 +32,7 @@ LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
AFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL
-SOBJS = start.o lowlevel_init.o
+SOBJS = start.o lowlevel_init.o proc.o reloc.o
COBJS = nand_boot_fsl_nfc.o
SRCS := $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c
@@ -71,6 +71,12 @@ $(obj)%.o: $(SRCTREE)/board/karo/tx25/%.S
$(obj)%.o: $(SRCTREE)/nand_spl/%.c
$(CC) $(CFLAGS) -c -o $@ $<
+$(obj)%.o: $(SRCTREE)/board/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)%.o: $(SRCTREE)/arch/arm/lib/%.S
+ $(CC) $(AFLAGS) -c -o $@ $<
+
# defines $(obj).depend target
include $(SRCTREE)/rules.mk
diff --git a/nand_spl/board/karo/tx25/u-boot.lds b/nand_spl/board/karo/tx25/u-boot.lds
index d2b08f6..2273e9b 100644
--- a/nand_spl/board/karo/tx25/u-boot.lds
+++ b/nand_spl/board/karo/tx25/u-boot.lds
@@ -51,6 +51,7 @@ SECTIONS
__u_boot_cmd_end = .;
. = ALIGN(4);
+ __image_copy_end = .;
.rel.dyn : {
__rel_dyn_start = .;
--
1.7.3.1
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 7/7] reboard: arm: Remove unused code in start.S
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
` (5 preceding siblings ...)
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 6/7] reboard: arm: Move over to generic relocation Simon Glass
@ 2011-11-21 23:58 ` Simon Glass
2011-11-29 3:15 ` Mike Frysinger
2011-11-28 23:45 ` [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Tom Rini
2011-12-07 8:10 ` Albert ARIBAUD
8 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-11-21 23:58 UTC (permalink / raw)
To: u-boot
Now that we are using the generic relocation framework,
we don't need this code. Once it is removed, we can change reloc.c's
relocate_code() function back to its correct name.
Note: Here we lose the ARM1176's enable_mmu code. This seems to duplicate
code already in U-Boot now. Can anyone comment on this?
Signed-off-by: Simon Glass <sjg@chromium.org>
---
arch/arm/cpu/arm1136/start.S | 121 ------------------------
arch/arm/cpu/arm1176/start.S | 202 ----------------------------------------
arch/arm/cpu/arm720t/start.S | 115 -----------------------
arch/arm/cpu/arm920t/start.S | 123 ------------------------
arch/arm/cpu/arm925t/start.S | 123 ------------------------
arch/arm/cpu/arm926ejs/start.S | 130 --------------------------
arch/arm/cpu/arm946es/start.S | 118 -----------------------
arch/arm/cpu/arm_intcm/start.S | 123 ------------------------
arch/arm/cpu/armv7/start.S | 126 -------------------------
arch/arm/cpu/ixp/start.S | 115 -----------------------
arch/arm/cpu/lh7a40x/start.S | 112 ----------------------
arch/arm/cpu/pxa/start.S | 122 ------------------------
arch/arm/cpu/s3c44b0/start.S | 115 -----------------------
arch/arm/cpu/sa1100/start.S | 112 ----------------------
board/reloc.c | 2 +-
15 files changed, 1 insertions(+), 1758 deletions(-)
diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S
index c0db96c..d69aa5d 100644
--- a/arch/arm/cpu/arm1136/start.S
+++ b/arch/arm/cpu/arm1136/start.S
@@ -169,127 +169,6 @@ call_board_init_f:
bl board_init_f
-/*------------------------------------------------------------------------------*/
-
-/*
- * void relocate_code (addr_sp, gd, addr_moni)
- *
- * This "function" does not return, instead it continues in RAM
- * after relocating the monitor code.
- *
- */
- .globl relocate_code
-relocate_code:
- mov r4, r0 /* save addr_sp */
- mov r5, r1 /* save addr of gd */
- mov r6, r2 /* save addr of destination */
-
- /* Set up the stack */
-stack_setup:
- mov sp, r4
-
- adr r0, _start
- cmp r0, r6
- beq clear_bss /* skip relocation */
- mov r1, r6 /* r1 <- scratch for copy_loop */
- ldr r3, _bss_start_ofs
- add r2, r0, r3 /* r2 <- source end address */
-
-copy_loop:
- ldmia r0!, {r9-r10} /* copy from source address [r0] */
- stmia r1!, {r9-r10} /* copy to target address [r1] */
- cmp r0, r2 /* until source end address [r2] */
- blo copy_loop
-
-#ifndef CONFIG_SPL_BUILD
- /*
- * fix .rel.dyn relocations
- */
- ldr r0, _TEXT_BASE /* r0 <- Text base */
- sub r9, r6, r0 /* r9 <- relocation offset */
- ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */
- add r10, r10, r0 /* r10 <- sym table in FLASH */
- ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */
- add r2, r2, r0 /* r2 <- rel dyn start in FLASH */
- ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */
- add r3, r3, r0 /* r3 <- rel dyn end in FLASH */
-fixloop:
- ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */
- add r0, r0, r9 /* r0 <- location to fix up in RAM */
- ldr r1, [r2, #4]
- and r7, r1, #0xff
- cmp r7, #23 /* relative fixup? */
- beq fixrel
- cmp r7, #2 /* absolute fixup? */
- beq fixabs
- /* ignore unknown type of fixup */
- b fixnext
-fixabs:
- /* absolute fix: set location to (offset) symbol value */
- mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */
- add r1, r10, r1 /* r1 <- address of symbol in table */
- ldr r1, [r1, #4] /* r1 <- symbol value */
- add r1, r1, r9 /* r1 <- relocated sym addr */
- b fixnext
-fixrel:
- /* relative fix: increase location by offset */
- ldr r1, [r0]
- add r1, r1, r9
-fixnext:
- str r1, [r0]
- add r2, r2, #8 /* each rel.dyn entry is 8 bytes */
- cmp r2, r3
- blo fixloop
-#endif
-
-clear_bss:
-#ifndef CONFIG_SPL_BUILD
- ldr r0, _bss_start_ofs
- ldr r1, _bss_end_ofs
- mov r4, r6 /* reloc addr */
- add r0, r0, r4
- add r1, r1, r4
- mov r2, #0x00000000 /* clear */
-
-clbss_l:str r2, [r0] /* clear loop... */
- add r0, r0, #4
- cmp r0, r1
- bne clbss_l
-#endif /* #ifndef CONFIG_SPL_BUILD */
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
-#ifdef CONFIG_NAND_SPL
- ldr r0, _nand_boot_ofs
- mov pc, r0
-
-_nand_boot_ofs:
- .word nand_boot
-#else
-jump_2_ram:
- ldr r0, _board_init_r_ofs
- ldr r1, _TEXT_BASE
- add lr, r0, r1
- add lr, lr, r9
- /* setup parameters for board_init_r */
- mov r0, r5 /* gd_t */
- mov r1, r6 /* dest_addr */
- /* jump to it ... */
- mov pc, lr
-
-_board_init_r_ofs:
- .word board_init_r - _start
-#endif
-
-_rel_dyn_start_ofs:
- .word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
- .word __rel_dyn_end - _start
-_dynsym_start_ofs:
- .word __dynsym_start - _start
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S
index 848144a..5b90810 100644
--- a/arch/arm/cpu/arm1176/start.S
+++ b/arch/arm/cpu/arm1176/start.S
@@ -231,208 +231,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
-#ifdef CONFIG_ENABLE_MMU
-enable_mmu:
- /* enable domain access */
- ldr r5, =0x0000ffff
- mcr p15, 0, r5, c3, c0, 0 /* load domain access register */
-
- /* Set the TTB register */
- ldr r0, _mmu_table_base
- ldr r1, =CONFIG_SYS_PHY_UBOOT_BASE
- ldr r2, =0xfff00000
- bic r0, r0, r2
- orr r1, r0, r1
- mcr p15, 0, r1, c2, c0, 0
-
- /* Enable the MMU */
- mrc p15, 0, r0, c1, c0, 0
- orr r0, r0, #1 /* Set CR_M to enable MMU */
-
- /* Prepare to enable the MMU */
- adr r1, skip_hw_init
- and r1, r1, #0x3fc
- ldr r2, _TEXT_BASE
- ldr r3, =0xfff00000
- and r2, r2, r3
- orr r2, r2, r1
- b mmu_enable
-
- .align 5
- /* Run in a single cache-line */
-mmu_enable:
-
- mcr p15, 0, r0, c1, c0, 0
- nop
- nop
- mov pc, r2
-skip_hw_init:
-#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
-
-#ifndef CONFIG_NAND_SPL
- bl coloured_LED_init
- bl red_led_on
-#endif
-#endif
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
-#ifdef CONFIG_NAND_SPL
- ldr pc, _nand_boot
-
-_nand_boot: .word nand_boot
-#else
- ldr r0, _board_init_r_ofs
- adr r1, _start
- add lr, r0, r1
- add lr, lr, r9
- /* setup parameters for board_init_r */
- mov r0, r5 /* gd_t */
- mov r1, r6 /* dest_addr */
- /* jump to it ... */
- mov pc, lr
-
-_board_init_r_ofs:
- .word board_init_r - _start
-#endif
-
-_rel_dyn_start_ofs:
- .word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
- .word __rel_dyn_end - _start
-_dynsym_start_ofs:
- .word __dynsym_start - _start
-
-#ifdef CONFIG_ENABLE_MMU
-_mmu_table_base:
- .word mmu_table
-#endif
-
-#ifndef CONFIG_NAND_SPL
-/*
- * we assume that cache operation is done before. (eg. cleanup_before_linux())
- * actually, we don't need to do anything about cache if not use d-cache in
- * U-Boot. So, in this function we clean only MMU. by scsuh
- *
- * void theLastJump(void *kernel, int arch_num, uint boot_params);
- */
-#ifdef CONFIG_ENABLE_MMU
- .globl theLastJump
-theLastJump:
- mov r9, r0
- ldr r3, =0xfff00000
- ldr r4, _TEXT_PHY_BASE
- adr r5, phy_last_jump
- bic r5, r5, r3
- orr r5, r5, r4
- mov pc, r5
-phy_last_jump:
- /*
- * disable MMU stuff
- */
- mrc p15, 0, r0, c1, c0, 0
- bic r0, r0, #0x00002300 /* clear bits 13, 9:8 (--V- --RS) */
- bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */
- orr r0, r0, #0x00000002 /* set bit 2 (A) Align */
- orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */
- mcr p15, 0, r0, c1, c0, 0
-
- mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
-
- mov r0, #0
- mov pc, r9
-#endif
-
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S
index 540e3c2..e80d281 100644
--- a/arch/arm/cpu/arm720t/start.S
+++ b/arch/arm/cpu/arm720t/start.S
@@ -146,121 +146,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
- bl coloured_LED_init
- bl red_led_on
-#endif
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
- ldr r0, _board_init_r_ofs
- adr r1, _start
- 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
-
-_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
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/arm920t/start.S b/arch/arm/cpu/arm920t/start.S
index 8c5612c..6b84bdf 100644
--- a/arch/arm/cpu/arm920t/start.S
+++ b/arch/arm/cpu/arm920t/start.S
@@ -189,129 +189,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
- bl coloured_LED_init
- bl red_led_on
-#endif
-
-/*
- * 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
- ldr r0, _board_init_r_ofs
- adr r1, _start
- add lr, r0, r1
- add lr, lr, r9
- /* setup parameters for board_init_r */
- mov r0, r5 /* gd_t */
- mov r1, r6 /* dest_addr */
- /* jump to it ... */
- mov pc, lr
-
-_board_init_r_ofs:
- .word board_init_r - _start
-#endif
-
-_rel_dyn_start_ofs:
- .word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
- .word __rel_dyn_end - _start
-_dynsym_start_ofs:
- .word __dynsym_start - _start
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/arm925t/start.S b/arch/arm/cpu/arm925t/start.S
index dbb93ef..cd395f9 100644
--- a/arch/arm/cpu/arm925t/start.S
+++ b/arch/arm/cpu/arm925t/start.S
@@ -183,129 +183,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
- bl coloured_LED_init
- bl red_led_on
-#endif
-
-/*
- * 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
- ldr r0, _board_init_r_ofs
- adr r1, _start
- add lr, r0, r1
- add lr, lr, r9
- /* setup parameters for board_init_r */
- mov r0, r5 /* gd_t */
- mov r1, r6 /* dest_addr */
- /* jump to it ... */
- mov pc, lr
-
-_board_init_r_ofs:
- .word board_init_r - _start
-#endif
-
-_rel_dyn_start_ofs:
- .word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
- .word __rel_dyn_end - _start
-_dynsym_start_ofs:
- .word __dynsym_start - _start
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S
index 339c5ed..837526b 100644
--- a/arch/arm/cpu/arm926ejs/start.S
+++ b/arch/arm/cpu/arm926ejs/start.S
@@ -213,136 +213,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
- sub r9, r6, r0 /* r9 <- relocation offset */
- 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:
-#ifdef CONFIG_SPL_BUILD
- /* No relocation for SPL */
- ldr r0, =__bss_start
- ldr r1, =__bss_end__
-#else
- ldr r0, _bss_start_ofs
- ldr r1, _bss_end_ofs
- mov r4, r6 /* reloc addr */
- add r0, r0, r4
- add r1, r1, r4
-#endif
- mov r2, #0x00000000 /* clear */
-
-clbss_l:str r2, [r0] /* clear loop... */
- add r0, r0, #4
- cmp r0, r1
- bne clbss_l
-
-#ifndef CONFIG_SPL_BUILD
- bl coloured_LED_init
- bl red_led_on
-#endif
-
-/*
- * 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
- ldr r0, _board_init_r_ofs
- ldr r1, _TEXT_BASE
- add lr, r0, r1
- add lr, lr, r9
- /* setup parameters for board_init_r */
- mov r0, r5 /* gd_t */
- mov r1, r6 /* dest_addr */
- /* jump to it ... */
- mov pc, lr
-
-_board_init_r_ofs:
- .word board_init_r - _start
-#endif
-
-_rel_dyn_start_ofs:
- .word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
- .word __rel_dyn_end - _start
-_dynsym_start_ofs:
- .word __dynsym_start - _start
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/arm946es/start.S b/arch/arm/cpu/arm946es/start.S
index 89ba558..ead9fb0 100644
--- a/arch/arm/cpu/arm946es/start.S
+++ b/arch/arm/cpu/arm946es/start.S
@@ -154,124 +154,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
- blo clbss_l
-#endif
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
-#ifdef CONFIG_NAND_SPL
- ldr pc, _nand_boot
-
-_nand_boot: .word nand_boot
-#else
- ldr r0, _board_init_r_ofs
- adr r1, _start
- add lr, r0, r1
- add lr, lr, r9
- /* setup parameters for board_init_r */
- mov r0, r5 /* gd_t */
- mov r1, r6 /* dest_addr */
- /* jump to it ... */
- mov pc, lr
-
-_board_init_r_ofs:
- .word board_init_r - _start
-#endif
-
-_rel_dyn_start_ofs:
- .word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
- .word __rel_dyn_end - _start
-_dynsym_start_ofs:
- .word __dynsym_start - _start
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/arm_intcm/start.S b/arch/arm/cpu/arm_intcm/start.S
index 2033b36..54448bd 100644
--- a/arch/arm/cpu/arm_intcm/start.S
+++ b/arch/arm/cpu/arm_intcm/start.S
@@ -150,129 +150,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
- bl coloured_LED_init
- bl red_led_on
-#endif
-
-/*
- * 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
- ldr r0, _board_init_r_ofs
- adr r1, _start
- add lr, r0, r1
- add lr, lr, r9
- /* setup parameters for board_init_r */
- mov r0, r5 /* gd_t */
- mov r1, r6 /* dest_addr */
- /* jump to it ... */
- mov pc, lr
-
-_board_init_r_ofs:
- .word board_init_r - _start
-#endif
-
-_rel_dyn_start_ofs:
- .word __rel_dyn_start - _start
-_rel_dyn_end_ofs:
- .word __rel_dyn_end - _start
-_dynsym_start_ofs:
- .word __dynsym_start - _start
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index db8e9d2..bb77fde 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -180,132 +180,6 @@ call_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
- moveq r9, #0 /* no relocation. relocation offset(r9) = 0 */
- beq clear_bss /* skip relocation */
- mov r1, r6 /* r1 <- scratch for copy_loop */
- ldr r3, _image_copy_end_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
- 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 */
-
-clear_bss:
-#ifdef CONFIG_SPL_BUILD
- /* No relocation for SPL */
- ldr r0, =__bss_start
- ldr r1, =__bss_end__
-#else
- ldr r0, _bss_start_ofs
- ldr r1, _bss_end_ofs
- mov r4, r6 /* reloc addr */
- add r0, r0, r4
- add r1, r1, r4
-#endif
- mov r2, #0x00000000 /* clear */
-
-clbss_l:str r2, [r0] /* clear loop... */
- add r0, r0, #4
- cmp r0, r1
- bne clbss_l
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
-jump_2_ram:
-/*
- * If I-cache is enabled invalidate it
- */
-#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
- ldr r0, _board_init_r_ofs
- adr r1, _start
- 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
-
-
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
/*************************************************************************
*
diff --git a/arch/arm/cpu/ixp/start.S b/arch/arm/cpu/ixp/start.S
index cb32121..33f471d 100644
--- a/arch/arm/cpu/ixp/start.S
+++ b/arch/arm/cpu/ixp/start.S
@@ -252,121 +252,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
- bl coloured_LED_init
- bl red_led_on
-#endif
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
- ldr r0, _board_init_r_ofs
- adr r1, _start
- 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
-
-_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 */
diff --git a/arch/arm/cpu/lh7a40x/start.S b/arch/arm/cpu/lh7a40x/start.S
index 62de8b8..014370c 100644
--- a/arch/arm/cpu/lh7a40x/start.S
+++ b/arch/arm/cpu/lh7a40x/start.S
@@ -163,118 +163,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
- ldr r0, _board_init_r_ofs
- adr r1, _start
- 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
-
-_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
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S
index 6191a73..76c693f 100644
--- a/arch/arm/cpu/pxa/start.S
+++ b/arch/arm/cpu/pxa/start.S
@@ -228,128 +228,6 @@ call_board_init_f:
ldr r0,=0x00000000
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 */
-
- stmfd sp!, {r0-r12}
-copy_loop:
- ldmia r0!, {r3-r5, r7-r11} /* copy from source address [r0] */
- stmia r1!, {r3-r5, r7-r11} /* copy to target address [r1] */
- cmp r0, r2 /* until source end address [r2] */
- blo copy_loop
- ldmfd sp!, {r0-r12}
-
-#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, 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 /* #ifndef CONFIG_SPL_BUILD */
-
-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_ONENAND_IPL
- ldr r0, _start_oneboot_ofs
- mov pc, r0
-
-_start_oneboot_ofs
- : .word start_oneboot
-#else
- ldr r0, _board_init_r_ofs
- adr r1, _start
- 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 /* CONFIG_ONENAND_IPL */
-
-_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
-
#else /* CONFIG_SPL_BUILD */
/****************************************************************************/
diff --git a/arch/arm/cpu/s3c44b0/start.S b/arch/arm/cpu/s3c44b0/start.S
index a29d5b4..10a8cc9 100644
--- a/arch/arm/cpu/s3c44b0/start.S
+++ b/arch/arm/cpu/s3c44b0/start.S
@@ -135,121 +135,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
- bl coloured_LED_init
- bl red_led_on
-#endif
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
- ldr r0, _board_init_r_ofs
- adr r1, _start
- 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
-
-_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
-
/*
*************************************************************************
*
diff --git a/arch/arm/cpu/sa1100/start.S b/arch/arm/cpu/sa1100/start.S
index 92546d8..fa7a3be 100644
--- a/arch/arm/cpu/sa1100/start.S
+++ b/arch/arm/cpu/sa1100/start.S
@@ -139,118 +139,6 @@ call_board_init_f:
ldr r0,=0x00000000
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
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
- ldr r0, _board_init_r_ofs
- adr r1, _start
- 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
-
-_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
-
/*
*************************************************************************
*
diff --git a/board/reloc.c b/board/reloc.c
index edbeabb..abd9c0b 100644
--- a/board/reloc.c
+++ b/board/reloc.c
@@ -87,7 +87,7 @@ static int reloc_elf(void)
return 0;
}
-void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
+void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
{
reloc_make_copy();
reloc_elf();
--
1.7.3.1
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
` (6 preceding siblings ...)
2011-11-21 23:58 ` [U-Boot] [RFC PATCH 7/7] reboard: arm: Remove unused code in start.S Simon Glass
@ 2011-11-28 23:45 ` Tom Rini
2011-12-07 1:56 ` Simon Glass
2011-12-07 23:29 ` Simon Glass
2011-12-07 8:10 ` Albert ARIBAUD
8 siblings, 2 replies; 47+ messages in thread
From: Tom Rini @ 2011-11-28 23:45 UTC (permalink / raw)
To: u-boot
On Mon, Nov 21, 2011 at 4:57 PM, Simon Glass <sjg@chromium.org> wrote:
> This is the second patch series aiming to unify the various board.c files
> in each architecture into a single one. This series creates a libboard
> library and implements relocation in it. It then moves ARM over to use
> this framework, as an example.
>
> On ARM the relocation code is duplicated for each CPU yet it
> is the same. We can bring this up to the arch level. But since (I believe)
> Elf relocation is basically the same process for all archs, there is no
> reason not to bring it up to the generic level.
>
> This series establishes a new libboard library in the board/ subdir and
> puts some relocation code in it. Each architecture which uses this
> framework needs to provide a function called arch_elf_relocate_entry()
> which processes a single relocation entry. If there is concern about
> calling a function for all 2000-odd relocations then I can change this.
>
> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
> ARM assembler code (things that cannot be written in C and are common
> functions used by all ARM CPUs). This helps reduce duplication. Interrupt
> handling code and perhaps even some startup code can move there later.
>
> It may be useful for other architectures to have a similar file.
>
> This series moves ARM over to use this framework. Overall this means that
> two new files are required 'early' in boot: board/reloc.c and
> arch/arm/lib/proc.S. ?This is tricky mainly due to SPL. I believe that
> we may need to adjust link scripts to put these two files early in the
> link scripts also. But I am not sure about this and can't actually find
> a problem as yet. I would much prefer to solve this with a new section
> name like .text.early if we can.
>
> (I should really cc all arch maintainers but I think in that case I get
> an error from the list server. Not sure what the limit is.)
>
> Comments please...
Seems like a good idea. Got some size's before and after? Maybe some
boot times too (as you mention 2000-odd function calls during
relocation) ?
--
Tom
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 2/7] reboard: Add generic link symbols
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 2/7] reboard: Add generic link symbols Simon Glass
@ 2011-11-29 2:59 ` Mike Frysinger
2011-12-07 22:37 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 2:59 UTC (permalink / raw)
To: u-boot
On Monday 21 November 2011 18:57:55 Simon Glass wrote:
> include/asm-generic/link_symbols.h | 38
this should be asm-generic/sections.h. might actually want to import the
Linux one and then add a section for u-boot specific symbols.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/27e276e7/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature Simon Glass
@ 2011-11-29 3:07 ` Mike Frysinger
2011-11-29 22:15 ` Simon Glass
2011-12-07 22:45 ` Simon Glass
0 siblings, 2 replies; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 3:07 UTC (permalink / raw)
To: u-boot
On Monday 21 November 2011 18:57:56 Simon Glass wrote:
> board/Makefile | 45
> board/reloc.c | 101
not to bikeshed, but i don't think we want files in board/. how about
board/common/ or board/generic/ instead ?
> --- /dev/null
> +++ b/board/Makefile
>
> +ifndef CONFIG_SYS_LEGACY_BOARD
> +COBJS += reloc.o
> +endif
i don't think relocation should be tied "legacy board". not all arches do
relocation at all, which means they might never opt in to this aspect.
> --- a/include/common.h
> +++ b/include/common.h
>
> -void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
> +#include <reloc.h>
i'd think very few funcs would need this. so maybe we should make the few
places include reloc.h explicitly.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/fc74e51a/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere Simon Glass
@ 2011-11-29 3:11 ` Mike Frysinger
2011-11-29 20:08 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 3:11 UTC (permalink / raw)
To: u-boot
On Monday 21 November 2011 18:57:54 Simon Glass wrote:
> We are introducing a new unified board setup and we want this to
> be the default. So we need to opt all architectures out first.
the define says "BOARD", so shouldn't it be in board configs ? we can do that
easily: add it to include/config_defaults.h. then boards that opt into it will
#undef it in their own configs.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/6e213a0b/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library Simon Glass
@ 2011-11-29 3:12 ` Mike Frysinger
2011-12-07 7:44 ` Albert ARIBAUD
1 sibling, 0 replies; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 3:12 UTC (permalink / raw)
To: u-boot
On Monday 21 November 2011 18:57:58 Simon Glass wrote:
> +.globl proc_call_board_init_r
> +proc_call_board_init_r:
ENTRY(proc_call_board_init_r)
> + mov sp, r3
> + /* jump to it ... */
> + mov pc, r2
then add ENDPROC(proc_call_board_init_r) here
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/04015bbc/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 6/7] reboard: arm: Move over to generic relocation
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 6/7] reboard: arm: Move over to generic relocation Simon Glass
@ 2011-11-29 3:14 ` Mike Frysinger
2011-12-09 3:41 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 3:14 UTC (permalink / raw)
To: u-boot
On Monday 21 November 2011 18:57:59 Simon Glass wrote:
> --- a/board/reloc.c
> +++ b/board/reloc.c
>
> -void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
> +void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
shouldn't this be squashed into the patch that added this func ?
> --- a/nand_spl/board/freescale/mx31pdk/Makefile
> +++ b/nand_spl/board/freescale/mx31pdk/Makefile
>
> +$(obj)%.o: $(SRCTREE)/board/%.c
> + $(CC) $(CFLAGS) -c -o $@ $<
> +
> +$(obj)%.o: $(SRCTREE)/arch/arm/lib/%.S
> + $(CC) $(AFLAGS) -c -o $@ $<
ugh. is this the SOP for SPL or something ? this is awful :(.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/a36ad23a/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 7/7] reboard: arm: Remove unused code in start.S
2011-11-21 23:58 ` [U-Boot] [RFC PATCH 7/7] reboard: arm: Remove unused code in start.S Simon Glass
@ 2011-11-29 3:15 ` Mike Frysinger
2011-12-09 3:42 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 3:15 UTC (permalink / raw)
To: u-boot
On Monday 21 November 2011 18:58:00 Simon Glass wrote:
> --- a/board/reloc.c
> +++ b/board/reloc.c
>
> -void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
> +void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
this is too fragile. we can't have every arch transition the way you did with
arm (otherwise arches that have transitioned will break in between). declare
this func weak and don't rename it. then there should be no migration issue.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/4f1806d9/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-29 3:11 ` Mike Frysinger
@ 2011-11-29 20:08 ` Simon Glass
2011-11-29 21:40 ` Mike Frysinger
0 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-11-29 20:08 UTC (permalink / raw)
To: u-boot
Hi Mike,
On Mon, Nov 28, 2011 at 7:11 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 21 November 2011 18:57:54 Simon Glass wrote:
>> We are introducing a new unified board setup and we want this to
>> be the default. So we need to opt all architectures out first.
>
> the define says "BOARD", so shouldn't it be in board configs ? ?we can do that
> easily: add it to include/config_defaults.h. ?then boards that opt into it will
> #undef it in their own configs.
Thanks for looking at this.
I see this as an architecture feature - perhaps a rename to something
like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving
boards over one at a time, or having boards for a particular
architecture that still do things the old way - it just increases
maintenance and means that my eventual patch to remove
arch/xxx/lib/board.c cannot be applied.
My idea for this CONFIG is purely as a temporary measure before boards
more over to the generic approach.
Regards,
Simon
> -mike
>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-29 20:08 ` Simon Glass
@ 2011-11-29 21:40 ` Mike Frysinger
2011-11-29 22:09 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 21:40 UTC (permalink / raw)
To: u-boot
On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
> On Mon, Nov 28, 2011 at 7:11 PM, Mike Frysinger wrote:
> > On Monday 21 November 2011 18:57:54 Simon Glass wrote:
> >> We are introducing a new unified board setup and we want this to
> >> be the default. So we need to opt all architectures out first.
> >
> > the define says "BOARD", so shouldn't it be in board configs ? we can do
> > that easily: add it to include/config_defaults.h. then boards that opt
> > into it will #undef it in their own configs.
>
> Thanks for looking at this.
>
> I see this as an architecture feature - perhaps a rename to something
> like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving
> boards over one at a time, or having boards for a particular
> architecture that still do things the old way - it just increases
> maintenance and means that my eventual patch to remove
> arch/xxx/lib/board.c cannot be applied.
>
> My idea for this CONFIG is purely as a temporary measure before boards
> more over to the generic approach.
how about we have the reloc code live in lib/reloc/ and be controlled by
CONFIG_LEGACY_ARCH_RELOC ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/af622694/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-29 21:40 ` Mike Frysinger
@ 2011-11-29 22:09 ` Simon Glass
2011-11-29 23:19 ` Mike Frysinger
2011-12-05 6:42 ` Aneesh V
0 siblings, 2 replies; 47+ messages in thread
From: Simon Glass @ 2011-11-29 22:09 UTC (permalink / raw)
To: u-boot
+omap, samsung, imx maintainers
Hi Mike,
On Tue, Nov 29, 2011 at 1:40 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
>> On Mon, Nov 28, 2011 at 7:11 PM, Mike Frysinger wrote:
>> > On Monday 21 November 2011 18:57:54 Simon Glass wrote:
>> >> We are introducing a new unified board setup and we want this to
>> >> be the default. So we need to opt all architectures out first.
>> >
>> > the define says "BOARD", so shouldn't it be in board configs ? ?we can do
>> > that easily: add it to include/config_defaults.h. ?then boards that opt
>> > into it will #undef it in their own configs.
>>
>> Thanks for looking at this.
>>
>> I see this as an architecture feature - perhaps a rename to something
>> like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving
>> boards over one at a time, or having boards for a particular
>> architecture that still do things the old way - it just increases
>> maintenance and means that my eventual patch to remove
>> arch/xxx/lib/board.c cannot be applied.
>>
>> My idea for this CONFIG is purely as a temporary measure before boards
>> more over to the generic approach.
>
> how about we have the reloc code live in lib/reloc/ and be controlled by
> CONFIG_LEGACY_ARCH_RELOC ?
> -mike
>
Yes I can do that.
My only concern is that if something like SPL needs to keep all the
early code at the start of the image. I personally don't like the
current method for doing that (would prefer a distinctive .text.early
section name) and I don't believe that any SPL implementation actually
relocates itself.
Perhaps someone in OMAP / Samsung knows?
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-29 3:07 ` Mike Frysinger
@ 2011-11-29 22:15 ` Simon Glass
2011-11-29 23:00 ` Graeme Russ
2011-11-29 23:20 ` Mike Frysinger
2011-12-07 22:45 ` Simon Glass
1 sibling, 2 replies; 47+ messages in thread
From: Simon Glass @ 2011-11-29 22:15 UTC (permalink / raw)
To: u-boot
Hi Mike,
On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>> ?board/Makefile ? | ? 45
>> ?board/reloc.c ? ?| ?101
>
> not to bikeshed, but i don't think we want files in board/. ?how about
> board/common/ or board/generic/ instead ?
Yes I wasn't sure, let's go with lib/reloc.c unless we hit SPL
problems (do we really need lib/reloc/reloc.c?)
>
>> --- /dev/null
>> +++ b/board/Makefile
>>
>> +ifndef CONFIG_SYS_LEGACY_BOARD
>> +COBJS ? ? ? ?+= reloc.o
>> +endif
>
> i don't think relocation should be tied "legacy board". ?not all arches do
> relocation at all, which means they might never opt in to this aspect.
If they don't do reloc then when we move them over we should add a
CONFIG for this I think. But would prefer to wait until we have an
arch moving over that requires no relocation, before addressing this.
>
>> --- a/include/common.h
>> +++ b/include/common.h
>>
>> -void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
>> +#include <reloc.h>
>
> i'd think very few funcs would need this. ?so maybe we should make the few
> places include reloc.h explicitly.
> -mike
>
Yes I wanted to do that but was concerned about complaints of
including multiple headers in every board.c for this. I really don't
like common.h so I will change it.
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-29 22:15 ` Simon Glass
@ 2011-11-29 23:00 ` Graeme Russ
2011-11-29 23:20 ` Mike Frysinger
1 sibling, 0 replies; 47+ messages in thread
From: Graeme Russ @ 2011-11-29 23:00 UTC (permalink / raw)
To: u-boot
Hi Simon,
On Wed, Nov 30, 2011 at 9:15 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Mike,
>
> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>>> board/Makefile | 45
>>> board/reloc.c | 101
>>
>> not to bikeshed, but i don't think we want files in board/. how about
>> board/common/ or board/generic/ instead ?
>
> Yes I wasn't sure, let's go with lib/reloc.c unless we hit SPL
> problems (do we really need lib/reloc/reloc.c?)
Hmmm, I think common/reloc.c may be more appropriate - I think /lib/ is
more for externally sourced libraries
Regards,
Graeme
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-29 22:09 ` Simon Glass
@ 2011-11-29 23:19 ` Mike Frysinger
2011-11-29 23:40 ` Simon Glass
2011-12-05 6:42 ` Aneesh V
1 sibling, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 23:19 UTC (permalink / raw)
To: u-boot
On Tuesday 29 November 2011 17:09:19 Simon Glass wrote:
> On Tue, Nov 29, 2011 at 1:40 PM, Mike Frysinger wrote:
> > On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
> >> On Mon, Nov 28, 2011 at 7:11 PM, Mike Frysinger wrote:
> >> > On Monday 21 November 2011 18:57:54 Simon Glass wrote:
> >> >> We are introducing a new unified board setup and we want this to
> >> >> be the default. So we need to opt all architectures out first.
> >> >
> >> > the define says "BOARD", so shouldn't it be in board configs ? we can
> >> > do that easily: add it to include/config_defaults.h. then boards
> >> > that opt into it will #undef it in their own configs.
> >>
> >> Thanks for looking at this.
> >>
> >> I see this as an architecture feature - perhaps a rename to something
> >> like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving
> >> boards over one at a time, or having boards for a particular
> >> architecture that still do things the old way - it just increases
> >> maintenance and means that my eventual patch to remove
> >> arch/xxx/lib/board.c cannot be applied.
> >>
> >> My idea for this CONFIG is purely as a temporary measure before boards
> >> more over to the generic approach.
> >
> > how about we have the reloc code live in lib/reloc/ and be controlled by
> > CONFIG_LEGACY_ARCH_RELOC ?
>
> My only concern is that if something like SPL needs to keep all the
> early code at the start of the image. I personally don't like the
> current method for doing that (would prefer a distinctive .text.early
> section name) and I don't believe that any SPL implementation actually
> relocates itself.
not sure why this matters ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/f792386e/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-29 22:15 ` Simon Glass
2011-11-29 23:00 ` Graeme Russ
@ 2011-11-29 23:20 ` Mike Frysinger
2011-11-29 23:41 ` Simon Glass
1 sibling, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-11-29 23:20 UTC (permalink / raw)
To: u-boot
On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger wrote:
> > On Monday 21 November 2011 18:57:56 Simon Glass wrote:
> >> --- /dev/null
> >> +++ b/board/Makefile
> >>
> >> +ifndef CONFIG_SYS_LEGACY_BOARD
> >> +COBJS += reloc.o
> >> +endif
> >
> > i don't think relocation should be tied "legacy board". not all arches
> > do relocation at all, which means they might never opt in to this
> > aspect.
>
> If they don't do reloc then when we move them over we should add a
> CONFIG for this I think. But would prefer to wait until we have an
> arch moving over that requires no relocation, before addressing this.
Blackfin does no relocation, so i'd be annoyed to have to carry a define like
"LEGACY_BOARD" forever ;)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/1ec49b07/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-29 23:19 ` Mike Frysinger
@ 2011-11-29 23:40 ` Simon Glass
2011-12-07 8:15 ` Albert ARIBAUD
0 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-11-29 23:40 UTC (permalink / raw)
To: u-boot
Hi Mike,
On Tue, Nov 29, 2011 at 3:19 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 29 November 2011 17:09:19 Simon Glass wrote:
>> On Tue, Nov 29, 2011 at 1:40 PM, Mike Frysinger wrote:
>> > On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
>> >> On Mon, Nov 28, 2011 at 7:11 PM, Mike Frysinger wrote:
>> >> > On Monday 21 November 2011 18:57:54 Simon Glass wrote:
>> >> >> We are introducing a new unified board setup and we want this to
>> >> >> be the default. So we need to opt all architectures out first.
>> >> >
>> >> > the define says "BOARD", so shouldn't it be in board configs ? ?we can
>> >> > do that easily: add it to include/config_defaults.h. ?then boards
>> >> > that opt into it will #undef it in their own configs.
>> >>
>> >> Thanks for looking at this.
>> >>
>> >> I see this as an architecture feature - perhaps a rename to something
>> >> like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving
>> >> boards over one at a time, or having boards for a particular
>> >> architecture that still do things the old way - it just increases
>> >> maintenance and means that my eventual patch to remove
>> >> arch/xxx/lib/board.c cannot be applied.
>> >>
>> >> My idea for this CONFIG is purely as a temporary measure before boards
>> >> more over to the generic approach.
>> >
>> > how about we have the reloc code live in lib/reloc/ and be controlled by
>> > CONFIG_LEGACY_ARCH_RELOC ?
>>
>> My only concern is that if something like SPL needs to keep all the
>> early code at the start of the image. I personally don't like the
>> current method for doing that (would prefer a distinctive .text.early
>> section name) and I don't believe that any SPL implementation actually
>> relocates itself.
>
> not sure why this matters ?
> -mike
>
Because if they require linking with reloc.o then we will get link
failures some boards. There is some ugly stuff in SPL which pulls in
particular files from around U-Boot. Any time I split something out of
start.S I may break something.
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-29 23:20 ` Mike Frysinger
@ 2011-11-29 23:41 ` Simon Glass
2011-11-29 23:49 ` Graeme Russ
0 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-11-29 23:41 UTC (permalink / raw)
To: u-boot
Hi Mike,
On Tue, Nov 29, 2011 at 3:20 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
>> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger wrote:
>> > On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>> >> --- /dev/null
>> >> +++ b/board/Makefile
>> >>
>> >> +ifndef CONFIG_SYS_LEGACY_BOARD
>> >> +COBJS ? ? ? ?+= reloc.o
>> >> +endif
>> >
>> > i don't think relocation should be tied "legacy board". ?not all arches
>> > do relocation at all, which means they might never opt in to this
>> > aspect.
>>
>> If they don't do reloc then when we move them over we should add a
>> CONFIG for this I think. But would prefer to wait until we have an
>> arch moving over that requires no relocation, before addressing this.
>
> Blackfin does no relocation, so i'd be annoyed to have to carry a define like
> "LEGACY_BOARD" forever ;)
> -mike
>
Would you be happier with CONFIG_ARCH_NO_RELOCATION?
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-29 23:41 ` Simon Glass
@ 2011-11-29 23:49 ` Graeme Russ
2011-11-30 2:58 ` Mike Frysinger
0 siblings, 1 reply; 47+ messages in thread
From: Graeme Russ @ 2011-11-29 23:49 UTC (permalink / raw)
To: u-boot
Hi Simon,
On Wed, Nov 30, 2011 at 10:41 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Mike,
>
> On Tue, Nov 29, 2011 at 3:20 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
>>> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger wrote:
>>> > On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>>> >> --- /dev/null
>>> >> +++ b/board/Makefile
>>> >>
>>> >> +ifndef CONFIG_SYS_LEGACY_BOARD
>>> >> +COBJS ? ? ? ?+= reloc.o
>>> >> +endif
>>> >
>>> > i don't think relocation should be tied "legacy board". ?not all arches
>>> > do relocation at all, which means they might never opt in to this
>>> > aspect.
>>>
>>> If they don't do reloc then when we move them over we should add a
>>> CONFIG for this I think. But would prefer to wait until we have an
>>> arch moving over that requires no relocation, before addressing this.
>>
>> Blackfin does no relocation, so i'd be annoyed to have to carry a define like
>> "LEGACY_BOARD" forever ;)
>> -mike
>>
>
> Would you be happier with CONFIG_ARCH_NO_RELOCATION?
CONFIG_SYS_NO_RELOC
Regards,
Graeme
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-29 23:49 ` Graeme Russ
@ 2011-11-30 2:58 ` Mike Frysinger
2011-12-07 7:38 ` Albert ARIBAUD
0 siblings, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-11-30 2:58 UTC (permalink / raw)
To: u-boot
On Tuesday 29 November 2011 18:49:58 Graeme Russ wrote:
> On Wed, Nov 30, 2011 at 10:41 AM, Simon Glass wrote:
> > On Tue, Nov 29, 2011 at 3:20 PM, Mike Frysinger wrote:
> >> On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
> >>> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger wrote:
> >>> > On Monday 21 November 2011 18:57:56 Simon Glass wrote:
> >>> >> --- /dev/null
> >>> >> +++ b/board/Makefile
> >>> >>
> >>> >> +ifndef CONFIG_SYS_LEGACY_BOARD
> >>> >> +COBJS += reloc.o
> >>> >> +endif
> >>> >
> >>> > i don't think relocation should be tied "legacy board". not all
> >>> > arches do relocation at all, which means they might never opt in to
> >>> > this aspect.
> >>>
> >>> If they don't do reloc then when we move them over we should add a
> >>> CONFIG for this I think. But would prefer to wait until we have an
> >>> arch moving over that requires no relocation, before addressing this.
> >>
> >> Blackfin does no relocation, so i'd be annoyed to have to carry a define
> >> like "LEGACY_BOARD" forever ;)
> >
> > Would you be happier with CONFIG_ARCH_NO_RELOCATION?
>
> CONFIG_SYS_NO_RELOC
either is fine by me
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/154e9bee/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-29 22:09 ` Simon Glass
2011-11-29 23:19 ` Mike Frysinger
@ 2011-12-05 6:42 ` Aneesh V
1 sibling, 0 replies; 47+ messages in thread
From: Aneesh V @ 2011-12-05 6:42 UTC (permalink / raw)
To: u-boot
Simon,
On Wednesday 30 November 2011 03:39 AM, Simon Glass wrote:
> +omap, samsung, imx maintainers
>
> Hi Mike,
>
> On Tue, Nov 29, 2011 at 1:40 PM, Mike Frysinger<vapier@gentoo.org> wrote:
>> On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
>>> On Mon, Nov 28, 2011 at 7:11 PM, Mike Frysinger wrote:
>>>> On Monday 21 November 2011 18:57:54 Simon Glass wrote:
>>>>> We are introducing a new unified board setup and we want this to
>>>>> be the default. So we need to opt all architectures out first.
>>>>
>>>> the define says "BOARD", so shouldn't it be in board configs ? we can do
>>>> that easily: add it to include/config_defaults.h. then boards that opt
>>>> into it will #undef it in their own configs.
>>>
>>> Thanks for looking at this.
>>>
>>> I see this as an architecture feature - perhaps a rename to something
>>> like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving
>>> boards over one at a time, or having boards for a particular
>>> architecture that still do things the old way - it just increases
>>> maintenance and means that my eventual patch to remove
>>> arch/xxx/lib/board.c cannot be applied.
>>>
>>> My idea for this CONFIG is purely as a temporary measure before boards
>>> more over to the generic approach.
>>
>> how about we have the reloc code live in lib/reloc/ and be controlled by
>> CONFIG_LEGACY_ARCH_RELOC ?
>> -mike
>>
>
> Yes I can do that.
>
> My only concern is that if something like SPL needs to keep all the
> early code at the start of the image. I personally don't like the
> current method for doing that (would prefer a distinctive .text.early
> section name) and I don't believe that any SPL implementation actually
> relocates itself.
OMAP SPL doesn't relocate itself. Neither does it have any restriction
on the position of early code in the image.
best regards,
Aneesh
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
2011-11-28 23:45 ` [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Tom Rini
@ 2011-12-07 1:56 ` Simon Glass
2011-12-07 2:56 ` Graeme Russ
2011-12-07 23:29 ` Simon Glass
1 sibling, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-12-07 1:56 UTC (permalink / raw)
To: u-boot
Hi Tom,
On Mon, Nov 28, 2011 at 3:45 PM, Tom Rini <tom.rini@gmail.com> wrote:
> On Mon, Nov 21, 2011 at 4:57 PM, Simon Glass <sjg@chromium.org> wrote:
>> This is the second patch series aiming to unify the various board.c files
>> in each architecture into a single one. This series creates a libboard
>> library and implements relocation in it. It then moves ARM over to use
>> this framework, as an example.
>>
>> On ARM the relocation code is duplicated for each CPU yet it
>> is the same. We can bring this up to the arch level. But since (I believe)
>> Elf relocation is basically the same process for all archs, there is no
>> reason not to bring it up to the generic level.
>>
>> This series establishes a new libboard library in the board/ subdir and
>> puts some relocation code in it. Each architecture which uses this
>> framework needs to provide a function called arch_elf_relocate_entry()
>> which processes a single relocation entry. If there is concern about
>> calling a function for all 2000-odd relocations then I can change this.
>>
>> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
>> ARM assembler code (things that cannot be written in C and are common
>> functions used by all ARM CPUs). This helps reduce duplication. Interrupt
>> handling code and perhaps even some startup code can move there later.
>>
>> It may be useful for other architectures to have a similar file.
>>
>> This series moves ARM over to use this framework. Overall this means that
>> two new files are required 'early' in boot: board/reloc.c and
>> arch/arm/lib/proc.S. ?This is tricky mainly due to SPL. I believe that
>> we may need to adjust link scripts to put these two files early in the
>> link scripts also. But I am not sure about this and can't actually find
>> a problem as yet. I would much prefer to solve this with a new section
>> name like .text.early if we can.
>>
>> (I should really cc all arch maintainers but I think in that case I get
>> an error from the list server. Not sure what the limit is.)
>>
>> Comments please...
>
> Seems like a good idea. ?Got some size's before and after? ?Maybe some
> boot times too (as you mention 2000-odd function calls during
> relocation) ?
>
> --
> Tom
Yes I have this info - will package it up tomorrow along with a new
series to deal with review comments.
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
2011-12-07 1:56 ` Simon Glass
@ 2011-12-07 2:56 ` Graeme Russ
2011-12-07 3:25 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Graeme Russ @ 2011-12-07 2:56 UTC (permalink / raw)
To: u-boot
Hi Simon
Sorry for the late review on this - I've only just now had a good
chance to look at it...
On Wed, Dec 7, 2011 at 12:56 PM, Simon Glass <sjg@chromium.org> wrote:
> Hi Tom,
>
> On Mon, Nov 28, 2011 at 3:45 PM, Tom Rini <tom.rini@gmail.com> wrote:
>> On Mon, Nov 21, 2011 at 4:57 PM, Simon Glass <sjg@chromium.org> wrote:
>>> This is the second patch series aiming to unify the various board.c files
>>> in each architecture into a single one. This series creates a libboard
>>> library and implements relocation in it. It then moves ARM over to use
>>> this framework, as an example.
>>>
>>> On ARM the relocation code is duplicated for each CPU yet it
>>> is the same. We can bring this up to the arch level. But since (I believe)
>>> Elf relocation is basically the same process for all archs, there is no
>>> reason not to bring it up to the generic level.
>>>
>>> This series establishes a new libboard library in the board/ subdir and
>>> puts some relocation code in it. Each architecture which uses this
>>> framework needs to provide a function called arch_elf_relocate_entry()
>>> which processes a single relocation entry. If there is concern about
>>> calling a function for all 2000-odd relocations then I can change this.
Ugh, that overhead is a killer - The relocation can be done entirely in a
tight loop with a switch statement in your reloc_elf() function. But I
think reloc_elf() should be weak - x86 relocation can be done in a few
lines of assembler which is smaller and faster than a C implementation
will ever be
>>> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
>>> ARM assembler code (things that cannot be written in C and are common
>>> functions used by all ARM CPUs). This helps reduce duplication. Interrupt
>>> handling code and perhaps even some startup code can move there later.
>>>
>>> It may be useful for other architectures to have a similar file.
>>>
>>> This series moves ARM over to use this framework. Overall this means that
>>> two new files are required 'early' in boot: board/reloc.c and
>>> arch/arm/lib/proc.S. This is tricky mainly due to SPL. I believe that
>>> we may need to adjust link scripts to put these two files early in the
>>> link scripts also. But I am not sure about this and can't actually find
>>> a problem as yet. I would much prefer to solve this with a new section
>>> name like .text.early if we can.
>>>
>>> (I should really cc all arch maintainers but I think in that case I get
>>> an error from the list server. Not sure what the limit is.)
>>>
>>> Comments please...
The whole sequence of the series seems a little bit 'random' to me - I
think patches 2 and 3 can be squahed and the dead code removal in patch 7
should be done in the same patch(es) that create the dead code.
It looks like reloc_make_copy(), reloc_clear_bss() and reloc_elf() have
been poached from x86 - The copy and clear loops are quite inefficient. I
have patches at home which change these to use memcpy and memset
>>
>> Seems like a good idea. Got some size's before and after? Maybe some
>> boot times too (as you mention 2000-odd function calls during
>> relocation) ?
>>
>> --
>> Tom
>
> Yes I have this info - will package it up tomorrow along with a new
> series to deal with review comments.
As far as I understand it, the long-term plan is to unify the board init
sequence across all architectures. I can see three approaches:
1) Tweak each arch until they are all the same and then 'throw the switch'
2) Pick one or two arches and 'throw the switch' on them and migrate the
others later
3) Pull out common bits and pieced and deal with the left-overs later
It looks like you've opted for number 3. The problem I see in this approach
is that you are relying on the other arches to follow your lead which is, at
best, a 50/50 bet.
Now I look at board_init_f() and board_init_r() in ARM and x86 and think
'why on earth isn't most of than in the init loops?'. The boot sequence
for ARM and x86 should be reducible to (all arches are generally pretty
close to this, so it should not introduce too much pain when they decide
to switch)
- Low level init (reset vector etc)
- Setup temporary stack and gd storage (typically in CPU cache)
+ init_f loop <-- SDRAM initialised
- Move gd to RAM
- Setup new stack in SDRAM
- Turn on caching (cannot be done while gd and stack in cache!!!)
+ Calculate relocation address
+ Copy to RAM
+ Do relocation fixups
+ Clear BSS
- Jump to RAM
+ init_r loop
+ main_loop()
+ = common code
- = arch, SoC, or board specific
Note: Typically the boot sequence currently has 'Turn on caching' after jump
to RAM - I have patches in the works which change this for x86
So my vote would be #2 - Unify the ARM and x86 and bring any code that can
be inside the init loops in and then switch both over to a generic init
implementation. Other arches can be switched later
Regards,
Graeme
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
2011-12-07 2:56 ` Graeme Russ
@ 2011-12-07 3:25 ` Simon Glass
2011-12-07 3:36 ` Graeme Russ
0 siblings, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-12-07 3:25 UTC (permalink / raw)
To: u-boot
Hi Graeme,
On Tue, Dec 6, 2011 at 6:56 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
> Hi Simon
>
> Sorry for the late review on this - I've only just now had a good
> chance to look at it...
>
Thanks for the comments.
> On Wed, Dec 7, 2011 at 12:56 PM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Tom,
>>
>> On Mon, Nov 28, 2011 at 3:45 PM, Tom Rini <tom.rini@gmail.com> wrote:
>>> On Mon, Nov 21, 2011 at 4:57 PM, Simon Glass <sjg@chromium.org> wrote:
>>>> This is the second patch series aiming to unify the various board.c files
>>>> in each architecture into a single one. This series creates a libboard
>>>> library and implements relocation in it. It then moves ARM over to use
>>>> this framework, as an example.
>>>>
>>>> On ARM the relocation code is duplicated for each CPU yet it
>>>> is the same. We can bring this up to the arch level. But since (I believe)
>>>> Elf relocation is basically the same process for all archs, there is no
>>>> reason not to bring it up to the generic level.
>>>>
>>>> This series establishes a new libboard library in the board/ subdir and
>>>> puts some relocation code in it. Each architecture which uses this
>>>> framework needs to provide a function called arch_elf_relocate_entry()
>>>> which processes a single relocation entry. If there is concern about
>>>> calling a function for all 2000-odd relocations then I can change this.
>
> Ugh, that overhead is a killer - The relocation can be done entirely in a
> tight loop with a switch statement in your reloc_elf() function. But I
> think reloc_elf() should be weak - x86 relocation can be done in a few
> lines of assembler which is smaller and faster than a C implementation
> will ever be
I will benchmark it tomorrow. If we move the for loop into the
architecture-specific code then it goes away. Just seemed to me that
the less duplicated code we have the better. We could use an inline
function but I'm not keen on that.
>
>>>> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
>>>> ARM assembler code (things that cannot be written in C and are common
>>>> functions used by all ARM CPUs). This helps reduce duplication. Interrupt
>>>> handling code and perhaps even some startup code can move there later.
>>>>
>>>> It may be useful for other architectures to have a similar file.
>>>>
>>>> This series moves ARM over to use this framework. Overall this means that
>>>> two new files are required 'early' in boot: board/reloc.c and
>>>> arch/arm/lib/proc.S. ?This is tricky mainly due to SPL. I believe that
>>>> we may need to adjust link scripts to put these two files early in the
>>>> link scripts also. But I am not sure about this and can't actually find
>>>> a problem as yet. I would much prefer to solve this with a new section
>>>> name like .text.early if we can.
>>>>
>>>> (I should really cc all arch maintainers but I think in that case I get
>>>> an error from the list server. Not sure what the limit is.)
>>>>
>>>> Comments please...
>
> The whole sequence of the series seems a little bit 'random' to me - I
> think patches 2 and 3 can be squahed and the dead code removal in patch 7
> should be done in the same patch(es) that create the dead code.
>
Yes I can clean this up.
> It looks like reloc_make_copy(), reloc_clear_bss() and reloc_elf() have
> been poached from x86 - The copy and clear loops are quite inefficient. I
> have patches at home which change these to use memcpy and memset
Yes they have - in fact I have a series here which unifies board.c
completely for ARM and x86. But I need to take this in baby steps as I
said.
>
>>>
>>> Seems like a good idea. ?Got some size's before and after? ?Maybe some
>>> boot times too (as you mention 2000-odd function calls during
>>> relocation) ?
>>>
>>> --
>>> Tom
>>
>> Yes I have this info - will package it up tomorrow along with a new
>> series to deal with review comments.
>
> As far as I understand it, the long-term plan is to unify the board init
> sequence across all architectures. I can see three approaches:
>
> ?1) Tweak each arch until they are all the same and then 'throw the switch'
> ?2) Pick one or two arches and 'throw the switch' on them and migrate the
> ? ?others later
> ?3) Pull out common bits and pieced and deal with the left-overs later
>
> It looks like you've opted for number 3. The problem I see in this approach
> is that you are relying on the other arches to follow your lead which is, at
> best, a 50/50 bet.
Sort of. Actually I have gone for option 2. But rather than send a
series which switches over ARM and then x86 (about 40 patches) I have
decided to do it in steps. Relocation is the first step.
>
> Now I look at board_init_f() and board_init_r() in ARM and x86 and think
> 'why on earth isn't most of than in the init loops?'. The boot sequence
> for ARM and x86 should be reducible to (all arches are generally pretty
> close to this, so it should not introduce too much pain when they decide
> to switch)
Yes my generic board.c consists of a couple of init loops. I can email
the patch if you like but it is not ready for the mailing list.
>
> ?- Low level init (reset vector etc)
> ?- Setup temporary stack and gd storage (typically in CPU cache)
> ?+ init_f loop <-- SDRAM initialised
> ?- Move gd to RAM
> ?- Setup new stack in SDRAM
> ?- Turn on caching (cannot be done while gd and stack in cache!!!)
> ?+ Calculate relocation address
> ?+ Copy to RAM
> ?+ Do relocation fixups
> ?+ Clear BSS
> ?- Jump to RAM
> ?+ init_r loop
> ?+ main_loop()
>
> + = common code
> - = arch, SoC, or board specific
>
> Note: Typically the boot sequence currently has 'Turn on caching' after jump
> to RAM - I have patches in the works which change this for x86
>
> So my vote would be #2 - Unify the ARM and x86 and bring any code that can
> be inside the init loops in and then switch both over to a generic init
> implementation. Other arches can be switched later
Agreed, but I can't send a series that big, so I am doing it in stages.
Regards,
Simon
>
> Regards,
>
> Graeme
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
2011-12-07 3:25 ` Simon Glass
@ 2011-12-07 3:36 ` Graeme Russ
0 siblings, 0 replies; 47+ messages in thread
From: Graeme Russ @ 2011-12-07 3:36 UTC (permalink / raw)
To: u-boot
Hi Simon,
On Wed, Dec 7, 2011 at 2:25 PM, Simon Glass <sjg@chromium.org> wrote:
> Hi Graeme,
>
> On Tue, Dec 6, 2011 at 6:56 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
>> Hi Simon
>>
>> Sorry for the late review on this - I've only just now had a good
>> chance to look at it...
>>
>
> Thanks for the comments.
>
>> On Wed, Dec 7, 2011 at 12:56 PM, Simon Glass <sjg@chromium.org> wrote:
>>> Hi Tom,
>>>
>>> On Mon, Nov 28, 2011 at 3:45 PM, Tom Rini <tom.rini@gmail.com> wrote:
>>>> On Mon, Nov 21, 2011 at 4:57 PM, Simon Glass <sjg@chromium.org> wrote:
>>>>> This is the second patch series aiming to unify the various board.c files
>>>>> in each architecture into a single one. This series creates a libboard
>>>>> library and implements relocation in it. It then moves ARM over to use
>>>>> this framework, as an example.
>>>>>
>>>>> On ARM the relocation code is duplicated for each CPU yet it
>>>>> is the same. We can bring this up to the arch level. But since (I believe)
>>>>> Elf relocation is basically the same process for all archs, there is no
>>>>> reason not to bring it up to the generic level.
>>>>>
>>>>> This series establishes a new libboard library in the board/ subdir and
>>>>> puts some relocation code in it. Each architecture which uses this
>>>>> framework needs to provide a function called arch_elf_relocate_entry()
>>>>> which processes a single relocation entry. If there is concern about
>>>>> calling a function for all 2000-odd relocations then I can change this.
>>
>> Ugh, that overhead is a killer - The relocation can be done entirely in a
>> tight loop with a switch statement in your reloc_elf() function. But I
>> think reloc_elf() should be weak - x86 relocation can be done in a few
>> lines of assembler which is smaller and faster than a C implementation
>> will ever be
>
> I will benchmark it tomorrow. If we move the for loop into the
> architecture-specific code then it goes away. Just seemed to me that
> the less duplicated code we have the better. We could use an inline
> function but I'm not keen on that.
This may be one case were performance outweighs the desire to be generic.
The nice thing is we can provide a generic function which will work for all
arches (albiet a little big and slow) - This will help when switching an
arch over as there is, at least, a default implementation much like all the
string functions (off topic, but why aren't they weak instead of #defined)
>>>>> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
>>>>> ARM assembler code (things that cannot be written in C and are common
>>>>> functions used by all ARM CPUs). This helps reduce duplication. Interrupt
>>>>> handling code and perhaps even some startup code can move there later.
>>>>>
>>>>> It may be useful for other architectures to have a similar file.
>>>>>
>>>>> This series moves ARM over to use this framework. Overall this means that
>>>>> two new files are required 'early' in boot: board/reloc.c and
>>>>> arch/arm/lib/proc.S. This is tricky mainly due to SPL. I believe that
>>>>> we may need to adjust link scripts to put these two files early in the
>>>>> link scripts also. But I am not sure about this and can't actually find
>>>>> a problem as yet. I would much prefer to solve this with a new section
>>>>> name like .text.early if we can.
>>>>>
>>>>> (I should really cc all arch maintainers but I think in that case I get
>>>>> an error from the list server. Not sure what the limit is.)
>>>>>
>>>>> Comments please...
>>
>> The whole sequence of the series seems a little bit 'random' to me - I
>> think patches 2 and 3 can be squahed and the dead code removal in patch 7
>> should be done in the same patch(es) that create the dead code.
>>
> Yes I can clean this up.
>
>> It looks like reloc_make_copy(), reloc_clear_bss() and reloc_elf() have
>> been poached from x86 - The copy and clear loops are quite inefficient. I
>> have patches at home which change these to use memcpy and memset
>
> Yes they have - in fact I have a series here which unifies board.c
> completely for ARM and x86. But I need to take this in baby steps as I
> said.
>
>>
>>>>
>>>> Seems like a good idea. Got some size's before and after? Maybe some
>>>> boot times too (as you mention 2000-odd function calls during
>>>> relocation) ?
>>>>
>>>> --
>>>> Tom
>>>
>>> Yes I have this info - will package it up tomorrow along with a new
>>> series to deal with review comments.
>>
>> As far as I understand it, the long-term plan is to unify the board init
>> sequence across all architectures. I can see three approaches:
>>
>> 1) Tweak each arch until they are all the same and then 'throw the switch'
>> 2) Pick one or two arches and 'throw the switch' on them and migrate the
>> others later
>> 3) Pull out common bits and pieced and deal with the left-overs later
>>
>> It looks like you've opted for number 3. The problem I see in this approach
>> is that you are relying on the other arches to follow your lead which is, at
>> best, a 50/50 bet.
>
> Sort of. Actually I have gone for option 2. But rather than send a
> series which switches over ARM and then x86 (about 40 patches) I have
> decided to do it in steps. Relocation is the first step.
OK, sounds like a plan
>> Now I look at board_init_f() and board_init_r() in ARM and x86 and think
>> 'why on earth isn't most of than in the init loops?'. The boot sequence
>> for ARM and x86 should be reducible to (all arches are generally pretty
>> close to this, so it should not introduce too much pain when they decide
>> to switch)
>
> Yes my generic board.c consists of a couple of init loops. I can email
> the patch if you like but it is not ready for the mailing list.
Hmm, I don't think I have the time right now
>> - Low level init (reset vector etc)
>> - Setup temporary stack and gd storage (typically in CPU cache)
>> + init_f loop <-- SDRAM initialised
>> - Move gd to RAM
>> - Setup new stack in SDRAM
>> - Turn on caching (cannot be done while gd and stack in cache!!!)
>> + Calculate relocation address
>> + Copy to RAM
>> + Do relocation fixups
>> + Clear BSS
>> - Jump to RAM
>> + init_r loop
>> + main_loop()
>>
>> + = common code
>> - = arch, SoC, or board specific
>>
>> Note: Typically the boot sequence currently has 'Turn on caching' after jump
>> to RAM - I have patches in the works which change this for x86
>>
>> So my vote would be #2 - Unify the ARM and x86 and bring any code that can
>> be inside the init loops in and then switch both over to a generic init
>> implementation. Other arches can be switched later
>
> Agreed, but I can't send a series that big, so I am doing it in stages.
Excellent - I don't have a huge amoun of spare time, but if you let me know
what you need, I can probably give x86 a little prod here and there to
align it with what you are doing. I already have a few patches, and Gabe has
been doing a bit as well in order to make the coreboot port integrate more
seamlessly.
Regards,
Graeme
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-30 2:58 ` Mike Frysinger
@ 2011-12-07 7:38 ` Albert ARIBAUD
2011-12-08 0:35 ` Mike Frysinger
0 siblings, 1 reply; 47+ messages in thread
From: Albert ARIBAUD @ 2011-12-07 7:38 UTC (permalink / raw)
To: u-boot
Le 30/11/2011 03:58, Mike Frysinger a ?crit :
> On Tuesday 29 November 2011 18:49:58 Graeme Russ wrote:
>> On Wed, Nov 30, 2011 at 10:41 AM, Simon Glass wrote:
>>> On Tue, Nov 29, 2011 at 3:20 PM, Mike Frysinger wrote:
>>>> On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
>>>>> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger wrote:
>>>>>> On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>>>>>>> --- /dev/null
>>>>>>> +++ b/board/Makefile
>>>>>>>
>>>>>>> +ifndef CONFIG_SYS_LEGACY_BOARD
>>>>>>> +COBJS += reloc.o
>>>>>>> +endif
>>>>>>
>>>>>> i don't think relocation should be tied "legacy board". not all
>>>>>> arches do relocation at all, which means they might never opt in to
>>>>>> this aspect.
>>>>>
>>>>> If they don't do reloc then when we move them over we should add a
>>>>> CONFIG for this I think. But would prefer to wait until we have an
>>>>> arch moving over that requires no relocation, before addressing this.
>>>>
>>>> Blackfin does no relocation, so i'd be annoyed to have to carry a define
>>>> like "LEGACY_BOARD" forever ;)
>>>
>>> Would you be happier with CONFIG_ARCH_NO_RELOCATION?
>>
>> CONFIG_SYS_NO_RELOC
>
> either is fine by me
> -mike
CONFIG_SYS_SKIP_RELOC clearly states there is some usual step we're
skipping, plus we could homogeneize with other config settings that
"SKIP" some step.
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library Simon Glass
2011-11-29 3:12 ` Mike Frysinger
@ 2011-12-07 7:44 ` Albert ARIBAUD
2011-12-07 16:24 ` Simon Glass
1 sibling, 1 reply; 47+ messages in thread
From: Albert ARIBAUD @ 2011-12-07 7:44 UTC (permalink / raw)
To: u-boot
Hi Simon,
Le 22/11/2011 00:57, Simon Glass a ?crit :
> Add a library to hold ARM assembler code which is generic across all
> ARM CPUs.
>
> Signed-off-by: Simon Glass<sjg@chromium.org>
> ---
> arch/arm/lib/Makefile | 1 +
> arch/arm/lib/proc.S | 35 +++++++++++++++++++++++++++++++++++
> 2 files changed, 36 insertions(+), 0 deletions(-)
> create mode 100644 arch/arm/lib/proc.S
>
> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
> index ca2802a..27749dc 100644
> --- a/arch/arm/lib/Makefile
> +++ b/arch/arm/lib/Makefile
> @@ -50,6 +50,7 @@ endif
>
> ifndef CONFIG_SYS_LEGACY_BOARD
> COBJS-y += arch_reloc.o
> +SOBJS-y += proc.o
> endif
>
> SRCS := $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \
> diff --git a/arch/arm/lib/proc.S b/arch/arm/lib/proc.S
> new file mode 100644
> index 0000000..99a2944
> --- /dev/null
> +++ b/arch/arm/lib/proc.S
> @@ -0,0 +1,35 @@
> +/*
> + * Copyright (c) 2011 The Chromium OS Authors.
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +
> +/**
> + * Jump to board_init_r with a new stack pointer
> + *
> + * @param gd Pointer to global data
> + * @param dest_addr Destination address from global data
> + * @param func Address of board_init_r function (relocated)
> + * @param sp New stack pointer
> + */
> +.globl proc_call_board_init_r
> +proc_call_board_init_r:
> + mov sp, r3
> + /* jump to it ... */
> + mov pc, r2
What do we gain from this patch exactly?
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
` (7 preceding siblings ...)
2011-11-28 23:45 ` [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Tom Rini
@ 2011-12-07 8:10 ` Albert ARIBAUD
2011-12-09 3:34 ` Simon Glass
8 siblings, 1 reply; 47+ messages in thread
From: Albert ARIBAUD @ 2011-12-07 8:10 UTC (permalink / raw)
To: u-boot
Hi Simon,
Le 22/11/2011 00:57, Simon Glass a ?crit :
> This is the second patch series aiming to unify the various board.c files
> in each architecture into a single one. This series creates a libboard
> library and implements relocation in it. It then moves ARM over to use
> this framework, as an example.
>
> On ARM the relocation code is duplicated for each CPU yet it
> is the same. We can bring this up to the arch level. But since (I believe)
> Elf relocation is basically the same process for all archs, there is no
> reason not to bring it up to the generic level.
Agreed.
> This series establishes a new libboard library in the board/ subdir and
> puts some relocation code in it. Each architecture which uses this
> framework needs to provide a function called arch_elf_relocate_entry()
> which processes a single relocation entry. If there is concern about
> calling a function for all 2000-odd relocations then I can change this.
NAK -- a generic relocation function should be not be in board/, it
should be in lib/
> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
> ARM assembler code (things that cannot be written in C and are common
> functions used by all ARM CPUs). This helps reduce duplication. Interrupt
> handling code and perhaps even some startup code can move there later.
As commented in detail, I am not sure creating a function for three asm
instructions is worthwhile. The overhead for calling the code might be
bigger than the body of the function. Did you compare with inline
functions with asm statements and/or intrinsics?
> It may be useful for other architectures to have a similar file.
>
> This series moves ARM over to use this framework. Overall this means that
> two new files are required 'early' in boot: board/reloc.c and
> arch/arm/lib/proc.S. This is tricky mainly due to SPL.
Can you develop what the issue is with SPL exactly?
> I believe that
> we may need to adjust link scripts to put these two files early in the
> link scripts also. But I am not sure about this and can't actually find
> a problem as yet. I would much prefer to solve this with a new section
> name like .text.early if we can.
>
> (I should really cc all arch maintainers but I think in that case I get
> an error from the list server. Not sure what the limit is.)
This would not cause an error, but Wolfgang would have to "OK' the post,
which is a good thing if many people are involved. :)
> Comments please...
Generic comment is that the patch is not about generic *board*. It is
about generic *relocation*, which is not a thing of boards IMO: it is
not related to peripheral or HW configuration, and is not actually
memory-mapped related.
Other than that, as stated in the detailed answers, we need to keep the
relocation code as efficient as possible. As happy as I am to see the
ELF relocation code rewritten in C for easy understanding and
maintenance, I would not want it done at the expense of speed or overall
architecture soundness. So:
- the C relocation code (both the generic function and the ELF specific
code) are neither board-related nor ARM-specific, so it has no reason to
reside in board/ or arch/arm. My first reflex was lib/, but indeed
common/ might be a better place.
- the relocation function should be as efficient as possible. Compared
numbers between 'before' and 'after' should also be provided -- I do not
necessarily expect the same or better performance, but we need to assess
what the performance issue is.
- I would prefer each patch to be as self-contained as possible --
'preparatory' patches I don't like much. For instance, to relace ASM
relocation with C relocation, I would want a single patch introducing
the C code and removing the ASM code or moving it out of the way.
- I am not sure why the code should be "early" or, more precisely,
should be specifically located in the linker file: any code in there is
accessible at any time, and the only special case is for _start because
we want it to be first in placement, not in time. Can you clarify this
'early' issue?
- indeed I would prefer a weak symbol for the relocation function. This
would allow a given config to easily override the generic C code if needed.
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-11-29 23:40 ` Simon Glass
@ 2011-12-07 8:15 ` Albert ARIBAUD
2011-12-07 16:28 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Albert ARIBAUD @ 2011-12-07 8:15 UTC (permalink / raw)
To: u-boot
Le 30/11/2011 00:40, Simon Glass a ?crit :
> Hi Mike,
>
> On Tue, Nov 29, 2011 at 3:19 PM, Mike Frysinger<vapier@gentoo.org> wrote:
>> On Tuesday 29 November 2011 17:09:19 Simon Glass wrote:
>>> On Tue, Nov 29, 2011 at 1:40 PM, Mike Frysinger wrote:
>>>> On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
>>>>> On Mon, Nov 28, 2011 at 7:11 PM, Mike Frysinger wrote:
>>>>>> On Monday 21 November 2011 18:57:54 Simon Glass wrote:
>>>>>>> We are introducing a new unified board setup and we want this to
>>>>>>> be the default. So we need to opt all architectures out first.
>>>>>>
>>>>>> the define says "BOARD", so shouldn't it be in board configs ? we can
>>>>>> do that easily: add it to include/config_defaults.h. then boards
>>>>>> that opt into it will #undef it in their own configs.
>>>>>
>>>>> Thanks for looking at this.
>>>>>
>>>>> I see this as an architecture feature - perhaps a rename to something
>>>>> like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving
>>>>> boards over one at a time, or having boards for a particular
>>>>> architecture that still do things the old way - it just increases
>>>>> maintenance and means that my eventual patch to remove
>>>>> arch/xxx/lib/board.c cannot be applied.
>>>>>
>>>>> My idea for this CONFIG is purely as a temporary measure before boards
>>>>> more over to the generic approach.
>>>>
>>>> how about we have the reloc code live in lib/reloc/ and be controlled by
>>>> CONFIG_LEGACY_ARCH_RELOC ?
>>>
>>> My only concern is that if something like SPL needs to keep all the
>>> early code at the start of the image. I personally don't like the
>>> current method for doing that (would prefer a distinctive .text.early
>>> section name) and I don't believe that any SPL implementation actually
>>> relocates itself.
>>
>> not sure why this matters ?
>> -mike
>>
>
> Because if they require linking with reloc.o then we will get link
> failures some boards. There is some ugly stuff in SPL which pulls in
> particular files from around U-Boot. Any time I split something out of
> start.S I may break something.
IIRC, SPL never relocates itself -- the goal of SPL is to get some code
in memory that will just enable RAM, move the rest of U-Boot in, and
jump to it.
What SPL pulls in is drivers/ functions for console output and access to
the RAM and main U-Boot image.
Besides, sometimes making boards all fail until they are fixed is a good
way to manage a change. :)
> Regards,
> Simon
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library
2011-12-07 7:44 ` Albert ARIBAUD
@ 2011-12-07 16:24 ` Simon Glass
0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-07 16:24 UTC (permalink / raw)
To: u-boot
Hi Albert,
On Tue, Dec 6, 2011 at 11:44 PM, Albert ARIBAUD
<albert.u.boot@aribaud.net> wrote:
> Hi Simon,
>
> Le 22/11/2011 00:57, Simon Glass a ?crit :
>
>> Add a library to hold ARM assembler code which is generic across all
>> ARM CPUs.
>>
>> Signed-off-by: Simon Glass<sjg@chromium.org>
>> ---
>> ?arch/arm/lib/Makefile | ? ?1 +
>> ?arch/arm/lib/proc.S ? | ? 35 +++++++++++++++++++++++++++++++++++
>> ?2 files changed, 36 insertions(+), 0 deletions(-)
>> ?create mode 100644 arch/arm/lib/proc.S
>>
>> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
>> index ca2802a..27749dc 100644
>> --- a/arch/arm/lib/Makefile
>> +++ b/arch/arm/lib/Makefile
>> @@ -50,6 +50,7 @@ endif
>>
>> ?ifndef CONFIG_SYS_LEGACY_BOARD
>> ?COBJS-y += arch_reloc.o
>> +SOBJS-y += proc.o
>> ?endif
>>
>> ?SRCS ?:= $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \
>> diff --git a/arch/arm/lib/proc.S b/arch/arm/lib/proc.S
>> new file mode 100644
>> index 0000000..99a2944
>> --- /dev/null
>> +++ b/arch/arm/lib/proc.S
>> @@ -0,0 +1,35 @@
>> +/*
>> + * Copyright (c) 2011 The Chromium OS Authors.
>> + * See file CREDITS for list of people who contributed to this
>> + * project.
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License as
>> + * published by the Free Software Foundation; either version 2 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ?See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
>> + * MA 02111-1307 USA
>> + */
>> +
>> +
>> +/**
>> + * Jump to board_init_r with a new stack pointer
>> + *
>> + * @param gd ? Pointer to global data
>> + * @param dest_addr ? ?Destination address from global data
>> + * @param func Address of board_init_r function (relocated)
>> + * @param sp ? New stack pointer
>> + */
>> +.globl proc_call_board_init_r
>> +proc_call_board_init_r:
>> + ? ? ? mov ? ? sp, r3
>> + ? ? ? /* jump to it ... */
>> + ? ? ? mov ? ? pc, r2
>
>
> What do we gain from this patch exactly?
The idea is to create a library to hold ARM assembler code which is
generic across all (or even most) ARM CPUs. So far it is just
relocation, but I feel that exception handling could move here too
eventually.
IMO start.S is a bad place for this sort of thing - it is private to
each cpu type so people tend to copy and paste large tracts of code
and it doesn't feel right to call back into your startup code later to
do things.
So I suggest a proc.S (or some other name) with processor-level
functions which are generic across ARM. We can then move this code
from all the little start.S files into one place, and maintain it more
easily.
Yes this is a trivial wee patch, but it's good to start the discussion
with something.
Regards,
Simon
>
> Amicalement,
> --
> Albert.
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere
2011-12-07 8:15 ` Albert ARIBAUD
@ 2011-12-07 16:28 ` Simon Glass
0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-07 16:28 UTC (permalink / raw)
To: u-boot
Hi Albert,
On Wed, Dec 7, 2011 at 12:15 AM, Albert ARIBAUD
<albert.u.boot@aribaud.net> wrote:
> Le 30/11/2011 00:40, Simon Glass a ?crit :
>
>> Hi Mike,
>>
>> On Tue, Nov 29, 2011 at 3:19 PM, Mike Frysinger<vapier@gentoo.org> ?wrote:
>>>
>>> On Tuesday 29 November 2011 17:09:19 Simon Glass wrote:
>>>>
>>>> On Tue, Nov 29, 2011 at 1:40 PM, Mike Frysinger wrote:
>>>>>
>>>>> On Tuesday 29 November 2011 15:08:09 Simon Glass wrote:
>>>>>>
>>>>>> On Mon, Nov 28, 2011 at 7:11 PM, Mike Frysinger wrote:
>>>>>>>
>>>>>>> On Monday 21 November 2011 18:57:54 Simon Glass wrote:
>>>>>>>>
>>>>>>>> We are introducing a new unified board setup and we want this to
>>>>>>>> be the default. So we need to opt all architectures out first.
>>>>>>>
>>>>>>>
>>>>>>> the define says "BOARD", so shouldn't it be in board configs ? ?we
>>>>>>> can
>>>>>>> do that easily: add it to include/config_defaults.h. ?then boards
>>>>>>> that opt into it will #undef it in their own configs.
>>>>>>
>>>>>>
>>>>>> Thanks for looking at this.
>>>>>>
>>>>>> I see this as an architecture feature - perhaps a rename to something
>>>>>> like CONFIG_LEGACY_ARCH would help? I quite badly want to avoid moving
>>>>>> boards over one at a time, or having boards for a particular
>>>>>> architecture that still do things the old way - it just increases
>>>>>> maintenance and means that my eventual patch to remove
>>>>>> arch/xxx/lib/board.c cannot be applied.
>>>>>>
>>>>>> My idea for this CONFIG is purely as a temporary measure before boards
>>>>>> more over to the generic approach.
>>>>>
>>>>>
>>>>> how about we have the reloc code live in lib/reloc/ and be controlled
>>>>> by
>>>>> CONFIG_LEGACY_ARCH_RELOC ?
>>>>
>>>>
>>>> My only concern is that if something like SPL needs to keep all the
>>>> early code at the start of the image. I personally don't like the
>>>> current method for doing that (would prefer a distinctive .text.early
>>>> section name) and I don't believe that any SPL implementation actually
>>>> relocates itself.
>>>
>>>
>>> not sure why this matters ?
>>> -mike
>>>
>>
>> Because if they require linking with reloc.o then we will get link
>> failures some boards. There is some ugly stuff in SPL which pulls in
>> particular files from around U-Boot. Any time I split something out of
>> start.S I may break something.
>
>
> IIRC, SPL never relocates itself -- the goal of SPL is to get some code in
> memory that will just enable RAM, move the rest of U-Boot in, and jump to
> it.
>
> What SPL pulls in is drivers/ functions for console output and access to the
> RAM and main U-Boot image.
>
> Besides, sometimes making boards all fail until they are fixed is a good way
> to manage a change. :)
OK it sounds like SPL won't cause problems with this series, good.
Regards,
Simon
>
>> Regards,
>> Simon
>
>
> Amicalement,
> --
> Albert.
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 2/7] reboard: Add generic link symbols
2011-11-29 2:59 ` Mike Frysinger
@ 2011-12-07 22:37 ` Simon Glass
0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-07 22:37 UTC (permalink / raw)
To: u-boot
Hi Mike,
On Mon, Nov 28, 2011 at 6:59 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 21 November 2011 18:57:55 Simon Glass wrote:
>> ?include/asm-generic/link_symbols.h | ? 38
>
> this should be asm-generic/sections.h. ?might actually want to import the
> Linux one and then add a section for u-boot specific symbols.
> -mike
OK I have done that - there are quite a few extra ones that we don't
need and some names are different but I suppose that is ok.
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-11-29 3:07 ` Mike Frysinger
2011-11-29 22:15 ` Simon Glass
@ 2011-12-07 22:45 ` Simon Glass
2011-12-07 22:54 ` Graeme Russ
1 sibling, 1 reply; 47+ messages in thread
From: Simon Glass @ 2011-12-07 22:45 UTC (permalink / raw)
To: u-boot
Hi Mike,
On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>> ?board/Makefile ? | ? 45
>> ?board/reloc.c ? ?| ?101
>
> not to bikeshed, but i don't think we want files in board/. ?how about
> board/common/ or board/generic/ instead ?
>
>> --- /dev/null
>> +++ b/board/Makefile
>>
>> +ifndef CONFIG_SYS_LEGACY_BOARD
>> +COBJS ? ? ? ?+= reloc.o
>> +endif
>
> i don't think relocation should be tied "legacy board". ?not all arches do
> relocation at all, which means they might never opt in to this aspect.
>
>> --- a/include/common.h
>> +++ b/include/common.h
>>
>> -void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
>> +#include <reloc.h>
>
> i'd think very few funcs would need this. ?so maybe we should make the few
> places include reloc.h explicitly.
> -mike
I found that 27 files call relocate_code(). Now we can discuss whether
the number should be that high, but for now I would prefer to move
this out of common.h in a later patch. What do you think?
./nand_spl/board/freescale/p1023rds/nand_boot.c
./nand_spl/board/freescale/p1010rdb/nand_boot.c
./nand_spl/board/freescale/mpc8536ds/nand_boot.c
./nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c
./nand_spl/board/freescale/mpc8569mds/nand_boot.c
./nand_spl/board/freescale/mpc8572ds/nand_boot.c
./nand_spl/board/freescale/p1_p2_rdb/nand_boot.c
./nand_spl/nand_boot_fsl_nfc.c
./arch/mips/lib/board.c
./arch/x86/lib/board.c
./arch/nds32/lib/board.c
./arch/arm/cpu/armv7/omap-common/spl.c
./arch/arm/cpu/arm926ejs/davinci/spl.c
./arch/arm/lib/board.c
./arch/avr32/lib/board.c
./arch/powerpc/lib/board.c
./arch/m68k/lib/board.c
./board/samsung/smdk6400/smdk6400_nand_spl.c
./board/sheldon/simpc8313/simpc8313.c
./board/freescale/mpc8313erdb/mpc8313erdb.c
./board/freescale/mpc8315erdb/mpc8315erdb.c
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-12-07 22:45 ` Simon Glass
@ 2011-12-07 22:54 ` Graeme Russ
2011-12-07 22:55 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Graeme Russ @ 2011-12-07 22:54 UTC (permalink / raw)
To: u-boot
Hi Simon,
On Thu, Dec 8, 2011 at 9:45 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Mike,
>
> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>>> ?board/Makefile ? | ? 45
>>> ?board/reloc.c ? ?| ?101
>>
>> not to bikeshed, but i don't think we want files in board/. ?how about
>> board/common/ or board/generic/ instead ?
>>
>>> --- /dev/null
>>> +++ b/board/Makefile
>>>
>>> +ifndef CONFIG_SYS_LEGACY_BOARD
>>> +COBJS ? ? ? ?+= reloc.o
>>> +endif
>>
>> i don't think relocation should be tied "legacy board". ?not all arches do
>> relocation at all, which means they might never opt in to this aspect.
>>
>>> --- a/include/common.h
>>> +++ b/include/common.h
>>>
>>> -void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
>>> +#include <reloc.h>
>>
>> i'd think very few funcs would need this. ?so maybe we should make the few
>> places include reloc.h explicitly.
>> -mike
>
> I found that 27 files call relocate_code(). Now we can discuss whether
> the number should be that high, but for now I would prefer to move
> this out of common.h in a later patch. What do you think?
27 out of how many source code files? Thousands?
Quite honestly, include/common.h has become a bit of a dumping ground
for one-off function definitions that should have been put in a
stand-alone header.
common.h is included nearly everywhere - is all this really needed everywhere:
/* Multicore arch functions */
#ifdef CONFIG_MP
int cpu_status(int nr);
int cpu_reset(int nr);
int cpu_disable(int nr);
int cpu_release(int nr, int argc, char * const argv[]);
#endif
...
int dpram_init (void);
uint dpram_base(void);
uint dpram_base_align(uint align);
uint dpram_alloc(uint size);
uint dpram_alloc_align(uint size,uint align);
...
#if defined(CONFIG_8260)
int prt_8260_rsr (void);
#elif defined(CONFIG_MPC83xx)
int prt_83xx_rsr (void);
#endif
...
/* $(CPU)/cpu_init.c */
#if defined(CONFIG_8xx) || defined(CONFIG_8260)
void cpu_init_f (volatile immap_t *immr);
#endif
#if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) ||
defined(CONFIG_MCF52x2) ||defined(CONFIG_MPC86xx)
void cpu_init_f (void);
#endif
...
#if defined(CONFIG_IMX)
ulong get_systemPLLCLK(void);
ulong get_FCLK(void);
ulong get_HCLK(void);
ulong get_BCLK(void);
ulong get_PERCLK1(void);
ulong get_PERCLK2(void);
ulong get_PERCLK3(void);
#endif
The list goes on - please, lets stop the rot
Regards,
Graeme
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-12-07 22:54 ` Graeme Russ
@ 2011-12-07 22:55 ` Simon Glass
0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-07 22:55 UTC (permalink / raw)
To: u-boot
Hi Graeme,
On Wed, Dec 7, 2011 at 2:54 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
> Hi Simon,
>
> On Thu, Dec 8, 2011 at 9:45 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Mike,
>>
>> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>>> On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>>>> ?board/Makefile ? | ? 45
>>>> ?board/reloc.c ? ?| ?101
>>>
>>> not to bikeshed, but i don't think we want files in board/. ?how about
>>> board/common/ or board/generic/ instead ?
>>>
>>>> --- /dev/null
>>>> +++ b/board/Makefile
>>>>
>>>> +ifndef CONFIG_SYS_LEGACY_BOARD
>>>> +COBJS ? ? ? ?+= reloc.o
>>>> +endif
>>>
>>> i don't think relocation should be tied "legacy board". ?not all arches do
>>> relocation at all, which means they might never opt in to this aspect.
>>>
>>>> --- a/include/common.h
>>>> +++ b/include/common.h
>>>>
>>>> -void relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
>>>> +#include <reloc.h>
>>>
>>> i'd think very few funcs would need this. ?so maybe we should make the few
>>> places include reloc.h explicitly.
>>> -mike
>>
>> I found that 27 files call relocate_code(). Now we can discuss whether
>> the number should be that high, but for now I would prefer to move
>> this out of common.h in a later patch. What do you think?
>
> 27 out of how many source code files? Thousands?
>
> Quite honestly, include/common.h has become a bit of a dumping ground
> for one-off function definitions that should have been put in a
> stand-alone header.
>
> common.h is included nearly everywhere - is all this really needed everywhere:
>
> /* Multicore arch functions */
> #ifdef CONFIG_MP
> int cpu_status(int nr);
> int cpu_reset(int nr);
> int cpu_disable(int nr);
> int cpu_release(int nr, int argc, char * const argv[]);
> #endif
>
> ...
>
> int ? ? dpram_init (void);
> uint ? ?dpram_base(void);
> uint ? ?dpram_base_align(uint align);
> uint ? ?dpram_alloc(uint size);
> uint ? ?dpram_alloc_align(uint size,uint align);
>
> ...
>
> #if defined(CONFIG_8260)
> int ? ? prt_8260_rsr ?(void);
> #elif defined(CONFIG_MPC83xx)
> int ? ? prt_83xx_rsr ?(void);
> #endif
>
> ...
>
> /* $(CPU)/cpu_init.c */
> #if defined(CONFIG_8xx) || defined(CONFIG_8260)
> void ? ?cpu_init_f ? ?(volatile immap_t *immr);
> #endif
> #if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) ||
> defined(CONFIG_MCF52x2) ||defined(CONFIG_MPC86xx)
> void ? ?cpu_init_f ? ?(void);
> #endif
>
> ...
>
> #if defined(CONFIG_IMX)
> ulong get_systemPLLCLK(void);
> ulong get_FCLK(void);
> ulong get_HCLK(void);
> ulong get_BCLK(void);
> ulong get_PERCLK1(void);
> ulong get_PERCLK2(void);
> ulong get_PERCLK3(void);
> #endif
>
>
> The list goes on - please, lets stop the rot
You are preaching to the choir...
OK I will add an initial patch to the series to clean this up.
Regards,
Simon
>
> Regards,
>
> Graeme
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
2011-11-28 23:45 ` [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Tom Rini
2011-12-07 1:56 ` Simon Glass
@ 2011-12-07 23:29 ` Simon Glass
1 sibling, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-07 23:29 UTC (permalink / raw)
To: u-boot
Hi Tomi,
On Mon, Nov 28, 2011 at 3:45 PM, Tom Rini <tom.rini@gmail.com> wrote:
> On Mon, Nov 21, 2011 at 4:57 PM, Simon Glass <sjg@chromium.org> wrote:
>> This is the second patch series aiming to unify the various board.c files
>> in each architecture into a single one. This series creates a libboard
>> library and implements relocation in it. It then moves ARM over to use
>> this framework, as an example.
>>
>> On ARM the relocation code is duplicated for each CPU yet it
>> is the same. We can bring this up to the arch level. But since (I believe)
>> Elf relocation is basically the same process for all archs, there is no
>> reason not to bring it up to the generic level.
>>
>> This series establishes a new libboard library in the board/ subdir and
>> puts some relocation code in it. Each architecture which uses this
>> framework needs to provide a function called arch_elf_relocate_entry()
>> which processes a single relocation entry. If there is concern about
>> calling a function for all 2000-odd relocations then I can change this.
>>
>> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
>> ARM assembler code (things that cannot be written in C and are common
>> functions used by all ARM CPUs). This helps reduce duplication. Interrupt
>> handling code and perhaps even some startup code can move there later.
>>
>> It may be useful for other architectures to have a similar file.
>>
>> This series moves ARM over to use this framework. Overall this means that
>> two new files are required 'early' in boot: board/reloc.c and
>> arch/arm/lib/proc.S. ?This is tricky mainly due to SPL. I believe that
>> we may need to adjust link scripts to put these two files early in the
>> link scripts also. But I am not sure about this and can't actually find
>> a problem as yet. I would much prefer to solve this with a new section
>> name like .text.early if we can.
>>
>> (I should really cc all arch maintainers but I think in that case I get
>> an error from the list server. Not sure what the limit is.)
>>
>> Comments please...
>
> Seems like a good idea. ?Got some size's before and after? ?Maybe some
> boot times too (as you mention 2000-odd function calls during
> relocation) ?
For my system it is currently 500us slower on a 320KB U-Boot binary
(so adding 0.5ms to a 95ms pre-relocation stage), It is currently 350
bytes larger.
I will see what I can do about the code size, and I expect the
performance penalty will reduce also, although it is already small.
Regards,
Simon
>
> --
> Tom
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-12-07 7:38 ` Albert ARIBAUD
@ 2011-12-08 0:35 ` Mike Frysinger
2011-12-09 3:36 ` Simon Glass
0 siblings, 1 reply; 47+ messages in thread
From: Mike Frysinger @ 2011-12-08 0:35 UTC (permalink / raw)
To: u-boot
On Wednesday 07 December 2011 02:38:40 Albert ARIBAUD wrote:
> Le 30/11/2011 03:58, Mike Frysinger a ?crit :
> > On Tuesday 29 November 2011 18:49:58 Graeme Russ wrote:
> >> On Wed, Nov 30, 2011 at 10:41 AM, Simon Glass wrote:
> >>> On Tue, Nov 29, 2011 at 3:20 PM, Mike Frysinger wrote:
> >>>> On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
> >>>>> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger wrote:
> >>>>>> On Monday 21 November 2011 18:57:56 Simon Glass wrote:
> >>>>>>> --- /dev/null
> >>>>>>> +++ b/board/Makefile
> >>>>>>>
> >>>>>>> +ifndef CONFIG_SYS_LEGACY_BOARD
> >>>>>>> +COBJS += reloc.o
> >>>>>>> +endif
> >>>>>>
> >>>>>> i don't think relocation should be tied "legacy board". not all
> >>>>>> arches do relocation at all, which means they might never opt in to
> >>>>>> this aspect.
> >>>>>
> >>>>> If they don't do reloc then when we move them over we should add a
> >>>>> CONFIG for this I think. But would prefer to wait until we have an
> >>>>> arch moving over that requires no relocation, before addressing this.
> >>>>
> >>>> Blackfin does no relocation, so i'd be annoyed to have to carry a
> >>>> define like "LEGACY_BOARD" forever ;)
> >>>
> >>> Would you be happier with CONFIG_ARCH_NO_RELOCATION?
> >>
> >> CONFIG_SYS_NO_RELOC
> >
> > either is fine by me
>
> CONFIG_SYS_SKIP_RELOC clearly states there is some usual step we're
> skipping, plus we could homogeneize with other config settings that
> "SKIP" some step.
fine by me as well
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111207/b91978f7/attachment.pgp>
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature
2011-12-07 8:10 ` Albert ARIBAUD
@ 2011-12-09 3:34 ` Simon Glass
0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-09 3:34 UTC (permalink / raw)
To: u-boot
Hi Albert,
On Wed, Dec 7, 2011 at 12:10 AM, Albert ARIBAUD
<albert.u.boot@aribaud.net> wrote:
> Hi Simon,
>
> Le 22/11/2011 00:57, Simon Glass a ?crit :
>
>> This is the second patch series aiming to unify the various board.c files
>> in each architecture into a single one. This series creates a libboard
>> library and implements relocation in it. It then moves ARM over to use
>> this framework, as an example.
>>
>> On ARM the relocation code is duplicated for each CPU yet it
>> is the same. We can bring this up to the arch level. But since (I believe)
>> Elf relocation is basically the same process for all archs, there is no
>> reason not to bring it up to the generic level.
>
>
> Agreed.
>
>
>> This series establishes a new libboard library in the board/ subdir and
>> puts some relocation code in it. Each architecture which uses this
>> framework needs to provide a function called arch_elf_relocate_entry()
>> which processes a single relocation entry. If there is concern about
>> calling a function for all 2000-odd relocations then I can change this.
>
>
> NAK -- a generic relocation function should be not be in board/, it should
> be in lib/
Well based on your other comments I have gone with common/ for now.
>
>
>> For ARM, a new arch/arm/lib/proc.S file is created, which holds generic
>> ARM assembler code (things that cannot be written in C and are common
>> functions used by all ARM CPUs). This helps reduce duplication. Interrupt
>> handling code and perhaps even some startup code can move there later.
>
>
> As commented in detail, I am not sure creating a function for three asm
> instructions is worthwhile. The overhead for calling the code might be
> bigger than the body of the function. Did you compare with inline functions
> with asm statements and/or intrinsics?
Well it still needs the I$ stuff and other archs may need more. It
could be an inline function, but what would be the benefit? No time or
code size saving I think.
>
>
>> It may be useful for other architectures to have a similar file.
>>
>> This series moves ARM over to use this framework. Overall this means that
>> two new files are required 'early' in boot: board/reloc.c and
>> arch/arm/lib/proc.S. ?This is tricky mainly due to SPL.
>
>
> Can you develop what the issue is with SPL exactly?
Well it is just that SPL brings in source files from around U-Boot and
builds them into an image. If we add a new object file which is needed
by SPL then we may need to change all those Makefiles. I don't think
that applies to relocation luckily. We will hit this issue anytime we
move code out of start.S.
>
>
>> I believe that
>> we may need to adjust link scripts to put these two files early in the
>> link scripts also. But I am not sure about this and can't actually find
>> a problem as yet. I would much prefer to solve this with a new section
>> name like .text.early if we can.
>>
>> (I should really cc all arch maintainers but I think in that case I get
>> an error from the list server. Not sure what the limit is.)
>
>
> This would not cause an error, but Wolfgang would have to "OK' the post,
> which is a good thing if many people are involved. :)
OK, well I may try that with the next revision.
>
>> Comments please...
>
>
> Generic comment is that the patch is not about generic *board*. It is about
> generic *relocation*, which is not a thing of boards IMO: it is not related
> to peripheral or HW configuration, and is not actually memory-mapped
> related.
Well it is the first thing I have chosen to deal with on the path to a
generic board.c. Relocation is a large part of what
arch/xxx/lib/board.c currently does. And after all I am actually
moving it out of board.c.
>
> Other than that, as stated in the detailed answers, we need to keep the
> relocation code as efficient as possible. As happy as I am to see the ELF
> relocation code rewritten in C for easy understanding and maintenance, I
> would not want it done at the expense of speed or overall architecture
> soundness. So:
>
> - the C relocation code (both the generic function and the ELF specific
> code) are neither board-related nor ARM-specific, so it has no reason to
> reside in board/ or arch/arm. My first reflex was lib/, but indeed common/
> might be a better place.
ok
>
> - the relocation function should be as efficient as possible. Compared
> numbers between 'before' and 'after' should also be provided -- I do not
> necessarily expect the same or better performance, but we need to assess
> what the performance issue is.
I sent some numbers, but hope to improve on them.
>
> - I would prefer each patch to be as self-contained as possible --
> 'preparatory' patches I don't like much. For instance, to relace ASM
> relocation with C relocation, I would want a single patch introducing the C
> code and removing the ASM code or moving it out of the way.
Well that's a bit tricky unless you want be to replace the code in
start.S to call my proc.S function, just before I delete the code in
start.S!
>
> - I am not sure why the code should be "early" or, more precisely, should be
> specifically located in the linker file: any code in there is accessible at
> any time, and the only special case is for _start because we want it to be
> first in placement, not in time. Can you clarify this 'early' issue?
I was referring to SPL, but I think we have established that it
shouldn't matter.
>
> - indeed I would prefer a weak symbol for the relocation function. This
> would allow a given config to easily override the generic C code if needed.
Ok.
>
> Amicalement,
> --
> Albert.
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature
2011-12-08 0:35 ` Mike Frysinger
@ 2011-12-09 3:36 ` Simon Glass
0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-09 3:36 UTC (permalink / raw)
To: u-boot
Hi,
On Wed, Dec 7, 2011 at 4:35 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday 07 December 2011 02:38:40 Albert ARIBAUD wrote:
>> Le 30/11/2011 03:58, Mike Frysinger a ?crit :
>> > On Tuesday 29 November 2011 18:49:58 Graeme Russ wrote:
>> >> On Wed, Nov 30, 2011 at 10:41 AM, Simon Glass wrote:
>> >>> On Tue, Nov 29, 2011 at 3:20 PM, Mike Frysinger wrote:
>> >>>> On Tuesday 29 November 2011 17:15:18 Simon Glass wrote:
>> >>>>> On Mon, Nov 28, 2011 at 7:07 PM, Mike Frysinger wrote:
>> >>>>>> On Monday 21 November 2011 18:57:56 Simon Glass wrote:
>> >>>>>>> --- /dev/null
>> >>>>>>> +++ b/board/Makefile
>> >>>>>>>
>> >>>>>>> +ifndef CONFIG_SYS_LEGACY_BOARD
>> >>>>>>> +COBJS ? ? ? ?+= reloc.o
>> >>>>>>> +endif
>> >>>>>>
>> >>>>>> i don't think relocation should be tied "legacy board". ?not all
>> >>>>>> arches do relocation at all, which means they might never opt in to
>> >>>>>> this aspect.
>> >>>>>
>> >>>>> If they don't do reloc then when we move them over we should add a
>> >>>>> CONFIG for this I think. But would prefer to wait until we have an
>> >>>>> arch moving over that requires no relocation, before addressing this.
>> >>>>
>> >>>> Blackfin does no relocation, so i'd be annoyed to have to carry a
>> >>>> define like "LEGACY_BOARD" forever ;)
>> >>>
>> >>> Would you be happier with CONFIG_ARCH_NO_RELOCATION?
>> >>
>> >> CONFIG_SYS_NO_RELOC
>> >
>> > either is fine by me
>>
>> CONFIG_SYS_SKIP_RELOC clearly states there is some usual step we're
>> skipping, plus we could homogeneize with other config settings that
>> "SKIP" some step.
>
> fine by me as well
> -mike
OK, will define that in boards with no relocation. Others (like
PowerPC) will end up with an unused relocation function until they
switch over. That might cause problems, we will see.
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 6/7] reboard: arm: Move over to generic relocation
2011-11-29 3:14 ` Mike Frysinger
@ 2011-12-09 3:41 ` Simon Glass
0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-09 3:41 UTC (permalink / raw)
To: u-boot
Hi Mike,
On Mon, Nov 28, 2011 at 7:14 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 21 November 2011 18:57:59 Simon Glass wrote:
>> --- a/board/reloc.c
>> +++ b/board/reloc.c
>>
>> -void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
>> +void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
>
> shouldn't this be squashed into the patch that added this func ?
Yes I'm going with the weak function idea. We can remove it when all
archs are moved over.
>
>> --- a/nand_spl/board/freescale/mx31pdk/Makefile
>> +++ b/nand_spl/board/freescale/mx31pdk/Makefile
>>
>> +$(obj)%.o: ? $(SRCTREE)/board/%.c
>> + ? ? $(CC) $(CFLAGS) -c -o $@ $<
>> +
>> +$(obj)%.o: ? $(SRCTREE)/arch/arm/lib/%.S
>> + ? ? $(CC) $(AFLAGS) -c -o $@ $<
>
> ugh. ?is this the SOP for SPL or something ? ?this is awful :(.
Yes, SPL. It makes me very sad too. The worse alternative is to break
all boards that don't use the new SPL framework.
Regards,
Simon
> -mike
^ permalink raw reply [flat|nested] 47+ messages in thread
* [U-Boot] [RFC PATCH 7/7] reboard: arm: Remove unused code in start.S
2011-11-29 3:15 ` Mike Frysinger
@ 2011-12-09 3:42 ` Simon Glass
0 siblings, 0 replies; 47+ messages in thread
From: Simon Glass @ 2011-12-09 3:42 UTC (permalink / raw)
To: u-boot
Hi Mike,
On Mon, Nov 28, 2011 at 7:15 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 21 November 2011 18:58:00 Simon Glass wrote:
>> --- a/board/reloc.c
>> +++ b/board/reloc.c
>>
>> -void new_relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
>> +void relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
>
> this is too fragile. ?we can't have every arch transition the way you did with
> arm (otherwise arches that have transitioned will break in between). ?declare
> this func weak and don't rename it. ?then there should be no migration issue.
> -mike
Yes I will do that, thanks. We can always remove it later when archs
have all moved over.
Regards,
Simon
^ permalink raw reply [flat|nested] 47+ messages in thread
end of thread, other threads:[~2011-12-09 3:42 UTC | newest]
Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-21 23:57 [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 1/7] reboard: define CONFIG_SYS_LEGACY_BOARD everywhere Simon Glass
2011-11-29 3:11 ` Mike Frysinger
2011-11-29 20:08 ` Simon Glass
2011-11-29 21:40 ` Mike Frysinger
2011-11-29 22:09 ` Simon Glass
2011-11-29 23:19 ` Mike Frysinger
2011-11-29 23:40 ` Simon Glass
2011-12-07 8:15 ` Albert ARIBAUD
2011-12-07 16:28 ` Simon Glass
2011-12-05 6:42 ` Aneesh V
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 2/7] reboard: Add generic link symbols Simon Glass
2011-11-29 2:59 ` Mike Frysinger
2011-12-07 22:37 ` Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 3/7] reboard: Add generic relocation feature Simon Glass
2011-11-29 3:07 ` Mike Frysinger
2011-11-29 22:15 ` Simon Glass
2011-11-29 23:00 ` Graeme Russ
2011-11-29 23:20 ` Mike Frysinger
2011-11-29 23:41 ` Simon Glass
2011-11-29 23:49 ` Graeme Russ
2011-11-30 2:58 ` Mike Frysinger
2011-12-07 7:38 ` Albert ARIBAUD
2011-12-08 0:35 ` Mike Frysinger
2011-12-09 3:36 ` Simon Glass
2011-12-07 22:45 ` Simon Glass
2011-12-07 22:54 ` Graeme Russ
2011-12-07 22:55 ` Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 4/7] reboard: arm: Add relocation function Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 5/7] reboard: arm: Add processor function library Simon Glass
2011-11-29 3:12 ` Mike Frysinger
2011-12-07 7:44 ` Albert ARIBAUD
2011-12-07 16:24 ` Simon Glass
2011-11-21 23:57 ` [U-Boot] [RFC PATCH 6/7] reboard: arm: Move over to generic relocation Simon Glass
2011-11-29 3:14 ` Mike Frysinger
2011-12-09 3:41 ` Simon Glass
2011-11-21 23:58 ` [U-Boot] [RFC PATCH 7/7] reboard: arm: Remove unused code in start.S Simon Glass
2011-11-29 3:15 ` Mike Frysinger
2011-12-09 3:42 ` Simon Glass
2011-11-28 23:45 ` [U-Boot] [RFC PATCH 0/7] reboard: Introduce generic relocation feature Tom Rini
2011-12-07 1:56 ` Simon Glass
2011-12-07 2:56 ` Graeme Russ
2011-12-07 3:25 ` Simon Glass
2011-12-07 3:36 ` Graeme Russ
2011-12-07 23:29 ` Simon Glass
2011-12-07 8:10 ` Albert ARIBAUD
2011-12-09 3:34 ` Simon Glass
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox