diff --git a/second/main.c b/second/main.c index 1e67a24..04fd4bf 100644 --- a/second/main.c +++ b/second/main.c @@ -40,11 +40,11 @@ extern unsigned long _ramdisk_offset; extern unsigned long _ramdisk_size; extern char _command_line; -unsigned long kernel_image_start; unsigned long ramdisk_start; int main(int argc, char** argv) { + unsigned long kernel_image_start; #ifdef TARGET_M68K char * kernel; unsigned long physImage; @@ -65,8 +65,6 @@ int main(int argc, char** argv) init_memory_map(); - bootinfo_init(); - /* load kernel */ printf("vmlinux %s\n", &_command_line); @@ -109,6 +107,7 @@ int main(int argc, char** argv) * and BI_ALLOC_SIZE for bootinfo */ + printf("Allocating %ld bytes for kernel\n", _kernel_size); kernel = (char*)malloc(_kernel_size + 4 + BI_ALLOC_SIZE); if (kernel == 0) { @@ -119,14 +118,12 @@ int main(int argc, char** argv) /* align kernel address to a 4 byte word */ kernel = (unsigned char*)(((unsigned long)kernel + 3) & 0xFFFFFFFC); - uncompress(kernel); - + uncompress(kernel, (char*)kernel_image_start); printf("\n"); } else { error("Kernel is missing !!!!\n"); - return 1; /* to make gcc happy */ } /* free kernel image */ @@ -161,6 +158,7 @@ int main(int argc, char** argv) /* set bootinfo at end of kernel image */ + bootinfo_init(); set_kernel_bootinfo(kernel + _kernel_size); /* disable interrupt */ diff --git a/second/uncompress.c b/second/uncompress.c index 26ae4a4..a6049a3 100644 --- a/second/uncompress.c +++ b/second/uncompress.c @@ -11,10 +11,6 @@ #include "uncompress.h" #include "misc.h" -unsigned long kernel_image_start; -unsigned long kernel_image_size; - - /* * gzip declarations */ @@ -33,11 +29,10 @@ static long bytes_out = 0; static uch *inbuf; /* input buffer */ static uch window[WSIZE]; /* Sliding window buffer */ -static unsigned insize; /* valid bytes in inbuf */ static unsigned inptr; /* index of next byte to be processed in inbuf */ static unsigned outcnt = 0; /* bytes in output buffer */ -#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) +#define get_byte() (inbuf[inptr++]) static uch *output_data; static unsigned long output_ptr = 0; @@ -51,14 +46,6 @@ static unsigned long output_ptr = 0; #define memzero(s, n) memset ((s), 0, (n)) -static int fill_inbuf(void) -{ - inbuf = (uch*)kernel_image_start; - insize = kernel_image_size; - inptr = 1; - return inbuf[0]; -} - static void gzip_mark(void **ptr) { } @@ -92,9 +79,11 @@ static void flush_window(void) console_put('.'); } -unsigned long uncompress(char* buf) +unsigned long uncompress(char* buf, char* image) { output_data = buf; + inbuf = (uch*)image; + inptr = 0; makecrc(); printf("Uncompressing kernel to %p", buf); diff --git a/second/uncompress.h b/second/uncompress.h index 58f7d56..a3b6e0e 100644 --- a/second/uncompress.h +++ b/second/uncompress.h @@ -4,4 +4,4 @@ * */ -extern unsigned long uncompress(char* buf); +extern unsigned long uncompress(char* buf, char* image);