4 * This is a collection of several routines from gzip-1.0.3
7 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
8 * puts by Nick Holloway 1993, better puts by Martin Mares 1995
9 * adaptation for Linux/CRIS Axis Communications AB, 1999
13 /* where the piggybacked kernel image expects itself to live.
14 * it is the same address we use when we network load an uncompressed
15 * image into DRAM, and it is the address the kernel is linked to live
19 #define KERNEL_LOAD_ADR 0x40004000
22 #include <linux/types.h>
23 #include <asm/arch/svinto.h>
32 void *memset(void *s
, int c
, size_t n
);
33 void *memcpy(void *__dest
, __const
void *__src
, size_t __n
);
35 #define memzero(s, n) memset((s), 0, (n))
37 typedef unsigned char uch
;
38 typedef unsigned short ush
;
39 typedef unsigned long ulg
;
41 #define WSIZE 0x8000 /* Window size must be at least 32k, */
42 /* and a power of two */
44 static uch
*inbuf
; /* input buffer */
45 static uch window
[WSIZE
]; /* Sliding window buffer */
47 unsigned inptr
= 0; /* index of next byte to be processed in inbuf
48 * After decompression it will contain the
49 * compressed size, and head.S will read it.
52 static unsigned outcnt
= 0; /* bytes in output buffer */
55 #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
56 #define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
57 #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
58 #define ORIG_NAME 0x08 /* bit 3 set: original file name present */
59 #define COMMENT 0x10 /* bit 4 set: file comment present */
60 #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
61 #define RESERVED 0xC0 /* bit 6,7: reserved */
63 #define get_byte() (inbuf[inptr++])
65 /* Diagnostic functions */
67 # define Assert(cond, msg) do { \
71 # define Trace(x) fprintf x
72 # define Tracev(x) do { \
76 # define Tracevv(x) do { \
80 # define Tracec(c, x) do { \
84 # define Tracecv(c, x) do { \
85 if (verbose > 1 && (c)) \
89 # define Assert(cond, msg)
94 # define Tracecv(c, x)
97 static void flush_window(void);
98 static void error(char *m
);
100 extern char *input_data
; /* lives in head.S */
102 static long bytes_out
= 0;
103 static uch
*output_data
;
104 static unsigned long output_ptr
= 0;
105 static void puts(const char *);
107 /* the "heap" is put directly after the BSS ends, at end */
110 static long free_mem_ptr
= (long)&_end
;
111 static long free_mem_end_ptr
;
113 #include "../../../../../lib/inflate.c"
115 /* decompressor info and error messages to serial console */
120 #ifndef CONFIG_ETRAX_DEBUG_PORT_NULL
122 #ifdef CONFIG_ETRAX_DEBUG_PORT0
123 while (!(*R_SERIAL0_STATUS
& (1 << 5))) ;
124 *R_SERIAL0_TR_DATA
= *s
++;
126 #ifdef CONFIG_ETRAX_DEBUG_PORT1
127 while (!(*R_SERIAL1_STATUS
& (1 << 5))) ;
128 *R_SERIAL1_TR_DATA
= *s
++;
130 #ifdef CONFIG_ETRAX_DEBUG_PORT2
131 while (!(*R_SERIAL2_STATUS
& (1 << 5))) ;
132 *R_SERIAL2_TR_DATA
= *s
++;
134 #ifdef CONFIG_ETRAX_DEBUG_PORT3
135 while (!(*R_SERIAL3_STATUS
& (1 << 5))) ;
136 *R_SERIAL3_TR_DATA
= *s
++;
142 void *memset(void *s
, int c
, size_t n
)
145 char *ss
= (char *)s
;
147 for (i
= 0; i
< n
; i
++)
153 void *memcpy(void *__dest
, __const
void *__src
, size_t __n
)
156 char *d
= (char *)__dest
, *s
= (char *)__src
;
158 for (i
= 0; i
< __n
; i
++)
164 /* ===========================================================================
165 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
166 * (Used for the decompressed data only.)
169 static void flush_window(void)
171 ulg c
= crc
; /* temporary variable */
176 out
= &output_data
[output_ptr
];
177 for (n
= 0; n
< outcnt
; n
++) {
181 c
= crc_32_tab
[((int)c
^ ch
) & 0xff] ^ (c
>> 8);
184 bytes_out
+= (ulg
)outcnt
;
185 output_ptr
+= (ulg
)outcnt
;
189 static void error(char *x
)
193 puts("\n\n -- System halted\n");
195 while (1); /* Halt */
198 void setup_normal_output_buffer(void)
200 output_data
= (char *)KERNEL_LOAD_ADR
;
203 void decompress_kernel(void)
207 /* input_data is set in head.S */
210 #ifdef CONFIG_ETRAX_DEBUG_PORT0
212 *R_SERIAL0_BAUD
= 0x99;
213 *R_SERIAL0_TR_CTRL
= 0x40;
215 #ifdef CONFIG_ETRAX_DEBUG_PORT1
217 *R_SERIAL1_BAUD
= 0x99;
218 *R_SERIAL1_TR_CTRL
= 0x40;
220 #ifdef CONFIG_ETRAX_DEBUG_PORT2
221 *R_GEN_CONFIG
= 0x08;
223 *R_SERIAL2_BAUD
= 0x99;
224 *R_SERIAL2_TR_CTRL
= 0x40;
226 #ifdef CONFIG_ETRAX_DEBUG_PORT3
227 *R_GEN_CONFIG
= 0x100;
229 *R_SERIAL3_BAUD
= 0x99;
230 *R_SERIAL3_TR_CTRL
= 0x40;
233 setup_normal_output_buffer();
237 __asm__
volatile ("move $vr,%0" : "=rm" (revision
));
239 puts("You need an ETRAX 100LX to run linux 2.6\n");
243 puts("Uncompressing Linux...\n");
245 puts("Done. Now booting the kernel.\n");
This page took 0.036505 seconds and 6 git commands to generate.