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 #define _LINUX_STRING_H_
23 #include <linux/compiler.h> /* for inline */
24 #include <linux/types.h> /* for size_t */
25 #include <linux/stddef.h> /* for NULL */
26 #include <linux/linkage.h>
27 #include <asm/string.h>
29 #include <asm/unaligned.h>
31 #ifdef STANDALONE_DEBUG
35 static void putstr(const char *ptr);
36 extern void error(char *x);
38 #include <mach/uncompress.h>
40 #ifdef CONFIG_DEBUG_ICEDCC
44 static void icedcc_putc(int ch)
46 int status, i = 0x4000000;
52 asm volatile ("mrc p14, 0, %0, c0, c1, 0" : "=r" (status));
53 } while (status & (1 << 29));
55 asm("mcr p14, 0, %0, c0, c5, 0" : : "r" (ch));
58 #elif defined(CONFIG_CPU_V7)
60 static void icedcc_putc(int ch)
63 "wait: mrc p14, 0, pc, c0, c1, 0 \n\
65 mcr p14, 0, %0, c0, c5, 0 "
69 #elif defined(CONFIG_CPU_XSCALE)
71 static void icedcc_putc(int ch)
73 int status, i = 0x4000000;
79 asm volatile ("mrc p14, 0, %0, c14, c0, 0" : "=r" (status));
80 } while (status & (1 << 28));
82 asm("mcr p14, 0, %0, c8, c0, 0" : : "r" (ch));
87 static void icedcc_putc(int ch)
89 int status, i = 0x4000000;
95 asm volatile ("mrc p14, 0, %0, c0, c0, 0" : "=r" (status));
98 asm("mcr p14, 0, %0, c1, c0, 0" : : "r" (ch));
103 #define putc(ch) icedcc_putc(ch)
106 static void putstr(const char *ptr)
110 while ((c = *ptr++) != '\0') {
121 void *memcpy(void *__dest, __const void *__src, size_t __n)
124 unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
126 for (i = __n >> 3; i > 0; i--) {
158 extern char input_data[];
159 extern char input_data_end[];
161 unsigned char *output_data;
162 unsigned long output_ptr;
164 unsigned long free_mem_ptr;
165 unsigned long free_mem_end_ptr;
168 #define arch_error(x)
177 putstr("\n\n -- System halted");
182 asmlinkage void __div0(void)
184 error("Attempting division by 0!");
187 extern void do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x));
189 #ifndef STANDALONE_DEBUG
192 decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
193 unsigned long free_mem_ptr_end_p,
198 output_data = (unsigned char *)output_start;
199 free_mem_ptr = free_mem_ptr_p;
200 free_mem_end_ptr = free_mem_ptr_end_p;
201 __machine_arch_type = arch_id;
205 tmp = (unsigned char *) (((unsigned long)input_data_end) - 4);
206 output_ptr = get_unaligned_le32(tmp);
208 putstr("Uncompressing Linux...");
209 do_decompress(input_data, input_data_end - input_data,
211 putstr(" done, booting the kernel.\n");
216 char output_buffer[1500*1024];
220 output_data = output_buffer;
222 putstr("Uncompressing Linux...");
223 decompress(input_data, input_data_end - input_data,
224 NULL, NULL, output_data, NULL, error);