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