3 @@ -18,6 +18,8 @@ config ARM
4 select HAVE_KRETPROBES if (HAVE_KPROBES)
5 select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
6 select HAVE_GENERIC_DMA_COHERENT
7 + select HAVE_KERNEL_GZIP
8 + select HAVE_KERNEL_LZO
10 The ARM series is a line of low-power-consumption RISC chip designs
11 licensed by ARM Ltd and targeted at embedded applications and
12 --- a/arch/arm/boot/compressed/Makefile
13 +++ b/arch/arm/boot/compressed/Makefile
14 @@ -63,8 +63,12 @@ endif
16 SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/
18 -targets := vmlinux vmlinux.lds piggy.gz piggy.o font.o font.c \
19 - head.o misc.o $(OBJS)
20 +suffix_$(CONFIG_KERNEL_GZIP) = gzip
21 +suffix_$(CONFIG_KERNEL_LZO) = lzo
23 +targets := vmlinux vmlinux.lds \
24 + piggy.$(suffix_y) piggy.$(suffix_y).o \
25 + font.o font.c head.o misc.o $(OBJS)
27 ifeq ($(CONFIG_FUNCTION_TRACER),y)
28 ORIG_CFLAGS := $(KBUILD_CFLAGS)
29 @@ -87,22 +91,31 @@ endif
30 ifneq ($(PARAMS_PHYS),)
31 LDFLAGS_vmlinux += --defsym params_phys=$(PARAMS_PHYS)
33 -LDFLAGS_vmlinux += -p --no-undefined -X \
34 - $(shell $(CC) $(KBUILD_CFLAGS) --print-libgcc-file-name) -T
36 +LDFLAGS_vmlinux += -p
37 +# Report unresolved symbol references
38 +LDFLAGS_vmlinux += --no-undefined
39 +# Delete all temporary local symbols
40 +LDFLAGS_vmlinux += -X
41 +# Next argument is a linker script
42 +LDFLAGS_vmlinux += -T
44 +# For __aeabi_uidivmod
45 +lib1funcs = $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.o
47 # Don't allow any static data in misc.o, which
48 # would otherwise mess up our GOT table
49 CFLAGS_misc.o := -Dstatic=
51 -$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
52 - $(addprefix $(obj)/, $(OBJS)) FORCE
53 +$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
54 + $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) FORCE
58 -$(obj)/piggy.gz: $(obj)/../Image FORCE
59 - $(call if_changed,gzip)
60 +$(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
61 + $(call if_changed,$(suffix_y))
63 -$(obj)/piggy.o: $(obj)/piggy.gz FORCE
64 +$(obj)/piggy.$(suffix_y).o: $(obj)/piggy.$(suffix_y) FORCE
66 CFLAGS_font.o := -Dstatic=
68 --- a/arch/arm/boot/compressed/misc.c
69 +++ b/arch/arm/boot/compressed/misc.c
72 unsigned int __machine_arch_type;
74 +#define _LINUX_STRING_H_
76 #include <linux/compiler.h> /* for inline */
77 #include <linux/types.h> /* for size_t */
78 #include <linux/stddef.h> /* for NULL */
79 #include <asm/string.h>
80 +#include <linux/linkage.h>
82 +#include <asm/unaligned.h>
84 #ifdef STANDALONE_DEBUG
86 @@ -188,34 +193,8 @@ static inline __ptr_t memcpy(__ptr_t __d
90 -#define OF(args) args
93 -typedef unsigned char uch;
94 -typedef unsigned short ush;
95 -typedef unsigned long ulg;
97 -#define WSIZE 0x8000 /* Window size must be at least 32k, */
98 - /* and a power of two */
100 -static uch *inbuf; /* input buffer */
101 -static uch window[WSIZE]; /* Sliding window buffer */
103 -static unsigned insize; /* valid bytes in inbuf */
104 -static unsigned inptr; /* index of next byte to be processed in inbuf */
105 -static unsigned outcnt; /* bytes in output buffer */
107 -/* gzip flag byte */
108 -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
109 -#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
110 -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
111 -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
112 -#define COMMENT 0x10 /* bit 4 set: file comment present */
113 -#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
114 -#define RESERVED 0xC0 /* bit 6,7: reserved */
116 -#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
118 /* Diagnostic functions */
120 # define Assert(cond,msg) {if(!(cond)) error(msg);}
121 @@ -233,24 +212,20 @@ static unsigned outcnt; /* bytes in out
122 # define Tracecv(c,x)
125 -static int fill_inbuf(void);
126 -static void flush_window(void);
127 static void error(char *m);
129 extern char input_data[];
130 extern char input_data_end[];
132 -static uch *output_data;
133 -static ulg output_ptr;
134 -static ulg bytes_out;
135 +static unsigned char *output_data;
136 +static unsigned long output_ptr;
138 static void error(char *m);
140 static void putstr(const char *);
143 -static ulg free_mem_ptr;
144 -static ulg free_mem_end_ptr;
145 +static unsigned long free_mem_ptr;
146 +static unsigned long free_mem_end_ptr;
148 #ifdef STANDALONE_DEBUG
149 #define NO_INFLATE_MALLOC
150 @@ -258,46 +233,13 @@ static ulg free_mem_end_ptr;
152 #define ARCH_HAS_DECOMP_WDOG
154 -#include "../../../../lib/inflate.c"
156 -/* ===========================================================================
157 - * Fill the input buffer. This is called only when the buffer is empty
158 - * and at least one byte is really needed.
160 -int fill_inbuf(void)
163 - error("ran out of input data");
165 - inbuf = input_data;
166 - insize = &input_data_end[0] - &input_data[0];
171 +#ifdef CONFIG_KERNEL_GZIP
172 +#include "../../../../lib/decompress_inflate.c"
175 -/* ===========================================================================
176 - * Write the output window window[0..outcnt-1] and update crc and bytes_out.
177 - * (Used for the decompressed data only.)
179 -void flush_window(void)
186 - out = &output_data[output_ptr];
187 - for (n = 0; n < outcnt; n++) {
188 - ch = *out++ = *in++;
189 - c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
192 - bytes_out += (ulg)outcnt;
193 - output_ptr += (ulg)outcnt;
197 +#ifdef CONFIG_KERNEL_LZO
198 +#include "../../../../lib/decompress_unlzo.c"
202 #define arch_error(x)
203 @@ -314,22 +256,33 @@ static void error(char *x)
207 +asmlinkage void __div0(void)
209 + error("Attempting division by 0!");
212 #ifndef STANDALONE_DEBUG
215 -decompress_kernel(ulg output_start, ulg free_mem_ptr_p, ulg free_mem_ptr_end_p,
218 +decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
219 + unsigned long free_mem_ptr_end_p,
222 - output_data = (uch *)output_start; /* Points to kernel start */
223 + unsigned char *tmp;
225 + output_data = (unsigned char *)output_start;
226 free_mem_ptr = free_mem_ptr_p;
227 free_mem_end_ptr = free_mem_ptr_end_p;
228 __machine_arch_type = arch_id;
233 + tmp = (unsigned char *) (((unsigned long)input_data_end) - 4);
234 + output_ptr = get_unaligned_le32(tmp);
236 putstr("Uncompressing Linux...");
238 + decompress(input_data, input_data_end - input_data,
239 + NULL, NULL, output_data, NULL, error);
240 putstr(" done, booting the kernel.\n");
243 @@ -341,11 +294,10 @@ int main()
245 output_data = output_buffer;
248 putstr("Uncompressing Linux...");
250 + decompress(input_data, input_data_end - input_data,
251 + NULL, NULL, output_data, NULL, error);
257 --- a/arch/arm/boot/compressed/piggy.S
260 - .section .piggydata,#alloc
263 - .incbin "arch/arm/boot/compressed/piggy.gz"
264 - .globl input_data_end
267 +++ b/arch/arm/boot/compressed/piggy.gzip.S
269 + .section .piggydata,#alloc
272 + .incbin "arch/arm/boot/compressed/piggy.gzip"
273 + .globl input_data_end
276 +++ b/arch/arm/boot/compressed/piggy.lzo.S
278 + .section .piggydata,#alloc
281 + .incbin "arch/arm/boot/compressed/piggy.lzo"
282 + .globl input_data_end