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