aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-02-20 23:03:48 -0500
committerIngo Molnar <mingo@elte.hu>2008-04-17 11:40:49 -0400
commit1180e01de50c0c7683c6648251f32957bc2d7850 (patch)
tree5d37ceb6f2a8f73008a64c77b84ccff6e3a0a087 /arch/x86/boot
parentfd77c7cabd71ab0c31758f5faf1b92b66e9fe461 (diff)
x86: more cleanups in arch/x86/boot/compressed/misc.c
Before: total: 7 errors, 8 warnings, 471 lines checked After: total: 5 errors, 5 warnings, 479 lines checked ( the rest cannot be eliminated due to zlib interface cruftiness. ) No code changed: arch/x86/boot/compressed/misc.o: text data bss dec hex filename 10716 8 2152 12876 324c misc.o.before 10716 8 2152 12876 324c misc.o.after md5: 2c20c903986a3c9bca44306c6646067e misc.o.before.asm 2c20c903986a3c9bca44306c6646067e misc.o.after.asm Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/boot')
-rw-r--r--arch/x86/boot/compressed/misc.c100
1 files changed, 54 insertions, 46 deletions
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 50d054c29018..9470a050f8a4 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -58,8 +58,8 @@
58 * 1 bit (last block flag) 58 * 1 bit (last block flag)
59 * 2 bits (block type) 59 * 2 bits (block type)
60 * 60 *
61 * 1 block occurs every 32K -1 bytes or when there 50% compression has been achieved. 61 * 1 block occurs every 32K -1 bytes or when there 50% compression
62 * The smallest block type encoding is always used. 62 * has been achieved. The smallest block type encoding is always used.
63 * 63 *
64 * stored: 64 * stored:
65 * 32 bits length in bytes. 65 * 32 bits length in bytes.
@@ -95,9 +95,9 @@
95 * 95 *
96 * All of which is enough to compute an amount of extra data that is required 96 * All of which is enough to compute an amount of extra data that is required
97 * to be safe. To avoid problems at the block level allocating 5 extra bytes 97 * to be safe. To avoid problems at the block level allocating 5 extra bytes
98 * per 32767 bytes of data is sufficient. To avoind problems internal to a block 98 * per 32767 bytes of data is sufficient. To avoind problems internal to a
99 * adding an extra 32767 bytes (the worst case uncompressed block size) is 99 * block adding an extra 32767 bytes (the worst case uncompressed block size)
100 * sufficient, to ensure that in the worst case the decompressed data for 100 * is sufficient, to ensure that in the worst case the decompressed data for
101 * block will stop the byte before the compressed data for a block begins. 101 * block will stop the byte before the compressed data for a block begins.
102 * To avoid problems with the compressed data's meta information an extra 18 102 * To avoid problems with the compressed data's meta information an extra 18
103 * bytes are needed. Leading to the formula: 103 * bytes are needed. Leading to the formula:
@@ -116,52 +116,59 @@
116 * gzip declarations 116 * gzip declarations
117 */ 117 */
118 118
119#define OF(args) args 119#define OF(args) args
120#define STATIC static 120#define STATIC static
121 121
122#undef memset 122#undef memset
123#undef memcpy 123#undef memcpy
124#define memzero(s, n) memset ((s), 0, (n)) 124#define memzero(s, n) memset((s), 0, (n))
125 125
126typedef unsigned char uch; 126typedef unsigned char uch;
127typedef unsigned short ush; 127typedef unsigned short ush;
128typedef unsigned long ulg; 128typedef unsigned long ulg;
129 129
130#define WSIZE 0x80000000 /* 130/*
131 * Window size must be at least 32k, 131 * Window size must be at least 32k, and a power of two.
132 * and a power of two 132 * We don't actually have a window just a huge output buffer,
133 * We don't actually have a window just 133 * so we report a 2G window size, as that should always be
134 * a huge output buffer so I report 134 * larger than our output buffer:
135 * a 2G windows size, as that should 135 */
136 * always be larger than our output buffer. 136#define WSIZE 0x80000000
137 */ 137
138/* Input buffer: */
139static unsigned char *inbuf;
140
141/* Sliding window buffer (and final output buffer): */
142static unsigned char *window;
143
144/* Valid bytes in inbuf: */
145static unsigned insize;
138 146
139static uch *inbuf; /* input buffer */ 147/* Index of next byte to be processed in inbuf: */
140static uch *window; /* Sliding window buffer, (and final output buffer) */ 148static unsigned inptr;
141 149
142static unsigned insize; /* valid bytes in inbuf */ 150/* Bytes in output buffer: */
143static unsigned inptr; /* index of next byte to be processed in inbuf */ 151static unsigned outcnt;
144static unsigned outcnt; /* bytes in output buffer */
145 152
146/* gzip flag byte */ 153/* gzip flag byte */
147#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */ 154#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
148#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ 155#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gz file */
149#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ 156#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
150#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ 157#define ORIG_NAM 0x08 /* bit 3 set: original file name present */
151#define COMMENT 0x10 /* bit 4 set: file comment present */ 158#define COMMENT 0x10 /* bit 4 set: file comment present */
152#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ 159#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
153#define RESERVED 0xC0 /* bit 6,7: reserved */ 160#define RESERVED 0xC0 /* bit 6, 7: reserved */
154 161
155#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) 162#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
156 163
157/* Diagnostic functions */ 164/* Diagnostic functions */
158#ifdef DEBUG 165#ifdef DEBUG
159# define Assert(cond, msg) {if(!(cond)) error(msg); } 166# define Assert(cond, msg) do { if (!(cond)) error(msg); } while (0)
160# define Trace(x) fprintf x 167# define Trace(x) do { fprintf x; } while (0)
161# define Tracev(x) {if (verbose) fprintf x ; } 168# define Tracev(x) do { if (verbose) fprintf x ; } while (0)
162# define Tracevv(x) {if (verbose > 1) fprintf x ; } 169# define Tracevv(x) do { if (verbose > 1) fprintf x ; } while (0)
163# define Tracec(c, x) {if (verbose && (c)) fprintf x ; } 170# define Tracec(c, x) do { if (verbose && (c)) fprintf x ; } while (0)
164# define Tracecv(c, x) {if (verbose > 1 && (c)) fprintf x ; } 171# define Tracecv(c, x) do { if (verbose > 1 && (c)) fprintf x ; } while (0)
165#else 172#else
166# define Assert(cond, msg) 173# define Assert(cond, msg)
167# define Trace(x) 174# define Trace(x)
@@ -349,9 +356,9 @@ static void flush_window(void)
349 /* With my window equal to my output buffer 356 /* With my window equal to my output buffer
350 * I only need to compute the crc here. 357 * I only need to compute the crc here.
351 */ 358 */
352 ulg c = crc; /* temporary variable */ 359 unsigned long c = crc; /* temporary variable */
353 unsigned n; 360 unsigned n;
354 uch *in, ch; 361 unsigned char *in, ch;
355 362
356 in = window; 363 in = window;
357 for (n = 0; n < outcnt; n++) { 364 for (n = 0; n < outcnt; n++) {
@@ -359,7 +366,7 @@ static void flush_window(void)
359 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); 366 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
360 } 367 }
361 crc = c; 368 crc = c;
362 bytes_out += (ulg)outcnt; 369 bytes_out += (unsigned long)outcnt;
363 outcnt = 0; 370 outcnt = 0;
364} 371}
365 372
@@ -423,8 +430,9 @@ static void parse_elf(void *output)
423} 430}
424 431
425asmlinkage void decompress_kernel(void *rmode, memptr heap, 432asmlinkage void decompress_kernel(void *rmode, memptr heap,
426 uch *input_data, unsigned long input_len, 433 unsigned char *input_data,
427 uch *output) 434 unsigned long input_len,
435 unsigned char *output)
428{ 436{
429 real_mode = rmode; 437 real_mode = rmode;
430 438
@@ -447,12 +455,12 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
447 inptr = 0; 455 inptr = 0;
448 456
449#ifdef CONFIG_X86_64 457#ifdef CONFIG_X86_64
450 if ((ulg)output & (__KERNEL_ALIGN - 1)) 458 if ((unsigned long)output & (__KERNEL_ALIGN - 1))
451 error("Destination address not 2M aligned"); 459 error("Destination address not 2M aligned");
452 if ((ulg)output >= 0xffffffffffUL) 460 if ((unsigned long)output >= 0xffffffffffUL)
453 error("Destination address too large"); 461 error("Destination address too large");
454#else 462#else
455 if ((u32)output & (CONFIG_PHYSICAL_ALIGN -1)) 463 if ((u32)output & (CONFIG_PHYSICAL_ALIGN - 1))
456 error("Destination address not CONFIG_PHYSICAL_ALIGN aligned"); 464 error("Destination address not CONFIG_PHYSICAL_ALIGN aligned");
457 if (heap > ((-__PAGE_OFFSET-(512<<20)-1) & 0x7fffffff)) 465 if (heap > ((-__PAGE_OFFSET-(512<<20)-1) & 0x7fffffff))
458 error("Destination address too large"); 466 error("Destination address too large");