blob: 244c69b8124f0dcbbab3784224f93a2f810607c8 [file] [log] [blame]
Rafal Jaworowskid3a02c32007-07-27 14:43:59 +02001/*
2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
4 * Copyright (C) 2000, 2001, 2002, 2007 Wolfgang Denk <wd@denx.de>
5 * Copyright Freescale Semiconductor, Inc. 2004, 2006. All rights reserved.
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 *
25 * Based on the MPC83xx code.
26 */
27
28/*
29 * U-Boot - Startup Code for MPC512x based Embedded Boards
30 */
31
32#include <config.h>
33#include <mpc512x.h>
34#include <version.h>
35
36#define CONFIG_521X 1 /* needed for Linux kernel header files*/
37
38#include <ppc_asm.tmpl>
39#include <ppc_defs.h>
40
41#include <asm/cache.h>
42#include <asm/mmu.h>
43
44#ifndef CONFIG_IDENT_STRING
45#define CONFIG_IDENT_STRING "MPC512X"
46#endif
47
48/*
49 * Floating Point enable, Machine Check and Recoverable Interr.
50 */
51#undef MSR_KERNEL
52#ifdef DEBUG
53#define MSR_KERNEL (MSR_FP|MSR_RI)
54#else
55#define MSR_KERNEL (MSR_FP|MSR_ME|MSR_RI)
56#endif
57
58/* Macros for manipulating CSx_START/STOP */
59#define START_REG(start) ((start) >> 16)
60#define STOP_REG(start, size) (((start) + (size) - 1) >> 16)
61
62/*
63 * Set up GOT: Global Offset Table
64 *
65 * Use r14 to access the GOT
66 */
67 START_GOT
68 GOT_ENTRY(_GOT2_TABLE_)
69 GOT_ENTRY(_FIXUP_TABLE_)
70
71 GOT_ENTRY(_start)
72 GOT_ENTRY(_start_of_vectors)
73 GOT_ENTRY(_end_of_vectors)
74 GOT_ENTRY(transfer_to_handler)
75
76 GOT_ENTRY(__init_end)
77 GOT_ENTRY(_end)
78 GOT_ENTRY(__bss_start)
79 END_GOT
80
81/*
82 * Magic number and version string
83 */
84 .long 0x27051956 /* U-Boot Magic Number */
85 .globl version_string
86version_string:
87 .ascii U_BOOT_VERSION
88 .ascii " (", __DATE__, " - ", __TIME__, ")"
89 .ascii " ", CONFIG_IDENT_STRING, "\0"
90
91/*
92 * Vector Table
93 */
94 .text
95 . = EXC_OFF_SYS_RESET
96
97 .globl _start
98 /* Start from here after reset/power on */
99_start:
100 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH */
101 b boot_cold
102
103 .globl _start_of_vectors
104_start_of_vectors:
105
106/* Machine check */
107 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
108
109/* Data Storage exception. */
110 STD_EXCEPTION(0x300, DataStorage, UnknownException)
111
112/* Instruction Storage exception. */
113 STD_EXCEPTION(0x400, InstStorage, UnknownException)
114
115/* External Interrupt exception. */
116 STD_EXCEPTION(0x500, ExtInterrupt, UnknownException)
117
118/* Alignment exception. */
119 . = 0x600
120Alignment:
121 EXCEPTION_PROLOG(SRR0, SRR1)
122 mfspr r4,DAR
123 stw r4,_DAR(r21)
124 mfspr r5,DSISR
125 stw r5,_DSISR(r21)
126 addi r3,r1,STACK_FRAME_OVERHEAD
127 li r20,MSR_KERNEL
128 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
129 rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */
130 lwz r6,GOT(transfer_to_handler)
131 mtlr r6
132 blrl
133.L_Alignment:
134 .long AlignmentException - _start + EXC_OFF_SYS_RESET
135 .long int_return - _start + EXC_OFF_SYS_RESET
136
137/* Program check exception */
138 . = 0x700
139ProgramCheck:
140 EXCEPTION_PROLOG(SRR0, SRR1)
141 addi r3,r1,STACK_FRAME_OVERHEAD
142 li r20,MSR_KERNEL
143 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
144 rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */
145 lwz r6,GOT(transfer_to_handler)
146 mtlr r6
147 blrl
148.L_ProgramCheck:
149 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
150 .long int_return - _start + EXC_OFF_SYS_RESET
151
152/* Floating Point Unit unavailable exception */
153 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
154
155/* Decrementer */
156 STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
157
158/* Critical interrupt */
159 STD_EXCEPTION(0xa00, Critical, UnknownException)
160
161/* System Call */
162 STD_EXCEPTION(0xc00, SystemCall, UnknownException)
163
164/* Trace interrupt */
165 STD_EXCEPTION(0xd00, Trace, UnknownException)
166
167/* Performance Monitor interrupt */
168 STD_EXCEPTION(0xf00, PerfMon, UnknownException)
169
170/* Intruction Translation Miss */
171 STD_EXCEPTION(0x1000, InstructionTLBMiss, UnknownException)
172
173/* Data Load Translation Miss */
174 STD_EXCEPTION(0x1100, DataLoadTLBMiss, UnknownException)
175
176/* Data Store Translation Miss */
177 STD_EXCEPTION(0x1200, DataStoreTLBMiss, UnknownException)
178
179/* Instruction Address Breakpoint */
180 STD_EXCEPTION(0x1300, InstructionAddrBreakpoint, DebugException)
181
182/* System Management interrupt */
183 STD_EXCEPTION(0x1400, SystemMgmtInterrupt, UnknownException)
184
185 .globl _end_of_vectors
186_end_of_vectors:
187
188 . = 0x3000
189boot_cold:
190 /* Save msr contents */
191 mfmsr r5
192
193 /* Set IMMR area to our preferred location */
194 lis r4, CONFIG_DEFAULT_IMMR@h
195 lis r3, CFG_IMMR@h
196 ori r3, r3, CFG_IMMR@l
197 stw r3, IMMRBAR(r4)
198 mtspr MBAR, r3 /* IMMRBAR is mirrored into the MBAR SPR (311) */
199
200 /* Initialise the machine */
201 bl cpu_early_init
202
203 /*
204 * Set up Local Access Windows:
205 *
206 * 1) Boot/CS0 (boot FLASH)
207 * 2) On-chip SRAM (initial stack purposes)
208 */
209
210 /* Boot CS/CS0 window range */
Wolfgang Denk530181f2007-08-02 21:27:46 +0200211 lis r3, CFG_IMMR@h
212 ori r3, r3, CFG_IMMR@l
Rafal Jaworowskid3a02c32007-07-27 14:43:59 +0200213
214 lis r4, START_REG(CFG_FLASH_BASE)
215 ori r4, r4, STOP_REG(CFG_FLASH_BASE, CFG_FLASH_SIZE)
216 stw r4, LPCS0AW(r3)
217
218 /*
219 * The SRAM window has a fixed size (256K), so only the start address
220 * is necessary
221 */
222 lis r4, START_REG(CFG_SRAM_BASE) & 0xff00
223 stw r4, SRAMBAR(r3)
224
Wolfgang Denk530181f2007-08-02 21:27:46 +0200225 /*
Rafal Jaworowskid3a02c32007-07-27 14:43:59 +0200226 * According to MPC5121e RM, configuring local access windows should
Wolfgang Denk530181f2007-08-02 21:27:46 +0200227 * be followed by a dummy read of the config register that was
Rafal Jaworowskid3a02c32007-07-27 14:43:59 +0200228 * modified last and an isync
Wolfgang Denk530181f2007-08-02 21:27:46 +0200229 */
Rafal Jaworowskid3a02c32007-07-27 14:43:59 +0200230 lwz r4, SRAMBAR(r3)
231 isync
232
233 /*
234 * Set configuration of the Boot/CS0, the SRAM window does not have a
235 * config register so no params can be set for it
236 */
237 lis r3, (CFG_IMMR + LPC_OFFSET)@h
Wolfgang Denk530181f2007-08-02 21:27:46 +0200238 ori r3, r3, (CFG_IMMR + LPC_OFFSET)@l
Rafal Jaworowskid3a02c32007-07-27 14:43:59 +0200239
Wolfgang Denk530181f2007-08-02 21:27:46 +0200240 lis r4, CFG_CS0_CFG@h
241 ori r4, r4, CFG_CS0_CFG@l
242 stw r4, CS0_CONFIG(r3)
Rafal Jaworowskid3a02c32007-07-27 14:43:59 +0200243
244 /* Master enable all CS's */
245 lis r4, CS_CTRL_ME@h
246 ori r4, r4, CS_CTRL_ME@l
247 stw r4, CS_CTRL(r3)
248
249 lis r4, (CFG_MONITOR_BASE)@h
250 ori r4, r4, (CFG_MONITOR_BASE)@l
251 addi r5, r4, in_flash - _start + EXC_OFF_SYS_RESET
252 mtlr r5
253 blr
254
255in_flash:
256 lis r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@h
257 ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@l
258
259 li r0, 0 /* Make room for stack frame header and */
260 stwu r0, -4(r1) /* clear final stack frame so that */
261 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
262
263 /* let the C-code set up the rest */
264 /* */
265 /* Be careful to keep code relocatable & stack humble */
266 /*------------------------------------------------------*/
267
268 GET_GOT /* initialize GOT access */
269
270 /* r3: IMMR */
271 lis r3, CFG_IMMR@h
272 /* run low-level CPU init code (in Flash) */
273 bl cpu_init_f
274
275 /* r3: BOOTFLAG */
276 mr r3, r21
277 /* run 1st part of board init code (in Flash) */
278 bl board_init_f
279
280 /* NOTREACHED - board_init_f() does not return */
281
282/*
283 * This code finishes saving the registers to the exception frame
284 * and jumps to the appropriate handler for the exception.
285 * Register r21 is pointer into trap frame, r1 has new stack pointer.
286 */
287 .globl transfer_to_handler
288transfer_to_handler:
289 stw r22,_NIP(r21)
290 lis r22,MSR_POW@h
291 andc r23,r23,r22
292 stw r23,_MSR(r21)
293 SAVE_GPR(7, r21)
294 SAVE_4GPRS(8, r21)
295 SAVE_8GPRS(12, r21)
296 SAVE_8GPRS(24, r21)
297 mflr r23
298 andi. r24,r23,0x3f00 /* get vector offset */
299 stw r24,TRAP(r21)
300 li r22,0
301 stw r22,RESULT(r21)
302 lwz r24,0(r23) /* virtual address of handler */
303 lwz r23,4(r23) /* where to go when done */
304 mtspr SRR0,r24
305 mtspr SRR1,r20
306 mtlr r23
307 SYNC
308 rfi /* jump to handler, enable MMU */
309
310int_return:
311 mfmsr r28 /* Disable interrupts */
312 li r4,0
313 ori r4,r4,MSR_EE
314 andc r28,r28,r4
315 SYNC /* Some chip revs need this... */
316 mtmsr r28
317 SYNC
318 lwz r2,_CTR(r1)
319 lwz r0,_LINK(r1)
320 mtctr r2
321 mtlr r0
322 lwz r2,_XER(r1)
323 lwz r0,_CCR(r1)
324 mtspr XER,r2
325 mtcrf 0xFF,r0
326 REST_10GPRS(3, r1)
327 REST_10GPRS(13, r1)
328 REST_8GPRS(23, r1)
329 REST_GPR(31, r1)
330 lwz r2,_NIP(r1) /* Restore environment */
331 lwz r0,_MSR(r1)
332 mtspr SRR0,r2
333 mtspr SRR1,r0
334 lwz r0,GPR0(r1)
335 lwz r2,GPR2(r1)
336 lwz r1,GPR1(r1)
337 SYNC
338 rfi
339
340/*
341 * This code initialises the machine, it expects original MSR contents to be in r5.
342 */
343cpu_early_init:
344 /* Initialize machine status; enable machine check interrupt */
345 /*-----------------------------------------------------------*/
346
347 li r3, MSR_KERNEL /* Set ME and RI flags */
348 rlwimi r3, r5, 0, 25, 25 /* preserve IP bit */
349#ifdef DEBUG
350 rlwimi r3, r5, 0, 21, 22 /* debugger might set SE, BE bits */
351#endif
352 mtmsr r3
353 SYNC
354 mtspr SRR1, r3 /* Mirror current MSR state in SRR1 */
355
356 lis r3, CFG_IMMR@h
357
358#if defined(CONFIG_WATCHDOG)
359 /* Initialise the watchdog and reset it */
360 /*--------------------------------------*/
361 lis r4, CFG_WATCHDOG_VALUE
362 ori r4, r4, (SWCRR_SWEN | SWCRR_SWRI | SWCRR_SWPR)
363 stw r4, SWCRR(r3)
364
365 /* reset */
366 li r4, 0x556C
367 sth r4, SWSRR@l(r3)
368 li r4, 0x0
369 ori r4, r4, 0xAA39
370 sth r4, SWSRR@l(r3)
371#else
372 /* Disable the watchdog */
373 /*----------------------*/
374 lwz r4, SWCRR(r3)
375 /*
376 * Check to see if it's enabled for disabling: once disabled by s/w
377 * it's not possible to re-enable it
378 */
379 andi. r4, r4, 0x4
380 beq 1f
381 xor r4, r4, r4
382 stw r4, SWCRR(r3)
3831:
384#endif /* CONFIG_WATCHDOG */
385
386 /* Initialize the Hardware Implementation-dependent Registers */
387 /* HID0 also contains cache control */
388 /*------------------------------------------------------*/
389 lis r3, CFG_HID0_INIT@h
390 ori r3, r3, CFG_HID0_INIT@l
391 SYNC
392 mtspr HID0, r3
393
394 lis r3, CFG_HID0_FINAL@h
395 ori r3, r3, CFG_HID0_FINAL@l
396 SYNC
397 mtspr HID0, r3
398
399 lis r3, CFG_HID2@h
400 ori r3, r3, CFG_HID2@l
401 SYNC
402 mtspr HID2, r3
403 sync
404 blr
405
406
407/* Cache functions.
408 *
409 * Note: requires that all cache bits in
410 * HID0 are in the low half word.
411 */
412 .globl icache_enable
413icache_enable:
414 mfspr r3, HID0
415 ori r3, r3, HID0_ICE
416 lis r4, 0
417 ori r4, r4, HID0_ILOCK
418 andc r3, r3, r4
419 ori r4, r3, HID0_ICFI
420 isync
421 mtspr HID0, r4 /* sets enable and invalidate, clears lock */
422 isync
423 mtspr HID0, r3 /* clears invalidate */
424 blr
425
426 .globl icache_disable
427icache_disable:
428 mfspr r3, HID0
429 lis r4, 0
430 ori r4, r4, HID0_ICE|HID0_ILOCK
431 andc r3, r3, r4
432 ori r4, r3, HID0_ICFI
433 isync
434 mtspr HID0, r4 /* sets invalidate, clears enable and lock*/
435 isync
436 mtspr HID0, r3 /* clears invalidate */
437 blr
438
439 .globl icache_status
440icache_status:
441 mfspr r3, HID0
442 rlwinm r3, r3, (31 - HID0_ICE_SHIFT + 1), 31, 31
443 blr
444
445 .globl dcache_enable
446dcache_enable:
447 mfspr r3, HID0
448 li r5, HID0_DCFI|HID0_DLOCK
449 andc r3, r3, r5
450 mtspr HID0, r3 /* no invalidate, unlock */
451 ori r3, r3, HID0_DCE
452 ori r5, r3, HID0_DCFI
453 mtspr HID0, r5 /* enable + invalidate */
454 mtspr HID0, r3 /* enable */
455 sync
456 blr
457
458 .globl dcache_disable
459dcache_disable:
460 mfspr r3, HID0
461 lis r4, 0
462 ori r4, r4, HID0_DCE|HID0_DLOCK
463 andc r3, r3, r4
464 ori r4, r3, HID0_DCI
465 sync
466 mtspr HID0, r4 /* sets invalidate, clears enable and lock */
467 sync
468 mtspr HID0, r3 /* clears invalidate */
469 blr
470
471 .globl dcache_status
472dcache_status:
473 mfspr r3, HID0
474 rlwinm r3, r3, (31 - HID0_DCE_SHIFT + 1), 31, 31
475 blr
476
477 .globl get_pvr
478get_pvr:
479 mfspr r3, PVR
480 blr
481
482/*------------------------------------------------------------------------------- */
483/* Function: ppcDcbf */
484/* Description: Data Cache block flush */
485/* Input: r3 = effective address */
486/* Output: none. */
487/*------------------------------------------------------------------------------- */
488 .globl ppcDcbf
489ppcDcbf:
490 dcbf r0,r3
491 blr
492
493/*------------------------------------------------------------------------------- */
494/* Function: ppcDcbi */
495/* Description: Data Cache block Invalidate */
496/* Input: r3 = effective address */
497/* Output: none. */
498/*------------------------------------------------------------------------------- */
499 .globl ppcDcbi
500ppcDcbi:
501 dcbi r0,r3
502 blr
503
504/*--------------------------------------------------------------------------
505 * Function: ppcDcbz
506 * Description: Data Cache block zero.
507 * Input: r3 = effective address
508 * Output: none.
509 *-------------------------------------------------------------------------- */
510
511 .globl ppcDcbz
512ppcDcbz:
513 dcbz r0,r3
514 blr
515
516 .globl ppcDWstore
517ppcDWstore:
518 lfd 1, 0(r4)
519 stfd 1, 0(r3)
520 blr
521
522 .globl ppcDWload
523ppcDWload:
524 lfd 1, 0(r3)
525 stfd 1, 0(r4)
526 blr
527
528/*-------------------------------------------------------------------*/
529
530/*
531 * void relocate_code (addr_sp, gd, addr_moni)
532 *
533 * This "function" does not return, instead it continues in RAM
534 * after relocating the monitor code.
535 *
536 * r3 = dest
537 * r4 = src
538 * r5 = length in bytes
539 * r6 = cachelinesize
540 */
541 .globl relocate_code
542relocate_code:
543 mr r1, r3 /* Set new stack pointer */
544 mr r9, r4 /* Save copy of Global Data pointer */
545 mr r10, r5 /* Save copy of Destination Address */
546
547 mr r3, r5 /* Destination Address */
548 lis r4, CFG_MONITOR_BASE@h /* Source Address */
549 ori r4, r4, CFG_MONITOR_BASE@l
550 lwz r5, GOT(__init_end)
551 sub r5, r5, r4
552 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
553
554 /*
555 * Fix GOT pointer:
556 *
557 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE)
558 * + Destination Address
559 *
560 * Offset:
561 */
562 sub r15, r10, r4
563
564 /* First our own GOT */
565 add r14, r14, r15
566 /* then the one used by the C code */
567 add r30, r30, r15
568
569 /*
570 * Now relocate code
571 */
572 cmplw cr1,r3,r4
573 addi r0,r5,3
574 srwi. r0,r0,2
575 beq cr1,4f /* In place copy is not necessary */
576 beq 7f /* Protect against 0 count */
577 mtctr r0
578 bge cr1,2f
579 la r8,-4(r4)
580 la r7,-4(r3)
581
582 /* copy */
5831: lwzu r0,4(r8)
584 stwu r0,4(r7)
585 bdnz 1b
586
587 addi r0,r5,3
588 srwi. r0,r0,2
589 mtctr r0
590 la r8,-4(r4)
591 la r7,-4(r3)
592
593 /* and compare */
59420: lwzu r20,4(r8)
595 lwzu r21,4(r7)
596 xor. r22, r20, r21
597 bne 30f
598 bdnz 20b
599 b 4f
600
601 /* compare failed */
60230: li r3, 0
603 blr
604
6052: slwi r0,r0,2 /* re copy in reverse order ... y do we needed it? */
606 add r8,r4,r0
607 add r7,r3,r0
6083: lwzu r0,-4(r8)
609 stwu r0,-4(r7)
610 bdnz 3b
611
612/*
613 * Now flush the cache: note that we must start from a cache aligned
614 * address. Otherwise we might miss one cache line.
615 */
6164: cmpwi r6,0
617 add r5,r3,r5
618 beq 7f /* Always flush prefetch queue in any case */
619 subi r0,r6,1
620 andc r3,r3,r0
621 mr r4,r3
6225: dcbst 0,r4
623 add r4,r4,r6
624 cmplw r4,r5
625 blt 5b
626 sync /* Wait for all dcbst to complete on bus */
627 mr r4,r3
6286: icbi 0,r4
629 add r4,r4,r6
630 cmplw r4,r5
631 blt 6b
6327: sync /* Wait for all icbi to complete on bus */
633 isync
634
635/*
636 * We are done. Do not return, instead branch to second part of board
637 * initialization, now running from RAM.
638 */
639 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
640 mtlr r0
641 blr
642
643in_ram:
644 /*
645 * Relocation Function, r14 point to got2+0x8000
646 *
647 * Adjust got2 pointers, no need to check for 0, this code
648 * already puts a few entries in the table.
649 */
650 li r0,__got2_entries@sectoff@l
651 la r3,GOT(_GOT2_TABLE_)
652 lwz r11,GOT(_GOT2_TABLE_)
653 mtctr r0
654 sub r11,r3,r11
655 addi r3,r3,-4
6561: lwzu r0,4(r3)
657 add r0,r0,r11
658 stw r0,0(r3)
659 bdnz 1b
660
661 /*
662 * Now adjust the fixups and the pointers to the fixups
663 * in case we need to move ourselves again.
664 */
6652: li r0,__fixup_entries@sectoff@l
666 lwz r3,GOT(_FIXUP_TABLE_)
667 cmpwi r0,0
668 mtctr r0
669 addi r3,r3,-4
670 beq 4f
6713: lwzu r4,4(r3)
672 lwzux r0,r4,r11
673 add r0,r0,r11
674 stw r10,0(r3)
675 stw r0,0(r4)
676 bdnz 3b
6774:
678clear_bss:
679 /*
680 * Now clear BSS segment
681 */
682 lwz r3,GOT(__bss_start)
683 lwz r4,GOT(_end)
684
685 cmplw 0, r3, r4
686 beq 6f
687
688 li r0, 0
6895:
690 stw r0, 0(r3)
691 addi r3, r3, 4
692 cmplw 0, r3, r4
693 bne 5b
6946:
695 mr r3, r9 /* Global Data pointer */
696 mr r4, r10 /* Destination Address */
697 bl board_init_r
698
699 /*
700 * Copy exception vector code to low memory
701 *
702 * r3: dest_addr
703 * r7: source address, r8: end address, r9: target address
704 */
705 .globl trap_init
706trap_init:
707 lwz r7, GOT(_start)
708 lwz r8, GOT(_end_of_vectors)
709
710 li r9, 0x100 /* reset vector at 0x100 */
711
712 cmplw 0, r7, r8
713 bgelr /* return if r7>=r8 - just in case */
714
715 mflr r4 /* save link register */
7161:
717 lwz r0, 0(r7)
718 stw r0, 0(r9)
719 addi r7, r7, 4
720 addi r9, r9, 4
721 cmplw 0, r7, r8
722 bne 1b
723
724 /*
725 * relocate `hdlr' and `int_return' entries
726 */
727 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
728 li r8, Alignment - _start + EXC_OFF_SYS_RESET
7292:
730 bl trap_reloc
731 addi r7, r7, 0x100 /* next exception vector */
732 cmplw 0, r7, r8
733 blt 2b
734
735 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
736 bl trap_reloc
737
738 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
739 bl trap_reloc
740
741 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
742 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
7433:
744 bl trap_reloc
745 addi r7, r7, 0x100 /* next exception vector */
746 cmplw 0, r7, r8
747 blt 3b
748
749 li r7, .L_Trace - _start + EXC_OFF_SYS_RESET
750 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
7514:
752 bl trap_reloc
753 addi r7, r7, 0x100 /* next exception vector */
754 cmplw 0, r7, r8
755 blt 4b
756
757 mfmsr r3 /* now that the vectors have */
758 lis r7, MSR_IP@h /* relocated into low memory */
759 ori r7, r7, MSR_IP@l /* MSR[IP] can be turned off */
760 andc r3, r3, r7 /* (if it was on) */
761 SYNC /* Some chip revs need this... */
762 mtmsr r3
763 SYNC
764
765 mtlr r4 /* restore link register */
766 blr
767
768 /*
769 * Function: relocate entries for one exception vector
770 */
771trap_reloc:
772 lwz r0, 0(r7) /* hdlr ... */
773 add r0, r0, r3 /* ... += dest_addr */
774 stw r0, 0(r7)
775
776 lwz r0, 4(r7) /* int_return ... */
777 add r0, r0, r3 /* ... += dest_addr */
778 stw r0, 4(r7)
779
780 blr