x86, efi: Set runtime_version to the EFI spec revision
[linux/fpc-iii.git] / arch / arm / boot / compressed / misc.c
blobdf899834d84ed688a8e77e90e0b584789aba6243
1 /*
2 * misc.c
3 *
4 * This is a collection of several routines from gzip-1.0.3
5 * adapted for Linux.
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) {}
32 #else
33 #include <mach/uncompress.h>
34 #endif
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;
44 do {
45 if (--i < 0)
46 return;
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;
61 do {
62 if (--i < 0)
63 return;
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));
71 #else
73 static void icedcc_putc(int ch)
75 int status, i = 0x4000000;
77 do {
78 if (--i < 0)
79 return;
81 asm volatile ("mrc p14, 0, %0, c0, c0, 0" : "=r" (status));
82 } while (status & 2);
84 asm("mcr p14, 0, %0, c1, c0, 0" : : "r" (ch));
87 #endif
89 #define putc(ch) icedcc_putc(ch)
90 #endif
92 static void putstr(const char *ptr)
94 char c;
96 while ((c = *ptr++) != '\0') {
97 if (c == '\n')
98 putc('\r');
99 putc(c);
102 flush();
106 * gzip declarations
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;
116 #ifndef arch_error
117 #define arch_error(x)
118 #endif
120 void error(char *x)
122 arch_error(x);
124 putstr("\n\n");
125 putstr(x);
126 putstr("\n\n -- System halted");
128 while(1); /* Halt */
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));
139 void
140 decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
141 unsigned long free_mem_ptr_end_p,
142 int arch_id)
144 int ret;
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;
151 arch_decomp_setup();
153 putstr("Uncompressing Linux...");
154 ret = do_decompress(input_data, input_data_end - input_data,
155 output_data, error);
156 if (ret)
157 error("decompressor returned an error");
158 else
159 putstr(" done, booting the kernel.\n");