| 1 | From 2d303b4683145f7dbc918bd14d04e1396581b2ce Mon Sep 17 00:00:00 2001 |
| 2 | From: Imre Kaloz <kaloz@openwrt.org> |
| 3 | Date: Thu, 7 Jul 2011 12:05:21 +0200 |
| 4 | Subject: [PATCH] ARM: support XZ compressed kernels |
| 5 | |
| 6 | Wire up support for the XZ decompressor |
| 7 | |
| 8 | Signed-off-by: Imre Kaloz <kaloz@openwrt.org> |
| 9 | --- |
| 10 | arch/arm/Kconfig | 1 + |
| 11 | arch/arm/boot/compressed/Makefile | 11 +++++++++-- |
| 12 | arch/arm/boot/compressed/decompress.c | 4 ++++ |
| 13 | arch/arm/boot/compressed/piggy.xzkern.S | 6 ++++++ |
| 14 | lib/xz/xz_dec_stream.c | 1 + |
| 15 | 5 files changed, 21 insertions(+), 2 deletions(-) |
| 16 | create mode 100644 arch/arm/boot/compressed/piggy.xzkern.S |
| 17 | |
| 18 | --- a/arch/arm/Kconfig |
| 19 | +++ b/arch/arm/Kconfig |
| 20 | @@ -20,6 +20,7 @@ config ARM |
| 21 | select HAVE_KERNEL_GZIP |
| 22 | select HAVE_KERNEL_LZO |
| 23 | select HAVE_KERNEL_LZMA |
| 24 | + select HAVE_KERNEL_XZ |
| 25 | select HAVE_IRQ_WORK |
| 26 | select HAVE_PERF_EVENTS |
| 27 | select PERF_USE_VMALLOC |
| 28 | --- a/arch/arm/boot/compressed/Makefile |
| 29 | +++ b/arch/arm/boot/compressed/Makefile |
| 30 | @@ -92,6 +92,7 @@ SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/ |
| 31 | suffix_$(CONFIG_KERNEL_GZIP) = gzip |
| 32 | suffix_$(CONFIG_KERNEL_LZO) = lzo |
| 33 | suffix_$(CONFIG_KERNEL_LZMA) = lzma |
| 34 | +suffix_$(CONFIG_KERNEL_XZ) = xzkern |
| 35 | |
| 36 | # Borrowed libfdt files for the ATAG compatibility mode |
| 37 | |
| 38 | @@ -115,7 +116,7 @@ targets := vmlinux vmlinux.lds \ |
| 39 | lib1funcs.o lib1funcs.S font.o font.c head.o misc.o $(OBJS) |
| 40 | |
| 41 | # Make sure files are removed during clean |
| 42 | -extra-y += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S $(libfdt) $(libfdt_hdrs) |
| 43 | +extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern lib1funcs.S ashldi3.S $(libfdt) $(libfdt_hdrs) |
| 44 | |
| 45 | ifeq ($(CONFIG_FUNCTION_TRACER),y) |
| 46 | ORIG_CFLAGS := $(KBUILD_CFLAGS) |
| 47 | @@ -170,8 +171,14 @@ if [ $(words $(ZRELADDR)) -gt 1 -a "$(CO |
| 48 | false; \ |
| 49 | fi |
| 50 | |
| 51 | +# For __aeabi_llsl |
| 52 | +ashldi3 = $(obj)/ashldi3.o |
| 53 | + |
| 54 | +$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S FORCE |
| 55 | + $(call cmd,shipped) |
| 56 | + |
| 57 | $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \ |
| 58 | - $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) FORCE |
| 59 | + $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) FORCE |
| 60 | @$(check_for_multiple_zreladdr) |
| 61 | $(call if_changed,ld) |
| 62 | @$(check_for_bad_syms) |
| 63 | --- a/arch/arm/boot/compressed/decompress.c |
| 64 | +++ b/arch/arm/boot/compressed/decompress.c |
| 65 | @@ -44,6 +44,12 @@ extern void error(char *); |
| 66 | #include "../../../../lib/decompress_unlzma.c" |
| 67 | #endif |
| 68 | |
| 69 | +#ifdef CONFIG_KERNEL_XZ |
| 70 | +#define memmove memmove |
| 71 | +#define memcpy memcpy |
| 72 | +#include "../../../../lib/decompress_unxz.c" |
| 73 | +#endif |
| 74 | + |
| 75 | int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)) |
| 76 | { |
| 77 | return decompress(input, len, NULL, NULL, output, NULL, error); |
| 78 | --- /dev/null |
| 79 | +++ b/arch/arm/boot/compressed/piggy.xzkern.S |
| 80 | @@ -0,0 +1,6 @@ |
| 81 | + .section .piggydata,#alloc |
| 82 | + .globl input_data |
| 83 | +input_data: |
| 84 | + .incbin "arch/arm/boot/compressed/piggy.xzkern" |
| 85 | + .globl input_data_end |
| 86 | +input_data_end: |
| 87 | --- a/lib/xz/xz_dec_stream.c |
| 88 | +++ b/lib/xz/xz_dec_stream.c |
| 89 | @@ -9,6 +9,7 @@ |
| 90 | |
| 91 | #include "xz_private.h" |
| 92 | #include "xz_stream.h" |
| 93 | +#include <linux/kernel.h> |
| 94 | |
| 95 | /* Hash used to validate the Index field */ |
| 96 | struct xz_dec_hash { |
| 97 | |