From 618d669117e9e59a11b389a1c06610e1a3c3aa70 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Mon, 15 Jul 2013 12:20:53 +0200 Subject: [PATCH] pbl: add lz4 support Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- arch/arm/pbl/Makefile | 3 ++- arch/arm/pbl/piggy.lz4.S | 6 ++++++ arch/mips/pbl/Makefile | 3 ++- arch/mips/pbl/piggy.lz4.S | 6 ++++++ images/Makefile | 1 + lib/decompress_unlz4.c | 6 +++++- pbl/Kconfig | 4 ++++ pbl/decomp.c | 4 ++++ 8 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 arch/arm/pbl/piggy.lz4.S create mode 100644 arch/mips/pbl/piggy.lz4.S diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile index 8923a704e..dd3e94680 100644 --- a/arch/arm/pbl/Makefile +++ b/arch/arm/pbl/Makefile @@ -1,6 +1,7 @@ suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo +suffix_$(CONFIG_IMAGE_COMPRESSION_LZ4) = lz4 suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = shipped OBJCOPYFLAGS_zbarebox.bin = -O binary @@ -10,7 +11,7 @@ targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \ $(piggy_o) piggy.$(suffix_y) # Make sure files are removed during clean -extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.shipped zbarebox.map +extra-y += piggy.gzip piggy.lz4 piggy.lzo piggy.lzma piggy.xzkern piggy.shipped zbarebox.map $(obj)/zbarebox.bin: $(obj)/zbarebox FORCE $(call if_changed,objcopy) diff --git a/arch/arm/pbl/piggy.lz4.S b/arch/arm/pbl/piggy.lz4.S new file mode 100644 index 000000000..fa9b2469e --- /dev/null +++ b/arch/arm/pbl/piggy.lz4.S @@ -0,0 +1,6 @@ + .section .piggydata,#alloc + .globl input_data +input_data: + .incbin "arch/arm/pbl/piggy.lz4" + .globl input_data_end +input_data_end: diff --git a/arch/mips/pbl/Makefile b/arch/mips/pbl/Makefile index 6eeee737c..fea1f249b 100644 --- a/arch/mips/pbl/Makefile +++ b/arch/mips/pbl/Makefile @@ -1,6 +1,7 @@ suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo +suffix_$(CONFIG_IMAGE_COMPRESSION_LZ4) = lz4 suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = shipped OBJCOPYFLAGS_zbarebox.bin = -O binary @@ -10,7 +11,7 @@ targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \ $(piggy_o) piggy.$(suffix_y) # Make sure files are removed during clean -extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.shipped zbarebox.map +extra-y += piggy.gzip piggy.lz4 piggy.lzo piggy.lzma piggy.xzkern piggy.shipped zbarebox.map $(obj)/zbarebox.bin: $(obj)/zbarebox FORCE $(call if_changed,objcopy) diff --git a/arch/mips/pbl/piggy.lz4.S b/arch/mips/pbl/piggy.lz4.S new file mode 100644 index 000000000..be9425bf0 --- /dev/null +++ b/arch/mips/pbl/piggy.lz4.S @@ -0,0 +1,6 @@ +#include + + .section .data +EXPORT(input_data) + .incbin "arch/mips/pbl/piggy.lz4" +EXPORT(input_data_end) diff --git a/images/Makefile b/images/Makefile index 925a98793..65c533ac0 100644 --- a/images/Makefile +++ b/images/Makefile @@ -81,6 +81,7 @@ $(obj)/%.s: $(obj)/% FORCE suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo +suffix_$(CONFIG_IMAGE_COMPRESSION_LZ4) = lz4 suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = shipped # barebox.z - compressed barebox binary diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c index 894cc37ab..0dfb08c7d 100644 --- a/lib/decompress_unlz4.c +++ b/lib/decompress_unlz4.c @@ -23,6 +23,10 @@ #include +#ifndef STATIC +#define STATIC +#endif + /* * Note: Uncompressed chunk size is used in the compressor side * (userspace side for compression). @@ -175,7 +179,7 @@ exit_0: return ret; } -int decompress_unlz4(unsigned char *buf, int in_len, +STATIC int decompress_unlz4(unsigned char *buf, int in_len, int(*fill)(void*, unsigned int), int(*flush)(void*, unsigned int), unsigned char *output, diff --git a/pbl/Kconfig b/pbl/Kconfig index a37c97610..dc3135734 100644 --- a/pbl/Kconfig +++ b/pbl/Kconfig @@ -53,6 +53,10 @@ if IMAGE_COMPRESSION choice prompt "Compression" + default IMAGE_COMPRESSION_LZO + +config IMAGE_COMPRESSION_LZ4 + bool "lz4" config IMAGE_COMPRESSION_LZO bool "lzo" diff --git a/pbl/decomp.c b/pbl/decomp.c index aa6a31e9d..ca0df6463 100644 --- a/pbl/decomp.c +++ b/pbl/decomp.c @@ -10,6 +10,10 @@ #define STATIC static +#ifdef CONFIG_IMAGE_COMPRESSION_LZ4 +#include "../../../lib/decompress_unlz4.c" +#endif + #ifdef CONFIG_IMAGE_COMPRESSION_LZO #include "../../../lib/decompress_unlzo.c" #endif