replace our arm LZMA loader with the one that goes upstream
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.31 / 051-lzo_compressed_kernel_for_arm.patch
1 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
2 index 1c4119c..350921d 100644
3 --- a/arch/arm/Kconfig
4 +++ b/arch/arm/Kconfig
5 @@ -18,6 +18,8 @@ config ARM
6 select HAVE_KRETPROBES if (HAVE_KPROBES)
7 select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
8 select HAVE_GENERIC_DMA_COHERENT
9 + select HAVE_KERNEL_GZIP
10 + select HAVE_KERNEL_LZO
11 help
12 The ARM series is a line of low-power-consumption RISC chip designs
13 licensed by ARM Ltd and targeted at embedded applications and
14 diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
15 index ce39dc5..5b4629b 100644
16 --- a/arch/arm/boot/compressed/Makefile
17 +++ b/arch/arm/boot/compressed/Makefile
18 @@ -63,8 +63,12 @@ endif
19
20 SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/
21
22 -targets := vmlinux vmlinux.lds piggy.gz piggy.o font.o font.c \
23 - head.o misc.o $(OBJS)
24 +suffix_$(CONFIG_KERNEL_GZIP) = gzip
25 +suffix_$(CONFIG_KERNEL_LZO) = lzo
26 +
27 +targets := vmlinux vmlinux.lds \
28 + piggy.$(suffix_y) piggy.$(suffix_y).o \
29 + font.o font.c head.o misc.o $(OBJS)
30
31 ifeq ($(CONFIG_FUNCTION_TRACER),y)
32 ORIG_CFLAGS := $(KBUILD_CFLAGS)
33 @@ -87,22 +91,31 @@ endif
34 ifneq ($(PARAMS_PHYS),)
35 LDFLAGS_vmlinux += --defsym params_phys=$(PARAMS_PHYS)
36 endif
37 -LDFLAGS_vmlinux += -p --no-undefined -X \
38 - $(shell $(CC) $(KBUILD_CFLAGS) --print-libgcc-file-name) -T
39 +# ?
40 +LDFLAGS_vmlinux += -p
41 +# Report unresolved symbol references
42 +LDFLAGS_vmlinux += --no-undefined
43 +# Delete all temporary local symbols
44 +LDFLAGS_vmlinux += -X
45 +# Next argument is a linker script
46 +LDFLAGS_vmlinux += -T
47 +
48 +# For __aeabi_uidivmod
49 +lib1funcs = $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.o
50
51 # Don't allow any static data in misc.o, which
52 # would otherwise mess up our GOT table
53 CFLAGS_misc.o := -Dstatic=
54
55 -$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
56 - $(addprefix $(obj)/, $(OBJS)) FORCE
57 +$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
58 + $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) FORCE
59 $(call if_changed,ld)
60 @:
61
62 -$(obj)/piggy.gz: $(obj)/../Image FORCE
63 - $(call if_changed,gzip)
64 +$(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
65 + $(call if_changed,$(suffix_y))
66
67 -$(obj)/piggy.o: $(obj)/piggy.gz FORCE
68 +$(obj)/piggy.$(suffix_y).o: $(obj)/piggy.$(suffix_y) FORCE
69
70 CFLAGS_font.o := -Dstatic=
71
72 diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c
73 index 17153b5..7e0fe4d 100644
74 --- a/arch/arm/boot/compressed/misc.c
75 +++ b/arch/arm/boot/compressed/misc.c
76 @@ -18,10 +18,15 @@
77
78 unsigned int __machine_arch_type;
79
80 +#define _LINUX_STRING_H_
81 +
82 #include <linux/compiler.h> /* for inline */
83 #include <linux/types.h> /* for size_t */
84 #include <linux/stddef.h> /* for NULL */
85 #include <asm/string.h>
86 +#include <linux/linkage.h>
87 +
88 +#include <asm/unaligned.h>
89
90 #ifdef STANDALONE_DEBUG
91 #define putstr printf
92 @@ -188,34 +193,8 @@ static inline __ptr_t memcpy(__ptr_t __dest, __const __ptr_t __src,
93 /*
94 * gzip delarations
95 */
96 -#define OF(args) args
97 #define STATIC static
98
99 -typedef unsigned char uch;
100 -typedef unsigned short ush;
101 -typedef unsigned long ulg;
102 -
103 -#define WSIZE 0x8000 /* Window size must be at least 32k, */
104 - /* and a power of two */
105 -
106 -static uch *inbuf; /* input buffer */
107 -static uch window[WSIZE]; /* Sliding window buffer */
108 -
109 -static unsigned insize; /* valid bytes in inbuf */
110 -static unsigned inptr; /* index of next byte to be processed in inbuf */
111 -static unsigned outcnt; /* bytes in output buffer */
112 -
113 -/* gzip flag byte */
114 -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
115 -#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
116 -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
117 -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
118 -#define COMMENT 0x10 /* bit 4 set: file comment present */
119 -#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
120 -#define RESERVED 0xC0 /* bit 6,7: reserved */
121 -
122 -#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
123 -
124 /* Diagnostic functions */
125 #ifdef DEBUG
126 # define Assert(cond,msg) {if(!(cond)) error(msg);}
127 @@ -233,24 +212,20 @@ static unsigned outcnt; /* bytes in output buffer */
128 # define Tracecv(c,x)
129 #endif
130
131 -static int fill_inbuf(void);
132 -static void flush_window(void);
133 static void error(char *m);
134
135 extern char input_data[];
136 extern char input_data_end[];
137
138 -static uch *output_data;
139 -static ulg output_ptr;
140 -static ulg bytes_out;
141 +static unsigned char *output_data;
142 +static unsigned long output_ptr;
143
144 static void error(char *m);
145
146 static void putstr(const char *);
147
148 -extern int end;
149 -static ulg free_mem_ptr;
150 -static ulg free_mem_end_ptr;
151 +static unsigned long free_mem_ptr;
152 +static unsigned long free_mem_end_ptr;
153
154 #ifdef STANDALONE_DEBUG
155 #define NO_INFLATE_MALLOC
156 @@ -258,46 +233,13 @@ static ulg free_mem_end_ptr;
157
158 #define ARCH_HAS_DECOMP_WDOG
159
160 -#include "../../../../lib/inflate.c"
161 -
162 -/* ===========================================================================
163 - * Fill the input buffer. This is called only when the buffer is empty
164 - * and at least one byte is really needed.
165 - */
166 -int fill_inbuf(void)
167 -{
168 - if (insize != 0)
169 - error("ran out of input data");
170 -
171 - inbuf = input_data;
172 - insize = &input_data_end[0] - &input_data[0];
173 -
174 - inptr = 1;
175 - return inbuf[0];
176 -}
177 +#ifdef CONFIG_KERNEL_GZIP
178 +#include "../../../../lib/decompress_inflate.c"
179 +#endif
180
181 -/* ===========================================================================
182 - * Write the output window window[0..outcnt-1] and update crc and bytes_out.
183 - * (Used for the decompressed data only.)
184 - */
185 -void flush_window(void)
186 -{
187 - ulg c = crc;
188 - unsigned n;
189 - uch *in, *out, ch;
190 -
191 - in = window;
192 - out = &output_data[output_ptr];
193 - for (n = 0; n < outcnt; n++) {
194 - ch = *out++ = *in++;
195 - c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
196 - }
197 - crc = c;
198 - bytes_out += (ulg)outcnt;
199 - output_ptr += (ulg)outcnt;
200 - outcnt = 0;
201 - putstr(".");
202 -}
203 +#ifdef CONFIG_KERNEL_LZO
204 +#include "../../../../lib/decompress_unlzo.c"
205 +#endif
206
207 #ifndef arch_error
208 #define arch_error(x)
209 @@ -314,22 +256,33 @@ static void error(char *x)
210 while(1); /* Halt */
211 }
212
213 +asmlinkage void __div0(void)
214 +{
215 + error("Attempting division by 0!");
216 +}
217 +
218 #ifndef STANDALONE_DEBUG
219
220 -ulg
221 -decompress_kernel(ulg output_start, ulg free_mem_ptr_p, ulg free_mem_ptr_end_p,
222 - int arch_id)
223 +unsigned long
224 +decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
225 + unsigned long free_mem_ptr_end_p,
226 + int arch_id)
227 {
228 - output_data = (uch *)output_start; /* Points to kernel start */
229 + unsigned char *tmp;
230 +
231 + output_data = (unsigned char *)output_start;
232 free_mem_ptr = free_mem_ptr_p;
233 free_mem_end_ptr = free_mem_ptr_end_p;
234 __machine_arch_type = arch_id;
235
236 arch_decomp_setup();
237
238 - makecrc();
239 + tmp = (unsigned char *) (((unsigned long)input_data_end) - 4);
240 + output_ptr = get_unaligned_le32(tmp);
241 +
242 putstr("Uncompressing Linux...");
243 - gunzip();
244 + decompress(input_data, input_data_end - input_data,
245 + NULL, NULL, output_data, NULL, error);
246 putstr(" done, booting the kernel.\n");
247 return output_ptr;
248 }
249 @@ -341,11 +294,10 @@ int main()
250 {
251 output_data = output_buffer;
252
253 - makecrc();
254 putstr("Uncompressing Linux...");
255 - gunzip();
256 + decompress(input_data, input_data_end - input_data,
257 + NULL, NULL, output_data, NULL, error);
258 putstr("done.\n");
259 return 0;
260 }
261 #endif
262 -
263 diff --git a/arch/arm/boot/compressed/piggy.S b/arch/arm/boot/compressed/piggy.S
264 deleted file mode 100644
265 index 54c9518..0000000
266 --- a/arch/arm/boot/compressed/piggy.S
267 +++ /dev/null
268 @@ -1,6 +0,0 @@
269 - .section .piggydata,#alloc
270 - .globl input_data
271 -input_data:
272 - .incbin "arch/arm/boot/compressed/piggy.gz"
273 - .globl input_data_end
274 -input_data_end:
275 diff --git a/arch/arm/boot/compressed/piggy.gzip.S b/arch/arm/boot/compressed/piggy.gzip.S
276 new file mode 100644
277 index 0000000..a68adf9
278 --- /dev/null
279 +++ b/arch/arm/boot/compressed/piggy.gzip.S
280 @@ -0,0 +1,6 @@
281 + .section .piggydata,#alloc
282 + .globl input_data
283 +input_data:
284 + .incbin "arch/arm/boot/compressed/piggy.gzip"
285 + .globl input_data_end
286 +input_data_end:
287 diff --git a/arch/arm/boot/compressed/piggy.lzo.S b/arch/arm/boot/compressed/piggy.lzo.S
288 new file mode 100644
289 index 0000000..a425ad9
290 --- /dev/null
291 +++ b/arch/arm/boot/compressed/piggy.lzo.S
292 @@ -0,0 +1,6 @@
293 + .section .piggydata,#alloc
294 + .globl input_data
295 +input_data:
296 + .incbin "arch/arm/boot/compressed/piggy.lzo"
297 + .globl input_data_end
298 +input_data_end:
This page took 0.063327 seconds and 5 git commands to generate.