1 // SPDX-License-Identifier: GPL-2.0
5 * This is a collection of several routines from gzip-1.0.3
8 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
10 * Modified for ARM Linux by Russell King
12 * Nicolas Pitre <nico@visuaide.com> 1999/04/14 :
13 * For this code to run directly from Flash, all constant variables must
14 * be marked with 'const' and all other variables initialized at run-time
15 * only. This way all non constant variables will end up in the bss segment,
16 * which should point to addresses in RAM and cleared to 0 on start.
17 * This allows for a much quicker boot time.
20 unsigned int __machine_arch_type;
22 #include <linux/compiler.h> /* for inline */
23 #include <linux/types.h>
24 #include <linux/linkage.h>
26 #include "misc-ep93xx.h"
28 static void putstr(const char *ptr);
30 #include CONFIG_UNCOMPRESS_INCLUDE
32 #ifdef CONFIG_DEBUG_ICEDCC
34 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
36 static void icedcc_putc(int ch)
38 int status, i = 0x4000000;
44 asm volatile ("mrc p14, 0, %0, c0, c1, 0" : "=r" (status));
45 } while (status & (1 << 29));
47 asm("mcr p14, 0, %0, c0, c5, 0" : : "r" (ch));
51 #elif defined(CONFIG_CPU_XSCALE)
53 static void icedcc_putc(int ch)
55 int status, i = 0x4000000;
61 asm volatile ("mrc p14, 0, %0, c14, c0, 0" : "=r" (status));
62 } while (status & (1 << 28));
64 asm("mcr p14, 0, %0, c8, c0, 0" : : "r" (ch));
69 static void icedcc_putc(int ch)
71 int status, i = 0x4000000;
77 asm volatile ("mrc p14, 0, %0, c0, c0, 0" : "=r" (status));
80 asm("mcr p14, 0, %0, c1, c0, 0" : : "r" (ch));
85 #define putc(ch) icedcc_putc(ch)
88 static void putstr(const char *ptr)
92 while ((c = *ptr++) != '\0') {
104 extern char input_data[];
105 extern char input_data_end[];
107 unsigned char *output_data;
109 unsigned long free_mem_ptr;
110 unsigned long free_mem_end_ptr;
113 #define arch_error(x)
122 putstr("\n\n -- System halted");
127 asmlinkage void __div0(void)
129 error("Attempting division by 0!");
132 extern int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x));
136 decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
137 unsigned long free_mem_ptr_end_p,
142 output_data = (unsigned char *)output_start;
143 free_mem_ptr = free_mem_ptr_p;
144 free_mem_end_ptr = free_mem_ptr_end_p;
145 __machine_arch_type = arch_id;
147 #ifdef CONFIG_ARCH_EP93XX
148 ep93xx_decomp_setup();
152 putstr("Uncompressing Linux...");
153 ret = do_decompress(input_data, input_data_end - input_data,
156 error("decompressor returned an error");
158 putstr(" done, booting the kernel.\n");
161 void fortify_panic(const char *name)
163 error("detected buffer overflow");