diff options
author | Jesper Nilsson <jesper.nilsson@axis.com> | 2009-04-21 05:44:57 -0400 |
---|---|---|
committer | Jesper Nilsson <jesper.nilsson@axis.com> | 2009-04-21 05:44:57 -0400 |
commit | 66ab3a74c5ce737effc2c64391e036b0938b1c36 (patch) | |
tree | abe71b0c811dd13c9b9ad2587ba8779a8f852220 /arch/cris/arch-v10/boot/compressed | |
parent | a939b96cccdb65df80a52447ec8e4a6d79c56dbb (diff) |
CRIS: Merge machine dependent boot/compressed and boot/rescue
Merge the machine dependent boot directories for v10 and v32.
This avoids some code duplication and eases the way for further
merging later on.
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Diffstat (limited to 'arch/cris/arch-v10/boot/compressed')
-rw-r--r-- | arch/cris/arch-v10/boot/compressed/Makefile | 27 | ||||
-rw-r--r-- | arch/cris/arch-v10/boot/compressed/README | 25 | ||||
-rw-r--r-- | arch/cris/arch-v10/boot/compressed/decompress.lds | 30 | ||||
-rw-r--r-- | arch/cris/arch-v10/boot/compressed/head.S | 126 | ||||
-rw-r--r-- | arch/cris/arch-v10/boot/compressed/misc.c | 246 |
5 files changed, 0 insertions, 454 deletions
diff --git a/arch/cris/arch-v10/boot/compressed/Makefile b/arch/cris/arch-v10/boot/compressed/Makefile deleted file mode 100644 index 6fe0ffaf3be6..000000000000 --- a/arch/cris/arch-v10/boot/compressed/Makefile +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | # | ||
2 | # arch/cris/arch-v10/boot/compressed/Makefile | ||
3 | # | ||
4 | |||
5 | asflags-y += $(LINUXINCLUDE) | ||
6 | ccflags-y += -O2 $(LINUXINCLUDE) | ||
7 | ldflags-y += -T $(srctree)/$(src)/decompress.lds | ||
8 | OBJECTS = $(obj)/head.o $(obj)/misc.o | ||
9 | OBJCOPYFLAGS = -O binary --remove-section=.bss | ||
10 | |||
11 | quiet_cmd_image = BUILD $@ | ||
12 | cmd_image = cat $(obj)/decompress.bin $(obj)/piggy.gz > $@ | ||
13 | |||
14 | targets := vmlinux piggy.gz decompress.o decompress.bin | ||
15 | |||
16 | $(obj)/decompress.o: $(OBJECTS) FORCE | ||
17 | $(call if_changed,ld) | ||
18 | |||
19 | $(obj)/decompress.bin: $(obj)/decompress.o FORCE | ||
20 | $(call if_changed,objcopy) | ||
21 | |||
22 | $(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE | ||
23 | $(call if_changed,image) | ||
24 | |||
25 | $(obj)/piggy.gz: $(obj)/../Image FORCE | ||
26 | $(call if_changed,gzip) | ||
27 | |||
diff --git a/arch/cris/arch-v10/boot/compressed/README b/arch/cris/arch-v10/boot/compressed/README deleted file mode 100644 index 48b3db9924b9..000000000000 --- a/arch/cris/arch-v10/boot/compressed/README +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | Creation of the self-extracting compressed kernel image (vmlinuz) | ||
2 | ----------------------------------------------------------------- | ||
3 | $Id: README,v 1.1 2001/12/17 13:59:27 bjornw Exp $ | ||
4 | |||
5 | This can be slightly confusing because it's a process with many steps. | ||
6 | |||
7 | The kernel object built by the arch/etrax100/Makefile, vmlinux, is split | ||
8 | by that makefile into text and data binary files, vmlinux.text and | ||
9 | vmlinux.data. | ||
10 | |||
11 | Those files together with a ROM filesystem can be catted together and | ||
12 | burned into a flash or executed directly at the DRAM origin. | ||
13 | |||
14 | They can also be catted together and compressed with gzip, which is what | ||
15 | happens in this makefile. Together they make up piggy.img. | ||
16 | |||
17 | The decompressor is built into the file decompress.o. It is turned into | ||
18 | the binary file decompress.bin, which is catted together with piggy.img | ||
19 | into the file vmlinuz. It can be executed in an arbitrary place in flash. | ||
20 | |||
21 | Be careful - it assumes some things about free locations in DRAM. It | ||
22 | assumes the DRAM starts at 0x40000000 and that it is at least 8 MB, | ||
23 | so it puts its code at 0x40700000, and initial stack at 0x40800000. | ||
24 | |||
25 | -Bjorn | ||
diff --git a/arch/cris/arch-v10/boot/compressed/decompress.lds b/arch/cris/arch-v10/boot/compressed/decompress.lds deleted file mode 100644 index e80f4594d543..000000000000 --- a/arch/cris/arch-v10/boot/compressed/decompress.lds +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | /* OUTPUT_FORMAT(elf32-us-cris) */ | ||
2 | OUTPUT_FORMAT(elf32-cris) | ||
3 | |||
4 | MEMORY | ||
5 | { | ||
6 | dram : ORIGIN = 0x40700000, | ||
7 | LENGTH = 0x00100000 | ||
8 | } | ||
9 | |||
10 | SECTIONS | ||
11 | { | ||
12 | .text : | ||
13 | { | ||
14 | _stext = . ; | ||
15 | *(.text) | ||
16 | *(.rodata) | ||
17 | *(.rodata.*) | ||
18 | _etext = . ; | ||
19 | } > dram | ||
20 | .data : | ||
21 | { | ||
22 | *(.data) | ||
23 | _edata = . ; | ||
24 | } > dram | ||
25 | .bss : | ||
26 | { | ||
27 | *(.bss) | ||
28 | _end = ALIGN( 0x10 ) ; | ||
29 | } > dram | ||
30 | } | ||
diff --git a/arch/cris/arch-v10/boot/compressed/head.S b/arch/cris/arch-v10/boot/compressed/head.S deleted file mode 100644 index 0bb4dcc29254..000000000000 --- a/arch/cris/arch-v10/boot/compressed/head.S +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | /* | ||
2 | * arch/cris/boot/compressed/head.S | ||
3 | * | ||
4 | * Copyright (C) 1999, 2001 Axis Communications AB | ||
5 | * | ||
6 | * Code that sets up the DRAM registers, calls the | ||
7 | * decompressor to unpack the piggybacked kernel, and jumps. | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #define ASSEMBLER_MACROS_ONLY | ||
12 | #include <arch/sv_addr_ag.h> | ||
13 | |||
14 | #define RAM_INIT_MAGIC 0x56902387 | ||
15 | #define COMMAND_LINE_MAGIC 0x87109563 | ||
16 | |||
17 | ;; Exported symbols | ||
18 | |||
19 | .globl input_data | ||
20 | |||
21 | |||
22 | .text | ||
23 | |||
24 | nop | ||
25 | di | ||
26 | |||
27 | ;; We need to initialze DRAM registers before we start using the DRAM | ||
28 | |||
29 | cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? | ||
30 | beq dram_init_finished | ||
31 | nop | ||
32 | |||
33 | #include "../../lib/dram_init.S" | ||
34 | |||
35 | dram_init_finished: | ||
36 | |||
37 | ;; Initiate the PA and PB ports | ||
38 | |||
39 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 | ||
40 | move.b $r0, [R_PORT_PA_DATA] | ||
41 | |||
42 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 | ||
43 | move.b $r0, [R_PORT_PA_DIR] | ||
44 | |||
45 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 | ||
46 | move.b $r0, [R_PORT_PB_DATA] | ||
47 | |||
48 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 | ||
49 | move.b $r0, [R_PORT_PB_DIR] | ||
50 | |||
51 | ;; Setup the stack to a suitably high address. | ||
52 | ;; We assume 8 MB is the minimum DRAM in an eLinux | ||
53 | ;; product and put the sp at the top for now. | ||
54 | |||
55 | move.d 0x40800000, $sp | ||
56 | |||
57 | ;; Figure out where the compressed piggyback image is | ||
58 | ;; in the flash (since we wont try to copy it to DRAM | ||
59 | ;; before unpacking). It is at _edata, but in flash. | ||
60 | ;; Use (_edata - basse) as offset to the current PC. | ||
61 | |||
62 | basse: move.d $pc, $r5 | ||
63 | and.d 0x7fffffff, $r5 ; strip any non-cache bit | ||
64 | subq 2, $r5 ; compensate for the move.d $pc instr | ||
65 | move.d $r5, $r0 ; save for later - flash address of 'basse' | ||
66 | add.d _edata, $r5 | ||
67 | sub.d basse, $r5 ; $r5 = flash address of '_edata' | ||
68 | |||
69 | ;; Copy text+data to DRAM | ||
70 | |||
71 | move.d basse, $r1 ; destination | ||
72 | move.d _edata, $r2 ; end destination | ||
73 | 1: move.w [$r0+], $r3 | ||
74 | move.w $r3, [$r1+] | ||
75 | cmp.d $r2, $r1 | ||
76 | bcs 1b | ||
77 | nop | ||
78 | |||
79 | move.d $r5, [input_data] ; for the decompressor | ||
80 | |||
81 | |||
82 | ;; Clear the decompressors BSS (between _edata and _end) | ||
83 | |||
84 | moveq 0, $r0 | ||
85 | move.d _edata, $r1 | ||
86 | move.d _end, $r2 | ||
87 | 1: move.w $r0, [$r1+] | ||
88 | cmp.d $r2, $r1 | ||
89 | bcs 1b | ||
90 | nop | ||
91 | |||
92 | ;; Save command line magic and address. | ||
93 | move.d _cmd_line_magic, $r12 | ||
94 | move.d $r10, [$r12] | ||
95 | move.d _cmd_line_addr, $r12 | ||
96 | move.d $r11, [$r12] | ||
97 | |||
98 | ;; Do the decompression and save compressed size in inptr | ||
99 | |||
100 | jsr decompress_kernel | ||
101 | |||
102 | ;; Put start address of root partition in $r9 so the kernel can use it | ||
103 | ;; when mounting from flash | ||
104 | |||
105 | move.d [input_data], $r9 ; flash address of compressed kernel | ||
106 | add.d [inptr], $r9 ; size of compressed kernel | ||
107 | |||
108 | ;; Restore command line magic and address. | ||
109 | move.d _cmd_line_magic, $r10 | ||
110 | move.d [$r10], $r10 | ||
111 | move.d _cmd_line_addr, $r11 | ||
112 | move.d [$r11], $r11 | ||
113 | |||
114 | ;; Enter the decompressed kernel | ||
115 | move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized | ||
116 | jump 0x40004000 ; kernel is linked to this address | ||
117 | |||
118 | .data | ||
119 | |||
120 | input_data: | ||
121 | .dword 0 ; used by the decompressor | ||
122 | _cmd_line_magic: | ||
123 | .dword 0 | ||
124 | _cmd_line_addr: | ||
125 | .dword 0 | ||
126 | #include "../../lib/hw_settings.S" | ||
diff --git a/arch/cris/arch-v10/boot/compressed/misc.c b/arch/cris/arch-v10/boot/compressed/misc.c deleted file mode 100644 index a4db1507d3b1..000000000000 --- a/arch/cris/arch-v10/boot/compressed/misc.c +++ /dev/null | |||
@@ -1,246 +0,0 @@ | |||
1 | /* | ||
2 | * misc.c | ||
3 | * | ||
4 | * This is a collection of several routines from gzip-1.0.3 | ||
5 | * adapted for Linux. | ||
6 | * | ||
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 | ||
10 | * | ||
11 | */ | ||
12 | |||
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 | ||
16 | * at by vmlinux.lds.S | ||
17 | */ | ||
18 | |||
19 | #define KERNEL_LOAD_ADR 0x40004000 | ||
20 | |||
21 | |||
22 | #include <linux/types.h> | ||
23 | #include <arch/svinto.h> | ||
24 | |||
25 | /* | ||
26 | * gzip declarations | ||
27 | */ | ||
28 | |||
29 | #define OF(args) args | ||
30 | #define STATIC static | ||
31 | |||
32 | void *memset(void *s, int c, size_t n); | ||
33 | void *memcpy(void *__dest, __const void *__src, size_t __n); | ||
34 | |||
35 | #define memzero(s, n) memset((s), 0, (n)) | ||
36 | |||
37 | typedef unsigned char uch; | ||
38 | typedef unsigned short ush; | ||
39 | typedef unsigned long ulg; | ||
40 | |||
41 | #define WSIZE 0x8000 /* Window size must be at least 32k, */ | ||
42 | /* and a power of two */ | ||
43 | |||
44 | static uch *inbuf; /* input buffer */ | ||
45 | static uch window[WSIZE]; /* Sliding window buffer */ | ||
46 | |||
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. | ||
50 | */ | ||
51 | |||
52 | static unsigned outcnt = 0; /* bytes in output buffer */ | ||
53 | |||
54 | /* gzip flag byte */ | ||
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 */ | ||
62 | |||
63 | #define get_byte() (inbuf[inptr++]) | ||
64 | |||
65 | /* Diagnostic functions */ | ||
66 | #ifdef DEBUG | ||
67 | # define Assert(cond, msg) do { \ | ||
68 | if (!(cond)) \ | ||
69 | error(msg); \ | ||
70 | } while (0) | ||
71 | # define Trace(x) fprintf x | ||
72 | # define Tracev(x) do { \ | ||
73 | if (verbose) \ | ||
74 | fprintf x; \ | ||
75 | } while (0) | ||
76 | # define Tracevv(x) do { \ | ||
77 | if (verbose > 1) \ | ||
78 | fprintf x; \ | ||
79 | } while (0) | ||
80 | # define Tracec(c, x) do { \ | ||
81 | if (verbose && (c)) \ | ||
82 | fprintf x; \ | ||
83 | } while (0) | ||
84 | # define Tracecv(c, x) do { \ | ||
85 | if (verbose > 1 && (c)) \ | ||
86 | fprintf x; \ | ||
87 | } while (0) | ||
88 | #else | ||
89 | # define Assert(cond, msg) | ||
90 | # define Trace(x) | ||
91 | # define Tracev(x) | ||
92 | # define Tracevv(x) | ||
93 | # define Tracec(c, x) | ||
94 | # define Tracecv(c, x) | ||
95 | #endif | ||
96 | |||
97 | static void flush_window(void); | ||
98 | static void error(char *m); | ||
99 | |||
100 | extern char *input_data; /* lives in head.S */ | ||
101 | |||
102 | static long bytes_out = 0; | ||
103 | static uch *output_data; | ||
104 | static unsigned long output_ptr = 0; | ||
105 | static void puts(const char *); | ||
106 | |||
107 | /* the "heap" is put directly after the BSS ends, at end */ | ||
108 | |||
109 | extern int _end; | ||
110 | static long free_mem_ptr = (long)&_end; | ||
111 | static long free_mem_end_ptr; | ||
112 | |||
113 | #include "../../../../../lib/inflate.c" | ||
114 | |||
115 | /* decompressor info and error messages to serial console */ | ||
116 | |||
117 | static void | ||
118 | puts(const char *s) | ||
119 | { | ||
120 | #ifndef CONFIG_ETRAX_DEBUG_PORT_NULL | ||
121 | while (*s) { | ||
122 | #ifdef CONFIG_ETRAX_DEBUG_PORT0 | ||
123 | while (!(*R_SERIAL0_STATUS & (1 << 5))) ; | ||
124 | *R_SERIAL0_TR_DATA = *s++; | ||
125 | #endif | ||
126 | #ifdef CONFIG_ETRAX_DEBUG_PORT1 | ||
127 | while (!(*R_SERIAL1_STATUS & (1 << 5))) ; | ||
128 | *R_SERIAL1_TR_DATA = *s++; | ||
129 | #endif | ||
130 | #ifdef CONFIG_ETRAX_DEBUG_PORT2 | ||
131 | while (!(*R_SERIAL2_STATUS & (1 << 5))) ; | ||
132 | *R_SERIAL2_TR_DATA = *s++; | ||
133 | #endif | ||
134 | #ifdef CONFIG_ETRAX_DEBUG_PORT3 | ||
135 | while (!(*R_SERIAL3_STATUS & (1 << 5))) ; | ||
136 | *R_SERIAL3_TR_DATA = *s++; | ||
137 | #endif | ||
138 | } | ||
139 | #endif | ||
140 | } | ||
141 | |||
142 | void *memset(void *s, int c, size_t n) | ||
143 | { | ||
144 | int i; | ||
145 | char *ss = (char *)s; | ||
146 | |||
147 | for (i = 0; i < n; i++) | ||
148 | ss[i] = c; | ||
149 | |||
150 | return s; | ||
151 | } | ||
152 | |||
153 | void *memcpy(void *__dest, __const void *__src, size_t __n) | ||
154 | { | ||
155 | int i; | ||
156 | char *d = (char *)__dest, *s = (char *)__src; | ||
157 | |||
158 | for (i = 0; i < __n; i++) | ||
159 | d[i] = s[i]; | ||
160 | |||
161 | return __dest; | ||
162 | } | ||
163 | |||
164 | /* =========================================================================== | ||
165 | * Write the output window window[0..outcnt-1] and update crc and bytes_out. | ||
166 | * (Used for the decompressed data only.) | ||
167 | */ | ||
168 | |||
169 | static void flush_window(void) | ||
170 | { | ||
171 | ulg c = crc; /* temporary variable */ | ||
172 | unsigned n; | ||
173 | uch *in, *out, ch; | ||
174 | |||
175 | in = window; | ||
176 | out = &output_data[output_ptr]; | ||
177 | for (n = 0; n < outcnt; n++) { | ||
178 | ch = *out = *in; | ||
179 | out++; | ||
180 | in++; | ||
181 | c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); | ||
182 | } | ||
183 | crc = c; | ||
184 | bytes_out += (ulg)outcnt; | ||
185 | output_ptr += (ulg)outcnt; | ||
186 | outcnt = 0; | ||
187 | } | ||
188 | |||
189 | static void error(char *x) | ||
190 | { | ||
191 | puts("\n\n"); | ||
192 | puts(x); | ||
193 | puts("\n\n -- System halted\n"); | ||
194 | |||
195 | while (1); /* Halt */ | ||
196 | } | ||
197 | |||
198 | void setup_normal_output_buffer(void) | ||
199 | { | ||
200 | output_data = (char *)KERNEL_LOAD_ADR; | ||
201 | } | ||
202 | |||
203 | void decompress_kernel(void) | ||
204 | { | ||
205 | char revision; | ||
206 | |||
207 | /* input_data is set in head.S */ | ||
208 | inbuf = input_data; | ||
209 | |||
210 | #ifdef CONFIG_ETRAX_DEBUG_PORT0 | ||
211 | *R_SERIAL0_XOFF = 0; | ||
212 | *R_SERIAL0_BAUD = 0x99; | ||
213 | *R_SERIAL0_TR_CTRL = 0x40; | ||
214 | #endif | ||
215 | #ifdef CONFIG_ETRAX_DEBUG_PORT1 | ||
216 | *R_SERIAL1_XOFF = 0; | ||
217 | *R_SERIAL1_BAUD = 0x99; | ||
218 | *R_SERIAL1_TR_CTRL = 0x40; | ||
219 | #endif | ||
220 | #ifdef CONFIG_ETRAX_DEBUG_PORT2 | ||
221 | *R_GEN_CONFIG = 0x08; | ||
222 | *R_SERIAL2_XOFF = 0; | ||
223 | *R_SERIAL2_BAUD = 0x99; | ||
224 | *R_SERIAL2_TR_CTRL = 0x40; | ||
225 | #endif | ||
226 | #ifdef CONFIG_ETRAX_DEBUG_PORT3 | ||
227 | *R_GEN_CONFIG = 0x100; | ||
228 | *R_SERIAL3_XOFF = 0; | ||
229 | *R_SERIAL3_BAUD = 0x99; | ||
230 | *R_SERIAL3_TR_CTRL = 0x40; | ||
231 | #endif | ||
232 | |||
233 | setup_normal_output_buffer(); | ||
234 | |||
235 | makecrc(); | ||
236 | |||
237 | __asm__ volatile ("move $vr,%0" : "=rm" (revision)); | ||
238 | if (revision < 10) { | ||
239 | puts("You need an ETRAX 100LX to run linux 2.6\n"); | ||
240 | while (1); | ||
241 | } | ||
242 | |||
243 | puts("Uncompressing Linux...\n"); | ||
244 | gunzip(); | ||
245 | puts("Done. Now booting the kernel.\n"); | ||
246 | } | ||