pbl: add lz4 compression support
Subsystems (4)
v2 cover pbl: add lz4 compression support
Hi,
v2:
keep lzo as default
The following patch serie add the lz4 support to the pbl
Jean-Christophe PLAGNIOL-VILLARD (1):
pbl: add lz4 support
Kyungsik Lee (2):
decompressor: Add LZ4 decompressor module
lib: Add support for LZ4-compressed kernel
arch/arm/pbl/Makefile | 3 +- arch/arm/pbl/piggy.lz4.S | 6 ++++ arch/mips/pbl/Makefile | 3 +- arch/mips/pbl/piggy.lz4.S | 6 ++++ common/filetype.c | 4 +++ images/Makefile | 1 + include/filetype.h | 1 + include/linux/decompress/unlz4.h | 10 ++++++ include/linux/lz4.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/Kconfig | 4 +++ lib/Makefile | 2 ++ lib/decompress_unlz4.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/lz4/Makefile | 1 + lib/lz4/lz4_decompress.c | 327 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/lz4/lz4defs.h | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/uncompress.c | 6 ++++ pbl/Kconfig | 4 ++ pbl/decomp.c | 4 +++ scripts/Makefile.lib | 5 +++ 19 files changed, 815 insertions(+), 2 deletions(-) create mode 100644 arch/arm/pbl/piggy.lz4.S create mode 100644 arch/mips/pbl/piggy.lz4.S create mode 100644 include/linux/decompress/unlz4.h create mode 100644 include/linux/lz4.h create mode 100644 lib/decompress_unlz4.c create mode 100644 lib/lz4/Makefile create mode 100644 lib/lz4/lz4_decompress.c create mode 100644 lib/lz4/lz4defs.h
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/3 decompressor: Add LZ4 decompressor module
From: Kyungsik Lee <[email protected]>
This patch adds support for LZ4 decompression in the Linux Kernel. LZ4 Decompression APIs for kernel are based on LZ4 implementation by Yann Collet.
LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
LZ4 source repository : http://code.google.com/p/lz4/
--- include/linux/lz4.h | 87 +++++++++++++ lib/lz4/lz4_decompress.c | 326 +++++++++++++++++++++++++++++++++++++++++++++++ lib/lz4/lz4defs.h | 156 +++++++++++++++++++++++ 3 files changed, 569 insertions(+) create mode 100644 include/linux/lz4.h create mode 100644 lib/lz4/lz4_decompress.c create mode 100644 lib/lz4/lz4defs.h
include/linux/lz4.h new file +87 -0
@@ -0,0 +1,87 @@ +#ifndef __LZ4_H__ +#define __LZ4_H__ +/* +* LZ4 Kernel Interface +* +* Copyright (C) 2013, LG Electronics, Kyungsik Lee <[email protected]> +* +* 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. +*/ +#define LZ4_MEM_COMPRESS (4096 * sizeof(unsigned char *)) +#define LZ4HC_MEM_COMPRESS (65538 * sizeof(unsigned char *)) + +/* +* lz4_compressbound() +* Provides the maximum size that LZ4 may output in a "worst case" scenario +* (input data not compressible) +*/ +static inline size_t lz4_compressbound (size_t isize) +{ +return isize + (isize /255 ) +16 ; +} + +/* +* lz4_compress() +* src : source address of the original data +* src_len : size of the original data +* dst : output buffer address of the compressed data +* This requires 'dst' of size LZ4_COMPRESSBOUND. +* dst_len : is the output size, which is returned after compress done +* workmem : address of the working memory. +* This requires 'workmem' of size LZ4_MEM_COMPRESS. +* return : Success if return 0 +* Error if return (< 0) +* note : Destination buffer and workmem must be already allocated with +* the defined size. +*/ +int lz4_compress (const unsigned char *src,size_t src_len, +unsigned char *dst,size_t *dst_len,void *wrkmem); + +/* +* lz4hc_compress() +* src : source address of the original data +* src_len : size of the original data +* dst : output buffer address of the compressed data +* This requires 'dst' of size LZ4_COMPRESSBOUND. +* dst_len : is the output size, which is returned after compress done +* workmem : address of the working memory. +* This requires 'workmem' of size LZ4HC_MEM_COMPRESS. +* return : Success if return 0 +* Error if return (< 0) +* note : Destination buffer and workmem must be already allocated with +* the defined size. +*/ +int lz4hc_compress (const unsigned char *src,size_t src_len, +unsigned char *dst,size_t *dst_len,void *wrkmem); + +/* +* lz4_decompress() +* src : source address of the compressed data +* src_len : is the input size, whcih is returned after decompress done +* dest : output buffer address of the decompressed data +* actual_dest_len: is the size of uncompressed data, supposing it's known +* return : Success if return 0 +* Error if return (< 0) +* note : Destination buffer must be already allocated. +* slightly faster than lz4_decompress_unknownoutputsize() +*/ +int lz4_decompress (const char *src,size_t *src_len,char *dest, +size_t actual_dest_len); + +/* +* lz4_decompress_unknownoutputsize() +* src : source address of the compressed data +* src_len : is the input size, therefore the compressed size +* dest : output buffer address of the decompressed data +* dest_len: is the max size of the destination buffer, which is +* returned with actual size of decompressed data after +* decompress done +* return : Success if return 0 +* Error if return (< 0) +* note : Destination buffer must be already allocated. +*/ +int lz4_decompress_unknownoutputsize (const char *src,size_t src_len, +char *dest,size_t *dest_len); +#endif
lib/lz4/lz4_decompress.c new file +326 -0
326 lines not on this page · raw message
lib/lz4/lz4defs.h new file +156 -0
156 lines not on this page · raw message
Signature · 7 lines
1.8.3.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/3 lib: Add support for LZ4-compressed kernel
From: Kyungsik Lee <[email protected]>
This patch adds support for extracting LZ4-compressed kernel images, as well as LZ4-compressed ramdisk images in the kernel boot process.
This depends on the patch below
decompressor: Add LZ4 decompressor module
--- common/filetype.c | 4 + include/filetype.h | 1 + include/linux/decompress/unlz4.h | 10 +++ lib/Kconfig | 4 + lib/Makefile | 2 + lib/decompress_unlz4.c | 188 +++++++++++++++++++++++++++++++++++++++ lib/lz4/Makefile | 1 + lib/lz4/lz4_decompress.c | 3 +- lib/uncompress.c | 6 ++ scripts/Makefile.lib | 5 ++ 10 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 include/linux/decompress/unlz4.h create mode 100644 lib/decompress_unlz4.c create mode 100644 lib/lz4/Makefile
common/filetype.c +4 -0
@@ -33,6 +33,7 @@ static const struct filetype_str filetype_str[] = { [filetype_unknown] = { "unknown", "unkown" }, [filetype_arm_zimage] = { "arm Linux zImage", "arm-zimage" }, [filetype_lzo_compressed] = { "lzo compressed", "lzo" }, + [filetype_lz4_compressed] = { "lz4 compressed", "lz4" }, [filetype_arm_barebox] = { "arm barebox image", "arm-barebox" }, [filetype_uimage] = { "U-Boot uImage", "u-boot" }, [filetype_ubi] = { "UBI image", "ubi" },
@@ -195,6 +196,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)if (buf8[0 ] ==0x89 && buf8[1 ] ==0x4c && buf8[2 ] ==0x5a && buf8[3 ] ==0x4f )return filetype_lzo_compressed; +if (buf8[0 ] ==0x02 && buf8[1 ] ==0x21 && buf8[2 ] ==0x4c && + buf8[3 ] ==0x18 ) +return filetype_lz4_compressed;if (buf[0 ] ==be32_to_cpu (0x27051956 ))return filetype_uimage;if (buf[0 ] ==0x23494255 )
include/filetype.h +1 -0
@@ -10,6 +10,7 @@ enum filetype { filetype_unknown, filetype_arm_zimage, filetype_lzo_compressed, + filetype_lz4_compressed, filetype_arm_barebox, filetype_uimage, filetype_ubi,
include/linux/decompress/unlz4.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef DECOMPRESS_UNLZ4_H +#define DECOMPRESS_UNLZ4_H + +int decompress_unlz4 (unsigned char *inbuf,int len, +int (*fill)(void *,unsigned int ), +int (*flush)(void *,unsigned int ), +unsigned char *output, +int *pos, +void (*error)(char *x)); +#endif
lib/Kconfig +4 -0
@@ -14,6 +14,10 @@ config BZLIB bool "include bzip2 uncompression support" select UNCOMPRESS +config LZ4_DECOMPRESS + bool "include lz4 uncompression support" + select UNCOMPRESS + config GENERIC_FIND_NEXT_BIT def_bool n
lib/Makefile +2 -0
@@ -28,8 +28,10 @@ obj-y += notifier.o obj-y += copy_file.o obj-y += random.o obj-y += lzo/ +obj-$(CONFIG_LZ4_DECOMPRESS) += lz4/ obj-y += show_progress.o obj-$(CONFIG_LZO_DECOMPRESS) += decompress_unlzo.o +obj-$(CONFIG_LZ4_DECOMPRESS) += decompress_unlz4.o obj-$(CONFIG_PROCESS_ESCAPE_SEQUENCE) += process_escape_sequence.o obj-$(CONFIG_UNCOMPRESS) += uncompress.o obj-$(CONFIG_BCH) += bch.o
lib/decompress_unlz4.c new file +188 -0
188 lines not on this page · raw message
lib/lz4/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_LZ4_DECOMPRESS) += lz4_decompress.o
lib/lz4/lz4_decompress.c +2 -1
@@ -38,10 +38,11 @@*/ #ifndef STATIC -#include <linux/module.h> +#include <module.h> #include <linux/kernel.h> #endif #include <linux/lz4.h> +#include <linux/string.h> #include <asm/unaligned.h>
lib/uncompress.c +6 -0
@@ -21,6 +21,7 @@#include <bunzip2.h> #include <gunzip.h> #include <lzo.h> +#include <linux/decompress/unlz4.h> #include <errno.h> #include <filetype.h> #include <malloc.h>
@@ -112,6 +113,11 @@ int uncompress(unsigned char *inbuf, int len, compfn = decompress_unlzo;break ;#endif +#ifdef CONFIG_LZ4_DECOMPRESS +case filetype_lz4_compressed: + compfn = decompress_unlz4; +break ; +#endif default : err =asprintf ("cannot handle filetype %s" ,file_type_to_string (ft));error_fn (err);
scripts/Makefile.lib +5 -0
@@ -289,6 +289,11 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ (rm -f $@ ; false) +quiet_cmd_lz4 = LZ4 $@ +cmd_lz4 = (cat $(filter-out FORCE,$^) | \ + lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ + (rm -f $@ ; false) + quiet_cmd_disasm = DISASM $@ cmd_disasm = $(OBJDUMP) -d $< > $@
Signature · 7 lines
1.8.3.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/3 pbl: add lz4 support
In reply to Jean-Christophe PLAGNIOL-VILLARD--- 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 + pbl/Kconfig | 4 ++++ pbl/decomp.c | 4 ++++ 7 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 arch/arm/pbl/piggy.lz4.S create mode 100644 arch/mips/pbl/piggy.lz4.S
arch/arm/pbl/Makefile +2 -1
@@ -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)
arch/arm/pbl/piggy.lz4.S new file +6 -0
@@ -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:
arch/mips/pbl/Makefile +2 -1
@@ -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)
arch/mips/pbl/piggy.lz4.S new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm/asm.h> + + .section .data +EXPORT(input_data) + .incbin "arch/mips/pbl/piggy.lz4" +EXPORT(input_data_end)
images/Makefile +1 -0
@@ -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
pbl/Kconfig +4 -0
@@ -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"
pbl/decomp.c +4 -0
@@ -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
Signature · 7 lines
1.8.3.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
v2:
keep lzo as default
Quoted 8 lines
The following patch serie add the lz4 support to the pbl
Jean-Christophe PLAGNIOL-VILLARD (1):
pbl: add lz4 supportKyungsik Lee (2):
decompressor: Add LZ4 decompressor module
lib: Add support for LZ4-compressed kernel
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 11 lines · On Tue, 16 Jul 2013 08:25:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
v2:
keep lzo as defaultThe following patch serie add the lz4 support to the pbl
Jean-Christophe PLAGNIOL-VILLARD (1):
pbl: add lz4 support
Quoted 7 lines
Quoted 3 lines
Kyungsik Lee (2):
decompressor: Add LZ4 decompressor module
lib: Add support for LZ4-compressed kernelApplied, thanks
Sascha
LZ4 decompressor work fine on MIPS but I have got a warning:
...
rm arch/mips/dts/qemu-malta.dtb.S arch/mips/dts/qemu-malta.dtb
LD pbl/built-in.o
PBLCC pbl/pbl-decomp.o
In file included from pbl/decomp.c:14:
/home/antony/barebox.git.rebased.isp/arch/mips/include/../../../lib/dec ompress_unlz4.c:185: warning: no previous prototype for 'decompress_unl z4'
PBLCC pbl/pbl-misc.o PBLCC pbl/pbl-string.o PBLLD pbl/built-in-pbl.o
...
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 22 lines · On Tue, Jul 16, 2013 at 07:39:36PM +0400, [email protected] wrote:
Quoted 11 lines · On Tue, 16 Jul 2013 08:25:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
v2:
keep lzo as defaultThe following patch serie add the lz4 support to the pbl
Jean-Christophe PLAGNIOL-VILLARD (1):
pbl: add lz4 supportQuoted 7 lines
Quoted 3 lines
Kyungsik Lee (2):
decompressor: Add LZ4 decompressor module
lib: Add support for LZ4-compressed kernelApplied, thanks
Sascha
Quoted 8 lines
LZ4 decompressor work fine on MIPS but I have got a warning:
...
rmarch/mips/dts/qemu-malta.dtb.Sarch/mips/dts/qemu-malta.dtb
LDpbl/built-in.o
PBLCCpbl/pbl-decomp.o
In file included frompbl/decomp.c:14:
/home/antony/barebox.git.rebased.isp/arch/mips/include/../../../lib/decompress_unlz4.c:185: warning: no previous prototype for 'decompress_unlz4'
I fixed this. It should work without warning now.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 35 lines · Sascha Hauer
Quoted 25 lines · On Tue, Jul 16, 2013 at 07:39:36PM +0400, [email protected] wrote:
Quoted 12 lines · On Tue, 16 Jul 2013 08:25:32 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
v2:
keep lzo as defaultThe following patch serie add the lz4 support to the pbl
Jean-Christophe PLAGNIOL-VILLARD (1):
pbl: add lz4 supportQuoted 7 lines
Quoted 3 lines
Kyungsik Lee (2):
decompressor: Add LZ4 decompressor module
lib: Add support for LZ4-compressed kernelApplied, thanks
Sascha
LZ4 decompressor work fine on MIPS but I have got a warning:
Quoted 8 lines
...
rmarch/mips/dts/qemu-malta.dtb.Sarch/mips/dts/qemu-malta.dtb
LDpbl/built-in.o
PBLCCpbl/pbl-decomp.o
In file included frompbl/decomp.c:14:
/home/antony/barebox.git.rebased.isp/arch/mips/include/../../../lib/dec
ompress_unlz4.c:185: warning: no previous prototype for 'decompress_unlz4'
Quoted 2 lines
I fixed this. It should work without warning now.
I have just checked the 'next' branch. The warning has gone away! Thanks, Sascha!
Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox