aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v10/boot/compressed/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/cris/arch-v10/boot/compressed/misc.c')
-rw-r--r--arch/cris/arch-v10/boot/compressed/misc.c144
1 files changed, 77 insertions, 67 deletions
diff --git a/arch/cris/arch-v10/boot/compressed/misc.c b/arch/cris/arch-v10/boot/compressed/misc.c
index 9a43ab19391..18e13bce140 100644
--- a/arch/cris/arch-v10/boot/compressed/misc.c
+++ b/arch/cris/arch-v10/boot/compressed/misc.c
@@ -29,12 +29,10 @@
29#define OF(args) args 29#define OF(args) args
30#define STATIC static 30#define STATIC static
31 31
32void* memset(void* s, int c, size_t n); 32void *memset(void *s, int c, size_t n);
33void* memcpy(void* __dest, __const void* __src, 33void *memcpy(void *__dest, __const void *__src, size_t __n);
34 size_t __n);
35
36#define memzero(s, n) memset ((s), 0, (n))
37 34
35#define memzero(s, n) memset((s), 0, (n))
38 36
39typedef unsigned char uch; 37typedef unsigned char uch;
40typedef unsigned short ush; 38typedef unsigned short ush;
@@ -62,57 +60,69 @@ static unsigned outcnt = 0; /* bytes in output buffer */
62#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ 60#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
63#define RESERVED 0xC0 /* bit 6,7: reserved */ 61#define RESERVED 0xC0 /* bit 6,7: reserved */
64 62
65#define get_byte() inbuf[inptr++] 63#define get_byte() (inbuf[inptr++])
66 64
67/* Diagnostic functions */ 65/* Diagnostic functions */
68#ifdef DEBUG 66#ifdef DEBUG
69# define Assert(cond,msg) {if(!(cond)) error(msg);} 67# define Assert(cond, msg) do { \
68 if (!(cond)) \
69 error(msg); \
70 } while (0)
70# define Trace(x) fprintf x 71# define Trace(x) fprintf x
71# define Tracev(x) {if (verbose) fprintf x ;} 72# define Tracev(x) do { \
72# define Tracevv(x) {if (verbose>1) fprintf x ;} 73 if (verbose) \
73# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} 74 fprintf x; \
74# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} 75 } while (0)
76# define Tracevv(x) do { \
77 if (verbose > 1) \
78 fprintf x; \
79 } while (0)
80# define Tracec(c, x) do { \
81 if (verbose && (c)) \
82 fprintf x; \
83 } while (0)
84# define Tracecv(c, x) do { \
85 if (verbose > 1 && (c)) \
86 fprintf x; \
87 } while (0)
75#else 88#else
76# define Assert(cond,msg) 89# define Assert(cond, msg)
77# define Trace(x) 90# define Trace(x)
78# define Tracev(x) 91# define Tracev(x)
79# define Tracevv(x) 92# define Tracevv(x)
80# define Tracec(c,x) 93# define Tracec(c, x)
81# define Tracecv(c,x) 94# define Tracecv(c, x)
82#endif 95#endif
83 96
84static int fill_inbuf(void);
85static void flush_window(void); 97static void flush_window(void);
86static void error(char *m); 98static void error(char *m);
87static void gzip_mark(void **);
88static void gzip_release(void **);
89 99
90extern char *input_data; /* lives in head.S */ 100extern char *input_data; /* lives in head.S */
91 101
92static long bytes_out = 0; 102static long bytes_out = 0;
93static uch *output_data; 103static uch *output_data;
94static unsigned long output_ptr = 0; 104static unsigned long output_ptr = 0;
95 105
96static void *malloc(int size); 106static void *malloc(int size);
97static void free(void *where); 107static void free(void *where);
98static void error(char *m);
99static void gzip_mark(void **); 108static void gzip_mark(void **);
100static void gzip_release(void **); 109static void gzip_release(void **);
101 110
102static void puts(const char *); 111static void puts(const char *);
103 112
104/* the "heap" is put directly after the BSS ends, at end */ 113/* the "heap" is put directly after the BSS ends, at end */
105 114
106extern int end; 115extern int _end;
107static long free_mem_ptr = (long)&end; 116static long free_mem_ptr = (long)&_end;
108 117
109#include "../../../../../lib/inflate.c" 118#include "../../../../../lib/inflate.c"
110 119
111static void *malloc(int size) 120static void *malloc(int size)
112{ 121{
113 void *p; 122 void *p;
114 123
115 if (size <0) error("Malloc error"); 124 if (size < 0)
125 error("Malloc error");
116 126
117 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */ 127 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
118 128
@@ -142,44 +152,47 @@ static void
142puts(const char *s) 152puts(const char *s)
143{ 153{
144#ifndef CONFIG_ETRAX_DEBUG_PORT_NULL 154#ifndef CONFIG_ETRAX_DEBUG_PORT_NULL
145 while(*s) { 155 while (*s) {
146#ifdef CONFIG_ETRAX_DEBUG_PORT0 156#ifdef CONFIG_ETRAX_DEBUG_PORT0
147 while(!(*R_SERIAL0_STATUS & (1 << 5))) ; 157 while (!(*R_SERIAL0_STATUS & (1 << 5))) ;
148 *R_SERIAL0_TR_DATA = *s++; 158 *R_SERIAL0_TR_DATA = *s++;
149#endif 159#endif
150#ifdef CONFIG_ETRAX_DEBUG_PORT1 160#ifdef CONFIG_ETRAX_DEBUG_PORT1
151 while(!(*R_SERIAL1_STATUS & (1 << 5))) ; 161 while (!(*R_SERIAL1_STATUS & (1 << 5))) ;
152 *R_SERIAL1_TR_DATA = *s++; 162 *R_SERIAL1_TR_DATA = *s++;
153#endif 163#endif
154#ifdef CONFIG_ETRAX_DEBUG_PORT2 164#ifdef CONFIG_ETRAX_DEBUG_PORT2
155 while(!(*R_SERIAL2_STATUS & (1 << 5))) ; 165 while (!(*R_SERIAL2_STATUS & (1 << 5))) ;
156 *R_SERIAL2_TR_DATA = *s++; 166 *R_SERIAL2_TR_DATA = *s++;
157#endif 167#endif
158#ifdef CONFIG_ETRAX_DEBUG_PORT3 168#ifdef CONFIG_ETRAX_DEBUG_PORT3
159 while(!(*R_SERIAL3_STATUS & (1 << 5))) ; 169 while (!(*R_SERIAL3_STATUS & (1 << 5))) ;
160 *R_SERIAL3_TR_DATA = *s++; 170 *R_SERIAL3_TR_DATA = *s++;
161#endif 171#endif
162 } 172 }
163#endif 173#endif
164} 174}
165 175
166void* 176void *memset(void *s, int c, size_t n)
167memset(void* s, int c, size_t n)
168{ 177{
169 int i; 178 int i;
170 char *ss = (char*)s; 179 char *ss = (char *)s;
180
181 for (i = 0; i < n; i++)
182 ss[i] = c;
171 183
172 for (i=0;i<n;i++) ss[i] = c; 184 return s;
173} 185}
174 186
175void* 187void *memcpy(void *__dest, __const void *__src, size_t __n)
176memcpy(void* __dest, __const void* __src,
177 size_t __n)
178{ 188{
179 int i; 189 int i;
180 char *d = (char *)__dest, *s = (char *)__src; 190 char *d = (char *)__dest, *s = (char *)__src;
181 191
182 for (i=0;i<__n;i++) d[i] = s[i]; 192 for (i = 0; i < __n; i++)
193 d[i] = s[i];
194
195 return __dest;
183} 196}
184 197
185/* =========================================================================== 198/* ===========================================================================
@@ -187,46 +200,44 @@ memcpy(void* __dest, __const void* __src,
187 * (Used for the decompressed data only.) 200 * (Used for the decompressed data only.)
188 */ 201 */
189 202
190static void 203static void flush_window(void)
191flush_window()
192{ 204{
193 ulg c = crc; /* temporary variable */ 205 ulg c = crc; /* temporary variable */
194 unsigned n; 206 unsigned n;
195 uch *in, *out, ch; 207 uch *in, *out, ch;
196 208
197 in = window; 209 in = window;
198 out = &output_data[output_ptr]; 210 out = &output_data[output_ptr];
199 for (n = 0; n < outcnt; n++) { 211 for (n = 0; n < outcnt; n++) {
200 ch = *out++ = *in++; 212 ch = *out = *in;
201 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); 213 out++;
202 } 214 in++;
203 crc = c; 215 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
204 bytes_out += (ulg)outcnt; 216 }
205 output_ptr += (ulg)outcnt; 217 crc = c;
206 outcnt = 0; 218 bytes_out += (ulg)outcnt;
219 output_ptr += (ulg)outcnt;
220 outcnt = 0;
207} 221}
208 222
209static void 223static void error(char *x)
210error(char *x)
211{ 224{
212 puts("\n\n"); 225 puts("\n\n");
213 puts(x); 226 puts(x);
214 puts("\n\n -- System halted\n"); 227 puts("\n\n -- System halted\n");
215 228
216 while(1); /* Halt */ 229 while (1); /* Halt */
217} 230}
218 231
219void 232void setup_normal_output_buffer(void)
220setup_normal_output_buffer()
221{ 233{
222 output_data = (char *)KERNEL_LOAD_ADR; 234 output_data = (char *)KERNEL_LOAD_ADR;
223} 235}
224 236
225void 237void decompress_kernel(void)
226decompress_kernel()
227{ 238{
228 char revision; 239 char revision;
229 240
230 /* input_data is set in head.S */ 241 /* input_data is set in head.S */
231 inbuf = input_data; 242 inbuf = input_data;
232 243
@@ -257,11 +268,10 @@ decompress_kernel()
257 268
258 makecrc(); 269 makecrc();
259 270
260 __asm__ volatile ("move vr,%0" : "=rm" (revision)); 271 __asm__ volatile ("move $vr,%0" : "=rm" (revision));
261 if (revision < 10) 272 if (revision < 10) {
262 {
263 puts("You need an ETRAX 100LX to run linux 2.6\n"); 273 puts("You need an ETRAX 100LX to run linux 2.6\n");
264 while(1); 274 while (1);
265 } 275 }
266 276
267 puts("Uncompressing Linux...\n"); 277 puts("Uncompressing Linux...\n");