diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-10-23 09:14:54 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-10-27 10:02:28 +0100 |
commit | 58eae8361c10fea661bcb48c4c5e75e7ad19e1c1 (patch) | |
tree | f25d31a025cfea28348d4279090877e3da72862a /arch/arm/cpu | |
parent | fcc6020164362f0c4877e6f50fb0d323d50ee540 (diff) | |
download | barebox-58eae8361c10fea661bcb48c4c5e75e7ad19e1c1.tar.gz barebox-58eae8361c10fea661bcb48c4c5e75e7ad19e1c1.tar.xz |
ARM: Allow compressed dtb binaries
In the current multi image build process the DTBs end up uncompressed
in the PBL. This can be annoying because the PBL is often very size
constrained.
This patch allows to put the DTBs in as lzo compressed binary into
the PBL. Since lzo offers quite good compression ratios for DTBs no
other compression algorithm has been implemented for now.
Boards which want to use the compressed DTBs only have to change
the __dtb_ prefix in the DTB name to __dtb_z_. Also they should select
ARM_USE_COMPRESSED_DTB to make sure barebox supports uncompressing
the DTB.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r-- | arch/arm/cpu/start.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 8e5097b560..bedc601d08 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -27,6 +27,8 @@ #include <asm/unaligned.h> #include <asm/cache.h> #include <memory.h> +#include <uncompress.h> +#include <malloc.h> #include <debug_ll.h> #include "mmu-early.h" @@ -46,10 +48,46 @@ u32 barebox_arm_machine(void) return bd->machine; } +struct barebox_arm_boarddata *barebox_arm_get_boarddata(void) +{ + return barebox_boarddata; +} + static void *barebox_boot_dtb; +struct barebox_arm_boarddata_compressed_dtb *compressed_dtb; void *barebox_arm_boot_dtb(void) { + void *dtb; + void *data; + int ret; + + if (barebox_boot_dtb) { + pr_debug("%s: using barebox_boot_dtb\n", __func__); + return barebox_boot_dtb; + } + + if (!IS_ENABLED(CONFIG_ARM_USE_COMPRESSED_DTB) || !compressed_dtb) + return NULL; + + pr_debug("%s: using compressed_dtb\n", __func__); + + dtb = malloc(compressed_dtb->datalen_uncompressed); + if (!dtb) + return NULL; + + data = compressed_dtb + 1; + + ret = uncompress(data, compressed_dtb->datalen, NULL, NULL, + dtb, NULL, NULL); + if (ret) { + pr_err("uncompressing dtb failed\n"); + free(dtb); + return NULL; + } + + barebox_boot_dtb = dtb; + return barebox_boot_dtb; } @@ -104,6 +142,14 @@ static noinline __noreturn void __start(unsigned long membase, barebox_boarddata); memcpy(barebox_boarddata, boarddata, sizeof(struct barebox_arm_boarddata)); + } else if (((struct barebox_arm_boarddata_compressed_dtb *)boarddata)->magic == + BAREBOX_ARM_BOARDDATA_COMPRESSED_DTB_MAGIC) { + struct barebox_arm_boarddata_compressed_dtb *bd = boarddata; + endmem -= ALIGN(sizeof(*bd) + bd->datalen, 64); + compressed_dtb = (void *)endmem; + pr_debug("found compressed DTB in boarddata, copying to 0x%p\n", + compressed_dtb); + memcpy(compressed_dtb, boarddata, sizeof(*bd) + bd->datalen); } } |