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#include <asm-offsets.h>
34#include <config.h>
35#include <mpc5xx.h>
36#include <version.h>
37
38#define CONFIG_5xx 1
39#define _LINUX_CONFIG_H 1
40
41#include <ppc_asm.tmpl>
42#include <ppc_defs.h>
43
44#include <linux/config.h>
45#include <asm/processor.h>
46#include <asm/u-boot.h>
47
48
49
50#undef MSR_KERNEL
51#define MSR_KERNEL ( MSR_ME | MSR_RI )
52
53
54
55
56
57
58 START_GOT
59 GOT_ENTRY(_GOT2_TABLE_)
60 GOT_ENTRY(_FIXUP_TABLE_)
61
62 GOT_ENTRY(_start)
63 GOT_ENTRY(_start_of_vectors)
64 GOT_ENTRY(_end_of_vectors)
65 GOT_ENTRY(transfer_to_handler)
66
67 GOT_ENTRY(__init_end)
68 GOT_ENTRY(__bss_end__)
69 GOT_ENTRY(__bss_start)
70 END_GOT
71
72
73
74
75
76 .text
77 .long 0x27051956
78 .globl version_string
79version_string:
80 .ascii U_BOOT_VERSION_STRING, "\0"
81
82 . = EXC_OFF_SYS_RESET
83 .globl _start
84_start:
85 mfspr r3, 638
86 li r4, CONFIG_SYS_ISB
87 or r3, r3, r4
88 mtspr 638, r3
89
90
91
92 li r3, MSR_KERNEL
93 mtmsr r3
94 mtspr SRR1, r3
95
96
97
98 xor r0, r0, r0
99 mtspr LCTRL1, r0
100 mtspr LCTRL2, r0
101 mtspr COUNTA, r0
102 mtspr COUNTB, r0
103
104
105
106
107
108 lis r3, CONFIG_SYS_MONITOR_BASE@h
109 ori r3, r3, CONFIG_SYS_MONITOR_BASE@l
110 addi r3, r3, pll_prog_code_start - _start + EXC_OFF_SYS_RESET
111
112 lis r4, CONFIG_SYS_INIT_RAM_ADDR@h
113 ori r4, r4, CONFIG_SYS_INIT_RAM_ADDR@l
114 mtlr r4
115 addis r5,0,0x0
116 ori r5,r5,((pll_prog_code_end - pll_prog_code_start) >>2)
117 mtctr r5
118 addi r3, r3, -4
119 addi r4, r4, -4
1200:
121 lwzu r0,4(r3)
122 stwu r0,4(r4)
123 bdnz 0b
124 blrl
125#endif
126
127
128
129
130
131 lis r3, CONFIG_SYS_MONITOR_BASE@h
132 ori r3, r3, CONFIG_SYS_MONITOR_BASE@l
133 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
134 mtlr r3
135 blr
136
137in_flash:
138
139
140
141
142 lis r3, CONFIG_SYS_IMMR@h
143 lis r2, CONFIG_SYS_INIT_SP_ADDR@h
144 ori r1, r2, CONFIG_SYS_INIT_SP_ADDR@l
145
146 stwu r0, -4(r1)
147 stwu r0, -4(r1)
148
149
150
151
152
153
154
155 li r2, 0x0007
156 mtspr ICTRL, r2
157
158
159
160 lis r2, CONFIG_SYS_DER@h
161 ori r2, r2, CONFIG_SYS_DER@l
162 mtspr DER, r2
163
164
165
166
167
168
169 GET_GOT
170
171
172 bl cpu_init_f
173
174 bl board_init_f
175
176
177
178
179 .globl _start_of_vectors
180_start_of_vectors:
181
182
183 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
184
185
186 STD_EXCEPTION(0x300, DataStorage, UnknownException)
187
188
189 STD_EXCEPTION(0x400, InstStorage, UnknownException)
190
191
192 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
193
194
195 . = 0x600
196Alignment:
197 EXCEPTION_PROLOG(SRR0, SRR1)
198 mfspr r4,DAR
199 stw r4,_DAR(r21)
200 mfspr r5,DSISR
201 stw r5,_DSISR(r21)
202 addi r3,r1,STACK_FRAME_OVERHEAD
203 EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
204
205
206 . = 0x700
207ProgramCheck:
208 EXCEPTION_PROLOG(SRR0, SRR1)
209 addi r3,r1,STACK_FRAME_OVERHEAD
210 EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
211 MSR_KERNEL, COPY_EE)
212
213
214
215 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
216
217
218
219
220 STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
221 STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
222 STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
223 STD_EXCEPTION(0xc00, SystemCall, UnknownException)
224 STD_EXCEPTION(0xd00, SingleStep, UnknownException)
225
226 STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
227 STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
228
229
230
231
232 STD_EXCEPTION(0x1000, SoftEmu, SoftEmuException)
233 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
234 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
235 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
236 STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
237
238 STD_EXCEPTION(0x1500, Reserved5, UnknownException)
239 STD_EXCEPTION(0x1600, Reserved6, UnknownException)
240 STD_EXCEPTION(0x1700, Reserved7, UnknownException)
241 STD_EXCEPTION(0x1800, Reserved8, UnknownException)
242 STD_EXCEPTION(0x1900, Reserved9, UnknownException)
243 STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
244 STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
245
246 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
247 STD_EXCEPTION(0x1d00, InstructionBreakpoint, DebugException)
248 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
249 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
250
251
252 .globl _end_of_vectors
253_end_of_vectors:
254
255
256 . = 0x2000
257
258
259
260
261
262
263 .globl transfer_to_handler
264transfer_to_handler:
265 stw r22,_NIP(r21)
266 lis r22,MSR_POW@h
267 andc r23,r23,r22
268 stw r23,_MSR(r21)
269 SAVE_GPR(7, r21)
270 SAVE_4GPRS(8, r21)
271 SAVE_8GPRS(12, r21)
272 SAVE_8GPRS(24, r21)
273 mflr r23
274 andi. r24,r23,0x3f00
275 stw r24,TRAP(r21)
276 li r22,0
277 stw r22,RESULT(r21)
278 mtspr SPRG2,r22
279 lwz r24,0(r23)
280 lwz r23,4(r23)
281 mtspr SRR0,r24
282 mtspr SRR1,r20
283 mtlr r23
284 SYNC
285 rfi
286
287int_return:
288 mfmsr r28
289 li r4,0
290 ori r4,r4,MSR_EE
291 andc r28,r28,r4
292 SYNC
293 mtmsr r28
294 SYNC
295 lwz r2,_CTR(r1)
296 lwz r0,_LINK(r1)
297 mtctr r2
298 mtlr r0
299 lwz r2,_XER(r1)
300 lwz r0,_CCR(r1)
301 mtspr XER,r2
302 mtcrf 0xFF,r0
303 REST_10GPRS(3, r1)
304 REST_10GPRS(13, r1)
305 REST_8GPRS(23, r1)
306 REST_GPR(31, r1)
307 lwz r2,_NIP(r1)
308 lwz r0,_MSR(r1)
309 mtspr SRR0,r2
310 mtspr SRR1,r0
311 lwz r0,GPR0(r1)
312 lwz r2,GPR2(r1)
313 lwz r1,GPR1(r1)
314 SYNC
315 rfi
316
317
318
319
320
321
322
323 .globl get_immr
324get_immr:
325 mr r4,r3
326 mfspr r3, IMMR
327 cmpwi 0,r4,0
328 beq 4f
329 and r3,r3,r4
3304:
331 blr
332
333 .globl get_pvr
334get_pvr:
335 mfspr r3, PVR
336 blr
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352 .globl relocate_code
353relocate_code:
354 mr r1, r3
355 mr r9, r4
356 mr r10, r5
357
358 GET_GOT
359 mr r3, r5
360 lis r4, CONFIG_SYS_MONITOR_BASE@h
361 ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
362 lwz r5, GOT(__init_end)
363 sub r5, r5, r4
364
365
366
367
368
369
370
371
372 sub r15, r10, r4
373
374
375 add r12, r12, r15
376
377 add r30, r30, r15
378
379
380
381
382
383 cmplw cr1,r3,r4
384 addi r0,r5,3
385 srwi. r0,r0,2
386 beq cr1,4f
387 beq 4f
388 mtctr r0
389 bge cr1,2f
390
391 la r8,-4(r4)
392 la r7,-4(r3)
3931: lwzu r0,4(r8)
394 stwu r0,4(r7)
395 bdnz 1b
396 b 4f
397
3982: slwi r0,r0,2
399 add r8,r4,r0
400 add r7,r3,r0
4013: lwzu r0,-4(r8)
402 stwu r0,-4(r7)
403 bdnz 3b
404
4054: sync
406 isync
407
408
409
410
411
412
413 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
414 mtlr r0
415 blr
416
417in_ram:
418
419
420
421
422
423
424
425 li r0,__got2_entries@sectoff@l
426 la r3,GOT(_GOT2_TABLE_)
427 lwz r11,GOT(_GOT2_TABLE_)
428 mtctr r0
429 sub r11,r3,r11
430 addi r3,r3,-4
4311: lwzu r0,4(r3)
432 cmpwi r0,0
433 beq- 2f
434 add r0,r0,r11
435 stw r0,0(r3)
4362: bdnz 1b
437
438
439
440
441
442 li r0,__fixup_entries@sectoff@l
443 lwz r3,GOT(_FIXUP_TABLE_)
444 cmpwi r0,0
445 mtctr r0
446 addi r3,r3,-4
447 beq 4f
4483: lwzu r4,4(r3)
449 lwzux r0,r4,r11
450 cmpwi r0,0
451 add r0,r0,r11
452 stw r4,0(r3)
453 beq- 5f
454 stw r0,0(r4)
4555: bdnz 3b
4564:
457clear_bss:
458
459
460
461 lwz r3,GOT(__bss_start)
462 lwz r4,GOT(__bss_end__)
463 cmplw 0, r3, r4
464 beq 6f
465
466 li r0, 0
4675:
468 stw r0, 0(r3)
469 addi r3, r3, 4
470 cmplw 0, r3, r4
471 bne 5b
4726:
473
474 mr r3, r9
475 mr r4, r10
476 bl board_init_r
477
478
479
480
481
482
483
484 .globl trap_init
485trap_init:
486 mflr r4
487 GET_GOT
488 lwz r7, GOT(_start)
489 lwz r8, GOT(_end_of_vectors)
490
491 li r9, 0x100
492
493 cmplw 0, r7, r8
494 bgelr
4951:
496 lwz r0, 0(r7)
497 stw r0, 0(r9)
498 addi r7, r7, 4
499 addi r9, r9, 4
500 cmplw 0, r7, r8
501 bne 1b
502
503
504
505
506 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
507 li r8, Alignment - _start + EXC_OFF_SYS_RESET
5082:
509 bl trap_reloc
510 addi r7, r7, 0x100
511 cmplw 0, r7, r8
512 blt 2b
513
514 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
515 bl trap_reloc
516
517 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
518 bl trap_reloc
519
520 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
521 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
5223:
523 bl trap_reloc
524 addi r7, r7, 0x100
525 cmplw 0, r7, r8
526 blt 3b
527
528 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
529 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
5304:
531 bl trap_reloc
532 addi r7, r7, 0x100
533 cmplw 0, r7, r8
534 blt 4b
535
536 mtlr r4
537 blr
538
539
540
541pll_prog_code_start:
542 lis r4, (CONFIG_SYS_IMMR + 0x002fc384)@h
543 ori r4, r4, (CONFIG_SYS_IMMR + 0x002fc384)@l
544 lis r3, (0x55ccaa33)@h
545 ori r3, r3, (0x55ccaa33)@l
546 stw r3, 0(r4)
547 lis r4, (CONFIG_SYS_IMMR + 0x002fc284)@h
548 ori r4, r4, (CONFIG_SYS_IMMR + 0x002fc284)@l
549 lis r3, CONFIG_SYS_PLPRCR@h
550 ori r3, r3, CONFIG_SYS_PLPRCR@l
551 stw r3, 0(r4)
552 addis r3,0,0x0
553 ori r3,r3,0xA000
554 mtctr r3
555..spinlp:
556 bdnz ..spinlp
557 blr
558pll_prog_code_end:
559 nop
560 blr
561#endif
562