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