[U-Boot] [PATCH v2 1/6] reboard: Create reloc.h and include it where needed

Simon Glass sjg at chromium.org
Sat Dec 10 20:16:11 CET 2011


Before adding new relocation functions, move this prototype out of
common.h where things are pretty crowded.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/arm/cpu/arm926ejs/davinci/spl.c              |    1 +
 arch/arm/cpu/armv7/omap-common/spl.c              |    1 +
 arch/arm/lib/board.c                              |    1 +
 arch/avr32/lib/board.c                            |    1 +
 arch/m68k/lib/board.c                             |    1 +
 arch/mips/lib/board.c                             |    1 +
 arch/nds32/lib/board.c                            |    1 +
 arch/powerpc/lib/board.c                          |    1 +
 arch/x86/lib/board.c                              |    1 +
 board/freescale/mpc8313erdb/mpc8313erdb.c         |    1 +
 board/freescale/mpc8315erdb/mpc8315erdb.c         |    1 +
 board/samsung/smdk6400/smdk6400_nand_spl.c        |    1 +
 board/sheldon/simpc8313/simpc8313.c               |    1 +
 include/common.h                                  |    2 +-
 include/reloc.h                                   |   39 +++++++++++++++++++++
 nand_spl/board/freescale/mpc8536ds/nand_boot.c    |    1 +
 nand_spl/board/freescale/mpc8569mds/nand_boot.c   |    1 +
 nand_spl/board/freescale/mpc8572ds/nand_boot.c    |    1 +
 nand_spl/board/freescale/p1010rdb/nand_boot.c     |    1 +
 nand_spl/board/freescale/p1023rds/nand_boot.c     |    1 +
 nand_spl/board/freescale/p1_p2_rdb/nand_boot.c    |    1 +
 nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c |    1 +
 nand_spl/nand_boot_fsl_nfc.c                      |    1 +
 23 files changed, 61 insertions(+), 1 deletions(-)
 create mode 100644 include/reloc.h

diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c
index d9b9398..aba50d1 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl.c
@@ -24,6 +24,7 @@
 #include <asm/u-boot.h>
 #include <asm/utils.h>
 #include <nand.h>
+#include <reloc.h>
 #include <asm/arch/dm365_lowlevel.h>
 #include <ns16550.h>
 
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c
index 9c35a09..06039fe 100644
--- a/arch/arm/cpu/armv7/omap-common/spl.c
+++ b/arch/arm/cpu/armv7/omap-common/spl.c
@@ -35,6 +35,7 @@
 #include <i2c.h>
 #include <image.h>
 #include <malloc.h>
+#include <reloc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 3d78274..bf1bf79 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -41,6 +41,7 @@
 #include <common.h>
 #include <command.h>
 #include <malloc.h>
+#include <reloc.h>
 #include <stdio_dev.h>
 #include <version.h>
 #include <net.h>
diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index 63fe297..a7eaf76 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -22,6 +22,7 @@
 #include <common.h>
 #include <command.h>
 #include <malloc.h>
+#include <reloc.h>
 #include <stdio_dev.h>
 #include <version.h>
 #include <net.h>
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index 259b71c..85495cc 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -28,6 +28,7 @@
 #include <watchdog.h>
 #include <command.h>
 #include <malloc.h>
+#include <reloc.h>
 #include <stdio_dev.h>
 
 #include <asm/immap.h>
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index d998f0e..e5bdcfc 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <command.h>
 #include <malloc.h>
+#include <reloc.h>
 #include <stdio_dev.h>
 #include <version.h>
 #include <net.h>
diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
index 66e4537..9295f46 100644
--- a/arch/nds32/lib/board.c
+++ b/arch/nds32/lib/board.c
@@ -28,6 +28,7 @@
 #include <common.h>
 #include <command.h>
 #include <malloc.h>
+#include <reloc.h>
 #include <stdio_dev.h>
 #include <timestamp.h>
 #include <version.h>
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index ff5888e..248d452 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -25,6 +25,7 @@
 #include <watchdog.h>
 #include <command.h>
 #include <malloc.h>
+#include <reloc.h>
 #include <stdio_dev.h>
 #ifdef CONFIG_8xx
 #include <mpc8xx.h>
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index d742fec..3d00f20 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -35,6 +35,7 @@
 #include <watchdog.h>
 #include <command.h>
 #include <stdio_dev.h>
+#include <reloc.h>
 #include <version.h>
 #include <malloc.h>
 #include <net.h>
diff --git a/board/freescale/mpc8313erdb/mpc8313erdb.c b/board/freescale/mpc8313erdb/mpc8313erdb.c
index 08f873d..89a4832 100644
--- a/board/freescale/mpc8313erdb/mpc8313erdb.c
+++ b/board/freescale/mpc8313erdb/mpc8313erdb.c
@@ -27,6 +27,7 @@
 #include <libfdt.h>
 #endif
 #include <pci.h>
+#include <reloc.h>
 #include <mpc83xx.h>
 #include <vsc7385.h>
 #include <ns16550.h>
diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c b/board/freescale/mpc8315erdb/mpc8315erdb.c
index 5dc558a..848847b 100644
--- a/board/freescale/mpc8315erdb/mpc8315erdb.c
+++ b/board/freescale/mpc8315erdb/mpc8315erdb.c
@@ -34,6 +34,7 @@
 #include <asm/io.h>
 #include <ns16550.h>
 #include <nand.h>
+#include <reloc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/board/samsung/smdk6400/smdk6400_nand_spl.c b/board/samsung/smdk6400/smdk6400_nand_spl.c
index a023284..23bbad3 100644
--- a/board/samsung/smdk6400/smdk6400_nand_spl.c
+++ b/board/samsung/smdk6400/smdk6400_nand_spl.c
@@ -29,6 +29,7 @@
  */
 
 #include <common.h>
+#include <reloc.h>
 
 void board_init_f(unsigned long bootflag)
 {
diff --git a/board/sheldon/simpc8313/simpc8313.c b/board/sheldon/simpc8313/simpc8313.c
index 9126c42..09d754b 100644
--- a/board/sheldon/simpc8313/simpc8313.c
+++ b/board/sheldon/simpc8313/simpc8313.c
@@ -29,6 +29,7 @@
 #include <mpc83xx.h>
 #include <ns16550.h>
 #include <nand.h>
+#include <reloc.h>
 #include <asm/io.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/include/common.h b/include/common.h
index 05a658c..57bfa4c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -470,7 +470,7 @@ int	dcache_status (void);
 void	dcache_enable (void);
 void	dcache_disable(void);
 void	mmu_disable(void);
-void	relocate_code (ulong, gd_t *, ulong) __attribute__ ((noreturn));
+#include <reloc.h>
 ulong	get_endaddr   (void);
 void	trap_init     (ulong);
 #if defined (CONFIG_4xx)	|| \
diff --git a/include/reloc.h b/include/reloc.h
new file mode 100644
index 0000000..3dc7b85
--- /dev/null
+++ b/include/reloc.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __RELOC_H
+#define __RELOC_H
+
+/**
+ * Relocate U-Boot and jump to the relocated coded
+ *
+ * This copies U-Boot to a new location, zeroes the BSS, sets up a new stack
+ * and jumps to board_init_r() in the relocated code using the
+ * proc_call_board_init_r() function. It does not return.
+ *
+ * @param dest_sp	New stack pointer to use
+ * @param new_gd	Pointer to the relocated global data
+ * @param dest_addr		Base code address of relocated U-Boot
+ */
+void relocate_code(ulong dest_sp, gd_t *new_gd, ulong dest_addr)
+		__attribute__ ((noreturn));
+#endif
diff --git a/nand_spl/board/freescale/mpc8536ds/nand_boot.c b/nand_spl/board/freescale/mpc8536ds/nand_boot.c
index 5a0a0c7..0356067 100644
--- a/nand_spl/board/freescale/mpc8536ds/nand_boot.c
+++ b/nand_spl/board/freescale/mpc8536ds/nand_boot.c
@@ -23,6 +23,7 @@
 #include <ns16550.h>
 #include <asm/io.h>
 #include <nand.h>
+#include <reloc.h>
 
 u32 sysclk_tbl[] = {
 	33333000, 39999600, 49999500, 66666000,
diff --git a/nand_spl/board/freescale/mpc8569mds/nand_boot.c b/nand_spl/board/freescale/mpc8569mds/nand_boot.c
index 047da34..df391dc 100644
--- a/nand_spl/board/freescale/mpc8569mds/nand_boot.c
+++ b/nand_spl/board/freescale/mpc8569mds/nand_boot.c
@@ -23,6 +23,7 @@
 #include <asm/io.h>
 #include <ns16550.h>
 #include <nand.h>
+#include <reloc.h>
 #include <asm/mmu.h>
 #include <asm/immap_85xx.h>
 #include <asm/fsl_ddr_sdram.h>
diff --git a/nand_spl/board/freescale/mpc8572ds/nand_boot.c b/nand_spl/board/freescale/mpc8572ds/nand_boot.c
index 7ca4d4d..d0a059c 100644
--- a/nand_spl/board/freescale/mpc8572ds/nand_boot.c
+++ b/nand_spl/board/freescale/mpc8572ds/nand_boot.c
@@ -23,6 +23,7 @@
 #include <ns16550.h>
 #include <asm/io.h>
 #include <nand.h>
+#include <reloc.h>
 
 u32 sysclk_tbl[] = {
 	33333000, 39999600, 49999500, 66666000,
diff --git a/nand_spl/board/freescale/p1010rdb/nand_boot.c b/nand_spl/board/freescale/p1010rdb/nand_boot.c
index 16eeb61..aba3cef 100644
--- a/nand_spl/board/freescale/p1010rdb/nand_boot.c
+++ b/nand_spl/board/freescale/p1010rdb/nand_boot.c
@@ -23,6 +23,7 @@
 #include <asm/io.h>
 #include <ns16550.h>
 #include <nand.h>
+#include <reloc.h>
 #include <asm/mmu.h>
 #include <asm/immap_85xx.h>
 #include <asm/fsl_ddr_sdram.h>
diff --git a/nand_spl/board/freescale/p1023rds/nand_boot.c b/nand_spl/board/freescale/p1023rds/nand_boot.c
index 0065c87..0c1a6b0 100644
--- a/nand_spl/board/freescale/p1023rds/nand_boot.c
+++ b/nand_spl/board/freescale/p1023rds/nand_boot.c
@@ -24,6 +24,7 @@
 #include <ns16550.h>
 #include <asm/io.h>
 #include <nand.h>
+#include <reloc.h>
 #include <asm/fsl_law.h>
 
 /* Fixed sdram init -- doesn't use serial presence detect. */
diff --git a/nand_spl/board/freescale/p1_p2_rdb/nand_boot.c b/nand_spl/board/freescale/p1_p2_rdb/nand_boot.c
index 16a756c..a482469 100644
--- a/nand_spl/board/freescale/p1_p2_rdb/nand_boot.c
+++ b/nand_spl/board/freescale/p1_p2_rdb/nand_boot.c
@@ -23,6 +23,7 @@
 #include <asm/io.h>
 #include <ns16550.h>
 #include <nand.h>
+#include <reloc.h>
 #include <asm/mmu.h>
 #include <asm/immap_85xx.h>
 #include <asm/fsl_ddr_sdram.h>
diff --git a/nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c b/nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c
index b9796ea..b7a1511 100644
--- a/nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c
+++ b/nand_spl/board/freescale/p1_p2_rdb_pc/nand_boot.c
@@ -23,6 +23,7 @@
 #include <ns16550.h>
 #include <asm/io.h>
 #include <nand.h>
+#include <reloc.h>
 #include <asm/fsl_law.h>
 #include <asm/fsl_ddr_sdram.h>
 
diff --git a/nand_spl/nand_boot_fsl_nfc.c b/nand_spl/nand_boot_fsl_nfc.c
index d6b0d9b..66dae24 100644
--- a/nand_spl/nand_boot_fsl_nfc.c
+++ b/nand_spl/nand_boot_fsl_nfc.c
@@ -29,6 +29,7 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/io.h>
 #include <fsl_nfc.h>
+#include <reloc.h>
 
 static struct fsl_nfc_regs *const nfc = (void *)NFC_BASE_ADDR;
 
-- 
1.7.3.1



More information about the U-Boot mailing list