2 * arch/sh/boot/compressed/misc.c
4 * This is a collection of several routines from gzip-1.0.3
7 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
9 * Adapted for SH by Stuart Menefy, Aug 1999
11 * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
14 #include <asm/uaccess.h>
15 #include <asm/addrspace.h>
17 #include <asm/sh_bios.h>
27 #define memzero(s, n) memset ((s), 0, (n))
30 #define CACHE_ENABLE 0
31 #define CACHE_DISABLE 1
32 int cache_control(unsigned int command);
34 extern char input_data[];
36 static unsigned char *output;
38 static void error(char *m);
40 int puts(const char *);
42 extern int _text; /* Defined in vmlinux.lds.S */
44 static unsigned long free_mem_ptr;
45 static unsigned long free_mem_end_ptr;
47 #ifdef CONFIG_HAVE_KERNEL_BZIP2
48 #define HEAP_SIZE 0x400000
50 #define HEAP_SIZE 0x10000
53 #ifdef CONFIG_KERNEL_GZIP
54 #include "../../../../lib/decompress_inflate.c"
57 #ifdef CONFIG_KERNEL_BZIP2
58 #include "../../../../lib/decompress_bunzip2.c"
61 #ifdef CONFIG_KERNEL_LZMA
62 #include "../../../../lib/decompress_unlzma.c"
65 #ifdef CONFIG_SH_STANDARD_BIOS
66 size_t strlen(const char *s)
75 int puts(const char *s)
78 sh_bios_console_write(s, len);
82 int puts(const char *s)
84 /* This should be updated to use the sh-sci routines */
89 void* memset(void* s, int c, size_t n)
94 for (i=0;i<n;i++) ss[i] = c;
98 void* memcpy(void* __dest, __const void* __src,
102 char *d = (char *)__dest, *s = (char *)__src;
104 for (i=0;i<__n;i++) d[i] = s[i];
108 static void error(char *x)
112 puts("\n\n -- System halted");
117 #ifdef CONFIG_SUPERH64
123 #define STACK_SIZE (4096)
124 long __attribute__ ((aligned(stackalign))) user_stack[STACK_SIZE];
125 long *stack_start = &user_stack[STACK_SIZE];
127 void decompress_kernel(void)
129 unsigned long output_addr;
131 #ifdef CONFIG_SUPERH64
132 output_addr = (CONFIG_MEMORY_START + 0x2000);
134 output_addr = __pa((unsigned long)&_text+PAGE_SIZE);
136 output_addr |= P2SEG;
140 output = (unsigned char *)output_addr;
141 free_mem_ptr = (unsigned long)&_end;
142 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
144 puts("Uncompressing Linux... ");
145 cache_control(CACHE_ENABLE);
146 decompress(input_data, input_len, NULL, NULL, output, NULL, error);
147 cache_control(CACHE_DISABLE);
148 puts("Ok, booting the kernel.\n");