aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/boot/compressed
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/boot/compressed')
-rw-r--r--arch/arm/boot/compressed/Makefile34
-rw-r--r--arch/arm/boot/compressed/misc.c116
-rw-r--r--arch/arm/boot/compressed/piggy.gzip.S6
-rw-r--r--arch/arm/boot/compressed/piggy.lzo.S (renamed from arch/arm/boot/compressed/piggy.S)2
4 files changed, 66 insertions, 92 deletions
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index ce39dc54008..2d4d88ba73b 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -63,8 +63,12 @@ endif
63 63
64SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/ 64SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/
65 65
66targets := vmlinux vmlinux.lds piggy.gz piggy.o font.o font.c \ 66suffix_$(CONFIG_KERNEL_GZIP) = gzip
67 head.o misc.o $(OBJS) 67suffix_$(CONFIG_KERNEL_LZO) = lzo
68
69targets := vmlinux vmlinux.lds \
70 piggy.$(suffix_y) piggy.$(suffix_y).o \
71 font.o font.c head.o misc.o $(OBJS)
68 72
69ifeq ($(CONFIG_FUNCTION_TRACER),y) 73ifeq ($(CONFIG_FUNCTION_TRACER),y)
70ORIG_CFLAGS := $(KBUILD_CFLAGS) 74ORIG_CFLAGS := $(KBUILD_CFLAGS)
@@ -87,22 +91,34 @@ endif
87ifneq ($(PARAMS_PHYS),) 91ifneq ($(PARAMS_PHYS),)
88LDFLAGS_vmlinux += --defsym params_phys=$(PARAMS_PHYS) 92LDFLAGS_vmlinux += --defsym params_phys=$(PARAMS_PHYS)
89endif 93endif
90LDFLAGS_vmlinux += -p --no-undefined -X \ 94# ?
91 $(shell $(CC) $(KBUILD_CFLAGS) --print-libgcc-file-name) -T 95LDFLAGS_vmlinux += -p
96# Report unresolved symbol references
97LDFLAGS_vmlinux += --no-undefined
98# Delete all temporary local symbols
99LDFLAGS_vmlinux += -X
100# Next argument is a linker script
101LDFLAGS_vmlinux += -T
102
103# For __aeabi_uidivmod
104lib1funcs = $(obj)/lib1funcs.o
105
106$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S FORCE
107 $(call cmd,shipped)
92 108
93# Don't allow any static data in misc.o, which 109# Don't allow any static data in misc.o, which
94# would otherwise mess up our GOT table 110# would otherwise mess up our GOT table
95CFLAGS_misc.o := -Dstatic= 111CFLAGS_misc.o := -Dstatic=
96 112
97$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \ 113$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
98 $(addprefix $(obj)/, $(OBJS)) FORCE 114 $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) FORCE
99 $(call if_changed,ld) 115 $(call if_changed,ld)
100 @: 116 @:
101 117
102$(obj)/piggy.gz: $(obj)/../Image FORCE 118$(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
103 $(call if_changed,gzip) 119 $(call if_changed,$(suffix_y))
104 120
105$(obj)/piggy.o: $(obj)/piggy.gz FORCE 121$(obj)/piggy.$(suffix_y).o: $(obj)/piggy.$(suffix_y) FORCE
106 122
107CFLAGS_font.o := -Dstatic= 123CFLAGS_font.o := -Dstatic=
108 124
diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c
index 17153b54613..7e0fe4d42c7 100644
--- a/arch/arm/boot/compressed/misc.c
+++ b/arch/arm/boot/compressed/misc.c
@@ -18,10 +18,15 @@
18 18
19unsigned int __machine_arch_type; 19unsigned int __machine_arch_type;
20 20
21#define _LINUX_STRING_H_
22
21#include <linux/compiler.h> /* for inline */ 23#include <linux/compiler.h> /* for inline */
22#include <linux/types.h> /* for size_t */ 24#include <linux/types.h> /* for size_t */
23#include <linux/stddef.h> /* for NULL */ 25#include <linux/stddef.h> /* for NULL */
24#include <asm/string.h> 26#include <asm/string.h>
27#include <linux/linkage.h>
28
29#include <asm/unaligned.h>
25 30
26#ifdef STANDALONE_DEBUG 31#ifdef STANDALONE_DEBUG
27#define putstr printf 32#define putstr printf
@@ -188,34 +193,8 @@ static inline __ptr_t memcpy(__ptr_t __dest, __const __ptr_t __src,
188/* 193/*
189 * gzip delarations 194 * gzip delarations
190 */ 195 */
191#define OF(args) args
192#define STATIC static 196#define STATIC static
193 197
194typedef unsigned char uch;
195typedef unsigned short ush;
196typedef unsigned long ulg;
197
198#define WSIZE 0x8000 /* Window size must be at least 32k, */
199 /* and a power of two */
200
201static uch *inbuf; /* input buffer */
202static uch window[WSIZE]; /* Sliding window buffer */
203
204static unsigned insize; /* valid bytes in inbuf */
205static unsigned inptr; /* index of next byte to be processed in inbuf */
206static unsigned outcnt; /* bytes in output buffer */
207
208/* gzip flag byte */
209#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
210#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
211#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
212#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
213#define COMMENT 0x10 /* bit 4 set: file comment present */
214#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
215#define RESERVED 0xC0 /* bit 6,7: reserved */
216
217#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
218
219/* Diagnostic functions */ 198/* Diagnostic functions */
220#ifdef DEBUG 199#ifdef DEBUG
221# define Assert(cond,msg) {if(!(cond)) error(msg);} 200# define Assert(cond,msg) {if(!(cond)) error(msg);}
@@ -233,24 +212,20 @@ static unsigned outcnt; /* bytes in output buffer */
233# define Tracecv(c,x) 212# define Tracecv(c,x)
234#endif 213#endif
235 214
236static int fill_inbuf(void);
237static void flush_window(void);
238static void error(char *m); 215static void error(char *m);
239 216
240extern char input_data[]; 217extern char input_data[];
241extern char input_data_end[]; 218extern char input_data_end[];
242 219
243static uch *output_data; 220static unsigned char *output_data;
244static ulg output_ptr; 221static unsigned long output_ptr;
245static ulg bytes_out;
246 222
247static void error(char *m); 223static void error(char *m);
248 224
249static void putstr(const char *); 225static void putstr(const char *);
250 226
251extern int end; 227static unsigned long free_mem_ptr;
252static ulg free_mem_ptr; 228static unsigned long free_mem_end_ptr;
253static ulg free_mem_end_ptr;
254 229
255#ifdef STANDALONE_DEBUG 230#ifdef STANDALONE_DEBUG
256#define NO_INFLATE_MALLOC 231#define NO_INFLATE_MALLOC
@@ -258,46 +233,13 @@ static ulg free_mem_end_ptr;
258 233
259#define ARCH_HAS_DECOMP_WDOG 234#define ARCH_HAS_DECOMP_WDOG
260 235
261#include "../../../../lib/inflate.c" 236#ifdef CONFIG_KERNEL_GZIP
262 237#include "../../../../lib/decompress_inflate.c"
263/* =========================================================================== 238#endif
264 * Fill the input buffer. This is called only when the buffer is empty
265 * and at least one byte is really needed.
266 */
267int fill_inbuf(void)
268{
269 if (insize != 0)
270 error("ran out of input data");
271
272 inbuf = input_data;
273 insize = &input_data_end[0] - &input_data[0];
274
275 inptr = 1;
276 return inbuf[0];
277}
278 239
279/* =========================================================================== 240#ifdef CONFIG_KERNEL_LZO
280 * Write the output window window[0..outcnt-1] and update crc and bytes_out. 241#include "../../../../lib/decompress_unlzo.c"
281 * (Used for the decompressed data only.) 242#endif
282 */
283void flush_window(void)
284{
285 ulg c = crc;
286 unsigned n;
287 uch *in, *out, ch;
288
289 in = window;
290 out = &output_data[output_ptr];
291 for (n = 0; n < outcnt; n++) {
292 ch = *out++ = *in++;
293 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
294 }
295 crc = c;
296 bytes_out += (ulg)outcnt;
297 output_ptr += (ulg)outcnt;
298 outcnt = 0;
299 putstr(".");
300}
301 243
302#ifndef arch_error 244#ifndef arch_error
303#define arch_error(x) 245#define arch_error(x)
@@ -314,22 +256,33 @@ static void error(char *x)
314 while(1); /* Halt */ 256 while(1); /* Halt */
315} 257}
316 258
259asmlinkage void __div0(void)
260{
261 error("Attempting division by 0!");
262}
263
317#ifndef STANDALONE_DEBUG 264#ifndef STANDALONE_DEBUG
318 265
319ulg 266unsigned long
320decompress_kernel(ulg output_start, ulg free_mem_ptr_p, ulg free_mem_ptr_end_p, 267decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
321 int arch_id) 268 unsigned long free_mem_ptr_end_p,
269 int arch_id)
322{ 270{
323 output_data = (uch *)output_start; /* Points to kernel start */ 271 unsigned char *tmp;
272
273 output_data = (unsigned char *)output_start;
324 free_mem_ptr = free_mem_ptr_p; 274 free_mem_ptr = free_mem_ptr_p;
325 free_mem_end_ptr = free_mem_ptr_end_p; 275 free_mem_end_ptr = free_mem_ptr_end_p;
326 __machine_arch_type = arch_id; 276 __machine_arch_type = arch_id;
327 277
328 arch_decomp_setup(); 278 arch_decomp_setup();
329 279
330 makecrc(); 280 tmp = (unsigned char *) (((unsigned long)input_data_end) - 4);
281 output_ptr = get_unaligned_le32(tmp);
282
331 putstr("Uncompressing Linux..."); 283 putstr("Uncompressing Linux...");
332 gunzip(); 284 decompress(input_data, input_data_end - input_data,
285 NULL, NULL, output_data, NULL, error);
333 putstr(" done, booting the kernel.\n"); 286 putstr(" done, booting the kernel.\n");
334 return output_ptr; 287 return output_ptr;
335} 288}
@@ -341,11 +294,10 @@ int main()
341{ 294{
342 output_data = output_buffer; 295 output_data = output_buffer;
343 296
344 makecrc();
345 putstr("Uncompressing Linux..."); 297 putstr("Uncompressing Linux...");
346 gunzip(); 298 decompress(input_data, input_data_end - input_data,
299 NULL, NULL, output_data, NULL, error);
347 putstr("done.\n"); 300 putstr("done.\n");
348 return 0; 301 return 0;
349} 302}
350#endif 303#endif
351
diff --git a/arch/arm/boot/compressed/piggy.gzip.S b/arch/arm/boot/compressed/piggy.gzip.S
new file mode 100644
index 00000000000..a68adf91a16
--- /dev/null
+++ b/arch/arm/boot/compressed/piggy.gzip.S
@@ -0,0 +1,6 @@
1 .section .piggydata,#alloc
2 .globl input_data
3input_data:
4 .incbin "arch/arm/boot/compressed/piggy.gzip"
5 .globl input_data_end
6input_data_end:
diff --git a/arch/arm/boot/compressed/piggy.S b/arch/arm/boot/compressed/piggy.lzo.S
index 54c951800eb..a425ad95959 100644
--- a/arch/arm/boot/compressed/piggy.S
+++ b/arch/arm/boot/compressed/piggy.lzo.S
@@ -1,6 +1,6 @@
1 .section .piggydata,#alloc 1 .section .piggydata,#alloc
2 .globl input_data 2 .globl input_data
3input_data: 3input_data:
4 .incbin "arch/arm/boot/compressed/piggy.gz" 4 .incbin "arch/arm/boot/compressed/piggy.lzo"
5 .globl input_data_end 5 .globl input_data_end
6input_data_end: 6input_data_end: