diff options
Diffstat (limited to 'arch/x86/boot/compressed/misc.c')
-rw-r--r-- | arch/x86/boot/compressed/misc.c | 118 |
1 files changed, 14 insertions, 104 deletions
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index da062216948a..e45be73684ff 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c | |||
@@ -116,71 +116,13 @@ | |||
116 | /* | 116 | /* |
117 | * gzip declarations | 117 | * gzip declarations |
118 | */ | 118 | */ |
119 | |||
120 | #define OF(args) args | ||
121 | #define STATIC static | 119 | #define STATIC static |
122 | 120 | ||
123 | #undef memset | 121 | #undef memset |
124 | #undef memcpy | 122 | #undef memcpy |
125 | #define memzero(s, n) memset((s), 0, (n)) | 123 | #define memzero(s, n) memset((s), 0, (n)) |
126 | 124 | ||
127 | typedef unsigned char uch; | ||
128 | typedef unsigned short ush; | ||
129 | typedef unsigned long ulg; | ||
130 | |||
131 | /* | ||
132 | * Window size must be at least 32k, and a power of two. | ||
133 | * We don't actually have a window just a huge output buffer, | ||
134 | * so we report a 2G window size, as that should always be | ||
135 | * larger than our output buffer: | ||
136 | */ | ||
137 | #define WSIZE 0x80000000 | ||
138 | |||
139 | /* Input buffer: */ | ||
140 | static unsigned char *inbuf; | ||
141 | |||
142 | /* Sliding window buffer (and final output buffer): */ | ||
143 | static unsigned char *window; | ||
144 | |||
145 | /* Valid bytes in inbuf: */ | ||
146 | static unsigned insize; | ||
147 | |||
148 | /* Index of next byte to be processed in inbuf: */ | ||
149 | static unsigned inptr; | ||
150 | |||
151 | /* Bytes in output buffer: */ | ||
152 | static unsigned outcnt; | ||
153 | |||
154 | /* gzip flag byte */ | ||
155 | #define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */ | ||
156 | #define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gz file */ | ||
157 | #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ | ||
158 | #define ORIG_NAM 0x08 /* bit 3 set: original file name present */ | ||
159 | #define COMMENT 0x10 /* bit 4 set: file comment present */ | ||
160 | #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ | ||
161 | #define RESERVED 0xC0 /* bit 6, 7: reserved */ | ||
162 | |||
163 | #define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) | ||
164 | |||
165 | /* Diagnostic functions */ | ||
166 | #ifdef DEBUG | ||
167 | # define Assert(cond, msg) do { if (!(cond)) error(msg); } while (0) | ||
168 | # define Trace(x) do { fprintf x; } while (0) | ||
169 | # define Tracev(x) do { if (verbose) fprintf x ; } while (0) | ||
170 | # define Tracevv(x) do { if (verbose > 1) fprintf x ; } while (0) | ||
171 | # define Tracec(c, x) do { if (verbose && (c)) fprintf x ; } while (0) | ||
172 | # define Tracecv(c, x) do { if (verbose > 1 && (c)) fprintf x ; } while (0) | ||
173 | #else | ||
174 | # define Assert(cond, msg) | ||
175 | # define Trace(x) | ||
176 | # define Tracev(x) | ||
177 | # define Tracevv(x) | ||
178 | # define Tracec(c, x) | ||
179 | # define Tracecv(c, x) | ||
180 | #endif | ||
181 | 125 | ||
182 | static int fill_inbuf(void); | ||
183 | static void flush_window(void); | ||
184 | static void error(char *m); | 126 | static void error(char *m); |
185 | 127 | ||
186 | /* | 128 | /* |
@@ -189,13 +131,8 @@ static void error(char *m); | |||
189 | static struct boot_params *real_mode; /* Pointer to real-mode data */ | 131 | static struct boot_params *real_mode; /* Pointer to real-mode data */ |
190 | static int quiet; | 132 | static int quiet; |
191 | 133 | ||
192 | extern unsigned char input_data[]; | ||
193 | extern int input_len; | ||
194 | |||
195 | static long bytes_out; | ||
196 | |||
197 | static void *memset(void *s, int c, unsigned n); | 134 | static void *memset(void *s, int c, unsigned n); |
198 | static void *memcpy(void *dest, const void *src, unsigned n); | 135 | void *memcpy(void *dest, const void *src, unsigned n); |
199 | 136 | ||
200 | static void __putstr(int, const char *); | 137 | static void __putstr(int, const char *); |
201 | #define putstr(__x) __putstr(0, __x) | 138 | #define putstr(__x) __putstr(0, __x) |
@@ -213,7 +150,17 @@ static char *vidmem; | |||
213 | static int vidport; | 150 | static int vidport; |
214 | static int lines, cols; | 151 | static int lines, cols; |
215 | 152 | ||
216 | #include "../../../../lib/inflate.c" | 153 | #ifdef CONFIG_KERNEL_GZIP |
154 | #include "../../../../lib/decompress_inflate.c" | ||
155 | #endif | ||
156 | |||
157 | #ifdef CONFIG_KERNEL_BZIP2 | ||
158 | #include "../../../../lib/decompress_bunzip2.c" | ||
159 | #endif | ||
160 | |||
161 | #ifdef CONFIG_KERNEL_LZMA | ||
162 | #include "../../../../lib/decompress_unlzma.c" | ||
163 | #endif | ||
217 | 164 | ||
218 | static void scroll(void) | 165 | static void scroll(void) |
219 | { | 166 | { |
@@ -282,7 +229,7 @@ static void *memset(void *s, int c, unsigned n) | |||
282 | return s; | 229 | return s; |
283 | } | 230 | } |
284 | 231 | ||
285 | static void *memcpy(void *dest, const void *src, unsigned n) | 232 | void *memcpy(void *dest, const void *src, unsigned n) |
286 | { | 233 | { |
287 | int i; | 234 | int i; |
288 | const char *s = src; | 235 | const char *s = src; |
@@ -293,38 +240,6 @@ static void *memcpy(void *dest, const void *src, unsigned n) | |||
293 | return dest; | 240 | return dest; |
294 | } | 241 | } |
295 | 242 | ||
296 | /* =========================================================================== | ||
297 | * Fill the input buffer. This is called only when the buffer is empty | ||
298 | * and at least one byte is really needed. | ||
299 | */ | ||
300 | static int fill_inbuf(void) | ||
301 | { | ||
302 | error("ran out of input data"); | ||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | /* =========================================================================== | ||
307 | * Write the output window window[0..outcnt-1] and update crc and bytes_out. | ||
308 | * (Used for the decompressed data only.) | ||
309 | */ | ||
310 | static void flush_window(void) | ||
311 | { | ||
312 | /* With my window equal to my output buffer | ||
313 | * I only need to compute the crc here. | ||
314 | */ | ||
315 | unsigned long c = crc; /* temporary variable */ | ||
316 | unsigned n; | ||
317 | unsigned char *in, ch; | ||
318 | |||
319 | in = window; | ||
320 | for (n = 0; n < outcnt; n++) { | ||
321 | ch = *in++; | ||
322 | c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); | ||
323 | } | ||
324 | crc = c; | ||
325 | bytes_out += (unsigned long)outcnt; | ||
326 | outcnt = 0; | ||
327 | } | ||
328 | 243 | ||
329 | static void error(char *x) | 244 | static void error(char *x) |
330 | { | 245 | { |
@@ -407,12 +322,8 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, | |||
407 | lines = real_mode->screen_info.orig_video_lines; | 322 | lines = real_mode->screen_info.orig_video_lines; |
408 | cols = real_mode->screen_info.orig_video_cols; | 323 | cols = real_mode->screen_info.orig_video_cols; |
409 | 324 | ||
410 | window = output; /* Output buffer (Normally at 1M) */ | ||
411 | free_mem_ptr = heap; /* Heap */ | 325 | free_mem_ptr = heap; /* Heap */ |
412 | free_mem_end_ptr = heap + BOOT_HEAP_SIZE; | 326 | free_mem_end_ptr = heap + BOOT_HEAP_SIZE; |
413 | inbuf = input_data; /* Input buffer */ | ||
414 | insize = input_len; | ||
415 | inptr = 0; | ||
416 | 327 | ||
417 | #ifdef CONFIG_X86_64 | 328 | #ifdef CONFIG_X86_64 |
418 | if ((unsigned long)output & (__KERNEL_ALIGN - 1)) | 329 | if ((unsigned long)output & (__KERNEL_ALIGN - 1)) |
@@ -430,10 +341,9 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, | |||
430 | #endif | 341 | #endif |
431 | #endif | 342 | #endif |
432 | 343 | ||
433 | makecrc(); | ||
434 | if (!quiet) | 344 | if (!quiet) |
435 | putstr("\nDecompressing Linux... "); | 345 | putstr("\nDecompressing Linux... "); |
436 | gunzip(); | 346 | decompress(input_data, input_len, NULL, NULL, output, NULL, error); |
437 | parse_elf(output); | 347 | parse_elf(output); |
438 | if (!quiet) | 348 | if (!quiet) |
439 | putstr("done.\nBooting the kernel.\n"); | 349 | putstr("done.\nBooting the kernel.\n"); |