1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40#include <config.h>
41#include <mpc8xx.h>
42#include <timestamp.h>
43#include <version.h>
44
45#define CONFIG_8xx 1
46#define _LINUX_CONFIG_H 1
47
48#include <ppc_asm.tmpl>
49#include <ppc_defs.h>
50
51#include <asm/cache.h>
52#include <asm/mmu.h>
53
54#ifndef CONFIG_IDENT_STRING
55#define CONFIG_IDENT_STRING ""
56#endif
57
58
59
60#undef MSR_KERNEL
61#define MSR_KERNEL ( MSR_ME | MSR_RI )
62
63
64
65
66
67
68 START_GOT
69 GOT_ENTRY(_GOT2_TABLE_)
70 GOT_ENTRY(_FIXUP_TABLE_)
71
72 GOT_ENTRY(_start)
73 GOT_ENTRY(_start_of_vectors)
74 GOT_ENTRY(_end_of_vectors)
75 GOT_ENTRY(transfer_to_handler)
76
77 GOT_ENTRY(__init_end)
78 GOT_ENTRY(_end)
79 GOT_ENTRY(__bss_start)
80 END_GOT
81
82
83
84
85
86 .text
87 .long 0x27051956
88 .globl version_string
89version_string:
90 .ascii U_BOOT_VERSION
91 .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
92 .ascii CONFIG_IDENT_STRING, "\0"
93
94 . = EXC_OFF_SYS_RESET
95 .globl _start
96_start:
97 lis r3, CONFIG_SYS_IMMR@h
98 mtspr 638, r3
99 li r21, BOOTFLAG_COLD
100 b boot_cold
101
102 . = EXC_OFF_SYS_RESET + 0x10
103
104 .globl _start_warm
105_start_warm:
106 li r21, BOOTFLAG_WARM
107 b boot_warm
108
109boot_cold:
110boot_warm:
111
112
113
114 li r3, MSR_KERNEL
115 mtmsr r3
116 mtspr SRR1, r3
117
118 mfspr r3, ICR
119
120
121
122 xor r0, r0, r0
123 mtspr LCTRL1, r0
124 mtspr LCTRL2, r0
125 mtspr COUNTA, r0
126 mtspr COUNTB, r0
127
128
129
130
131 mfspr r3, IC_CST
132 mfspr r3, DC_CST
133
134 lis r3, IDC_UNALL@h
135 mtspr IC_CST, r3
136 mtspr DC_CST, r3
137
138 lis r3, IDC_INVALL@h
139 mtspr IC_CST, r3
140 mtspr DC_CST, r3
141
142 lis r3, IDC_DISABLE@h
143 mtspr DC_CST, r3
144
145
146
147
148
149 lis r3, IDC_ENABLE@h
150#endif
151 mtspr IC_CST, r3
152
153
154
155
156 tlbia
157 isync
158
159
160
161
162
163 lis r3, CONFIG_SYS_MONITOR_BASE@h
164 ori r3, r3, CONFIG_SYS_MONITOR_BASE@l
165 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
166 mtlr r3
167 blr
168
169in_flash:
170
171
172
173
174 lis r3, CONFIG_SYS_IMMR@h
175 ori r1, r3, CONFIG_SYS_INIT_SP_OFFSET
176
177 stwu r0, -4(r1)
178 stwu r0, -4(r1)
179
180
181
182
183
184
185
186 li r2, 0x0007
187 mtspr ICTRL, r2
188
189
190
191 lis r2, CONFIG_SYS_DER@h
192 ori r2, r2, CONFIG_SYS_DER@l
193 mtspr DER, r2
194
195
196
197
198
199
200 GET_GOT
201
202
203 bl cpu_init_f
204
205 mr r3, r21
206
207 bl board_init_f
208
209
210 .globl _start_of_vectors
211_start_of_vectors:
212
213
214 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
215
216
217 STD_EXCEPTION(0x300, DataStorage, UnknownException)
218
219
220 STD_EXCEPTION(0x400, InstStorage, UnknownException)
221
222
223 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
224
225
226 . = 0x600
227Alignment:
228 EXCEPTION_PROLOG(SRR0, SRR1)
229 mfspr r4,DAR
230 stw r4,_DAR(r21)
231 mfspr r5,DSISR
232 stw r5,_DSISR(r21)
233 addi r3,r1,STACK_FRAME_OVERHEAD
234 li r20,MSR_KERNEL
235 rlwimi r20,r23,0,16,16
236 lwz r6,GOT(transfer_to_handler)
237 mtlr r6
238 blrl
239.L_Alignment:
240 .long AlignmentException - _start + EXC_OFF_SYS_RESET
241 .long int_return - _start + EXC_OFF_SYS_RESET
242
243
244 . = 0x700
245ProgramCheck:
246 EXCEPTION_PROLOG(SRR0, SRR1)
247 addi r3,r1,STACK_FRAME_OVERHEAD
248 li r20,MSR_KERNEL
249 rlwimi r20,r23,0,16,16
250 lwz r6,GOT(transfer_to_handler)
251 mtlr r6
252 blrl
253.L_ProgramCheck:
254 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
255 .long int_return - _start + EXC_OFF_SYS_RESET
256
257
258
259 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
260
261
262
263
264 STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
265 STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
266 STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
267 STD_EXCEPTION(0xc00, SystemCall, UnknownException)
268 STD_EXCEPTION(0xd00, SingleStep, UnknownException)
269
270 STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
271 STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
272
273
274
275
276 STD_EXCEPTION(0x1000, SoftEmu, SoftEmuException)
277
278 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
279 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
280 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
281 STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
282
283 STD_EXCEPTION(0x1500, Reserved5, UnknownException)
284 STD_EXCEPTION(0x1600, Reserved6, UnknownException)
285 STD_EXCEPTION(0x1700, Reserved7, UnknownException)
286 STD_EXCEPTION(0x1800, Reserved8, UnknownException)
287 STD_EXCEPTION(0x1900, Reserved9, UnknownException)
288 STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
289 STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
290
291 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
292 STD_EXCEPTION(0x1d00, InstructionBreakpoint, DebugException)
293 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
294 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
295
296
297 .globl _end_of_vectors
298_end_of_vectors:
299
300
301 . = 0x2000
302
303
304
305
306
307
308 .globl transfer_to_handler
309transfer_to_handler:
310 stw r22,_NIP(r21)
311 lis r22,MSR_POW@h
312 andc r23,r23,r22
313 stw r23,_MSR(r21)
314 SAVE_GPR(7, r21)
315 SAVE_4GPRS(8, r21)
316 SAVE_8GPRS(12, r21)
317 SAVE_8GPRS(24, r21)
318 mflr r23
319 andi. r24,r23,0x3f00
320 stw r24,TRAP(r21)
321 li r22,0
322 stw r22,RESULT(r21)
323 mtspr SPRG2,r22
324 lwz r24,0(r23)
325 lwz r23,4(r23)
326 mtspr SRR0,r24
327 mtspr SRR1,r20
328 mtlr r23
329 SYNC
330 rfi
331
332int_return:
333 mfmsr r28
334 li r4,0
335 ori r4,r4,MSR_EE
336 andc r28,r28,r4
337 SYNC
338 mtmsr r28
339 SYNC
340 lwz r2,_CTR(r1)
341 lwz r0,_LINK(r1)
342 mtctr r2
343 mtlr r0
344 lwz r2,_XER(r1)
345 lwz r0,_CCR(r1)
346 mtspr XER,r2
347 mtcrf 0xFF,r0
348 REST_10GPRS(3, r1)
349 REST_10GPRS(13, r1)
350 REST_8GPRS(23, r1)
351 REST_GPR(31, r1)
352 lwz r2,_NIP(r1)
353 lwz r0,_MSR(r1)
354 mtspr SRR0,r2
355 mtspr SRR1,r0
356 lwz r0,GPR0(r1)
357 lwz r2,GPR2(r1)
358 lwz r1,GPR1(r1)
359 SYNC
360 rfi
361
362
363
364 .globl icache_enable
365icache_enable:
366 SYNC
367 lis r3, IDC_INVALL@h
368 mtspr IC_CST, r3
369 lis r3, IDC_ENABLE@h
370 mtspr IC_CST, r3
371 blr
372
373 .globl icache_disable
374icache_disable:
375 SYNC
376 lis r3, IDC_DISABLE@h
377 mtspr IC_CST, r3
378 blr
379
380 .globl icache_status
381icache_status:
382 mfspr r3, IC_CST
383 srwi r3, r3, 31
384 blr
385
386 .globl dcache_enable
387dcache_enable:
388
389 SYNC
390#endif
391
392 lis r3, 0x0400
393 mtspr MD_CTR, r3
394#endif
395
396 lis r3, IDC_INVALL@h
397 mtspr DC_CST, r3
398
399 lis r3, DC_SFWT@h
400 mtspr DC_CST, r3
401#endif
402 lis r3, IDC_ENABLE@h
403 mtspr DC_CST, r3
404 blr
405
406 .globl dcache_disable
407dcache_disable:
408 SYNC
409 lis r3, IDC_DISABLE@h
410 mtspr DC_CST, r3
411 lis r3, IDC_INVALL@h
412 mtspr DC_CST, r3
413 blr
414
415 .globl dcache_status
416dcache_status:
417 mfspr r3, DC_CST
418 srwi r3, r3, 31
419 blr
420
421 .globl dc_read
422dc_read:
423 mtspr DC_ADR, r3
424 mfspr r3, DC_DAT
425 blr
426
427
428
429
430
431
432 .globl get_immr
433get_immr:
434 mr r4,r3
435 mfspr r3, IMMR
436 cmpwi 0,r4,0
437 beq 4f
438 and r3,r3,r4
4394:
440 blr
441
442 .globl get_pvr
443get_pvr:
444 mfspr r3, PVR
445 blr
446
447
448 .globl wr_ic_cst
449wr_ic_cst:
450 mtspr IC_CST, r3
451 blr
452
453 .globl rd_ic_cst
454rd_ic_cst:
455 mfspr r3, IC_CST
456 blr
457
458 .globl wr_ic_adr
459wr_ic_adr:
460 mtspr IC_ADR, r3
461 blr
462
463
464 .globl wr_dc_cst
465wr_dc_cst:
466 mtspr DC_CST, r3
467 blr
468
469 .globl rd_dc_cst
470rd_dc_cst:
471 mfspr r3, DC_CST
472 blr
473
474 .globl wr_dc_adr
475wr_dc_adr:
476 mtspr DC_ADR, r3
477 blr
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492 .globl relocate_code
493relocate_code:
494 mr r1, r3
495 mr r9, r4
496 mr r10, r5
497
498 mr r3, r5
499 lis r4, CONFIG_SYS_MONITOR_BASE@h
500 ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
501 lwz r5, GOT(__init_end)
502 sub r5, r5, r4
503 li r6, CONFIG_SYS_CACHELINE_SIZE
504
505
506
507
508
509
510
511
512 sub r15, r10, r4
513
514
515 add r14, r14, r15
516
517 add r30, r30, r15
518
519
520
521
522
523 cmplw cr1,r3,r4
524 addi r0,r5,3
525 srwi. r0,r0,2
526 beq cr1,4f
527 beq 7f
528 mtctr r0
529 bge cr1,2f
530
531 la r8,-4(r4)
532 la r7,-4(r3)
5331: lwzu r0,4(r8)
534 stwu r0,4(r7)
535 bdnz 1b
536 b 4f
537
5382: slwi r0,r0,2
539 add r8,r4,r0
540 add r7,r3,r0
5413: lwzu r0,-4(r8)
542 stwu r0,-4(r7)
543 bdnz 3b
544
545
546
547
548
5494: cmpwi r6,0
550 add r5,r3,r5
551 beq 7f
552 subi r0,r6,1
553 andc r3,r3,r0
554 mr r4,r3
5555: dcbst 0,r4
556 add r4,r4,r6
557 cmplw r4,r5
558 blt 5b
559 sync
560 mr r4,r3
5616: icbi 0,r4
562 add r4,r4,r6
563 cmplw r4,r5
564 blt 6b
5657: sync
566 isync
567
568
569
570
571
572
573 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
574 mtlr r0
575 blr
576
577in_ram:
578
579
580
581
582
583
584
585 li r0,__got2_entries@sectoff@l
586 la r3,GOT(_GOT2_TABLE_)
587 lwz r11,GOT(_GOT2_TABLE_)
588 mtctr r0
589 sub r11,r3,r11
590 addi r3,r3,-4
5911: lwzu r0,4(r3)
592 add r0,r0,r11
593 stw r0,0(r3)
594 bdnz 1b
595
596
597
598
599
6002: li r0,__fixup_entries@sectoff@l
601 lwz r3,GOT(_FIXUP_TABLE_)
602 cmpwi r0,0
603 mtctr r0
604 addi r3,r3,-4
605 beq 4f
6063: lwzu r4,4(r3)
607 lwzux r0,r4,r11
608 add r0,r0,r11
609 stw r10,0(r3)
610 stw r0,0(r4)
611 bdnz 3b
6124:
613clear_bss:
614
615
616
617 lwz r3,GOT(__bss_start)
618 lwz r4,GOT(_end)
619
620 cmplw 0, r3, r4
621 beq 6f
622
623 li r0, 0
6245:
625 stw r0, 0(r3)
626 addi r3, r3, 4
627 cmplw 0, r3, r4
628 bne 5b
6296:
630
631 mr r3, r9
632 mr r4, r10
633 bl board_init_r
634
635
636
637
638
639
640
641 .globl trap_init
642trap_init:
643 lwz r7, GOT(_start)
644 lwz r8, GOT(_end_of_vectors)
645
646 li r9, 0x100
647
648 cmplw 0, r7, r8
649 bgelr
650
651 mflr r4
6521:
653 lwz r0, 0(r7)
654 stw r0, 0(r9)
655 addi r7, r7, 4
656 addi r9, r9, 4
657 cmplw 0, r7, r8
658 bne 1b
659
660
661
662
663 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
664 li r8, Alignment - _start + EXC_OFF_SYS_RESET
6652:
666 bl trap_reloc
667 addi r7, r7, 0x100
668 cmplw 0, r7, r8
669 blt 2b
670
671 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
672 bl trap_reloc
673
674 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
675 bl trap_reloc
676
677 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
678 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
6793:
680 bl trap_reloc
681 addi r7, r7, 0x100
682 cmplw 0, r7, r8
683 blt 3b
684
685 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
686 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
6874:
688 bl trap_reloc
689 addi r7, r7, 0x100
690 cmplw 0, r7, r8
691 blt 4b
692
693 mtlr r4
694 blr
695
696
697
698
699trap_reloc:
700 lwz r0, 0(r7)
701 add r0, r0, r3
702 stw r0, 0(r7)
703
704 lwz r0, 4(r7)
705 add r0, r0, r3
706 stw r0, 4(r7)
707
708 sync
709 isync
710
711 blr
712