aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2011-01-12 20:01:22 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 11:03:24 -0500
commit24fa0402a9b6a537e87e38341e78b7da86486846 (patch)
tree06adb32802cf8a3491dff1f4e5cad464c676040a /scripts
parentfb7fa589fd3ecc212fabd7867a4ecc3b175260c1 (diff)
decompressors: add XZ decompressor module
In userspace, the .lzma format has become mostly a legacy file format that got superseded by the .xz format. Similarly, LZMA Utils was superseded by XZ Utils. These patches add support for XZ decompression into the kernel. Most of the code is as is from XZ Embedded <http://tukaani.org/xz/embedded.html>. It was written for the Linux kernel but is usable in other projects too. Advantages of XZ over the current LZMA code in the kernel: - Nice API that can be used by other kernel modules; it's not limited to kernel, initramfs, and initrd decompression. - Integrity check support (CRC32) - BCJ filters improve compression of executable code on certain architectures. These together with LZMA2 can produce a few percent smaller kernel or Squashfs images than plain LZMA without making the decompression slower. This patch: Add the main decompression code (xz_dec), testing module (xz_dec_test), wrapper script (xz_wrap.sh) for the xz command line tool, and documentation. The xz_dec module is enough to have a usable XZ decompressor e.g. for Squashfs. Signed-off-by: Lasse Collin <lasse.collin@tukaani.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Alain Knaff <alain@knaff.lu> Cc: Albin Tonnerre <albin.tonnerre@free-electrons.com> Cc: Phillip Lougher <phillip@lougher.demon.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.lib28
-rw-r--r--scripts/xz_wrap.sh23
2 files changed, 51 insertions, 0 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 396da16aabf8..1c702ca8aac8 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -262,6 +262,34 @@ cmd_lzo = (cat $(filter-out FORCE,$^) | \
262 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 262 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
263 (rm -f $@ ; false) 263 (rm -f $@ ; false)
264 264
265# XZ
266# ---------------------------------------------------------------------------
267# Use xzkern to compress the kernel image and xzmisc to compress other things.
268#
269# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
270# of the kernel decompressor. A BCJ filter is used if it is available for
271# the target architecture. xzkern also appends uncompressed size of the data
272# using size_append. The .xz format has the size information available at
273# the end of the file too, but it's in more complex format and it's good to
274# avoid changing the part of the boot code that reads the uncompressed size.
275# Note that the bytes added by size_append will make the xz tool think that
276# the file is corrupt. This is expected.
277#
278# xzmisc doesn't use size_append, so it can be used to create normal .xz
279# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
280# big dictionary would increase the memory usage too much in the multi-call
281# decompression mode. A BCJ filter isn't used either.
282quiet_cmd_xzkern = XZKERN $@
283cmd_xzkern = (cat $(filter-out FORCE,$^) | \
284 sh $(srctree)/scripts/xz_wrap.sh && \
285 $(call size_append, $(filter-out FORCE,$^))) > $@ || \
286 (rm -f $@ ; false)
287
288quiet_cmd_xzmisc = XZMISC $@
289cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
290 xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
291 (rm -f $@ ; false)
292
265# misc stuff 293# misc stuff
266# --------------------------------------------------------------------------- 294# ---------------------------------------------------------------------------
267quote:=" 295quote:="
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
new file mode 100644
index 000000000000..17a5798c29da
--- /dev/null
+++ b/scripts/xz_wrap.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2#
3# This is a wrapper for xz to compress the kernel image using appropriate
4# compression options depending on the architecture.
5#
6# Author: Lasse Collin <lasse.collin@tukaani.org>
7#
8# This file has been put into the public domain.
9# You can do whatever you want with this file.
10#
11
12BCJ=
13LZMA2OPTS=
14
15case $ARCH in
16 x86|x86_64) BCJ=--x86 ;;
17 powerpc) BCJ=--powerpc ;;
18 ia64) BCJ=--ia64; LZMA2OPTS=pb=4 ;;
19 arm) BCJ=--arm ;;
20 sparc) BCJ=--sparc ;;
21esac
22
23exec xz --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB