add support for and switch to XZ compressed kernels on ARM
[librecmc/librecmc.git] / target / linux / generic / patches-3.0 / 006-arm_kernel_xz_support.patch
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 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
19 index c2e5f3d..489fe16 100644
20 --- a/arch/arm/Kconfig
21 +++ b/arch/arm/Kconfig
22 @@ -20,6 +20,7 @@ config ARM
23         select HAVE_KERNEL_GZIP
24         select HAVE_KERNEL_LZO
25         select HAVE_KERNEL_LZMA
26 +       select HAVE_KERNEL_XZ
27         select HAVE_IRQ_WORK
28         select HAVE_PERF_EVENTS
29         select PERF_USE_VMALLOC
30 diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
31 index 23aad07..e5db34e 100644
32 --- a/arch/arm/boot/compressed/Makefile
33 +++ b/arch/arm/boot/compressed/Makefile
34 @@ -82,13 +82,14 @@ SEDFLAGS    = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/
35  suffix_$(CONFIG_KERNEL_GZIP) = gzip
36  suffix_$(CONFIG_KERNEL_LZO)  = lzo
37  suffix_$(CONFIG_KERNEL_LZMA) = lzma
38 +suffix_$(CONFIG_KERNEL_XZ)   = xzkern
39  
40  targets       := vmlinux vmlinux.lds \
41                  piggy.$(suffix_y) piggy.$(suffix_y).o \
42                  font.o font.c head.o misc.o $(OBJS)
43  
44  # Make sure files are removed during clean
45 -extra-y       += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S
46 +extra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern lib1funcs.S ashldi3.S
47  
48  ifeq ($(CONFIG_FUNCTION_TRACER),y)
49  ORIG_CFLAGS := $(KBUILD_CFLAGS)
50 @@ -133,8 +134,14 @@ bad_syms=$$($(CROSS_COMPILE)nm $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
51    ( echo "following symbols must have non local/private scope:" >&2; \
52      echo "$$bad_syms" >&2; rm -f $@; false )
53  
54 +# For __aeabi_llsl
55 +ashldi3 = $(obj)/ashldi3.o
56 +
57 +$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S FORCE
58 +       $(call cmd,shipped)
59 +
60  $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
61 -               $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) FORCE
62 +               $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) FORCE
63         $(call if_changed,ld)
64         @$(check_for_bad_syms)
65  
66 diff --git a/arch/arm/boot/compressed/decompress.c b/arch/arm/boot/compressed/decompress.c
67 index 07be5a2..0ecd8b4 100644
68 --- a/arch/arm/boot/compressed/decompress.c
69 +++ b/arch/arm/boot/compressed/decompress.c
70 @@ -44,6 +44,10 @@ extern void error(char *);
71  #include "../../../../lib/decompress_unlzma.c"
72  #endif
73  
74 +#ifdef CONFIG_KERNEL_XZ
75 +#include "../../../../lib/decompress_unxz.c"
76 +#endif
77 +
78  int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
79  {
80         return decompress(input, len, NULL, NULL, output, NULL, error);
81 diff --git a/arch/arm/boot/compressed/piggy.xzkern.S b/arch/arm/boot/compressed/piggy.xzkern.S
82 new file mode 100644
83 index 0000000..5703f30
84 --- /dev/null
85 +++ b/arch/arm/boot/compressed/piggy.xzkern.S
86 @@ -0,0 +1,6 @@
87 +       .section .piggydata,#alloc
88 +       .globl  input_data
89 +input_data:
90 +       .incbin "arch/arm/boot/compressed/piggy.xzkern"
91 +       .globl  input_data_end
92 +input_data_end:
93 diff --git a/lib/xz/xz_dec_stream.c b/lib/xz/xz_dec_stream.c
94 index ac809b1..9a60cc2 100644
95 --- a/lib/xz/xz_dec_stream.c
96 +++ b/lib/xz/xz_dec_stream.c
97 @@ -9,6 +9,7 @@
98  
99  #include "xz_private.h"
100  #include "xz_stream.h"
101 +#include <linux/kernel.h>
102  
103  /* Hash used to validate the Index field */
104  struct xz_dec_hash {
105 -- 
106 1.7.1
107