[U-Boot] [RFC PATCH 02/19] Make relocation functions global
Simon Glass
sjg at chromium.org
Wed Dec 28 07:35:43 CET 2011
We want to be able to call relocations functions from our new board code,
so make them global and add to the header.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
common/reloc.c | 29 ++++++++++++++++++++++++++---
include/reloc.h | 16 ++++++++++++++++
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/common/reloc.c b/common/reloc.c
index 2344e98..ec0d72f 100644
--- a/common/reloc.c
+++ b/common/reloc.c
@@ -28,7 +28,15 @@
DECLARE_GLOBAL_DATA_PTR;
-static int reloc_make_copy(void)
+int reloc_calculate_dest(void)
+{
+ gd->relocaddr = gd->dest_addr;
+ gd->reloc_off = gd->dest_addr - CONFIG_SYS_TEXT_BASE;
+ debug("relocation Offset is: %08lx\n", gd->reloc_off);
+ return 0;
+}
+
+int reloc_make_copy(void)
{
char *dst_addr = (char *)gd->relocaddr;
@@ -51,7 +59,7 @@ static int reloc_make_copy(void)
return 0;
}
-static int reloc_elf(void)
+int reloc_elf(void)
{
#ifndef CONFIG_SPL_BUILD
const Elf32_Rel *ptr, *end;
@@ -76,7 +84,7 @@ static int reloc_elf(void)
return 0;
}
-static int reloc_clear_bss(void)
+int reloc_clear_bss(void)
{
char *dst_addr = (char *)_start + _bss_start_ofs;
size_t size = _bss_end_ofs - _bss_start_ofs;
@@ -93,6 +101,20 @@ static int reloc_clear_bss(void)
return 0;
}
+#ifndef CONFIG_SYS_LEGACY_BOARD
+int reloc_jump_to_copy(void)
+{
+ /* TODO: tidy this up since we don't want a separate nand_boot() */
+#ifdef CONFIG_NAND_SPL
+ nand_boot();
+#else
+ proc_call_board_init_r(gd->new_gd, gd->dest_addr,
+ (board_init_r_func)board_init_r,
+ gd->dest_addr_sp);
+#endif
+}
+#endif
+
void __relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
{
ulong new_board_init_r = (uintptr_t)board_init_r + gd->reloc_off;
@@ -106,6 +128,7 @@ void __relocate_code(ulong dest_addr_sp, gd_t *new_gd, ulong dest_addr)
debug("relocation complete: starting from board_init_r() at %lx\n",
new_board_init_r);
+
/* TODO: tidy this up since we don't want a separate nand_boot() */
#ifdef CONFIG_NAND_SPL
nand_boot();
diff --git a/include/reloc.h b/include/reloc.h
index 79c0a24..adaa3bc 100644
--- a/include/reloc.h
+++ b/include/reloc.h
@@ -51,4 +51,20 @@ void proc_call_board_init_r(gd_t *new_gd, ulong dest_addr,
*/
void relocate_code(ulong dest_sp, gd_t *new_gd, ulong dest_addr)
__attribute__ ((noreturn));
+
+/* Work out the destination code address */
+int reloc_calculate_dest(void);
+
+/* Make a copy of the U-Boot code in the new location */
+int reloc_make_copy(void);
+
+/* Fixup relocations in the new code */
+int reloc_elf(void);
+
+/* Clear the new BSS region */
+int reloc_clear_bss(void);
+
+/* Jump to the new relocated U-Boot code */
+int reloc_jump_to_copy(void);
+
#endif
--
1.7.3.1
More information about the U-Boot
mailing list