diff options
Diffstat (limited to 'arch/cris/arch-v10/boot/compressed/misc.c')
-rw-r--r-- | arch/cris/arch-v10/boot/compressed/misc.c | 144 |
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 9a43ab19391e..18e13bce1400 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 | ||
32 | void* memset(void* s, int c, size_t n); | 32 | void *memset(void *s, int c, size_t n); |
33 | void* memcpy(void* __dest, __const void* __src, | 33 | void *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 | ||
39 | typedef unsigned char uch; | 37 | typedef unsigned char uch; |
40 | typedef unsigned short ush; | 38 | typedef 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 | ||
84 | static int fill_inbuf(void); | ||
85 | static void flush_window(void); | 97 | static void flush_window(void); |
86 | static void error(char *m); | 98 | static void error(char *m); |
87 | static void gzip_mark(void **); | ||
88 | static void gzip_release(void **); | ||
89 | 99 | ||
90 | extern char *input_data; /* lives in head.S */ | 100 | extern char *input_data; /* lives in head.S */ |
91 | 101 | ||
92 | static long bytes_out = 0; | 102 | static long bytes_out = 0; |
93 | static uch *output_data; | 103 | static uch *output_data; |
94 | static unsigned long output_ptr = 0; | 104 | static unsigned long output_ptr = 0; |
95 | 105 | ||
96 | static void *malloc(int size); | 106 | static void *malloc(int size); |
97 | static void free(void *where); | 107 | static void free(void *where); |
98 | static void error(char *m); | ||
99 | static void gzip_mark(void **); | 108 | static void gzip_mark(void **); |
100 | static void gzip_release(void **); | 109 | static void gzip_release(void **); |
101 | 110 | ||
102 | static void puts(const char *); | 111 | static 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 | ||
106 | extern int end; | 115 | extern int _end; |
107 | static long free_mem_ptr = (long)&end; | 116 | static long free_mem_ptr = (long)&_end; |
108 | 117 | ||
109 | #include "../../../../../lib/inflate.c" | 118 | #include "../../../../../lib/inflate.c" |
110 | 119 | ||
111 | static void *malloc(int size) | 120 | static 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 | |||
142 | puts(const char *s) | 152 | puts(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 | ||
166 | void* | 176 | void *memset(void *s, int c, size_t n) |
167 | memset(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 | ||
175 | void* | 187 | void *memcpy(void *__dest, __const void *__src, size_t __n) |
176 | memcpy(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 | ||
190 | static void | 203 | static void flush_window(void) |
191 | flush_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 | ||
209 | static void | 223 | static void error(char *x) |
210 | error(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 | ||
219 | void | 232 | void setup_normal_output_buffer(void) |
220 | setup_normal_output_buffer() | ||
221 | { | 233 | { |
222 | output_data = (char *)KERNEL_LOAD_ADR; | 234 | output_data = (char *)KERNEL_LOAD_ADR; |
223 | } | 235 | } |
224 | 236 | ||
225 | void | 237 | void decompress_kernel(void) |
226 | decompress_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"); |