From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 05/12] Add compressed image support
Date: Fri, 27 Jul 2012 20:33:03 +0200 [thread overview]
Message-ID: <1343413990-31891-5-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1343413990-31891-1-git-send-email-plagnioj@jcrosoft.com>
From: Sascha Hauer <s.hauer@pengutronix.de>
This allows for creating a lzo compressed binary unsing the pbl.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>]
re-integrate it in the new pbl target.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/Kconfig | 1 +
arch/arm/Makefile | 4 ++++
arch/arm/cpu/start.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
arch/arm/pbl/Makefile | 16 +++++++++++--
arch/arm/pbl/piggy.lzo.S | 6 +++++
5 files changed, 84 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/pbl/piggy.lzo.S
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3d11497..245bec8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -5,6 +5,7 @@ config ARM
select HAVE_CONFIGURABLE_MEMORY_LAYOUT
select HAVE_CONFIGURABLE_TEXT_BASE
select HAVE_PBL_IMAGE
+ select HAVE_IMAGE_COMPRESSION
default y
config ARM_AMBA
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 80ef986..8e4bb48 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -194,6 +194,10 @@ ifeq ($(CONFIG_ARCH_DAVINCI),y)
KBUILD_IMAGE := barebox.ubl
endif
+ifdef CONFIG_IMAGE_COMPRESSION
+KBUILD_IMAGE := zbarebox.bin
+endif
+
pbl := arch/arm/pbl
zbarebox.S zbarebox.bin zbarebox: barebox.bin
$(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 49b1d5b..a54f5fd 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -98,8 +98,67 @@ void __naked __bare_init reset(void)
}
#ifdef __PBL__
+extern void *input_data;
+extern void *input_data_end;
+
+#define STATIC static
+
+#ifdef CONFIG_IMAGE_COMPRESSION_LZO
+#include "../../../lib/decompress_unlzo.c"
+#endif
+
+void barebox_uncompress(void *compressed_start, unsigned int len)
+{
+ void (*barebox)(void);
+
+ if (IS_ENABLED(CONFIG_THUMB2_BAREBOX))
+ barebox = (void *)(TEXT_BASE + 1);
+ else
+ barebox = (void *)TEXT_BASE;
+
+ decompress((void *)compressed_start,
+ len,
+ NULL, NULL,
+ (void *)TEXT_BASE, NULL, NULL);
+
+ /* flush I-cache before jumping to the uncompressed binary */
+ __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
+
+ barebox();
+}
+
void barebox_pbl(uint32_t offset)
{
+ uint32_t compressed_start, compressed_end, len;
+ void (*uncompress)(void *compressed_start, unsigned int len);
+
+ compressed_start = (uint32_t)&input_data - offset;
+ compressed_end = (uint32_t)&input_data_end - offset;
+ len = compressed_end - compressed_start;
+
+ /*
+ * Check if the compressed binary will be overwritten
+ * by the uncompressed binary
+ */
+ if (compressed_start >= TEXT_BASE &&
+ compressed_start < TEXT_BASE + len * 4 ) {
+ /*
+ * copy compressed binary to its link address
+ */
+ memcpy(&input_data, (void *)compressed_start, len);
+ compressed_start = (uint32_t)&input_data;
+ }
+
+ uncompress = barebox_uncompress;
+
+ /* call barebox_uncompress with its absolute address */
+ __asm__ __volatile__(
+ "mov r0, %1\n"
+ "mov r1, %2\n"
+ "mov pc, %0\n"
+ :
+ : "r"(uncompress), "r"(compressed_start), "r"(len)
+ : "r0", "r1");
}
#else
void barebox_pbl(uint32_t offset) {}
diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile
index 9b364bb..4135911 100644
--- a/arch/arm/pbl/Makefile
+++ b/arch/arm/pbl/Makefile
@@ -1,7 +1,14 @@
+suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo
+
OBJCOPYFLAGS_zbarebox.bin = -O binary
+piggy_o := piggy.$(suffix_y).o
+
+targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \
+ $(piggy_o) piggy.$(suffix_y)
-targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S
+# Make sure files are removed during clean
+extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern
$(obj)/zbarebox.bin: $(obj)/zbarebox FORCE
$(call if_changed,objcopy)
@@ -12,7 +19,7 @@ $(obj)/zbarebox.S: $(obj)/zbarebox FORCE
$(call if_changed,disasm)
LDFLAGS_zbarebox := -Map zbarebox.map
-zbarebox-common := $(barebox-pbl-common)
+zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o)
zbarebox-lds := $(obj)/zbarebox.lds
quiet_cmd_zbarebox__ ?= LD $@
@@ -23,3 +30,8 @@ quiet_cmd_zbarebox__ ?= LD $@
$(obj)/zbarebox: $(zbarebox-lds) $(zbarebox-common) FORCE
$(call if_changed,zbarebox__)
+
+$(obj)/piggy.$(suffix_y): $(obj)/../../../barebox.bin FORCE
+ $(call if_changed,$(suffix_y))
+
+$(obj)/$(piggy_o): $(obj)/piggy.$(suffix_y) FORCE
diff --git a/arch/arm/pbl/piggy.lzo.S b/arch/arm/pbl/piggy.lzo.S
new file mode 100644
index 0000000..0c0d216
--- /dev/null
+++ b/arch/arm/pbl/piggy.lzo.S
@@ -0,0 +1,6 @@
+ .section .piggydata,#alloc
+ .globl input_data
+input_data:
+ .incbin "arch/arm/compressed/piggy.lzo"
+ .globl input_data_end
+input_data_end:
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-07-27 18:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-27 18:31 [PATCH 00/12] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:32 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` [PATCH 02/12] kbuild: add pre-bootloader (pbl) target Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` [PATCH 03/12] Add pre-bootloader (pbl) image support Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` [PATCH 04/12] pbl: discard unwind symbol if enable in barebox Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-07-27 18:33 ` [PATCH 06/12] only compress default env in uncompressed images Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` [PATCH 07/12] ARM: Separate assembler functions into their own section Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 7:50 ` Sascha Hauer
2012-07-30 8:27 ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` [PATCH 08/12] decompress_unlzo: define decompress_unlzo as decompress Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 7:56 ` Sascha Hauer
2012-07-30 8:06 ` Sascha Hauer
2012-07-27 18:33 ` [PATCH 09/12] decompressor: import malloc/free implementation for linux 3.4 Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` [PATCH 10/12] ARM: add early malloc support needed by the decompressor Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 8:02 ` Sascha Hauer
2012-07-30 8:19 ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 8:30 ` Sascha Hauer
2012-07-30 8:49 ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 8:59 ` Sascha Hauer
2012-07-30 9:04 ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 9:20 ` Sascha Hauer
2012-07-30 9:30 ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` [PATCH 11/12] compressed image: add gzip support Jean-Christophe PLAGNIOL-VILLARD
2012-07-27 18:33 ` [PATCH 12/12] at91: add lowlevel init to the pbl Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 10:00 [PATCH 00/12 v3] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 10:02 ` [PATCH 01/12] kbuild: Init all relevant variables used in kbuild files so Jean-Christophe PLAGNIOL-VILLARD
2012-07-30 10:02 ` [PATCH 05/12] Add compressed image support Jean-Christophe PLAGNIOL-VILLARD
2012-08-02 15:30 ` Sascha Hauer
2012-08-02 15:34 ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-03 6:34 ` Sascha Hauer
2012-08-03 10:23 [PATCH 00/12 v4] Add Pre-Bootloader support Jean-Christophe PLAGNIOL-VILLARD
2012-08-03 10:25 ` [PATCH 01/12] Makefile.clean: include Makefiles again Jean-Christophe PLAGNIOL-VILLARD
2012-08-03 10:25 ` [PATCH 05/12] Add compressed image support Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343413990-31891-5-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox