1
2
3
4
5
6
7
8
9
10#include <common.h>
11#include <asm-offsets.h>
12#include <config.h>
13#include <timestamp.h>
14#include "version.h"
15#include <asm/cache.h>
16
17#define _START _start
18#define _FAULT _fault
19
20#define SAVE_ALL \
21 move.w
22 subl
23 moveml %d0-%d7/%a0-%a6,%sp@;
24
25#define RESTORE_ALL \
26 moveml %sp@,%d0-%d7/%a0-%a6; \
27 addl
28 rte;
29
30
31#define ASM_DRAMINIT (asm_dram_init - CONFIG_SYS_TEXT_BASE + \
32 CONFIG_SYS_INIT_RAM_ADDR)
33#define ASM_DRAMINIT_N (asm_dram_init - CONFIG_SYS_TEXT_BASE)
34#define ASM_SBF_IMG_HDR (asm_sbf_img_hdr - CONFIG_SYS_TEXT_BASE + \
35 CONFIG_SYS_INIT_RAM_ADDR)
36#endif
37
38.text
39
40
41
42
43
44_vectors:
45
46
47INITSP: .long 0
48#ifdef CONFIG_CF_SBF
49INITPC: .long ASM_DRAMINIT
50#endif
51#ifdef CONFIG_SYS_NAND_BOOT
52INITPC: .long ASM_DRAMINIT_N
53#endif
54
55#else
56
57INITSP: .long 0
58INITPC: .long _START
59
60#endif
61
62vector02_0F:
63.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
64.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
65
66
67vector10_17:
68.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
69
70vector18_1F:
71.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
72
73
74
75
76vector20_2F:
77.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
78.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
79
80
81vector30_3F:
82.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
83.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
84
85vector64_127:
86.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
87.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
88.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
89.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
90.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
91.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
92.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
93.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
94
95vector128_191:
96.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
97.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
98.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
99.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
100.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
101.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
102.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
103.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
104
105vector192_255:
106.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
107.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
108.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
109.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
110.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
111.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
112.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
113.long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
114#endif
115
116
117
118asm_sbf_img_hdr:
119 .long 0x00000000
120 .long 0x00040000
121 .long CONFIG_SYS_TEXT_BASE
122
123asm_dram_init:
124 move.w
125
126#ifdef CONFIG_SYS_NAND_BOOT
127
128 move.l
129 movec %d0, %RAMBAR1
130
131 move.l
132 clr.l %sp@-
133#endif
134
135#ifdef CONFIG_CF_SBF
136 move.l
137 movec %d0, %VBR
138
139 move.l
140 movec %d0, %RAMBAR1
141
142
143 move.l
144 move.l
145 move.l
146 move.l %d0, (%a1)
147 move.l %d0, (%a2)
148
149
150 move.l
151 movec %d0, %CACR
152 move.l
153 movec %d0, %ACR0
154 movec %d0, %ACR1
155 movec %d0, %ACR2
156 movec %d0, %ACR3
157
158 move.l
159 clr.l %sp@-
160
161#ifdef CONFIG_SYS_CS0_BASE
162
163 move.l
164 move.l
165 move.l
166 move.l
167 move.l
168 move.l
169#endif
170#endif
171
172#ifdef CONFIG_MCF5441x
173
174
175 move.l
176
177
178 move.b
179#endif
180#endif
181
182
183
184
185 bsr sbf_dram_init
186
187#ifdef CONFIG_CF_SBF
188
189
190
191
192
193
194
195
196
197asm_dspi_init:
198#ifdef CONFIG_MCF5441x
199 move.l
200 move.l
201 move.b
202 move.b
203#endif
204
205#ifdef CONFIG_MCF5445x
206 move.l
207 move.b
208#endif
209
210 move.l
211 move.l
212
213 move.l
214#ifdef CONFIG_MCF5441x
215 move.l
216#endif
217#ifdef CONFIG_MCF5445x
218 move.l
219#endif
220
221 move.l
222 move.l
223
224 move.l
225 move.l (%a1)+, %d5
226 move.l (%a1), %a4
227
228 move.l
229 move.l
230
231 move.l
232
233
234 move.l
235 jsr asm_dspi_wr_status
236 jsr asm_dspi_rd_status
237
238 move.l
239 jsr asm_dspi_wr_status
240 jsr asm_dspi_rd_status
241
242 move.l
243 jsr asm_dspi_wr_status
244 jsr asm_dspi_rd_status
245
246 move.l
247 jsr asm_dspi_wr_status
248 jsr asm_dspi_rd_status
249
250 move.l
251 jsr asm_dspi_wr_status
252 jsr asm_dspi_rd_status
253
254
255asm_dspi_rd_loop1:
256 move.l
257 jsr asm_dspi_wr_status
258 jsr asm_dspi_rd_status
259
260 move.b %d1, (%a0)
261
262 add.l
263 sub.l
264 bne asm_dspi_rd_loop1
265
266
267asm_dspi_rd_loop2:
268 move.l
269 jsr asm_dspi_wr_status
270 jsr asm_dspi_rd_status
271
272 move.b %d1, (%a4)
273
274 add.l
275 sub.l
276 bne asm_dspi_rd_loop2
277
278 move.l
279 jsr asm_dspi_wr_status
280 jsr asm_dspi_rd_status
281
282
283 move.l
284 jmp (%a0)
285
286asm_dspi_wr_status:
287 move.l (%a1), %d0
288 and.l
289 cmp.l
290 bgt asm_dspi_wr_status
291
292 move.l %d2, (%a2)
293 rts
294
295asm_dspi_rd_status:
296 move.l (%a1), %d0
297 and.l
298 lsr.l
299 cmp.l
300 beq asm_dspi_rd_status
301
302 move.b (%a3), %d1
303 rts
304#endif
305
306#ifdef CONFIG_SYS_NAND_BOOT
307
308
309 move.l
310 move.l
311 move.l
312
313asm_boot_nand_copy:
314 move.l (%a1)+, (%a2)+
315 subq.l
316 bne asm_boot_nand_copy
317
318
319 move.l
320 jmp (%a0)
321
322asm_nand_init:
323
324 move.l
325 or.l
326 move.l %d1, (%a1)
327
328
329 move.l
330 move.l
331 move.l
332 move.l
333 move.l %d0, (%a1)
334 move.l %d0, (%a2)
335 move.l %d0, (%a3)
336
337
338 move.l
339 movec %d0, %CACR
340 move.l
341 movec %d0, %ACR0
342 movec %d0, %ACR1
343 movec %d0, %ACR2
344 movec %d0, %ACR3
345
346#ifdef CONFIG_SYS_CS0_BASE
347
348 move.l
349 move.l
350 move.l
351 move.l
352 move.l
353 move.l
354#endif
355
356
357 move.l
358 move.b
359 move.b
360 move.b
361
362
363 move.l
364 move.l
365 move.l
366 move.l
367 move.l
368 move.l
369 move.l
370 move.l
371 move.l
372 move.l
373 move.l
374 move.l
375 move.l
376
377 move.l
378 bsr asm_delay
379
380
381 move.l
382 move.l
383 move.l
384
385 move.l
386 move.l
387 move.l
388
389 move.l
390 move.l
391 move.l
392 move.l
393 move.l
394
395asm_nand_read:
396 move.l
397 or.l %d2, %d0
398 move.l %d0, (%a1)
399 add.l
400
401 move.l (%a0), %d0
402 or.l
403 move.l %d0, (%a0)
404
405 move.l
406 bsr asm_delay
407
408asm_nand_chk_status:
409 move.l
410 move.l (%a4), %d0
411 and.l
412 tst.l %d0
413 beq asm_nand_chk_status
414
415 move.l
416 move.l (%a4), %d0
417 or.l
418 move.l %d0, (%a4)
419
420 move.l
421 move.l
422asm_nand_copy:
423 move.l (%a3)+, (%a2)+
424 subq.l
425 bgt asm_nand_copy
426
427 subq.l
428 bgt asm_nand_read
429
430
431 move.l
432 jmp (%a0)
433
434#endif
435
436.globl asm_delay
437asm_delay:
438 nop
439 subq.l
440 bne asm_delay
441 rts
442#endif
443
444.text
445 . = 0x400
446.globl _start
447_start:
448
449 nop
450 nop
451 move.w
452
453
454 move.l
455 movec %d0, %VBR
456
457 move.l
458 movec %d0, %RAMBAR1
459
460
461 move.l
462 move.l
463 move.l
464 move.l %d0, (%a1)
465 move.l %d0, (%a2)
466
467
468 move.l
469 movec %d0, %CACR
470 move.l
471 movec %d0, %ACR0
472 movec %d0, %ACR1
473 movec %d0, %ACR2
474 movec %d0, %ACR3
475#else
476 move.l
477 movec %d0, %RAMBAR1
478#endif
479
480
481 move.l
482
483
484 move.l
485
486
487
488
489
490 move.l %sp, -(%sp)
491 move.l
492 jsr (%a1)
493
494
495 move.l %d0, %sp
496 move.l %sp, %fp
497
498
499 move.l %d0, -(%sp)
500 move.l
501 jsr (%a1)
502
503
504 move.l
505 jsr (%a1)
506
507
508 clr.l %sp@-
509 move.l
510 jsr (%a1)
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527.globl relocate_code
528relocate_code:
529 link.w %a6,
530 move.l 8(%a6), %sp
531
532 move.l 12(%a6), %d0
533 move.l 16(%a6), %a0
534
535 move.l
536 move.l
537 move.l %a0, %a3
538
539
5401:
541 move.l (%a1)+, (%a3)+
542 cmp.l %a1,%a2
543 bgt.s 1b
544
545
546
547
548
549 move.l %a0, %a1
550 add.l
551 jmp (%a1)
552
553in_ram:
554
555clear_bss:
556
557
558
559 move.l %a0, %a1
560 add.l
561 move.l %a0, %d1
562 add.l
5636:
564 clr.l (%a1)+
565 cmp.l %a1,%d1
566 bgt.s 6b
567
568
569
570
571 move.l %a0, %a1
572 add.l
573 move.l %a1,%a5
574
575 move.l %a0, %a2
576 add.l
577
5787:
579 move.l (%a1),%d1
580 sub.l
581 add.l %a0,%d1
582 move.l %d1,(%a1)+
583 cmp.l %a2, %a1
584 bne 7b
585
586
587 move.l %a0, %a1
588 add.l
589
590
591 move.l %a0,-(%sp)
592 move.l %d0,-(%sp)
593 jsr (%a1)
594
595
596
597
598.globl _fault
599_fault:
600 bra _fault
601
602.globl _exc_handler
603_exc_handler:
604 SAVE_ALL
605 movel %sp,%sp@-
606 bsr exc_handler
607 addql
608 RESTORE_ALL
609
610.globl _int_handler
611_int_handler:
612 SAVE_ALL
613 movel %sp,%sp@-
614 bsr int_handler
615 addql
616 RESTORE_ALL
617
618
619
620.globl version_string
621version_string:
622.ascii U_BOOT_VERSION_STRING, "\0"
623.align 4
624