aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v10
diff options
context:
space:
mode:
authorJesper Nilsson <jesper.nilsson@axis.com>2007-11-30 10:13:29 -0500
committerJesper Nilsson <jesper.nilsson@axis.com>2008-02-08 05:06:26 -0500
commit8c11bffae7d234928fd3ee5b4419e9d1b6f7f55a (patch)
tree34f2eab4675cb988856291362206d9b1846a4b53 /arch/cris/arch-v10
parent63e6b9a0b876a287782a706351e0868789673f90 (diff)
CRIS v10: Update rescue head.s
- Correct whitespace problems. - Add ifdef for ETRAX_AXISFLASHMAP to avoid compile error when not set.
Diffstat (limited to 'arch/cris/arch-v10')
-rw-r--r--arch/cris/arch-v10/boot/rescue/head.S117
1 files changed, 61 insertions, 56 deletions
diff --git a/arch/cris/arch-v10/boot/rescue/head.S b/arch/cris/arch-v10/boot/rescue/head.S
index f223cc0c00bb..cf644e2d6aa2 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,16 +58,18 @@
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
@@ -78,7 +79,7 @@
78 ;; having setup the DRAM etc). It is the same length as the on-chip 79 ;; having setup the DRAM etc). It is the same length as the on-chip
79 ;; ROM loads, so the same host loader can be used to load a rescued 80 ;; ROM loads, so the same host loader can be used to load a rescued
80 ;; product as well as one booted through the Etrax serial boot code. 81 ;; product as well as one booted through the Etrax serial boot code.
81 82
82#define CODE_START 0x40000000 83#define CODE_START 0x40000000
83#define CODE_LENGTH 784 84#define CODE_LENGTH 784
84 85
@@ -102,7 +103,7 @@
102#define SERRECC R_SERIAL2_REC_CTRL 103#define SERRECC R_SERIAL2_REC_CTRL
103#define SERRDAT R_SERIAL2_REC_DATA 104#define SERRDAT R_SERIAL2_REC_DATA
104#define SERSTAT R_SERIAL2_STATUS 105#define SERSTAT R_SERIAL2_STATUS
105#endif 106#endif
106#ifdef CONFIG_ETRAX_RESCUE_SER3 107#ifdef CONFIG_ETRAX_RESCUE_SER3
107#define SERXOFF R_SERIAL3_XOFF 108#define SERXOFF R_SERIAL3_XOFF
108#define SERBAUD R_SERIAL3_BAUD 109#define SERBAUD R_SERIAL3_BAUD
@@ -115,60 +116,61 @@
115#define RAM_INIT_MAGIC 0x56902387 116#define RAM_INIT_MAGIC 0x56902387
116 117
117 .text 118 .text
118 119
119 ;; This is the entry point of the rescue code 120 ;; This is the entry point of the rescue code
120 ;; 0x80000000 if loaded in flash (as it should be) 121 ;; 0x80000000 if loaded in flash (as it should be)
121 ;; since etrax actually starts at address 2 when booting from flash, we 122 ;; 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 123 ;; put a nop (2 bytes) here first so we dont accidentally skip the di
123 124
124 nop 125 nop
125 di 126 di
126 127
127 jump in_cache ; enter cached area instead 128 jump in_cache ; enter cached area instead
128in_cache: 129in_cache:
129 130
130 131
131 ;; first put a jump test to give a possibility of upgrading the rescue code 132 ;; 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 133 ;; rescue code without erasing/reflashing the sector.
133 ;; it is not -1, we jump using the value as jump target. since we can always 134 ;; 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 135 ;; the value as jump target. Since we can always change 1's to 0's
136 ;; without erasing the sector, it is possible to add new
135 ;; code after this and altering the jumptarget in an upgrade. 137 ;; code after this and altering the jumptarget in an upgrade.
136 138
137jtcd: move.d [jumptarget], $r0 139jtcd: move.d [jumptarget], $r0
138 cmp.d 0xffffffff, $r0 140 cmp.d 0xffffffff, $r0
139 beq no_newjump 141 beq no_newjump
140 nop 142 nop
141 143
142 jump [$r0] 144 jump [$r0]
143 145
144jumptarget: 146jumptarget:
145 .dword 0xffffffff ; can be overwritten later to insert new code 147 .dword 0xffffffff ; can be overwritten later to insert new code
146 148
147no_newjump: 149no_newjump:
148#ifdef CONFIG_ETRAX_ETHERNET 150#ifdef CONFIG_ETRAX_ETHERNET
149 ;; Start MII clock to make sure it is running when tranceiver is reset 151 ;; Start MII clock to make sure it is running when tranceiver is reset
150 move.d 0x3, $r0 ; enable = on, phy = mii_clk 152 move.d 0x3, $r0 ; enable = on, phy = mii_clk
151 move.d $r0, [R_NETWORK_GEN_CONFIG] 153 move.d $r0, [R_NETWORK_GEN_CONFIG]
152#endif 154#endif
153 155
154 ;; We need to setup the bus registers before we start using the DRAM 156 ;; We need to setup the bus registers before we start using the DRAM
155#include "../../lib/dram_init.S" 157#include "../../lib/dram_init.S"
156 158
157 ;; we now should go through the checksum-table and check the listed 159 ;; we now should go through the checksum-table and check the listed
158 ;; partitions for errors. 160 ;; partitions for errors.
159 161
160 move.d PTABLE_START, $r3 162 move.d PTABLE_START, $r3
161 move.d [$r3], $r0 163 move.d [$r3], $r0
162 cmp.d NOP_DI, $r0 ; make sure the nop/di is there... 164 cmp.d NOP_DI, $r0 ; make sure the nop/di is there...
163 bne do_rescue 165 bne do_rescue
164 nop 166 nop
165 167
166 ;; skip the code transparency block (10 bytes). 168 ;; skip the code transparency block (10 bytes).
167 169
168 addq 10, $r3 170 addq 10, $r3
169 171
170 ;; check for correct magic 172 ;; check for correct magic
171 173
172 move.w [$r3+], $r0 174 move.w [$r3+], $r0
173 cmp.w PTABLE_MAGIC, $r0 175 cmp.w PTABLE_MAGIC, $r0
174 bne do_rescue ; didn't recognize - trig rescue 176 bne do_rescue ; didn't recognize - trig rescue
@@ -186,11 +188,11 @@ no_newjump:
186 cmp.d $r0, $r4 188 cmp.d $r0, $r4
187 bne do_rescue ; didn't match - trig rescue 189 bne do_rescue ; didn't match - trig rescue
188 nop 190 nop
189 191
190 ;; ptable is ok. validate each entry. 192 ;; ptable is ok. validate each entry.
191 193
192 moveq -1, $r7 194 moveq -1, $r7
193 195
194ploop: move.d [$r3+], $r1 ; partition offset (from ptable start) 196ploop: move.d [$r3+], $r1 ; partition offset (from ptable start)
195 bne notfirst ; check if it is the partition containing ptable 197 bne notfirst ; check if it is the partition containing ptable
196 nop ; yes.. 198 nop ; yes..
@@ -199,7 +201,7 @@ ploop: move.d [$r3+], $r1 ; partition offset (from ptable start)
199 sub.d $r8, $r2 ; minus the ptable length 201 sub.d $r8, $r2 ; minus the ptable length
200 ba bosse 202 ba bosse
201 nop 203 nop
202notfirst: 204notfirst:
203 cmp.d -1, $r1 ; the end of the ptable ? 205 cmp.d -1, $r1 ; the end of the ptable ?
204 beq flash_ok ; if so, the flash is validated 206 beq flash_ok ; if so, the flash is validated
205 move.d [$r3+], $r2 ; partition length 207 move.d [$r3+], $r2 ; partition length
@@ -213,47 +215,46 @@ bosse: move.d [$r3+], $r5 ; checksum
213 bpl 1f 215 bpl 1f
214 nop 216 nop
215 move.d $r1, $r7 ; remember boot partition offset 217 move.d $r1, $r7 ; remember boot partition offset
2161: 2181:
217
218 add.d PTABLE_START, $r1 219 add.d PTABLE_START, $r1
219 220
220 jsr checksum ; checksum the partition 221 jsr checksum ; checksum the partition
221 222
222 cmp.d $r0, $r5 223 cmp.d $r0, $r5
223 beq ploop ; checksums matched, go to next entry 224 beq ploop ; checksums matched, go to next entry
224 nop 225 nop
225 226
226 ;; otherwise fall through to the rescue code. 227 ;; otherwise fall through to the rescue code.
227 228
228do_rescue: 229do_rescue:
229 ;; setup port PA and PB default initial directions and data 230 ;; setup port PA and PB default initial directions and data
230 ;; (so we can flash LEDs, and so that DTR and others are set) 231 ;; (so we can flash LEDs, and so that DTR and others are set)
231 232
232 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 233 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
233 move.b $r0, [R_PORT_PA_DIR] 234 move.b $r0, [R_PORT_PA_DIR]
234 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 235 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
235 move.b $r0, [R_PORT_PA_DATA] 236 move.b $r0, [R_PORT_PA_DATA]
236 237
237 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 238 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
238 move.b $r0, [R_PORT_PB_DIR] 239 move.b $r0, [R_PORT_PB_DIR]
239 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 240 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
240 move.b $r0, [R_PORT_PB_DATA] 241 move.b $r0, [R_PORT_PB_DATA]
241 242
242 ;; setup the serial port at 115200 baud 243 ;; setup the serial port at 115200 baud
243 244
244 moveq 0, $r0 245 moveq 0, $r0
245 move.d $r0, [SERXOFF] 246 move.d $r0, [SERXOFF]
246 247
247 move.b 0x99, $r0 248 move.b 0x99, $r0
248 move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive 249 move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive
249 250
250 move.b 0x40, $r0 ; rec enable 251 move.b 0x40, $r0 ; rec enable
251 move.b $r0, [SERRECC] 252 move.b $r0, [SERRECC]
252 253
253 moveq 0, $r1 ; "timer" to clock out a LED red flash 254 moveq 0, $r1 ; "timer" to clock out a LED red flash
254 move.d CODE_START, $r3 ; destination counter 255 move.d CODE_START, $r3 ; destination counter
255 movu.w CODE_LENGTH, $r4; length 256 movu.w CODE_LENGTH, $r4; length
256 257
257wait_ser: 258wait_ser:
258 addq 1, $r1 259 addq 1, $r1
259#ifndef CONFIG_ETRAX_NO_LEDS 260#ifndef CONFIG_ETRAX_NO_LEDS
@@ -272,20 +273,20 @@ wait_ser:
272 nop 273 nop
2731: not $r0 ; clear bit 2741: not $r0 ; clear bit
274 and.d $r0, $r2 275 and.d $r0, $r2
2752: 2762:
276#ifdef CONFIG_ETRAX_PA_LEDS 277#ifdef CONFIG_ETRAX_PA_LEDS
277 move.b $r2, [R_PORT_PA_DATA] 278 move.b $r2, [R_PORT_PA_DATA]
278#endif 279#endif
279#ifdef CONFIG_ETRAX_PB_LEDS 280#ifdef CONFIG_ETRAX_PB_LEDS
280 move.b $r2, [R_PORT_PB_DATA] 281 move.b $r2, [R_PORT_PB_DATA]
281#endif 282#endif
282#ifdef CONFIG_ETRAX_90000000_LEDS 283#ifdef CONFIG_ETRAX_90000000_LEDS
283 move.b $r2, [0x90000000] 284 move.b $r2, [0x90000000]
284#endif 285#endif
285#endif 286#endif
286 287
287 ;; check if we got something on the serial port 288 ;; check if we got something on the serial port
288 289
289 move.b [SERSTAT], $r0 290 move.b [SERSTAT], $r0
290 btstq 0, $r0 ; data_avail 291 btstq 0, $r0 ; data_avail
291 bpl wait_ser 292 bpl wait_ser
@@ -295,14 +296,15 @@ wait_ser:
295 296
296 move.b [SERRDAT], $r0 297 move.b [SERRDAT], $r0
297 move.b $r0, [$r3+] 298 move.b $r0, [$r3+]
298 299
299 subq 1, $r4 ; decrease length 300 subq 1, $r4 ; decrease length
300 bne wait_ser 301 bne wait_ser
301 nop 302 nop
302 303
303 ;; jump into downloaded code 304 ;; jump into downloaded code
304 305
305 move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is initialized 306 move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is
307 ; initialized
306 jump CODE_START 308 jump CODE_START
307 309
308flash_ok: 310flash_ok:
@@ -313,7 +315,8 @@ flash_ok:
313 nop 315 nop
314 move.d PTABLE_START, $r7; otherwise use the ptable start 316 move.d PTABLE_START, $r7; otherwise use the ptable start
3151: 3171:
316 move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is initialized 318 move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is
319 ; initialized
317 jump $r7 ; boot! 320 jump $r7 ; boot!
318 321
319 322
@@ -327,7 +330,7 @@ checksum:
327 moveq 0, $r0 330 moveq 0, $r0
328 moveq CONFIG_ETRAX_FLASH1_SIZE, $r6 331 moveq CONFIG_ETRAX_FLASH1_SIZE, $r6
329 332
330 ;; If the first physical flash memory is exceeded wrap to the second one. 333 ;; If the first physical flash memory is exceeded wrap to the second one
331 btstq 26, $r1 ; Are we addressing first flash? 334 btstq 26, $r1 ; Are we addressing first flash?
332 bpl 1f 335 bpl 1f
333 nop 336 nop
@@ -351,3 +354,5 @@ checksum:
3513: move.d MEM_CSE1_START, $r1 ; wrap to second flash 3543: move.d MEM_CSE1_START, $r1 ; wrap to second flash
352 ba 2b 355 ba 2b
353 nop 356 nop
357
358#endif