summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-06-23 11:32:31 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-01 10:13:12 +0200
commit2078438662a5343cb32eb799daf9de7693c63def (patch)
tree5668de780b832e4a90c4daad2ba32f8154186682 /arch
parent82915c3a6a54238ba031de41ce569a13ebbed382 (diff)
downloadbarebox-2078438662a5343cb32eb799daf9de7693c63def.tar.gz
barebox-2078438662a5343cb32eb799daf9de7693c63def.tar.xz
Add multi images support
This adds the make infrastructure to build multiple SoC or board specific images from a single barebox binary. The basic idea is that we no longer have a single pbl, but instead multiple pbls, one per image if necessary. Each pbl is defined by its entry function so that each pbl can do exactly what a given board needs. Additionally the pbls together with a self extracting barebox binary can be encapsulated in specific image formats. squashed in build fixes from Lucas Stach for make version >= 3.82: Split Multimage Makefile rule in explicit and implicit parts Fixes build with make version >=3.82 Frome the make 3.82 NEWS file: * WARNING: Backward-incompatibility! In previous versions of make it was acceptable to list one or more explicit targets followed by one or more pattern targets in the same rule and it worked "as expected". However, this was not documented as acceptable and if you listed any explicit targets AFTER the pattern targets, the entire rule would be mis-parsed. This release removes this ability completely: make will generate an error message if you mix explicit and pattern targets in the same rule. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Lucas Stach <dev@lynxeye.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/cpu/Makefile4
-rw-r--r--arch/arm/cpu/start-images.c49
-rw-r--r--arch/arm/cpu/uncompress.c108
-rw-r--r--arch/arm/include/asm/barebox-arm.h4
-rw-r--r--arch/arm/mach-imx/Kconfig1
5 files changed, 165 insertions, 1 deletions
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index 99973ae46e..fba8ff2784 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -21,7 +21,9 @@ obj-$(CONFIG_CPU_32v7) += cache-armv7.o
pbl-$(CONFIG_CPU_32v7) += cache-armv7.o
obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o
-pbl-y += start-pbl.o setupc.o
+pbl-y += setupc.o
+pbl-$(CONFIG_PBL_SINGLE_IMAGE) += start-pbl.o
+pbl-$(CONFIG_PBL_MULTI_IMAGES) += start-images.o uncompress.o
obj-y += common.o
pbl-y += common.o
diff --git a/arch/arm/cpu/start-images.c b/arch/arm/cpu/start-images.c
new file mode 100644
index 0000000000..d48d245294
--- /dev/null
+++ b/arch/arm/cpu/start-images.c
@@ -0,0 +1,49 @@
+/*
+ * 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 <sizes.h>
+#include <pbl.h>
+#include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
+#include <asm-generic/memory_layout.h>
+#include <asm/sections.h>
+#include <asm/pgtable.h>
+#include <debug_ll.h>
+
+void __naked __noreturn barebox_arm_entry(uint32_t membase, uint32_t memsize,
+ uint32_t boarddata)
+{
+ unsigned long barebox_base;
+ void __noreturn (*barebox)(uint32_t, uint32_t, uint32_t);
+
+ barebox_base = ld_var(__image_end) - get_runtime_offset() + 4;
+
+ if (IS_ENABLED(CONFIG_THUMB2_BAREBOX))
+ barebox = (void *)(barebox_base + 1);
+ else
+ barebox = (void *)barebox_base;
+
+ barebox(membase, memsize, boarddata);
+}
diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
new file mode 100644
index 0000000000..b401f8efe2
--- /dev/null
+++ b/arch/arm/cpu/uncompress.c
@@ -0,0 +1,108 @@
+/*
+ * uncompress.c - uncompressor code for self extracing pbl image
+ *
+ * Copyright (c) 2010-2013 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 <sizes.h>
+#include <pbl.h>
+#include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
+#include <asm-generic/memory_layout.h>
+#include <asm/sections.h>
+#include <asm/pgtable.h>
+#include <asm/cache.h>
+
+#include <debug_ll.h>
+
+#include "mmu-early.h"
+
+unsigned long free_mem_ptr;
+unsigned long free_mem_end_ptr;
+
+static int __attribute__((__used__))
+ __attribute__((__section__(".image_end")))
+ __image_end_dummy = 0xdeadbeef;
+
+static void noinline uncompress(uint32_t membase,
+ uint32_t memsize, uint32_t boarddata)
+{
+ uint32_t offset;
+ uint32_t pg_len;
+ void __noreturn (*barebox)(uint32_t, uint32_t, uint32_t);
+ uint32_t endmem = membase + memsize;
+ unsigned long barebox_base;
+ uint32_t *ptr;
+ void *pg_start;
+
+ endmem -= STACK_SIZE; /* stack */
+
+ if (IS_ENABLED(CONFIG_PBL_RELOCATABLE))
+ relocate_to_current_adr();
+
+ /* Get offset between linked address and runtime address */
+ offset = get_runtime_offset();
+
+ if (IS_ENABLED(CONFIG_RELOCATABLE))
+ barebox_base = arm_barebox_image_place(membase + memsize);
+ else
+ barebox_base = TEXT_BASE;
+
+ setup_c();
+
+ if (IS_ENABLED(CONFIG_MMU_EARLY)) {
+ endmem &= ~0x3fff;
+ endmem -= SZ_16K; /* ttb */
+ mmu_early_enable(membase, memsize, endmem);
+ }
+
+ endmem -= SZ_128K; /* early malloc */
+ free_mem_ptr = endmem;
+ free_mem_end_ptr = free_mem_ptr + SZ_128K;
+
+ ptr = (void *)__image_end;
+ pg_start = ptr + 1;
+ pg_len = *(ptr);
+
+ pbl_barebox_uncompress((void*)barebox_base, pg_start, pg_len);
+
+ arm_early_mmu_cache_flush();
+ flush_icache();
+
+ if (IS_ENABLED(CONFIG_THUMB2_BAREBOX))
+ barebox = (void *)(barebox_base + 1);
+ else
+ barebox = (void *)barebox_base;
+
+ barebox(membase, memsize, boarddata);
+}
+
+/*
+ * Generic second stage pbl uncompressor entry
+ */
+ENTRY_FUNCTION(start_uncompress)(uint32_t membase, uint32_t memsize,
+ uint32_t boarddata)
+{
+ arm_setup_stack(membase + memsize - 16);
+
+ uncompress(membase, memsize, boarddata);
+}
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index ddcafd1af7..622bd13622 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -79,4 +79,8 @@ static inline unsigned long arm_barebox_image_place(unsigned long endmem)
return endmem;
}
+#define ENTRY_FUNCTION(name) \
+ void __naked __section(.text_head_entry_##name) \
+ name
+
#endif /* _BAREBOX_ARM_H_ */
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index b13fa99ba9..174f0df93c 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -67,6 +67,7 @@ config BOARDINFO
choice
prompt "Select boot mode"
depends on !ARCH_IMX_INTERNAL_BOOT_USE_IMXIMAGE
+ depends on !HAVE_PBL_MULTI_IMAGES
help
i.MX processors support two different boot modes. With the internal
boot mode the boot medium contains a header describing the image to