aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v10/boot/rescue/head.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/cris/arch-v10/boot/rescue/head.S')
-rw-r--r--arch/cris/arch-v10/boot/rescue/head.S129
1 files changed, 68 insertions, 61 deletions
diff --git a/arch/cris/arch-v10/boot/rescue/head.S b/arch/cris/arch-v10/boot/rescue/head.S
index f223cc0c00bb..6ba7be8ac4a0 100644
--- a/arch/cris/arch-v10/boot/rescue/head.S
+++ b/arch/cris/arch-v10/boot/rescue/head.S
@@ -1,5 +1,4 @@
1/* $Id: head.S,v 1.7 2005/03/07 12:11:06 starvik Exp $ 1/*
2 *
3 * Rescue code, made to reside at the beginning of the 2 * Rescue code, made to reside at the beginning of the
4 * flash-memory. when it starts, it checks a partition 3 * flash-memory. when it starts, it checks a partition
5 * table at the first sector after the rescue sector. 4 * table at the first sector after the rescue sector.
@@ -23,20 +22,20 @@
23 * Partition table format: 22 * Partition table format:
24 * 23 *
25 * Code transparency: 24 * Code transparency:
26 * 25 *
27 * 2 bytes [opcode 'nop'] 26 * 2 bytes [opcode 'nop']
28 * 2 bytes [opcode 'di'] 27 * 2 bytes [opcode 'di']
29 * 4 bytes [opcode 'ba <offset>', 8-bit or 16-bit version] 28 * 4 bytes [opcode 'ba <offset>', 8-bit or 16-bit version]
30 * 2 bytes [opcode 'nop', delay slot] 29 * 2 bytes [opcode 'nop', delay slot]
31 * 30 *
32 * Table validation (at +10): 31 * Table validation (at +10):
33 * 32 *
34 * 2 bytes [magic/version word for partitiontable - 0xef, 0xbe] 33 * 2 bytes [magic/version word for partitiontable - 0xef, 0xbe]
35 * 2 bytes [length of all entries plus the end marker] 34 * 2 bytes [length of all entries plus the end marker]
36 * 4 bytes [checksum for the partitiontable itself] 35 * 4 bytes [checksum for the partitiontable itself]
37 * 36 *
38 * Entries, each with the following format, last has offset -1: 37 * Entries, each with the following format, last has offset -1:
39 * 38 *
40 * 4 bytes [offset in bytes, from start of flash] 39 * 4 bytes [offset in bytes, from start of flash]
41 * 4 bytes [length in bytes of partition] 40 * 4 bytes [length in bytes of partition]
42 * 4 bytes [checksum, simple longword sum] 41 * 4 bytes [checksum, simple longword sum]
@@ -47,9 +46,9 @@
47 * End marker 46 * End marker
48 * 47 *
49 * 4 bytes [-1] 48 * 4 bytes [-1]
50 * 49 *
51 * 10 bytes [0, padding] 50 * 10 bytes [0, padding]
52 * 51 *
53 * Bit 0 in flags signifies RW or RO. The rescue code only bothers 52 * Bit 0 in flags signifies RW or RO. The rescue code only bothers
54 * to check the checksum for RO partitions, since the others will 53 * to check the checksum for RO partitions, since the others will
55 * change their data without updating the checksums. A 1 in bit 0 54 * change their data without updating the checksums. A 1 in bit 0
@@ -59,26 +58,29 @@
59 * 58 *
60 * During the wait for serial input, the status LED will flash so the 59 * During the wait for serial input, the status LED will flash so the
61 * user knows something went wrong. 60 * user knows something went wrong.
62 * 61 *
63 * Copyright (C) 1999, 2000, 2001, 2002, 2003 Axis Communications AB 62 * Copyright (C) 1999-2007 Axis Communications AB
64 */ 63 */
65 64
65#ifdef CONFIG_ETRAX_AXISFLASHMAP
66
66#define ASSEMBLER_MACROS_ONLY 67#define ASSEMBLER_MACROS_ONLY
67#include <asm/arch/sv_addr_ag.h> 68#include <asm/arch/sv_addr_ag.h>
68 69
69 ;; The partitiontable is looked for at the first sector after the boot 70 ;; The partitiontable is looked for at the first sector after the boot
70 ;; sector. Sector size is 65536 bytes in all flashes we use. 71 ;; sector. Sector size is 65536 bytes in all flashes we use.
71 72
72#define PTABLE_START CONFIG_ETRAX_PTABLE_SECTOR 73#define PTABLE_START CONFIG_ETRAX_PTABLE_SECTOR
73#define PTABLE_MAGIC 0xbeef 74#define PTABLE_MAGIC 0xbeef
74 75
75 ;; The normal Etrax100 on-chip boot ROM does serial boot at 0x380000f0. 76 ;; The normal Etrax100 on-chip boot ROM does serial boot at 0x380000f0.
76 ;; That is not where we put our downloaded serial boot-code. The length is 77 ;; That is not where we put our downloaded serial boot-code.
77 ;; enough for downloading code that loads the rest of itself (after 78 ;; The length is enough for downloading code that loads the rest
78 ;; having setup the DRAM etc). It is the same length as the on-chip 79 ;; of itself (after having setup the DRAM etc).
79 ;; ROM loads, so the same host loader can be used to load a rescued 80 ;; It is the same length as the on-chip ROM loads, so the same
80 ;; product as well as one booted through the Etrax serial boot code. 81 ;; host loader can be used to load a rescued product as well as
81 82 ;; one booted through the Etrax serial boot code.
83
82#define CODE_START 0x40000000 84#define CODE_START 0x40000000
83#define CODE_LENGTH 784 85#define CODE_LENGTH 784
84 86
@@ -102,7 +104,7 @@
102#define SERRECC R_SERIAL2_REC_CTRL 104#define SERRECC R_SERIAL2_REC_CTRL
103#define SERRDAT R_SERIAL2_REC_DATA 105#define SERRDAT R_SERIAL2_REC_DATA
104#define SERSTAT R_SERIAL2_STATUS 106#define SERSTAT R_SERIAL2_STATUS
105#endif 107#endif
106#ifdef CONFIG_ETRAX_RESCUE_SER3 108#ifdef CONFIG_ETRAX_RESCUE_SER3
107#define SERXOFF R_SERIAL3_XOFF 109#define SERXOFF R_SERIAL3_XOFF
108#define SERBAUD R_SERIAL3_BAUD 110#define SERBAUD R_SERIAL3_BAUD
@@ -115,60 +117,61 @@
115#define RAM_INIT_MAGIC 0x56902387 117#define RAM_INIT_MAGIC 0x56902387
116 118
117 .text 119 .text
118 120
119 ;; This is the entry point of the rescue code 121 ;; This is the entry point of the rescue code
120 ;; 0x80000000 if loaded in flash (as it should be) 122 ;; 0x80000000 if loaded in flash (as it should be)
121 ;; since etrax actually starts at address 2 when booting from flash, we 123 ;; Since etrax actually starts at address 2 when booting from flash, we
122 ;; put a nop (2 bytes) here first so we dont accidentally skip the di 124 ;; put a nop (2 bytes) here first so we dont accidentally skip the di
123 125
124 nop 126 nop
125 di 127 di
126 128
127 jump in_cache ; enter cached area instead 129 jump in_cache ; enter cached area instead
128in_cache: 130in_cache:
129 131
130 132
131 ;; first put a jump test to give a possibility of upgrading the rescue code 133 ;; First put a jump test to give a possibility of upgrading the
132 ;; without erasing/reflashing the sector. we put a longword of -1 here and if 134 ;; rescue code without erasing/reflashing the sector.
133 ;; it is not -1, we jump using the value as jump target. since we can always 135 ;; We put a longword of -1 here and if it is not -1, we jump using
134 ;; change 1's to 0's without erasing the sector, it is possible to add new 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
135 ;; code after this and altering the jumptarget in an upgrade. 138 ;; code after this and altering the jumptarget in an upgrade.
136 139
137jtcd: move.d [jumptarget], $r0 140jtcd: move.d [jumptarget], $r0
138 cmp.d 0xffffffff, $r0 141 cmp.d 0xffffffff, $r0
139 beq no_newjump 142 beq no_newjump
140 nop 143 nop
141 144
142 jump [$r0] 145 jump [$r0]
143 146
144jumptarget: 147jumptarget:
145 .dword 0xffffffff ; can be overwritten later to insert new code 148 .dword 0xffffffff ; can be overwritten later to insert new code
146 149
147no_newjump: 150no_newjump:
148#ifdef CONFIG_ETRAX_ETHERNET 151#ifdef CONFIG_ETRAX_ETHERNET
149 ;; Start MII clock to make sure it is running when tranceiver is reset 152 ;; Start MII clock to make sure it is running when tranceiver is reset
150 move.d 0x3, $r0 ; enable = on, phy = mii_clk 153 move.d 0x3, $r0 ; enable = on, phy = mii_clk
151 move.d $r0, [R_NETWORK_GEN_CONFIG] 154 move.d $r0, [R_NETWORK_GEN_CONFIG]
152#endif 155#endif
153 156
154 ;; We need to setup the bus registers before we start using the DRAM 157 ;; We need to setup the bus registers before we start using the DRAM
155#include "../../lib/dram_init.S" 158#include "../../lib/dram_init.S"
156 159
157 ;; we now should go through the checksum-table and check the listed 160 ;; we now should go through the checksum-table and check the listed
158 ;; partitions for errors. 161 ;; partitions for errors.
159 162
160 move.d PTABLE_START, $r3 163 move.d PTABLE_START, $r3
161 move.d [$r3], $r0 164 move.d [$r3], $r0
162 cmp.d NOP_DI, $r0 ; make sure the nop/di is there... 165 cmp.d NOP_DI, $r0 ; make sure the nop/di is there...
163 bne do_rescue 166 bne do_rescue
164 nop 167 nop
165 168
166 ;; skip the code transparency block (10 bytes). 169 ;; skip the code transparency block (10 bytes).
167 170
168 addq 10, $r3 171 addq 10, $r3
169 172
170 ;; check for correct magic 173 ;; check for correct magic
171 174
172 move.w [$r3+], $r0 175 move.w [$r3+], $r0
173 cmp.w PTABLE_MAGIC, $r0 176 cmp.w PTABLE_MAGIC, $r0
174 bne do_rescue ; didn't recognize - trig rescue 177 bne do_rescue ; didn't recognize - trig rescue
@@ -186,11 +189,11 @@ no_newjump:
186 cmp.d $r0, $r4 189 cmp.d $r0, $r4
187 bne do_rescue ; didn't match - trig rescue 190 bne do_rescue ; didn't match - trig rescue
188 nop 191 nop
189 192
190 ;; ptable is ok. validate each entry. 193 ;; ptable is ok. validate each entry.
191 194
192 moveq -1, $r7 195 moveq -1, $r7
193 196
194ploop: move.d [$r3+], $r1 ; partition offset (from ptable start) 197ploop: move.d [$r3+], $r1 ; partition offset (from ptable start)
195 bne notfirst ; check if it is the partition containing ptable 198 bne notfirst ; check if it is the partition containing ptable
196 nop ; yes.. 199 nop ; yes..
@@ -199,7 +202,7 @@ ploop: move.d [$r3+], $r1 ; partition offset (from ptable start)
199 sub.d $r8, $r2 ; minus the ptable length 202 sub.d $r8, $r2 ; minus the ptable length
200 ba bosse 203 ba bosse
201 nop 204 nop
202notfirst: 205notfirst:
203 cmp.d -1, $r1 ; the end of the ptable ? 206 cmp.d -1, $r1 ; the end of the ptable ?
204 beq flash_ok ; if so, the flash is validated 207 beq flash_ok ; if so, the flash is validated
205 move.d [$r3+], $r2 ; partition length 208 move.d [$r3+], $r2 ; partition length
@@ -213,47 +216,46 @@ bosse: move.d [$r3+], $r5 ; checksum
213 bpl 1f 216 bpl 1f
214 nop 217 nop
215 move.d $r1, $r7 ; remember boot partition offset 218 move.d $r1, $r7 ; remember boot partition offset
2161: 2191:
217
218 add.d PTABLE_START, $r1 220 add.d PTABLE_START, $r1
219 221
220 jsr checksum ; checksum the partition 222 jsr checksum ; checksum the partition
221 223
222 cmp.d $r0, $r5 224 cmp.d $r0, $r5
223 beq ploop ; checksums matched, go to next entry 225 beq ploop ; checksums matched, go to next entry
224 nop 226 nop
225 227
226 ;; otherwise fall through to the rescue code. 228 ;; otherwise fall through to the rescue code.
227 229
228do_rescue: 230do_rescue:
229 ;; setup port PA and PB default initial directions and data 231 ;; setup port PA and PB default initial directions and data
230 ;; (so we can flash LEDs, and so that DTR and others are set) 232 ;; (so we can flash LEDs, and so that DTR and others are set)
231 233
232 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 234 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
233 move.b $r0, [R_PORT_PA_DIR] 235 move.b $r0, [R_PORT_PA_DIR]
234 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 236 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
235 move.b $r0, [R_PORT_PA_DATA] 237 move.b $r0, [R_PORT_PA_DATA]
236 238
237 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 239 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
238 move.b $r0, [R_PORT_PB_DIR] 240 move.b $r0, [R_PORT_PB_DIR]
239 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 241 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
240 move.b $r0, [R_PORT_PB_DATA] 242 move.b $r0, [R_PORT_PB_DATA]
241 243
242 ;; setup the serial port at 115200 baud 244 ;; setup the serial port at 115200 baud
243 245
244 moveq 0, $r0 246 moveq 0, $r0
245 move.d $r0, [SERXOFF] 247 move.d $r0, [SERXOFF]
246 248
247 move.b 0x99, $r0 249 move.b 0x99, $r0
248 move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive 250 move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive
249 251
250 move.b 0x40, $r0 ; rec enable 252 move.b 0x40, $r0 ; rec enable
251 move.b $r0, [SERRECC] 253 move.b $r0, [SERRECC]
252 254
253 moveq 0, $r1 ; "timer" to clock out a LED red flash 255 moveq 0, $r1 ; "timer" to clock out a LED red flash
254 move.d CODE_START, $r3 ; destination counter 256 move.d CODE_START, $r3 ; destination counter
255 movu.w CODE_LENGTH, $r4; length 257 movu.w CODE_LENGTH, $r4; length
256 258
257wait_ser: 259wait_ser:
258 addq 1, $r1 260 addq 1, $r1
259#ifndef CONFIG_ETRAX_NO_LEDS 261#ifndef CONFIG_ETRAX_NO_LEDS
@@ -272,20 +274,20 @@ wait_ser:
272 nop 274 nop
2731: not $r0 ; clear bit 2751: not $r0 ; clear bit
274 and.d $r0, $r2 276 and.d $r0, $r2
2752: 2772:
276#ifdef CONFIG_ETRAX_PA_LEDS 278#ifdef CONFIG_ETRAX_PA_LEDS
277 move.b $r2, [R_PORT_PA_DATA] 279 move.b $r2, [R_PORT_PA_DATA]
278#endif 280#endif
279#ifdef CONFIG_ETRAX_PB_LEDS 281#ifdef CONFIG_ETRAX_PB_LEDS
280 move.b $r2, [R_PORT_PB_DATA] 282 move.b $r2, [R_PORT_PB_DATA]
281#endif 283#endif
282#ifdef CONFIG_ETRAX_90000000_LEDS 284#ifdef CONFIG_ETRAX_90000000_LEDS
283 move.b $r2, [0x90000000] 285 move.b $r2, [0x90000000]
284#endif 286#endif
285#endif 287#endif
286 288
287 ;; check if we got something on the serial port 289 ;; check if we got something on the serial port
288 290
289 move.b [SERSTAT], $r0 291 move.b [SERSTAT], $r0
290 btstq 0, $r0 ; data_avail 292 btstq 0, $r0 ; data_avail
291 bpl wait_ser 293 bpl wait_ser
@@ -295,14 +297,15 @@ wait_ser:
295 297
296 move.b [SERRDAT], $r0 298 move.b [SERRDAT], $r0
297 move.b $r0, [$r3+] 299 move.b $r0, [$r3+]
298 300
299 subq 1, $r4 ; decrease length 301 subq 1, $r4 ; decrease length
300 bne wait_ser 302 bne wait_ser
301 nop 303 nop
302 304
303 ;; jump into downloaded code 305 ;; jump into downloaded code
304 306
305 move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is initialized 307 move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is
308 ; initialized
306 jump CODE_START 309 jump CODE_START
307 310
308flash_ok: 311flash_ok:
@@ -313,7 +316,8 @@ flash_ok:
313 nop 316 nop
314 move.d PTABLE_START, $r7; otherwise use the ptable start 317 move.d PTABLE_START, $r7; otherwise use the ptable start
3151: 3181:
316 move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is initialized 319 move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is
320 ; initialized
317 jump $r7 ; boot! 321 jump $r7 ; boot!
318 322
319 323
@@ -327,7 +331,8 @@ checksum:
327 moveq 0, $r0 331 moveq 0, $r0
328 moveq CONFIG_ETRAX_FLASH1_SIZE, $r6 332 moveq CONFIG_ETRAX_FLASH1_SIZE, $r6
329 333
330 ;; If the first physical flash memory is exceeded wrap to the second one. 334 ;; If the first physical flash memory is exceeded wrap to the
335 ;; second one
331 btstq 26, $r1 ; Are we addressing first flash? 336 btstq 26, $r1 ; Are we addressing first flash?
332 bpl 1f 337 bpl 1f
333 nop 338 nop
@@ -351,3 +356,5 @@ checksum:
3513: move.d MEM_CSE1_START, $r1 ; wrap to second flash 3563: move.d MEM_CSE1_START, $r1 ; wrap to second flash
352 ba 2b 357 ba 2b
353 nop 358 nop
359
360#endif