kernel: add linux 4.9 support
[openwrt/staging/yousong.git] / target / linux / generic / patches-4.9 / 222-arm_zimage_none.patch
1 ARM: implement "uncompressed zImage"
2
3 Based on RFC patch by Uwe Kleine-König
4 http://www.spinics.net/lists/arm-kernel/msg230153.html
5
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 ---
8 --- a/arch/arm/boot/compressed/Makefile
9 +++ b/arch/arm/boot/compressed/Makefile
10 @@ -71,6 +71,7 @@ compress-$(CONFIG_KERNEL_LZO) = lzo
11 compress-$(CONFIG_KERNEL_LZMA) = lzma
12 compress-$(CONFIG_KERNEL_XZ) = xzkern
13 compress-$(CONFIG_KERNEL_LZ4) = lz4
14 +compress-$(CONFIG_KERNEL_CAT) = cat
15
16 # Borrowed libfdt files for the ATAG compatibility mode
17
18 --- a/arch/arm/boot/compressed/decompress.c
19 +++ b/arch/arm/boot/compressed/decompress.c
20 @@ -55,6 +55,10 @@ extern char * strstr(const char * s1, co
21 #include "../../../../lib/decompress_unlz4.c"
22 #endif
23
24 +#ifdef CONFIG_KERNEL_CAT
25 +#include "../../../../lib/decompress_uncat.c"
26 +#endif
27 +
28 int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
29 {
30 return __decompress(input, len, NULL, NULL, output, 0, NULL, error);
31 --- /dev/null
32 +++ b/arch/arm/boot/compressed/piggy.cat.S
33 @@ -0,0 +1,6 @@
34 + .section .piggydata,#alloc
35 + .globl input_data
36 +input_data:
37 + .incbin "arch/arm/boot/compressed/piggy.cat"
38 + .globl input_data_end
39 +input_data_end:
40 --- a/init/Kconfig
41 +++ b/init/Kconfig
42 @@ -127,6 +127,9 @@ config HAVE_KERNEL_LZO
43 config HAVE_KERNEL_LZ4
44 bool
45
46 +config HAVE_KERNEL_CAT
47 + bool
48 +
49 choice
50 prompt "Kernel compression mode"
51 default KERNEL_GZIP
52 @@ -193,9 +196,10 @@ config KERNEL_LZO
53 bool "LZO"
54 depends on HAVE_KERNEL_LZO
55 help
56 - Its compression ratio is the poorest among the choices. The kernel
57 - size is about 10% bigger than gzip; however its speed
58 - (both compression and decompression) is the fastest.
59 + Its compression ratio is the poorest among the choices (apart from
60 + uncompressed below). The kernel size is about 10% bigger than gzip;
61 + however its speed (both compression and decompression) is the
62 + fastest.
63
64 config KERNEL_LZ4
65 bool "LZ4"
66 @@ -209,6 +213,12 @@ config KERNEL_LZ4
67 is about 8% bigger than LZO. But the decompression speed is
68 faster than LZO.
69
70 +config KERNEL_CAT
71 + bool "uncompressed"
72 + depends on HAVE_KERNEL_CAT
73 + help
74 + Don't use compression at all.
75 +
76 endchoice
77
78 config DEFAULT_HOSTNAME
79 --- /dev/null
80 +++ b/lib/decompress_uncat.c
81 @@ -0,0 +1,17 @@
82 +#include <linux/types.h>
83 +#include <linux/compiler.h>
84 +
85 +#ifdef STATIC
86 +
87 +STATIC int __decompress(unsigned char *buf, long in_len,
88 + long (*fill)(void*, unsigned long),
89 + long (*flush)(void*, unsigned long),
90 + unsigned char *output, long out_len,
91 + long *posp,
92 + void (*error)(char *x))
93 +{
94 + memmove(output, buf, in_len);
95 + return 0;
96 +}
97 +
98 +#endif
99 --- a/scripts/Makefile.lib
100 +++ b/scripts/Makefile.lib
101 @@ -357,6 +357,13 @@ cmd_lz4 = (cat $(filter-out FORCE,$^) |
102 lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
103 (rm -f $@ ; false)
104
105 +# uncompressed
106 +# ---------------------------------------------------------------------------
107 +quiet_cmd_cat = CAT $@
108 +cmd_cat = (cat $(filter-out FORCE,$^) \
109 + && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
110 + (rm -f $@ ; false)
111 +
112 # U-Boot mkimage
113 # ---------------------------------------------------------------------------
114
115 --- a/arch/arm/Kconfig
116 +++ b/arch/arm/Kconfig
117 @@ -65,6 +65,7 @@ config ARM
118 select HAVE_KERNEL_LZMA
119 select HAVE_KERNEL_LZO
120 select HAVE_KERNEL_XZ
121 + select HAVE_KERNEL_CAT
122 select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
123 select HAVE_KRETPROBES if (HAVE_KPROBES)
124 select HAVE_MEMBLOCK