2 * arch/sh/boot/compressed/misc_64.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 SHmedia from sh by Stuart Menefy, May 2002
12 #include <asm/uaccess.h>
15 #define CACHE_ENABLE 0
16 #define CACHE_DISABLE 1
17 int cache_control(unsigned int command
);
27 #define memzero(s, n) memset ((s), 0, (n))
29 static void error(char *m
);
31 extern char input_data
[];
34 static unsigned char *output_data
;
36 static void puts(const char *);
38 extern int _text
; /* Defined in vmlinux.lds.S */
40 static unsigned long free_mem_ptr
;
41 static unsigned long free_mem_end_ptr
;
43 #ifdef CONFIG_HAVE_KERNEL_BZIP2
44 #define HEAP_SIZE 0x400000
46 #define HEAP_SIZE 0x10000
49 #ifdef CONFIG_KERNEL_GZIP
50 #include "../../../../lib/decompress_inflate.c"
53 #ifdef CONFIG_KERNEL_BZIP2
54 #include "../../../../lib/decompress_bunzip2.c"
57 #ifdef CONFIG_KERNEL_LZMA
58 #include "../../../../lib/decompress_unlzma.c"
61 void puts(const char *s
)
65 void *memset(void *s
, int c
, size_t n
)
68 char *ss
= (char *) s
;
70 for (i
= 0; i
< n
; i
++)
75 void *memcpy(void *__dest
, __const
void *__src
, size_t __n
)
78 char *d
= (char *) __dest
, *s
= (char *) __src
;
80 for (i
= 0; i
< __n
; i
++)
85 static void error(char *x
)
89 puts("\n\n -- System halted");
91 while (1) ; /* Halt */
94 #define STACK_SIZE (4096)
95 long __attribute__ ((aligned(8))) user_stack
[STACK_SIZE
];
96 long *stack_start
= &user_stack
[STACK_SIZE
];
98 void decompress_kernel(void)
100 output_data
= (unsigned char *) (CONFIG_MEMORY_START
+ 0x2000);
101 free_mem_ptr
= (unsigned long) &_end
;
102 free_mem_end_ptr
= free_mem_ptr
+ HEAP_SIZE
;
104 puts("Uncompressing Linux... ");
105 cache_control(CACHE_ENABLE
);
106 decompress(input_data
, input_len
, NULL
, NULL
, output_data
, NULL
, error
);
107 cache_control(CACHE_DISABLE
);
108 puts("Ok, booting the kernel.\n");