aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boot/compressed/misc_64.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boot/compressed/misc_64.c')
-rw-r--r--arch/sh/boot/compressed/misc_64.c127
1 files changed, 7 insertions, 120 deletions
diff --git a/arch/sh/boot/compressed/misc_64.c b/arch/sh/boot/compressed/misc_64.c
index 2941657e18a..0c6894e3711 100644
--- a/arch/sh/boot/compressed/misc_64.c
+++ b/arch/sh/boot/compressed/misc_64.c
@@ -20,67 +20,18 @@ int cache_control(unsigned int command);
20 * gzip declarations 20 * gzip declarations
21 */ 21 */
22 22
23#define OF(args) args
24#define STATIC static 23#define STATIC static
25 24
26#undef memset 25#undef memset
27#undef memcpy 26#undef memcpy
28#define memzero(s, n) memset ((s), 0, (n)) 27#define memzero(s, n) memset ((s), 0, (n))
29 28
30typedef unsigned char uch;
31typedef unsigned short ush;
32typedef unsigned long ulg;
33
34#define WSIZE 0x8000 /* Window size must be at least 32k, */
35 /* and a power of two */
36
37static uch *inbuf; /* input buffer */
38static uch window[WSIZE]; /* Sliding window buffer */
39
40static unsigned insize = 0; /* valid bytes in inbuf */
41static unsigned inptr = 0; /* index of next byte to be processed in inbuf */
42static unsigned outcnt = 0; /* bytes in output buffer */
43
44/* gzip flag byte */
45#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
46#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
47#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
48#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
49#define COMMENT 0x10 /* bit 4 set: file comment present */
50#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
51#define RESERVED 0xC0 /* bit 6,7: reserved */
52
53#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
54
55/* Diagnostic functions */
56#ifdef DEBUG
57# define Assert(cond,msg) {if(!(cond)) error(msg);}
58# define Trace(x) fprintf x
59# define Tracev(x) {if (verbose) fprintf x ;}
60# define Tracevv(x) {if (verbose>1) fprintf x ;}
61# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
62# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
63#else
64# define Assert(cond,msg)
65# define Trace(x)
66# define Tracev(x)
67# define Tracevv(x)
68# define Tracec(c,x)
69# define Tracecv(c,x)
70#endif
71
72static int fill_inbuf(void);
73static void flush_window(void);
74static void error(char *m); 29static void error(char *m);
75 30
76extern char input_data[]; 31extern char input_data[];
77extern int input_len; 32extern int input_len;
78 33
79static long bytes_out = 0; 34static unsigned char *output_data;
80static uch *output_data;
81static unsigned long output_ptr = 0;
82
83static void error(char *m);
84 35
85static void puts(const char *); 36static void puts(const char *);
86 37
@@ -91,7 +42,9 @@ static unsigned long free_mem_end_ptr;
91 42
92#define HEAP_SIZE 0x10000 43#define HEAP_SIZE 0x10000
93 44
94#include "../../../../lib/inflate.c" 45#ifdef CONFIG_KERNEL_GZIP
46#include "../../../../lib/decompress_inflate.c"
47#endif
95 48
96void puts(const char *s) 49void puts(const char *s)
97{ 50{
@@ -117,45 +70,6 @@ void *memcpy(void *__dest, __const void *__src, size_t __n)
117 return __dest; 70 return __dest;
118} 71}
119 72
120/* ===========================================================================
121 * Fill the input buffer. This is called only when the buffer is empty
122 * and at least one byte is really needed.
123 */
124static int fill_inbuf(void)
125{
126 if (insize != 0) {
127 error("ran out of input data\n");
128 }
129
130 inbuf = input_data;
131 insize = input_len;
132 inptr = 1;
133 return inbuf[0];
134}
135
136/* ===========================================================================
137 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
138 * (Used for the decompressed data only.)
139 */
140static void flush_window(void)
141{
142 ulg c = crc; /* temporary variable */
143 unsigned n;
144 uch *in, *out, ch;
145
146 in = window;
147 out = &output_data[output_ptr];
148 for (n = 0; n < outcnt; n++) {
149 ch = *out++ = *in++;
150 c = crc_32_tab[((int) c ^ ch) & 0xff] ^ (c >> 8);
151 }
152 crc = c;
153 bytes_out += (ulg) outcnt;
154 output_ptr += (ulg) outcnt;
155 outcnt = 0;
156 puts(".");
157}
158
159static void error(char *x) 73static void error(char *x)
160{ 74{
161 puts("\n\n"); 75 puts("\n\n");
@@ -171,40 +85,13 @@ long *stack_start = &user_stack[STACK_SIZE];
171 85
172void decompress_kernel(void) 86void decompress_kernel(void)
173{ 87{
174 output_data = (uch *) (CONFIG_MEMORY_START + 0x2000); 88 output_data = (unsigned char *) (CONFIG_MEMORY_START + 0x2000);
175 free_mem_ptr = (unsigned long) &_end; 89 free_mem_ptr = (unsigned long) &_end;
176 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; 90 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
177 91
178 makecrc();
179 puts("Uncompressing Linux... "); 92 puts("Uncompressing Linux... ");
180 cache_control(CACHE_ENABLE); 93 cache_control(CACHE_ENABLE);
181 gunzip(); 94 decompress(input_data, input_len, NULL, NULL, output_data, NULL, error);
182 puts("\n");
183
184#if 0
185 /* When booting from ROM may want to do something like this if the
186 * boot loader doesn't.
187 */
188
189 /* Set up the parameters and command line */
190 {
191 volatile unsigned int *parambase =
192 (int *) (CONFIG_MEMORY_START + 0x1000);
193
194 parambase[0] = 0x1; /* MOUNT_ROOT_RDONLY */
195 parambase[1] = 0x0; /* RAMDISK_FLAGS */
196 parambase[2] = 0x0200; /* ORIG_ROOT_DEV */
197 parambase[3] = 0x0; /* LOADER_TYPE */
198 parambase[4] = 0x0; /* INITRD_START */
199 parambase[5] = 0x0; /* INITRD_SIZE */
200 parambase[6] = 0;
201
202 strcpy((char *) ((int) parambase + 0x100),
203 "console=ttySC0,38400");
204 }
205#endif
206
207 puts("Ok, booting the kernel.\n");
208
209 cache_control(CACHE_DISABLE); 95 cache_control(CACHE_DISABLE);
96 puts("Ok, booting the kernel.\n");
210} 97}