summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu/start-pbl.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-07-28 01:25:56 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-08-03 18:09:13 +0800
commit78867e2bbd066df7d56e281e03a8cdbe82adf4e4 (patch)
tree311c827a5dc95a2d557f2c308a87f9808aede902 /arch/arm/cpu/start-pbl.c
parentd4c42fb33deb6c061e4410520a6601fb2d072a60 (diff)
downloadbarebox-78867e2bbd066df7d56e281e03a8cdbe82adf4e4.tar.gz
barebox-78867e2bbd066df7d56e281e03a8cdbe82adf4e4.tar.xz
Add pre-bootloader (pbl) image support
This allows for creating a pre-bootloader binary for - nand boot - mmc boot - compressed image The pbl will be incharge of the lowlevel init if needed. The barebox will skip it. Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic. For now on introduce dummy zbarebox* targets and c code that will contain later the decompressor. This only implemeted on ARM. This patch is based on Sascha Hauer <s.hauer@pengutronix.de> Add compressed image support patch Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'arch/arm/cpu/start-pbl.c')
-rw-r--r--arch/arm/cpu/start-pbl.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
new file mode 100644
index 0000000000..28d6f34449
--- /dev/null
+++ b/arch/arm/cpu/start-pbl.c
@@ -0,0 +1,80 @@
+/*
+ * start-pbl.c
+ *
+ * Copyright (c) 2010-2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * 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 version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 <init.h>
+#include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
+#include <asm-generic/memory_layout.h>
+#include <asm/sections.h>
+
+void __naked __section(.text_head_entry) pbl_start(void)
+{
+ barebox_arm_head();
+}
+
+void barebox_pbl(uint32_t offset)
+{
+}
+
+/*
+ * Board code can jump here by either returning from board_init_lowlevel
+ * or by calling this function directly.
+ */
+void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
+{
+ uint32_t r, addr, offset;
+
+ /*
+ * Get runtime address of this function. Do not
+ * put any code above this.
+ */
+ __asm__ __volatile__("1: adr %0, 1b":"=r"(addr));
+
+ /* Setup the stack */
+ r = STACK_BASE + STACK_SIZE - 16;
+ __asm__ __volatile__("mov sp, %0" : : "r"(r));
+
+ /* Get offset between linked address and runtime address */
+ offset = (uint32_t)__ll_return - addr;
+
+ /* relocate to link address if necessary */
+ if (offset)
+ memcpy((void *)_text, (void *)(_text - offset),
+ __bss_start - _text);
+
+ /* clear bss */
+ memset(__bss_start, 0, __bss_stop - __bss_start);
+
+ /* flush I-cache before jumping to the copied binary */
+ __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
+
+ r = (unsigned int)&barebox_pbl;
+ /* call barebox_uncompress with its absolute address */
+ __asm__ __volatile__(
+ "mov r0, %1\n"
+ "mov pc, %0\n"
+ :
+ : "r"(r), "r"(offset),
+ : "r0");
+}