4 * This is a collection of several routines from gzip-1.0.3
7 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
9 * Modified for ARM Linux by Russell King
11 * Nicolas Pitre <nico@visuaide.com> 1999/04/14 :
12 * For this code to run directly from Flash, all constant variables must
13 * be marked with 'const' and all other variables initialized at run-time
14 * only. This way all non constant variables will end up in the bss segment,
15 * which should point to addresses in RAM and cleared to 0 on start.
16 * This allows for a much quicker boot time.
19 unsigned int __machine_arch_type
;
21 #include <linux/compiler.h> /* for inline */
22 #include <linux/types.h>
23 #include <linux/linkage.h>
25 static void putstr(const char *ptr
);
26 extern void error(char *x
);
28 #include CONFIG_UNCOMPRESS_INCLUDE
30 #ifdef CONFIG_DEBUG_ICEDCC
32 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
34 static void icedcc_putc(int ch
)
36 int status
, i
= 0x4000000;
42 asm volatile ("mrc p14, 0, %0, c0, c1, 0" : "=r" (status
));
43 } while (status
& (1 << 29));
45 asm("mcr p14, 0, %0, c0, c5, 0" : : "r" (ch
));
49 #elif defined(CONFIG_CPU_XSCALE)
51 static void icedcc_putc(int ch
)
53 int status
, i
= 0x4000000;
59 asm volatile ("mrc p14, 0, %0, c14, c0, 0" : "=r" (status
));
60 } while (status
& (1 << 28));
62 asm("mcr p14, 0, %0, c8, c0, 0" : : "r" (ch
));
67 static void icedcc_putc(int ch
)
69 int status
, i
= 0x4000000;
75 asm volatile ("mrc p14, 0, %0, c0, c0, 0" : "=r" (status
));
78 asm("mcr p14, 0, %0, c1, c0, 0" : : "r" (ch
));
83 #define putc(ch) icedcc_putc(ch)
86 static void putstr(const char *ptr
)
90 while ((c
= *ptr
++) != '\0') {
102 extern char input_data
[];
103 extern char input_data_end
[];
105 unsigned char *output_data
;
107 unsigned long free_mem_ptr
;
108 unsigned long free_mem_end_ptr
;
111 #define arch_error(x)
120 putstr("\n\n -- System halted");
125 asmlinkage
void __div0(void)
127 error("Attempting division by 0!");
130 unsigned long __stack_chk_guard
;
132 void __stack_chk_guard_setup(void)
134 __stack_chk_guard
= 0x000a0dff;
137 void __stack_chk_fail(void)
139 error("stack-protector: Kernel stack is corrupted\n");
142 extern int do_decompress(u8
*input
, int len
, u8
*output
, void (*error
)(char *x
));
146 decompress_kernel(unsigned long output_start
, unsigned long free_mem_ptr_p
,
147 unsigned long free_mem_ptr_end_p
,
152 __stack_chk_guard_setup();
154 output_data
= (unsigned char *)output_start
;
155 free_mem_ptr
= free_mem_ptr_p
;
156 free_mem_end_ptr
= free_mem_ptr_end_p
;
157 __machine_arch_type
= arch_id
;
161 putstr("Uncompressing Linux...");
162 ret
= do_decompress(input_data
, input_data_end
- input_data
,
165 error("decompressor returned an error");
167 putstr(" done, booting the kernel.\n");