485773c0280332a5b5f78258fcfc01256b5950a8
[openwrt.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 --- 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 @@ -82,13 +82,14 @@ 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  targets       := vmlinux vmlinux.lds \
37                  piggy.$(suffix_y) piggy.$(suffix_y).o \
38                  font.o font.c head.o misc.o $(OBJS)
39  
40  # Make sure files are removed during clean
41 -extra-y       += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S
42 +extra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern lib1funcs.S ashldi3.S
43  
44  ifeq ($(CONFIG_FUNCTION_TRACER),y)
45  ORIG_CFLAGS := $(KBUILD_CFLAGS)
46 @@ -133,8 +134,14 @@ bad_syms=$$($(CROSS_COMPILE)nm $@ | sed
47    ( echo "following symbols must have non local/private scope:" >&2; \
48      echo "$$bad_syms" >&2; rm -f $@; false )
49  
50 +# For __aeabi_llsl
51 +ashldi3 = $(obj)/ashldi3.o
52 +
53 +$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S FORCE
54 +       $(call cmd,shipped)
55 +
56  $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
57 -               $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) FORCE
58 +               $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) FORCE
59         $(call if_changed,ld)
60         @$(check_for_bad_syms)
61  
62 --- a/arch/arm/boot/compressed/decompress.c
63 +++ b/arch/arm/boot/compressed/decompress.c
64 @@ -44,6 +44,10 @@ extern void error(char *);
65  #include "../../../../lib/decompress_unlzma.c"
66  #endif
67  
68 +#ifdef CONFIG_KERNEL_XZ
69 +#include "../../../../lib/decompress_unxz.c"
70 +#endif
71 +
72  int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
73  {
74         return decompress(input, len, NULL, NULL, output, NULL, error);
75 --- /dev/null
76 +++ b/arch/arm/boot/compressed/piggy.xzkern.S
77 @@ -0,0 +1,6 @@
78 +       .section .piggydata,#alloc
79 +       .globl  input_data
80 +input_data:
81 +       .incbin "arch/arm/boot/compressed/piggy.xzkern"
82 +       .globl  input_data_end
83 +input_data_end:
84 --- a/lib/xz/xz_dec_stream.c
85 +++ b/lib/xz/xz_dec_stream.c
86 @@ -9,6 +9,7 @@
87  
88  #include "xz_private.h"
89  #include "xz_stream.h"
90 +#include <linux/kernel.h>
91  
92  /* Hash used to validate the Index field */
93  struct xz_dec_hash {