This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / arch / m32r / boot / compressed / misc.c
index 70fa799..4661d38 100644 (file)
@@ -8,6 +8,8 @@
  *
  * Adapted for SH by Stuart Menefy, Aug 1999
  *
+ * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
+ *
  * 2003-02-12: Support M32R by Takeo Takahashi
  *             This is based on arch/sh/boot/compressed/misc.c.
  */
@@ -36,9 +38,9 @@ typedef unsigned long  ulg;
 static uch *inbuf;          /* input buffer */
 static uch window[WSIZE];    /* Sliding window buffer */
 
-static unsigned insize = 0;  /* valid bytes in inbuf */
-static unsigned inptr = 0;   /* index of next byte to be processed in inbuf */
-static unsigned outcnt = 0;  /* bytes in output buffer */
+static unsigned insize;  /* valid bytes in inbuf */
+static unsigned inptr;   /* index of next byte to be processed in inbuf */
+static unsigned outcnt;  /* bytes in output buffer */
 
 /* gzip flag byte */
 #define ASCII_FLAG   0x01 /* bit 0 set: file probably ASCII text */
@@ -74,18 +76,24 @@ static void error(char *m);
 static void gzip_mark(void **);
 static void gzip_release(void **);
 
-static unsigned char *input_data;
-static int input_len;
+extern char input_data[];
+extern int input_len;
 
-static long bytes_out = 0;
+static long bytes_out;
 static uch *output_data;
-static unsigned long output_ptr = 0;
+static unsigned long output_ptr;
 
-#include "m32r_sio.c"
 
 static void *malloc(int size);
 static void free(void *where);
+static void error(char *m);
+static void gzip_mark(void **);
+static void gzip_release(void **);
+
+extern int puts(const char *);
 
+extern int _text;              /* Defined in vmlinux.lds.S */
+extern int _end;
 static unsigned long free_mem_ptr;
 static unsigned long free_mem_end_ptr;
 
@@ -97,8 +105,8 @@ static void *malloc(int size)
 {
        void *p;
 
-       if (size <0) error("Malloc error");
-       if (free_mem_ptr == 0) error("Memory error");
+       if (size <0) error("Malloc error\n");
+       if (free_mem_ptr == 0) error("Memory error\n");
 
        free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
 
@@ -106,7 +114,7 @@ static void *malloc(int size)
        free_mem_ptr += size;
 
        if (free_mem_ptr >= free_mem_end_ptr)
-               error("Out of memory");
+               error("\nOut of memory\n");
 
        return p;
 }
@@ -151,7 +159,7 @@ void* memcpy(void* __dest, __const void* __src,
 static int fill_inbuf(void)
 {
        if (insize != 0) {
-               error("ran out of input data");
+               error("ran out of input data\n");
        }
 
        inbuf = input_data;
@@ -191,20 +199,25 @@ static void error(char *x)
        while(1);       /* Halt */
 }
 
+#define STACK_SIZE (4096)
+long user_stack [STACK_SIZE];
+long* stack_start = &user_stack[STACK_SIZE];
+
 /* return decompressed size */
-void
-decompress_kernel(int mmu_on, unsigned char *zimage_data,
-                 unsigned int zimage_len, unsigned long heap)
+long decompress_kernel(void)
 {
-       output_data = (unsigned char *)CONFIG_MEMORY_START + 0x2000
-               + (mmu_on ? 0x80000000 : 0);
-       free_mem_ptr = heap;
+       insize = 0;
+       inptr = 0;
+       bytes_out = 0;
+       outcnt = 0;
+       output_data = 0;
+       output_ptr = CONFIG_MEMORY_START + 0x2000;
+       free_mem_ptr = (unsigned long)&_end;
        free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
-       input_data = zimage_data;
-       input_len = zimage_len;
 
        makecrc();
        puts("Uncompressing Linux... ");
        gunzip();
        puts("Ok, booting the kernel.\n");
+       return bytes_out;
 }