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 #ifdef CONFIG_ARCH_MULTIPLATFORM
29 static inline void putc(int c
) {}
30 static inline void flush(void) {}
31 static inline void arch_decomp_setup(void) {}
33 #include <mach/uncompress.h>
36 #ifdef CONFIG_DEBUG_ICEDCC
38 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
40 static void icedcc_putc(int ch
)
42 int status
, i
= 0x4000000;
48 asm volatile ("mrc p14, 0, %0, c0, c1, 0" : "=r" (status
));
49 } while (status
& (1 << 29));
51 asm("mcr p14, 0, %0, c0, c5, 0" : : "r" (ch
));
55 #elif defined(CONFIG_CPU_XSCALE)
57 static void icedcc_putc(int ch
)
59 int status
, i
= 0x4000000;
65 asm volatile ("mrc p14, 0, %0, c14, c0, 0" : "=r" (status
));
66 } while (status
& (1 << 28));
68 asm("mcr p14, 0, %0, c8, c0, 0" : : "r" (ch
));
73 static void icedcc_putc(int ch
)
75 int status
, i
= 0x4000000;
81 asm volatile ("mrc p14, 0, %0, c0, c0, 0" : "=r" (status
));
84 asm("mcr p14, 0, %0, c1, c0, 0" : : "r" (ch
));
89 #define putc(ch) icedcc_putc(ch)
92 static void putstr(const char *ptr
)
96 while ((c
= *ptr
++) != '\0') {
108 extern char input_data
[];
109 extern char input_data_end
[];
111 unsigned char *output_data
;
113 unsigned long free_mem_ptr
;
114 unsigned long free_mem_end_ptr
;
117 #define arch_error(x)
126 putstr("\n\n -- System halted");
131 asmlinkage
void __div0(void)
133 error("Attempting division by 0!");
136 extern int do_decompress(u8
*input
, int len
, u8
*output
, void (*error
)(char *x
));
140 decompress_kernel(unsigned long output_start
, unsigned long free_mem_ptr_p
,
141 unsigned long free_mem_ptr_end_p
,
146 output_data
= (unsigned char *)output_start
;
147 free_mem_ptr
= free_mem_ptr_p
;
148 free_mem_end_ptr
= free_mem_ptr_end_p
;
149 __machine_arch_type
= arch_id
;
153 putstr("Uncompressing Linux...");
154 ret
= do_decompress(input_data
, input_data_end
- input_data
,
157 error("decompressor returned an error");
159 putstr(" done, booting the kernel.\n");