diff options
-rw-r--r-- | arch/x86/boot/compressed/misc.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 69aec2f4155d..50d054c29018 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c | |||
@@ -127,7 +127,8 @@ typedef unsigned char uch; | |||
127 | typedef unsigned short ush; | 127 | typedef unsigned short ush; |
128 | typedef unsigned long ulg; | 128 | typedef unsigned long ulg; |
129 | 129 | ||
130 | #define WSIZE 0x80000000 /* Window size must be at least 32k, | 130 | #define WSIZE 0x80000000 /* |
131 | * Window size must be at least 32k, | ||
131 | * and a power of two | 132 | * and a power of two |
132 | * We don't actually have a window just | 133 | * We don't actually have a window just |
133 | * a huge output buffer so I report | 134 | * a huge output buffer so I report |
@@ -152,22 +153,22 @@ static unsigned outcnt; /* bytes in output buffer */ | |||
152 | #define RESERVED 0xC0 /* bit 6,7: reserved */ | 153 | #define RESERVED 0xC0 /* bit 6,7: reserved */ |
153 | 154 | ||
154 | #define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) | 155 | #define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) |
155 | 156 | ||
156 | /* Diagnostic functions */ | 157 | /* Diagnostic functions */ |
157 | #ifdef DEBUG | 158 | #ifdef DEBUG |
158 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | 159 | # define Assert(cond, msg) {if(!(cond)) error(msg); } |
159 | # define Trace(x) fprintf x | 160 | # define Trace(x) fprintf x |
160 | # define Tracev(x) {if (verbose) fprintf x ;} | 161 | # define Tracev(x) {if (verbose) fprintf x ; } |
161 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | 162 | # define Tracevv(x) {if (verbose > 1) fprintf x ; } |
162 | # define Tracec(c,x) {if (verbose && (c)) fprintf x ;} | 163 | # define Tracec(c, x) {if (verbose && (c)) fprintf x ; } |
163 | # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} | 164 | # define Tracecv(c, x) {if (verbose > 1 && (c)) fprintf x ; } |
164 | #else | 165 | #else |
165 | # define Assert(cond,msg) | 166 | # define Assert(cond, msg) |
166 | # define Trace(x) | 167 | # define Trace(x) |
167 | # define Tracev(x) | 168 | # define Tracev(x) |
168 | # define Tracevv(x) | 169 | # define Tracevv(x) |
169 | # define Tracec(c,x) | 170 | # define Tracec(c, x) |
170 | # define Tracecv(c,x) | 171 | # define Tracecv(c, x) |
171 | #endif | 172 | #endif |
172 | 173 | ||
173 | static int fill_inbuf(void); | 174 | static int fill_inbuf(void); |
@@ -175,7 +176,7 @@ static void flush_window(void); | |||
175 | static void error(char *m); | 176 | static void error(char *m); |
176 | static void gzip_mark(void **); | 177 | static void gzip_mark(void **); |
177 | static void gzip_release(void **); | 178 | static void gzip_release(void **); |
178 | 179 | ||
179 | /* | 180 | /* |
180 | * This is set up by the setup-routine at boot-time | 181 | * This is set up by the setup-routine at boot-time |
181 | */ | 182 | */ |
@@ -190,7 +191,7 @@ static unsigned char *real_mode; /* Pointer to real-mode data */ | |||
190 | extern unsigned char input_data[]; | 191 | extern unsigned char input_data[]; |
191 | extern int input_len; | 192 | extern int input_len; |
192 | 193 | ||
193 | static long bytes_out = 0; | 194 | static long bytes_out; |
194 | 195 | ||
195 | static void *malloc(int size); | 196 | static void *malloc(int size); |
196 | static void free(void *where); | 197 | static void free(void *where); |
@@ -229,8 +230,10 @@ static void *malloc(int size) | |||
229 | { | 230 | { |
230 | void *p; | 231 | void *p; |
231 | 232 | ||
232 | if (size <0) error("Malloc error"); | 233 | if (size < 0) |
233 | if (free_mem_ptr <= 0) error("Memory error"); | 234 | error("Malloc error"); |
235 | if (free_mem_ptr <= 0) | ||
236 | error("Memory error"); | ||
234 | 237 | ||
235 | free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */ | 238 | free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */ |
236 | 239 | ||
@@ -256,19 +259,19 @@ static void gzip_release(void **ptr) | |||
256 | { | 259 | { |
257 | free_mem_ptr = (memptr) *ptr; | 260 | free_mem_ptr = (memptr) *ptr; |
258 | } | 261 | } |
259 | 262 | ||
260 | static void scroll(void) | 263 | static void scroll(void) |
261 | { | 264 | { |
262 | int i; | 265 | int i; |
263 | 266 | ||
264 | memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 ); | 267 | memcpy(vidmem, vidmem + cols * 2, (lines - 1) * cols * 2); |
265 | for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 ) | 268 | for (i = (lines - 1) * cols * 2; i < lines * cols * 2; i += 2) |
266 | vidmem[i] = ' '; | 269 | vidmem[i] = ' '; |
267 | } | 270 | } |
268 | 271 | ||
269 | static void putstr(const char *s) | 272 | static void putstr(const char *s) |
270 | { | 273 | { |
271 | int x,y,pos; | 274 | int x, y, pos; |
272 | char c; | 275 | char c; |
273 | 276 | ||
274 | #ifdef CONFIG_X86_32 | 277 | #ifdef CONFIG_X86_32 |
@@ -279,18 +282,18 @@ static void putstr(const char *s) | |||
279 | x = RM_SCREEN_INFO.orig_x; | 282 | x = RM_SCREEN_INFO.orig_x; |
280 | y = RM_SCREEN_INFO.orig_y; | 283 | y = RM_SCREEN_INFO.orig_y; |
281 | 284 | ||
282 | while ( ( c = *s++ ) != '\0' ) { | 285 | while ((c = *s++) != '\0') { |
283 | if ( c == '\n' ) { | 286 | if (c == '\n') { |
284 | x = 0; | 287 | x = 0; |
285 | if ( ++y >= lines ) { | 288 | if (++y >= lines) { |
286 | scroll(); | 289 | scroll(); |
287 | y--; | 290 | y--; |
288 | } | 291 | } |
289 | } else { | 292 | } else { |
290 | vidmem [(x + cols * y) * 2] = c; | 293 | vidmem [(x + cols * y) * 2] = c; |
291 | if ( ++x >= cols ) { | 294 | if (++x >= cols) { |
292 | x = 0; | 295 | x = 0; |
293 | if ( ++y >= lines ) { | 296 | if (++y >= lines) { |
294 | scroll(); | 297 | scroll(); |
295 | y--; | 298 | y--; |
296 | } | 299 | } |
@@ -308,22 +311,22 @@ static void putstr(const char *s) | |||
308 | outb(0xff & (pos >> 1), vidport+1); | 311 | outb(0xff & (pos >> 1), vidport+1); |
309 | } | 312 | } |
310 | 313 | ||
311 | static void* memset(void* s, int c, unsigned n) | 314 | static void *memset(void *s, int c, unsigned n) |
312 | { | 315 | { |
313 | int i; | 316 | int i; |
314 | char *ss = s; | 317 | char *ss = s; |
315 | 318 | ||
316 | for (i=0;i<n;i++) ss[i] = c; | 319 | for (i = 0; i < n; i++) ss[i] = c; |
317 | return s; | 320 | return s; |
318 | } | 321 | } |
319 | 322 | ||
320 | static void* memcpy(void* dest, const void* src, unsigned n) | 323 | static void *memcpy(void *dest, const void *src, unsigned n) |
321 | { | 324 | { |
322 | int i; | 325 | int i; |
323 | const char *s = src; | 326 | const char *s = src; |
324 | char *d = dest; | 327 | char *d = dest; |
325 | 328 | ||
326 | for (i=0;i<n;i++) d[i] = s[i]; | 329 | for (i = 0; i < n; i++) d[i] = s[i]; |
327 | return dest; | 330 | return dest; |
328 | } | 331 | } |
329 | 332 | ||
@@ -383,11 +386,10 @@ static void parse_elf(void *output) | |||
383 | int i; | 386 | int i; |
384 | 387 | ||
385 | memcpy(&ehdr, output, sizeof(ehdr)); | 388 | memcpy(&ehdr, output, sizeof(ehdr)); |
386 | if(ehdr.e_ident[EI_MAG0] != ELFMAG0 || | 389 | if (ehdr.e_ident[EI_MAG0] != ELFMAG0 || |
387 | ehdr.e_ident[EI_MAG1] != ELFMAG1 || | 390 | ehdr.e_ident[EI_MAG1] != ELFMAG1 || |
388 | ehdr.e_ident[EI_MAG2] != ELFMAG2 || | 391 | ehdr.e_ident[EI_MAG2] != ELFMAG2 || |
389 | ehdr.e_ident[EI_MAG3] != ELFMAG3) | 392 | ehdr.e_ident[EI_MAG3] != ELFMAG3) { |
390 | { | ||
391 | error("Kernel is not a valid ELF file"); | 393 | error("Kernel is not a valid ELF file"); |
392 | return; | 394 | return; |
393 | } | 395 | } |
@@ -400,7 +402,7 @@ static void parse_elf(void *output) | |||
400 | 402 | ||
401 | memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); | 403 | memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); |
402 | 404 | ||
403 | for (i=0; i<ehdr.e_phnum; i++) { | 405 | for (i = 0; i < ehdr.e_phnum; i++) { |
404 | phdr = &phdrs[i]; | 406 | phdr = &phdrs[i]; |
405 | 407 | ||
406 | switch (phdr->p_type) { | 408 | switch (phdr->p_type) { |
@@ -409,7 +411,7 @@ static void parse_elf(void *output) | |||
409 | dest = output; | 411 | dest = output; |
410 | dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR); | 412 | dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR); |
411 | #else | 413 | #else |
412 | dest = (void*)(phdr->p_paddr); | 414 | dest = (void *)(phdr->p_paddr); |
413 | #endif | 415 | #endif |
414 | memcpy(dest, | 416 | memcpy(dest, |
415 | output + phdr->p_offset, | 417 | output + phdr->p_offset, |