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/boot/rescue | |
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/boot/rescue')
-rw-r--r-- | arch/cris/boot/rescue/Makefile | 47 | ||||
-rw-r--r-- | arch/cris/boot/rescue/head_v10.S | 360 | ||||
-rw-r--r-- | arch/cris/boot/rescue/head_v32.S | 26 | ||||
-rw-r--r-- | arch/cris/boot/rescue/kimagerescue.S | 143 | ||||
-rw-r--r-- | arch/cris/boot/rescue/rescue_v10.lds | 20 | ||||
-rw-r--r-- | arch/cris/boot/rescue/rescue_v32.lds | 43 | ||||
-rw-r--r-- | arch/cris/boot/rescue/testrescue.S | 24 |
7 files changed, 663 insertions, 0 deletions
diff --git a/arch/cris/boot/rescue/Makefile b/arch/cris/boot/rescue/Makefile new file mode 100644 index 000000000000..52bd0bd1dd22 --- /dev/null +++ b/arch/cris/boot/rescue/Makefile | |||
@@ -0,0 +1,47 @@ | |||
1 | # | ||
2 | # Makefile for rescue (bootstrap) code | ||
3 | # | ||
4 | |||
5 | # CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE) | ||
6 | # ccflags-$(CONFIG_ETRAX_ARCH_V32) += -I$(srctree)/include/asm/arch/mach/ \ | ||
7 | # -I$(srctree)/include/asm/arch | ||
8 | # asflags-y += -I $(srctree)/include/asm/arch/mach/ -I $(srctree)/include/asm/arch | ||
9 | # LD = gcc-cris -mlinux -march=v32 -nostdlib | ||
10 | |||
11 | asflags-y += $(LINUXINCLUDE) | ||
12 | ccflags-y += -O2 $(LINUXINCLUDE) | ||
13 | arch-$(CONFIG_ETRAX_ARCH_V10) = v10 | ||
14 | arch-$(CONFIG_ETRAX_ARCH_V32) = v32 | ||
15 | |||
16 | ldflags-y += -T $(srctree)/$(src)/rescue_$(arch-y).lds | ||
17 | OBJCOPYFLAGS = -O binary --remove-section=.bss | ||
18 | obj-$(CONFIG_ETRAX_ARCH_V32) = $(obj)/head_v32.o | ||
19 | obj-$(CONFIG_ETRAX_ARCH_V10) = $(obj)/head_v10.o | ||
20 | OBJECTS := $(obj-y) | ||
21 | |||
22 | targets := rescue.o rescue.bin | ||
23 | |||
24 | $(obj)/rescue.o: $(OBJECTS) FORCE | ||
25 | $(call if_changed,ld) | ||
26 | |||
27 | $(obj)/rescue.bin: $(obj)/rescue.o FORCE | ||
28 | $(call if_changed,objcopy) | ||
29 | cp -p $(obj)/rescue.bin $(objtree) | ||
30 | |||
31 | $(obj)/testrescue.bin: $(obj)/testrescue.o | ||
32 | $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin | ||
33 | # Pad it to 784 bytes | ||
34 | dd if=/dev/zero of=tmp2423 bs=1 count=784 | ||
35 | cat tr.bin tmp2423 >testrescue_tmp.bin | ||
36 | dd if=testrescue_tmp.bin of=$(obj)/testrescue.bin bs=1 count=784 | ||
37 | rm tr.bin tmp2423 testrescue_tmp.bin | ||
38 | |||
39 | |||
40 | $(obj)/kimagerescue.bin: $(obj)/kimagerescue.o | ||
41 | $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/kimagerescue.o ktr.bin | ||
42 | # Pad it to 784 bytes, that's what the rescue loader expects | ||
43 | dd if=/dev/zero of=tmp2423 bs=1 count=784 | ||
44 | cat ktr.bin tmp2423 >kimagerescue_tmp.bin | ||
45 | dd if=kimagerescue_tmp.bin of=$(obj)/kimagerescue.bin bs=1 count=784 | ||
46 | rm ktr.bin tmp2423 kimagerescue_tmp.bin | ||
47 | |||
diff --git a/arch/cris/boot/rescue/head_v10.S b/arch/cris/boot/rescue/head_v10.S new file mode 100644 index 000000000000..2fafe247a25b --- /dev/null +++ b/arch/cris/boot/rescue/head_v10.S | |||
@@ -0,0 +1,360 @@ | |||
1 | /* | ||
2 | * Rescue code, made to reside at the beginning of the | ||
3 | * flash-memory. when it starts, it checks a partition | ||
4 | * table at the first sector after the rescue sector. | ||
5 | * the partition table was generated by the product builder | ||
6 | * script and contains offsets, lengths, types and checksums | ||
7 | * for each partition that this code should check. | ||
8 | * | ||
9 | * If any of the checksums fail, we assume the flash is so | ||
10 | * corrupt that we cant use it to boot into the ftp flash | ||
11 | * loader, and instead we initialize the serial port to | ||
12 | * receive a flash-loader and new flash image. we dont include | ||
13 | * any flash code here, but just accept a certain amount of | ||
14 | * bytes from the serial port and jump into it. the downloaded | ||
15 | * code is put in the cache. | ||
16 | * | ||
17 | * The partitiontable is designed so that it is transparent to | ||
18 | * code execution - it has a relative branch opcode in the | ||
19 | * beginning that jumps over it. each entry contains extra | ||
20 | * data so we can add stuff later. | ||
21 | * | ||
22 | * Partition table format: | ||
23 | * | ||
24 | * Code transparency: | ||
25 | * | ||
26 | * 2 bytes [opcode 'nop'] | ||
27 | * 2 bytes [opcode 'di'] | ||
28 | * 4 bytes [opcode 'ba <offset>', 8-bit or 16-bit version] | ||
29 | * 2 bytes [opcode 'nop', delay slot] | ||
30 | * | ||
31 | * Table validation (at +10): | ||
32 | * | ||
33 | * 2 bytes [magic/version word for partitiontable - 0xef, 0xbe] | ||
34 | * 2 bytes [length of all entries plus the end marker] | ||
35 | * 4 bytes [checksum for the partitiontable itself] | ||
36 | * | ||
37 | * Entries, each with the following format, last has offset -1: | ||
38 | * | ||
39 | * 4 bytes [offset in bytes, from start of flash] | ||
40 | * 4 bytes [length in bytes of partition] | ||
41 | * 4 bytes [checksum, simple longword sum] | ||
42 | * 2 bytes [partition type] | ||
43 | * 2 bytes [flags, only bit 0 used, ro/rw = 1/0] | ||
44 | * 16 bytes [reserved for future use] | ||
45 | * | ||
46 | * End marker | ||
47 | * | ||
48 | * 4 bytes [-1] | ||
49 | * | ||
50 | * 10 bytes [0, padding] | ||
51 | * | ||
52 | * Bit 0 in flags signifies RW or RO. The rescue code only bothers | ||
53 | * to check the checksum for RO partitions, since the others will | ||
54 | * change their data without updating the checksums. A 1 in bit 0 | ||
55 | * means RO, 0 means RW. That way, it is possible to set a partition | ||
56 | * in RO mode initially, and later mark it as RW, since you can always | ||
57 | * write 0's to the flash. | ||
58 | * | ||
59 | * During the wait for serial input, the status LED will flash so the | ||
60 | * user knows something went wrong. | ||
61 | * | ||
62 | * Copyright (C) 1999-2007 Axis Communications AB | ||
63 | */ | ||
64 | |||
65 | #ifdef CONFIG_ETRAX_AXISFLASHMAP | ||
66 | |||
67 | #define ASSEMBLER_MACROS_ONLY | ||
68 | #include <arch/sv_addr_ag.h> | ||
69 | |||
70 | ;; The partitiontable is looked for at the first sector after the boot | ||
71 | ;; sector. Sector size is 65536 bytes in all flashes we use. | ||
72 | |||
73 | #define PTABLE_START CONFIG_ETRAX_PTABLE_SECTOR | ||
74 | #define PTABLE_MAGIC 0xbeef | ||
75 | |||
76 | ;; The normal Etrax100 on-chip boot ROM does serial boot at 0x380000f0. | ||
77 | ;; That is not where we put our downloaded serial boot-code. | ||
78 | ;; The length is enough for downloading code that loads the rest | ||
79 | ;; of itself (after having setup the DRAM etc). | ||
80 | ;; It is the same length as the on-chip ROM loads, so the same | ||
81 | ;; host loader can be used to load a rescued product as well as | ||
82 | ;; one booted through the Etrax serial boot code. | ||
83 | |||
84 | #define CODE_START 0x40000000 | ||
85 | #define CODE_LENGTH 784 | ||
86 | |||
87 | #ifdef CONFIG_ETRAX_RESCUE_SER0 | ||
88 | #define SERXOFF R_SERIAL0_XOFF | ||
89 | #define SERBAUD R_SERIAL0_BAUD | ||
90 | #define SERRECC R_SERIAL0_REC_CTRL | ||
91 | #define SERRDAT R_SERIAL0_REC_DATA | ||
92 | #define SERSTAT R_SERIAL0_STATUS | ||
93 | #endif | ||
94 | #ifdef CONFIG_ETRAX_RESCUE_SER1 | ||
95 | #define SERXOFF R_SERIAL1_XOFF | ||
96 | #define SERBAUD R_SERIAL1_BAUD | ||
97 | #define SERRECC R_SERIAL1_REC_CTRL | ||
98 | #define SERRDAT R_SERIAL1_REC_DATA | ||
99 | #define SERSTAT R_SERIAL1_STATUS | ||
100 | #endif | ||
101 | #ifdef CONFIG_ETRAX_RESCUE_SER2 | ||
102 | #define SERXOFF R_SERIAL2_XOFF | ||
103 | #define SERBAUD R_SERIAL2_BAUD | ||
104 | #define SERRECC R_SERIAL2_REC_CTRL | ||
105 | #define SERRDAT R_SERIAL2_REC_DATA | ||
106 | #define SERSTAT R_SERIAL2_STATUS | ||
107 | #endif | ||
108 | #ifdef CONFIG_ETRAX_RESCUE_SER3 | ||
109 | #define SERXOFF R_SERIAL3_XOFF | ||
110 | #define SERBAUD R_SERIAL3_BAUD | ||
111 | #define SERRECC R_SERIAL3_REC_CTRL | ||
112 | #define SERRDAT R_SERIAL3_REC_DATA | ||
113 | #define SERSTAT R_SERIAL3_STATUS | ||
114 | #endif | ||
115 | |||
116 | #define NOP_DI 0xf025050f | ||
117 | #define RAM_INIT_MAGIC 0x56902387 | ||
118 | |||
119 | .text | ||
120 | |||
121 | ;; This is the entry point of the rescue code | ||
122 | ;; 0x80000000 if loaded in flash (as it should be) | ||
123 | ;; Since etrax actually starts at address 2 when booting from flash, we | ||
124 | ;; put a nop (2 bytes) here first so we dont accidentally skip the di | ||
125 | |||
126 | nop | ||
127 | di | ||
128 | |||
129 | jump in_cache ; enter cached area instead | ||
130 | in_cache: | ||
131 | |||
132 | |||
133 | ;; First put a jump test to give a possibility of upgrading the | ||
134 | ;; rescue code without erasing/reflashing the sector. | ||
135 | ;; We put a longword of -1 here and if it is not -1, we jump using | ||
136 | ;; the value as jump target. Since we can always change 1's to 0's | ||
137 | ;; without erasing the sector, it is possible to add new | ||
138 | ;; code after this and altering the jumptarget in an upgrade. | ||
139 | |||
140 | jtcd: move.d [jumptarget], $r0 | ||
141 | cmp.d 0xffffffff, $r0 | ||
142 | beq no_newjump | ||
143 | nop | ||
144 | |||
145 | jump [$r0] | ||
146 | |||
147 | jumptarget: | ||
148 | .dword 0xffffffff ; can be overwritten later to insert new code | ||
149 | |||
150 | no_newjump: | ||
151 | #ifdef CONFIG_ETRAX_ETHERNET | ||
152 | ;; Start MII clock to make sure it is running when tranceiver is reset | ||
153 | move.d 0x3, $r0 ; enable = on, phy = mii_clk | ||
154 | move.d $r0, [R_NETWORK_GEN_CONFIG] | ||
155 | #endif | ||
156 | |||
157 | ;; We need to setup the bus registers before we start using the DRAM | ||
158 | #include "../../../arch-v10/lib/dram_init.S" | ||
159 | |||
160 | ;; we now should go through the checksum-table and check the listed | ||
161 | ;; partitions for errors. | ||
162 | |||
163 | move.d PTABLE_START, $r3 | ||
164 | move.d [$r3], $r0 | ||
165 | cmp.d NOP_DI, $r0 ; make sure the nop/di is there... | ||
166 | bne do_rescue | ||
167 | nop | ||
168 | |||
169 | ;; skip the code transparency block (10 bytes). | ||
170 | |||
171 | addq 10, $r3 | ||
172 | |||
173 | ;; check for correct magic | ||
174 | |||
175 | move.w [$r3+], $r0 | ||
176 | cmp.w PTABLE_MAGIC, $r0 | ||
177 | bne do_rescue ; didn't recognize - trig rescue | ||
178 | nop | ||
179 | |||
180 | ;; check for correct ptable checksum | ||
181 | |||
182 | movu.w [$r3+], $r2 ; ptable length | ||
183 | move.d $r2, $r8 ; save for later, length of total ptable | ||
184 | addq 28, $r8 ; account for the rest | ||
185 | move.d [$r3+], $r4 ; ptable checksum | ||
186 | move.d $r3, $r1 | ||
187 | jsr checksum ; r1 source, r2 length, returns in r0 | ||
188 | |||
189 | cmp.d $r0, $r4 | ||
190 | bne do_rescue ; didn't match - trig rescue | ||
191 | nop | ||
192 | |||
193 | ;; ptable is ok. validate each entry. | ||
194 | |||
195 | moveq -1, $r7 | ||
196 | |||
197 | ploop: move.d [$r3+], $r1 ; partition offset (from ptable start) | ||
198 | bne notfirst ; check if it is the partition containing ptable | ||
199 | nop ; yes.. | ||
200 | move.d $r8, $r1 ; for its checksum check, skip the ptable | ||
201 | move.d [$r3+], $r2 ; partition length | ||
202 | sub.d $r8, $r2 ; minus the ptable length | ||
203 | ba bosse | ||
204 | nop | ||
205 | notfirst: | ||
206 | cmp.d -1, $r1 ; the end of the ptable ? | ||
207 | beq flash_ok ; if so, the flash is validated | ||
208 | move.d [$r3+], $r2 ; partition length | ||
209 | bosse: move.d [$r3+], $r5 ; checksum | ||
210 | move.d [$r3+], $r4 ; type and flags | ||
211 | addq 16, $r3 ; skip the reserved bytes | ||
212 | btstq 16, $r4 ; check ro flag | ||
213 | bpl ploop ; rw partition, skip validation | ||
214 | nop | ||
215 | btstq 17, $r4 ; check bootable flag | ||
216 | bpl 1f | ||
217 | nop | ||
218 | move.d $r1, $r7 ; remember boot partition offset | ||
219 | 1: | ||
220 | add.d PTABLE_START, $r1 | ||
221 | |||
222 | jsr checksum ; checksum the partition | ||
223 | |||
224 | cmp.d $r0, $r5 | ||
225 | beq ploop ; checksums matched, go to next entry | ||
226 | nop | ||
227 | |||
228 | ;; otherwise fall through to the rescue code. | ||
229 | |||
230 | do_rescue: | ||
231 | ;; setup port PA and PB default initial directions and data | ||
232 | ;; (so we can flash LEDs, and so that DTR and others are set) | ||
233 | |||
234 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 | ||
235 | move.b $r0, [R_PORT_PA_DIR] | ||
236 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 | ||
237 | move.b $r0, [R_PORT_PA_DATA] | ||
238 | |||
239 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 | ||
240 | move.b $r0, [R_PORT_PB_DIR] | ||
241 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 | ||
242 | move.b $r0, [R_PORT_PB_DATA] | ||
243 | |||
244 | ;; setup the serial port at 115200 baud | ||
245 | |||
246 | moveq 0, $r0 | ||
247 | move.d $r0, [SERXOFF] | ||
248 | |||
249 | move.b 0x99, $r0 | ||
250 | move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive | ||
251 | |||
252 | move.b 0x40, $r0 ; rec enable | ||
253 | move.b $r0, [SERRECC] | ||
254 | |||
255 | moveq 0, $r1 ; "timer" to clock out a LED red flash | ||
256 | move.d CODE_START, $r3 ; destination counter | ||
257 | movu.w CODE_LENGTH, $r4; length | ||
258 | |||
259 | wait_ser: | ||
260 | addq 1, $r1 | ||
261 | #ifndef CONFIG_ETRAX_NO_LEDS | ||
262 | #ifdef CONFIG_ETRAX_PA_LEDS | ||
263 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r2 | ||
264 | #endif | ||
265 | #ifdef CONFIG_ETRAX_PB_LEDS | ||
266 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r2 | ||
267 | #endif | ||
268 | move.d (1 << CONFIG_ETRAX_LED1R) | (1 << CONFIG_ETRAX_LED2R), $r0 | ||
269 | btstq 16, $r1 | ||
270 | bpl 1f | ||
271 | nop | ||
272 | or.d $r0, $r2 ; set bit | ||
273 | ba 2f | ||
274 | nop | ||
275 | 1: not $r0 ; clear bit | ||
276 | and.d $r0, $r2 | ||
277 | 2: | ||
278 | #ifdef CONFIG_ETRAX_PA_LEDS | ||
279 | move.b $r2, [R_PORT_PA_DATA] | ||
280 | #endif | ||
281 | #ifdef CONFIG_ETRAX_PB_LEDS | ||
282 | move.b $r2, [R_PORT_PB_DATA] | ||
283 | #endif | ||
284 | #ifdef CONFIG_ETRAX_90000000_LEDS | ||
285 | move.b $r2, [0x90000000] | ||
286 | #endif | ||
287 | #endif | ||
288 | |||
289 | ;; check if we got something on the serial port | ||
290 | |||
291 | move.b [SERSTAT], $r0 | ||
292 | btstq 0, $r0 ; data_avail | ||
293 | bpl wait_ser | ||
294 | nop | ||
295 | |||
296 | ;; got something - copy the byte and loop | ||
297 | |||
298 | move.b [SERRDAT], $r0 | ||
299 | move.b $r0, [$r3+] | ||
300 | |||
301 | subq 1, $r4 ; decrease length | ||
302 | bne wait_ser | ||
303 | nop | ||
304 | |||
305 | ;; jump into downloaded code | ||
306 | |||
307 | move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is | ||
308 | ; initialized | ||
309 | jump CODE_START | ||
310 | |||
311 | flash_ok: | ||
312 | ;; check r7, which contains either -1 or the partition to boot from | ||
313 | |||
314 | cmp.d -1, $r7 | ||
315 | bne 1f | ||
316 | nop | ||
317 | move.d PTABLE_START, $r7; otherwise use the ptable start | ||
318 | 1: | ||
319 | move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is | ||
320 | ; initialized | ||
321 | jump $r7 ; boot! | ||
322 | |||
323 | |||
324 | ;; Helper subroutines | ||
325 | |||
326 | ;; Will checksum by simple addition | ||
327 | ;; r1 - source | ||
328 | ;; r2 - length in bytes | ||
329 | ;; result will be in r0 | ||
330 | checksum: | ||
331 | moveq 0, $r0 | ||
332 | moveq CONFIG_ETRAX_FLASH1_SIZE, $r6 | ||
333 | |||
334 | ;; If the first physical flash memory is exceeded wrap to the | ||
335 | ;; second one | ||
336 | btstq 26, $r1 ; Are we addressing first flash? | ||
337 | bpl 1f | ||
338 | nop | ||
339 | clear.d $r6 | ||
340 | |||
341 | 1: test.d $r6 ; 0 = no wrapping | ||
342 | beq 2f | ||
343 | nop | ||
344 | lslq 20, $r6 ; Convert MB to bytes | ||
345 | sub.d $r1, $r6 | ||
346 | |||
347 | 2: addu.b [$r1+], $r0 | ||
348 | subq 1, $r6 ; Flash memory left | ||
349 | beq 3f | ||
350 | subq 1, $r2 ; Length left | ||
351 | bne 2b | ||
352 | nop | ||
353 | ret | ||
354 | nop | ||
355 | |||
356 | 3: move.d MEM_CSE1_START, $r1 ; wrap to second flash | ||
357 | ba 2b | ||
358 | nop | ||
359 | |||
360 | #endif | ||
diff --git a/arch/cris/boot/rescue/head_v32.S b/arch/cris/boot/rescue/head_v32.S new file mode 100644 index 000000000000..5f846b7700a3 --- /dev/null +++ b/arch/cris/boot/rescue/head_v32.S | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Just get started by jumping to CONFIG_ETRAX_PTABLE_SECTOR to start | ||
3 | * kernel decompressor. | ||
4 | * | ||
5 | * In practice, this only works for NOR flash (or some convoluted RAM boot) | ||
6 | * and hence is not really useful for Artpec-3, so it's Etrax FS / NOR only. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #include <mach/startup.inc> | ||
11 | |||
12 | #ifdef CONFIG_ETRAX_AXISFLASHMAP | ||
13 | |||
14 | ;; Code | ||
15 | |||
16 | .text | ||
17 | start: | ||
18 | |||
19 | ;; Start clocks for used blocks. | ||
20 | START_CLOCKS | ||
21 | |||
22 | move.d CONFIG_ETRAX_PTABLE_SECTOR, $r10 | ||
23 | jump $r10 ; Jump to decompressor | ||
24 | nop | ||
25 | |||
26 | #endif | ||
diff --git a/arch/cris/boot/rescue/kimagerescue.S b/arch/cris/boot/rescue/kimagerescue.S new file mode 100644 index 000000000000..6f7b3e61260b --- /dev/null +++ b/arch/cris/boot/rescue/kimagerescue.S | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | * Rescue code to be prepended on a kimage and copied to the | ||
3 | * rescue serial port. | ||
4 | * This is called from the rescue code, it will copy received data to | ||
5 | * 4004000 and after a timeout jump to it. | ||
6 | */ | ||
7 | |||
8 | #define ASSEMBLER_MACROS_ONLY | ||
9 | #include <arch/sv_addr_ag.h> | ||
10 | |||
11 | #define CODE_START 0x40004000 | ||
12 | #define CODE_LENGTH 784 | ||
13 | #define TIMEOUT_VALUE 1000 | ||
14 | |||
15 | |||
16 | #ifdef CONFIG_ETRAX_RESCUE_SER0 | ||
17 | #define SERXOFF R_SERIAL0_XOFF | ||
18 | #define SERBAUD R_SERIAL0_BAUD | ||
19 | #define SERRECC R_SERIAL0_REC_CTRL | ||
20 | #define SERRDAT R_SERIAL0_REC_DATA | ||
21 | #define SERSTAT R_SERIAL0_STATUS | ||
22 | #endif | ||
23 | #ifdef CONFIG_ETRAX_RESCUE_SER1 | ||
24 | #define SERXOFF R_SERIAL1_XOFF | ||
25 | #define SERBAUD R_SERIAL1_BAUD | ||
26 | #define SERRECC R_SERIAL1_REC_CTRL | ||
27 | #define SERRDAT R_SERIAL1_REC_DATA | ||
28 | #define SERSTAT R_SERIAL1_STATUS | ||
29 | #endif | ||
30 | #ifdef CONFIG_ETRAX_RESCUE_SER2 | ||
31 | #define SERXOFF R_SERIAL2_XOFF | ||
32 | #define SERBAUD R_SERIAL2_BAUD | ||
33 | #define SERRECC R_SERIAL2_REC_CTRL | ||
34 | #define SERRDAT R_SERIAL2_REC_DATA | ||
35 | #define SERSTAT R_SERIAL2_STATUS | ||
36 | #endif | ||
37 | #ifdef CONFIG_ETRAX_RESCUE_SER3 | ||
38 | #define SERXOFF R_SERIAL3_XOFF | ||
39 | #define SERBAUD R_SERIAL3_BAUD | ||
40 | #define SERRECC R_SERIAL3_REC_CTRL | ||
41 | #define SERRDAT R_SERIAL3_REC_DATA | ||
42 | #define SERSTAT R_SERIAL3_STATUS | ||
43 | #endif | ||
44 | |||
45 | .text | ||
46 | ;; This is the entry point of the rescue code | ||
47 | ;; 0x80000000 if loaded in flash (as it should be) | ||
48 | ;; since etrax actually starts at address 2 when booting from flash, we | ||
49 | ;; put a nop (2 bytes) here first so we dont accidentally skip the di | ||
50 | |||
51 | nop | ||
52 | di | ||
53 | #ifndef CONFIG_SVINTO_SIM | ||
54 | ;; setup port PA and PB default initial directions and data | ||
55 | ;; (so we can flash LEDs, and so that DTR and others are set) | ||
56 | |||
57 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 | ||
58 | move.b $r0, [R_PORT_PA_DIR] | ||
59 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 | ||
60 | move.b $r0, [R_PORT_PA_DATA] | ||
61 | |||
62 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 | ||
63 | move.b $r0, [R_PORT_PB_DIR] | ||
64 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 | ||
65 | move.b $r0, [R_PORT_PB_DATA] | ||
66 | |||
67 | ;; We need to setup the bus registers before we start using the DRAM | ||
68 | #include "../../lib/dram_init.S" | ||
69 | |||
70 | #endif | ||
71 | ;; Setup the stack to a suitably high address. | ||
72 | ;; We assume 8 MB is the minimum DRAM in an eLinux | ||
73 | ;; product and put the sp at the top for now. | ||
74 | |||
75 | move.d 0x40800000, $sp | ||
76 | |||
77 | ;; setup the serial port at 115200 baud | ||
78 | |||
79 | moveq 0, $r0 | ||
80 | move.d $r0, [SERXOFF] | ||
81 | |||
82 | move.b 0x99, $r0 | ||
83 | move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit | ||
84 | ; and receive | ||
85 | |||
86 | move.b 0x40, $r0 ; rec enable | ||
87 | move.b $r0, [SERRECC] | ||
88 | |||
89 | |||
90 | moveq 0, $r1 ; "timer" to clock out a LED red flash | ||
91 | move.d CODE_START, $r3 ; destination counter | ||
92 | move.d CODE_LENGTH, $r4 ; length | ||
93 | move.d TIMEOUT_VALUE, $r5 ; "timeout" until jump | ||
94 | |||
95 | wait_ser: | ||
96 | addq 1, $r1 | ||
97 | subq 1, $r5 ; decrease timeout | ||
98 | beq jump_start ; timed out | ||
99 | nop | ||
100 | #ifndef CONFIG_ETRAX_NO_LEDS | ||
101 | #ifdef CONFIG_ETRAX_PA_LEDS | ||
102 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r2 | ||
103 | #endif | ||
104 | #ifdef CONFIG_ETRAX_PB_LEDS | ||
105 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r2 | ||
106 | #endif | ||
107 | move.d (1 << CONFIG_ETRAX_LED1R) | (1 << CONFIG_ETRAX_LED2R), $r0 | ||
108 | btstq 16, $r1 | ||
109 | bpl 1f | ||
110 | nop | ||
111 | or.d $r0, $r2 ; set bit | ||
112 | ba 2f | ||
113 | nop | ||
114 | 1: not $r0 ; clear bit | ||
115 | and.d $r0, $r2 | ||
116 | 2: | ||
117 | #ifdef CONFIG_ETRAX_PA_LEDS | ||
118 | move.b $r2, [R_PORT_PA_DATA] | ||
119 | #endif | ||
120 | #ifdef CONFIG_ETRAX_PB_LEDS | ||
121 | move.b $r2, [R_PORT_PB_DATA] | ||
122 | #endif | ||
123 | #endif | ||
124 | |||
125 | ;; check if we got something on the serial port | ||
126 | |||
127 | move.b [SERSTAT], $r0 | ||
128 | btstq 0, $r0 ; data_avail | ||
129 | bpl wait_ser | ||
130 | nop | ||
131 | |||
132 | ;; got something - copy the byte and loop | ||
133 | |||
134 | move.b [SERRDAT], $r0 | ||
135 | move.b $r0, [$r3+] | ||
136 | move.d TIMEOUT_VALUE, $r5 ; reset "timeout" | ||
137 | subq 1, $r4 ; decrease length | ||
138 | bne wait_ser | ||
139 | nop | ||
140 | jump_start: | ||
141 | ;; jump into downloaded code | ||
142 | |||
143 | jump CODE_START | ||
diff --git a/arch/cris/boot/rescue/rescue_v10.lds b/arch/cris/boot/rescue/rescue_v10.lds new file mode 100644 index 000000000000..0b52a9490db6 --- /dev/null +++ b/arch/cris/boot/rescue/rescue_v10.lds | |||
@@ -0,0 +1,20 @@ | |||
1 | MEMORY | ||
2 | { | ||
3 | flash : ORIGIN = 0x00000000, | ||
4 | LENGTH = 0x00100000 | ||
5 | } | ||
6 | |||
7 | SECTIONS | ||
8 | { | ||
9 | .text : | ||
10 | { | ||
11 | stext = . ; | ||
12 | *(.text) | ||
13 | etext = . ; | ||
14 | } > flash | ||
15 | .data : | ||
16 | { | ||
17 | *(.data) | ||
18 | edata = . ; | ||
19 | } > flash | ||
20 | } | ||
diff --git a/arch/cris/boot/rescue/rescue_v32.lds b/arch/cris/boot/rescue/rescue_v32.lds new file mode 100644 index 000000000000..8ac646bc1a2b --- /dev/null +++ b/arch/cris/boot/rescue/rescue_v32.lds | |||
@@ -0,0 +1,43 @@ | |||
1 | /*#OUTPUT_FORMAT(elf32-us-cris) */ | ||
2 | OUTPUT_ARCH (crisv32) | ||
3 | /* Now that NAND support has been stripped, this file could be simplified, | ||
4 | * but it doesn't do any harm on the other hand so why bother. */ | ||
5 | |||
6 | MEMORY | ||
7 | { | ||
8 | bootblk : ORIGIN = 0x38000000, | ||
9 | LENGTH = 0x00004000 | ||
10 | intmem : ORIGIN = 0x38004000, | ||
11 | LENGTH = 0x00005000 | ||
12 | } | ||
13 | |||
14 | SECTIONS | ||
15 | { | ||
16 | .text : | ||
17 | { | ||
18 | _stext = . ; | ||
19 | *(.text) | ||
20 | *(.init.text) | ||
21 | *(.rodata) | ||
22 | *(.rodata.*) | ||
23 | _etext = . ; | ||
24 | } > bootblk | ||
25 | .data : | ||
26 | { | ||
27 | *(.data) | ||
28 | _edata = . ; | ||
29 | } > bootblk | ||
30 | .bss : | ||
31 | { | ||
32 | _bss = . ; | ||
33 | *(.bss) | ||
34 | _end = ALIGN( 0x10 ) ; | ||
35 | } > intmem | ||
36 | |||
37 | /* Get rid of stuff from EXPORT_SYMBOL(foo). */ | ||
38 | /DISCARD/ : | ||
39 | { | ||
40 | *(__ksymtab_strings) | ||
41 | *(__ksymtab) | ||
42 | } | ||
43 | } | ||
diff --git a/arch/cris/boot/rescue/testrescue.S b/arch/cris/boot/rescue/testrescue.S new file mode 100644 index 000000000000..fc7ec674eca5 --- /dev/null +++ b/arch/cris/boot/rescue/testrescue.S | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Simple testcode to download by the rescue block. | ||
3 | * Just lights some LEDs to show it was downloaded correctly. | ||
4 | * | ||
5 | * Copyright (C) 1999 Axis Communications AB | ||
6 | */ | ||
7 | |||
8 | #define ASSEMBLER_MACROS_ONLY | ||
9 | #include <arch/sv_addr_ag.h> | ||
10 | |||
11 | .text | ||
12 | |||
13 | nop | ||
14 | nop | ||
15 | moveq -1, $r2 | ||
16 | move.b $r2, [R_PORT_PA_DIR] | ||
17 | moveq 0, $r2 | ||
18 | move.b $r2, [R_PORT_PA_DATA] | ||
19 | |||
20 | endless: | ||
21 | nop | ||
22 | ba endless | ||
23 | nop | ||
24 | |||