102 #define memzero(s, n) memset((s), 0, (n))
105 static void error(
char *
m);
118 #define memptr unsigned
126 static int lines,
cols;
128 #ifdef CONFIG_KERNEL_GZIP
129 #include "../../../../lib/decompress_inflate.c"
132 #ifdef CONFIG_KERNEL_BZIP2
133 #include "../../../../lib/decompress_bunzip2.c"
136 #ifdef CONFIG_KERNEL_LZMA
137 #include "../../../../lib/decompress_unlzma.c"
140 #ifdef CONFIG_KERNEL_XZ
141 #include "../../../../lib/decompress_unxz.c"
144 #ifdef CONFIG_KERNEL_LZO
145 #include "../../../../lib/decompress_unlzo.c"
148 static void scroll(
void)
153 for (i = (lines - 1) *
cols * 2; i < lines *
cols * 2; i += 2)
161 static void serial_putchar(
int ch)
180 serial_putchar(
'\r');
181 serial_putchar(*str++);
186 lines == 0 &&
cols == 0)
192 while ((c = *s++) !=
'\0') {
200 vidmem[(x +
cols *
y) * 2] = c;
214 pos = (x +
cols *
y) * 2;
216 outb(0xff & (pos >> 9), vidport+1);
218 outb(0xff & (pos >> 1), vidport+1);
226 for (i = 0; i <
n; i++)
238 :
"=&c" (
d0),
"=&D" (d1),
"=&S" (
d2)
239 :
"0" (n >> 2),
"g" (n & 3),
"1" (dest),
"2" (
src)
245 void *
memcpy(
void *dest,
const void *src,
size_t n)
252 :
"=&c" (
d0),
"=&D" (d1),
"=&S" (
d2)
253 :
"0" (n >> 3),
"g" (n & 7),
"1" (dest),
"2" (
src)
260 static void error(
char *
x)
270 static void parse_elf(
void *output)
282 memcpy(&ehdr, output,
sizeof(ehdr));
287 error(
"Kernel is not a valid ELF file");
291 debug_putstr(
"Parsing ELF... ");
295 error(
"Failed to allocate space for phdrs");
299 for (i = 0; i < ehdr.
e_phnum; i++) {
304 #ifdef CONFIG_RELOCATABLE
306 dest += (phdr->
p_paddr - LOAD_PHYSICAL_ADDR);
308 dest = (
void *)(phdr->
p_paddr);
322 unsigned char *input_data,
323 unsigned long input_len,
324 unsigned char *output)
329 vidmem = (
char *) 0xb0000;
332 vidmem = (
char *) 0xb8000;
340 debug_putstr(
"early console in decompress_kernel\n");
345 if ((
unsigned long)output & (MIN_KERNEL_ALIGN - 1))
346 error(
"Destination address inappropriately aligned");
348 if (heap > 0x3fffffffffffUL)
349 error(
"Destination address too large");
352 error(
"Destination address too large");
354 #ifndef CONFIG_RELOCATABLE
355 if ((
unsigned long)output != LOAD_PHYSICAL_ADDR)
356 error(
"Wrong destination address");
359 debug_putstr(
"\nDecompressing Linux... ");
362 debug_putstr(
"done.\nBooting the kernel.\n");