[U-Boot] [RFC PATCH 13/19] x86: Add processor library and relocation functions

Simon Glass sjg at chromium.org
Wed Dec 28 07:35:54 CET 2011


These are needed for generic relocation to function correctly.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
 arch/x86/include/asm/reloc.h |   32 ++++++++++++++++++++
 arch/x86/lib/Makefile        |    1 +
 arch/x86/lib/proc.S          |   67 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/reloc.h
 create mode 100644 arch/x86/lib/proc.S

diff --git a/arch/x86/include/asm/reloc.h b/arch/x86/include/asm/reloc.h
new file mode 100644
index 0000000..61e0887
--- /dev/null
+++ b/arch/x86/include/asm/reloc.h
@@ -0,0 +1,32 @@
+/*
+ * 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 <elf.h>
+
+int arch_elf_relocate_entry(Elf32_Addr *addr, Elf32_Word info,
+			    Elf32_Sym *symtab,  ulong reloc_off)
+{
+	/* TODO: if(ELF32_R_TYPE(ptr->r_info) != ... return -1 */
+	if (*addr >= CONFIG_SYS_TEXT_BASE)
+		*addr += reloc_off;
+
+	return 0;
+}
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index d584aa4..ff5a864 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -27,6 +27,7 @@ LIB	= $(obj)lib$(ARCH).o
 
 SOBJS-$(CONFIG_SYS_PC_BIOS)	+= bios.o
 SOBJS-$(CONFIG_SYS_PCI_BIOS)	+= bios_pci.o
+SOBJS-y += proc.o
 SOBJS-$(CONFIG_SYS_X86_REALMODE)	+= realmode_switch.o
 
 COBJS-$(CONFIG_SYS_PC_BIOS)	+= bios_setup.o
diff --git a/arch/x86/lib/proc.S b/arch/x86/lib/proc.S
new file mode 100644
index 0000000..432ce0c
--- /dev/null
+++ b/arch/x86/lib/proc.S
@@ -0,0 +1,67 @@
+/*
+ *  U-boot - x86 processor assembler library
+ *
+ * (C) Copyright 2008-2011
+ * Graeme Russ, <graeme.russ at gmail.com>
+ *
+ * (C) Copyright 2002
+ * Daniel Engström, Omicron Ceti AB, <daniel at omicron.se>
+ *
+ * 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 <config.h>
+#include <version.h>
+/* #include <asm/global_data.h> */
+#include <asm/processor-flags.h>
+#include <generated/asm-offsets.h>
+
+.section .text
+.code32
+
+	/*
+	 * TODO: Sort out the argument passing and setup here. See C prototype
+	 * for proc_call_board_init_r()
+	 */
+.globl proc_call_board_init_r
+.type proc_call_board_init_r, @function
+proc_call_board_init_r:
+	/*
+	 * SDRAM has been initialised, U-Boot code has been copied into
+	 * RAM, BSS has been cleared and relocation adjustments have been
+	 * made. It is now time to jump into the in-RAM copy of U-Boot
+	 *
+	 * %eax = Address of top of stack
+	 * %edx = Address of Global Data
+	 * %ecx = Base address of in-RAM copy of U-Boot
+	 */
+
+	/* Setup stack in RAM */
+	movl	%eax, %esp
+
+	/* Setup call address of in-RAM copy of board_init_r() */
+	movl	$board_init_r, %ebp
+	addl	(GENERATED_GD_RELOC_OFF)(%edx), %ebp
+
+	/* Setup parameters to board_init_r() */
+	movl	%edx, %eax
+	movl	%ecx, %edx
+
+	/* Jump to in-RAM copy of board_init_r() */
+	call	*%ebp
-- 
1.7.3.1



More information about the U-Boot mailing list