blob: 4fb2047da47fec33f7eb8e35dfedf078e6bddabe [file] [log] [blame]
wdenk0db5bca2003-03-31 17:27:09 +00001/*
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 Wolfgang Denk <wd@denx.de>
5 * Copyright (C) 2003 Martin Winistoerfer, martinwinistoerfer@gmx.ch.
wdenk8bde7f72003-06-27 21:31:46 +00006 *
wdenk0db5bca2003-03-31 17:27:09 +00007 * 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
26/*
27 * File: start.S
wdenk8bde7f72003-06-27 21:31:46 +000028 *
wdenk0db5bca2003-03-31 17:27:09 +000029 * Discription: startup code
30 *
31 */
32
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +020033#include <asm-offsets.h>
wdenk0db5bca2003-03-31 17:27:09 +000034#include <config.h>
35#include <mpc5xx.h>
Peter Tyser561858e2008-11-03 09:30:59 -060036#include <timestamp.h>
wdenk0db5bca2003-03-31 17:27:09 +000037#include <version.h>
38
39#define CONFIG_5xx 1 /* needed for Linux kernel header files */
40#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
41
42#include <ppc_asm.tmpl>
43#include <ppc_defs.h>
wdenk8bde7f72003-06-27 21:31:46 +000044
wdenk0db5bca2003-03-31 17:27:09 +000045#include <linux/config.h>
wdenk8bde7f72003-06-27 21:31:46 +000046#include <asm/processor.h>
Peter Tyserd98b0522010-10-14 23:33:24 -050047#include <asm/u-boot.h>
wdenk0db5bca2003-03-31 17:27:09 +000048
49#ifndef CONFIG_IDENT_STRING
50#define CONFIG_IDENT_STRING ""
51#endif
52
53/* We don't have a MMU.
54*/
55#undef MSR_KERNEL
56#define MSR_KERNEL ( MSR_ME | MSR_RI ) /* Machine Check and Recoverable Interr. */
57
58/*
59 * Set up GOT: Global Offset Table
60 *
Joakim Tjernlund0f8aa152010-01-19 14:41:56 +010061 * Use r12 to access the GOT
wdenk0db5bca2003-03-31 17:27:09 +000062 */
63 START_GOT
64 GOT_ENTRY(_GOT2_TABLE_)
65 GOT_ENTRY(_FIXUP_TABLE_)
66
67 GOT_ENTRY(_start)
68 GOT_ENTRY(_start_of_vectors)
69 GOT_ENTRY(_end_of_vectors)
70 GOT_ENTRY(transfer_to_handler)
71
wdenk3b57fe02003-05-30 12:48:29 +000072 GOT_ENTRY(__init_end)
Po-Yu Chuang44c6e652011-03-01 22:59:59 +000073 GOT_ENTRY(__bss_end__)
wdenk5d232d02003-05-22 22:52:13 +000074 GOT_ENTRY(__bss_start)
wdenk0db5bca2003-03-31 17:27:09 +000075 END_GOT
76
77/*
78 * r3 - 1st arg to board_init(): IMMP pointer
79 * r4 - 2nd arg to board_init(): boot flag
80 */
81 .text
82 .long 0x27051956 /* U-Boot Magic Number */
83 .globl version_string
84version_string:
85 .ascii U_BOOT_VERSION
Peter Tyser561858e2008-11-03 09:30:59 -060086 .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
wdenk0db5bca2003-03-31 17:27:09 +000087 .ascii CONFIG_IDENT_STRING, "\0"
88
89 . = EXC_OFF_SYS_RESET
90 .globl _start
91_start:
92 mfspr r3, 638
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020093 li r4, CONFIG_SYS_ISB /* Set ISB bit */
wdenk8bde7f72003-06-27 21:31:46 +000094 or r3, r3, r4
wdenk0db5bca2003-03-31 17:27:09 +000095 mtspr 638, r3
wdenk0db5bca2003-03-31 17:27:09 +000096
97 /* Initialize machine status; enable machine check interrupt */
98 /*----------------------------------------------------------------------*/
99 li r3, MSR_KERNEL /* Set ME, RI flags */
100 mtmsr r3
101 mtspr SRR1, r3 /* Make SRR1 match MSR */
102
103 /* Initialize debug port registers */
104 /*----------------------------------------------------------------------*/
105 xor r0, r0, r0 /* Clear R0 */
106 mtspr LCTRL1, r0 /* Initialize debug port regs */
107 mtspr LCTRL2, r0
108 mtspr COUNTA, r0
109 mtspr COUNTB, r0
110
wdenkb6e4c402004-01-02 16:05:07 +0000111#if defined(CONFIG_PATI)
112 /* the external flash access on PATI fails if programming the PLL to 40MHz.
113 * Copy the PLL programming code to the internal RAM and execute it
114 *----------------------------------------------------------------------*/
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200115 lis r3, CONFIG_SYS_MONITOR_BASE@h
116 ori r3, r3, CONFIG_SYS_MONITOR_BASE@l
wdenkb6e4c402004-01-02 16:05:07 +0000117 addi r3, r3, pll_prog_code_start - _start + EXC_OFF_SYS_RESET
118
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200119 lis r4, CONFIG_SYS_INIT_RAM_ADDR@h
120 ori r4, r4, CONFIG_SYS_INIT_RAM_ADDR@l
wdenkb6e4c402004-01-02 16:05:07 +0000121 mtlr r4
122 addis r5,0,0x0
123 ori r5,r5,((pll_prog_code_end - pll_prog_code_start) >>2)
124 mtctr r5
125 addi r3, r3, -4
126 addi r4, r4, -4
1270:
128 lwzu r0,4(r3)
129 stwu r0,4(r4)
130 bdnz 0b /* copy loop */
131 blrl
132#endif
133
wdenk0db5bca2003-03-31 17:27:09 +0000134 /*
135 * Calculate absolute address in FLASH and jump there
136 *----------------------------------------------------------------------*/
137
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200138 lis r3, CONFIG_SYS_MONITOR_BASE@h
139 ori r3, r3, CONFIG_SYS_MONITOR_BASE@l
wdenk0db5bca2003-03-31 17:27:09 +0000140 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
141 mtlr r3
142 blr
143
144in_flash:
145
146 /* Initialize some SPRs that are hard to access from C */
147 /*----------------------------------------------------------------------*/
wdenk8bde7f72003-06-27 21:31:46 +0000148
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200149 lis r3, CONFIG_SYS_IMMR@h /* Pass IMMR as arg1 to C routine */
150 lis r2, CONFIG_SYS_INIT_SP_ADDR@h
151 ori r1, r2, CONFIG_SYS_INIT_SP_ADDR@l /* Set up the stack in internal SRAM */
wdenk0db5bca2003-03-31 17:27:09 +0000152 /* Note: R0 is still 0 here */
153 stwu r0, -4(r1) /* Clear final stack frame so that */
154 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
155
156 /*
157 * Disable serialized ifetch and show cycles
158 * (i.e. set processor to normal mode) for maximum
159 * performance.
160 */
161
162 li r2, 0x0007
163 mtspr ICTRL, r2
164
165 /* Set up debug mode entry */
166
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200167 lis r2, CONFIG_SYS_DER@h
168 ori r2, r2, CONFIG_SYS_DER@l
wdenk0db5bca2003-03-31 17:27:09 +0000169 mtspr DER, r2
170
171 /* Let the C-code set up the rest */
172 /* */
173 /* Be careful to keep code relocatable ! */
174 /*----------------------------------------------------------------------*/
175
176 GET_GOT /* initialize GOT access */
Joakim Tjernlund39768f72010-12-06 18:35:37 +0100177#if defined(__pic__) && __pic__ == 1
178 /* Needed for upcoming -msingle-pic-base */
179 bl _GLOBAL_OFFSET_TABLE_@local-4
180 mflr r30
181#endif
wdenk0db5bca2003-03-31 17:27:09 +0000182 /* r3: IMMR */
183 bl cpu_init_f /* run low-level CPU init code (from Flash) */
184
wdenk0db5bca2003-03-31 17:27:09 +0000185 bl board_init_f /* run 1st part of board init code (from Flash) */
186
Peter Tyser52ebd9c2010-09-14 19:13:53 -0500187 /* NOTREACHED - board_init_f() does not return */
188
wdenk0db5bca2003-03-31 17:27:09 +0000189
wdenk0db5bca2003-03-31 17:27:09 +0000190 .globl _start_of_vectors
191_start_of_vectors:
192
193/* Machine check */
194 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
195
196/* Data Storage exception. "Never" generated on the 860. */
197 STD_EXCEPTION(0x300, DataStorage, UnknownException)
198
199/* Instruction Storage exception. "Never" generated on the 860. */
200 STD_EXCEPTION(0x400, InstStorage, UnknownException)
201
202/* External Interrupt exception. */
203 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
204
205/* Alignment exception. */
206 . = 0x600
207Alignment:
Rafal Jaworowski02032e82007-06-22 14:58:04 +0200208 EXCEPTION_PROLOG(SRR0, SRR1)
wdenk0db5bca2003-03-31 17:27:09 +0000209 mfspr r4,DAR
210 stw r4,_DAR(r21)
211 mfspr r5,DSISR
212 stw r5,_DSISR(r21)
213 addi r3,r1,STACK_FRAME_OVERHEAD
Joakim Tjernlundfc4e1882010-01-19 14:41:55 +0100214 EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
wdenk0db5bca2003-03-31 17:27:09 +0000215
216/* Program check exception */
217 . = 0x700
218ProgramCheck:
Rafal Jaworowski02032e82007-06-22 14:58:04 +0200219 EXCEPTION_PROLOG(SRR0, SRR1)
wdenk0db5bca2003-03-31 17:27:09 +0000220 addi r3,r1,STACK_FRAME_OVERHEAD
Joakim Tjernlundfc4e1882010-01-19 14:41:55 +0100221 EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
222 MSR_KERNEL, COPY_EE)
wdenk0db5bca2003-03-31 17:27:09 +0000223
224 /* FPU on MPC5xx available. We will use it later.
225 */
226 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
227
228 /* I guess we could implement decrementer, and may have
229 * to someday for timekeeping.
230 */
231 STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
232 STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
233 STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
wdenk27b207f2003-07-24 23:38:38 +0000234 STD_EXCEPTION(0xc00, SystemCall, UnknownException)
wdenk0db5bca2003-03-31 17:27:09 +0000235 STD_EXCEPTION(0xd00, SingleStep, UnknownException)
236
237 STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
238 STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
239
240 /* On the MPC8xx, this is a software emulation interrupt. It occurs
241 * for all unimplemented and illegal instructions.
242 */
243 STD_EXCEPTION(0x1000, SoftEmu, SoftEmuException)
244 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
245 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
246 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
247 STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
248
249 STD_EXCEPTION(0x1500, Reserved5, UnknownException)
250 STD_EXCEPTION(0x1600, Reserved6, UnknownException)
251 STD_EXCEPTION(0x1700, Reserved7, UnknownException)
252 STD_EXCEPTION(0x1800, Reserved8, UnknownException)
253 STD_EXCEPTION(0x1900, Reserved9, UnknownException)
254 STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
255 STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
256
257 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
258 STD_EXCEPTION(0x1d00, InstructionBreakpoint, DebugException)
259 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
260 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
261
262
263 .globl _end_of_vectors
264_end_of_vectors:
265
266
267 . = 0x2000
268
269/*
270 * This code finishes saving the registers to the exception frame
271 * and jumps to the appropriate handler for the exception.
272 * Register r21 is pointer into trap frame, r1 has new stack pointer.
273 */
274 .globl transfer_to_handler
275transfer_to_handler:
276 stw r22,_NIP(r21)
277 lis r22,MSR_POW@h
278 andc r23,r23,r22
279 stw r23,_MSR(r21)
280 SAVE_GPR(7, r21)
281 SAVE_4GPRS(8, r21)
282 SAVE_8GPRS(12, r21)
283 SAVE_8GPRS(24, r21)
284 mflr r23
285 andi. r24,r23,0x3f00 /* get vector offset */
286 stw r24,TRAP(r21)
287 li r22,0
288 stw r22,RESULT(r21)
289 mtspr SPRG2,r22 /* r1 is now kernel sp */
290 lwz r24,0(r23) /* virtual address of handler */
291 lwz r23,4(r23) /* where to go when done */
292 mtspr SRR0,r24
293 mtspr SRR1,r20
294 mtlr r23
295 SYNC
296 rfi /* jump to handler, enable MMU */
297
298int_return:
299 mfmsr r28 /* Disable interrupts */
300 li r4,0
301 ori r4,r4,MSR_EE
302 andc r28,r28,r4
303 SYNC /* Some chip revs need this... */
304 mtmsr r28
305 SYNC
306 lwz r2,_CTR(r1)
307 lwz r0,_LINK(r1)
308 mtctr r2
309 mtlr r0
310 lwz r2,_XER(r1)
311 lwz r0,_CCR(r1)
312 mtspr XER,r2
313 mtcrf 0xFF,r0
314 REST_10GPRS(3, r1)
315 REST_10GPRS(13, r1)
316 REST_8GPRS(23, r1)
317 REST_GPR(31, r1)
318 lwz r2,_NIP(r1) /* Restore environment */
319 lwz r0,_MSR(r1)
320 mtspr SRR0,r2
321 mtspr SRR1,r0
322 lwz r0,GPR0(r1)
323 lwz r2,GPR2(r1)
324 lwz r1,GPR1(r1)
325 SYNC
326 rfi
327
wdenk8bde7f72003-06-27 21:31:46 +0000328
wdenk0db5bca2003-03-31 17:27:09 +0000329/*
330 * unsigned int get_immr (unsigned int mask)
331 *
332 * return (mask ? (IMMR & mask) : IMMR);
333 */
334 .globl get_immr
335get_immr:
336 mr r4,r3 /* save mask */
337 mfspr r3, IMMR /* IMMR */
338 cmpwi 0,r4,0 /* mask != 0 ? */
339 beq 4f
340 and r3,r3,r4 /* IMMR & mask */
3414:
342 blr
343
344 .globl get_pvr
345get_pvr:
346 mfspr r3, PVR
347 blr
348
349
350/*------------------------------------------------------------------------------*/
351
352/*
353 * void relocate_code (addr_sp, gd, addr_moni)
354 *
355 * This "function" does not return, instead it continues in RAM
356 * after relocating the monitor code.
357 *
358 * r3 = dest
359 * r4 = src
360 * r5 = length in bytes
361 * r6 = cachelinesize
362 */
363 .globl relocate_code
364relocate_code:
365 mr r1, r3 /* Set new stack pointer in SRAM */
366 mr r9, r4 /* Save copy of global data pointer in SRAM */
367 mr r10, r5 /* Save copy of monitor destination Address in SRAM */
368
Joakim Tjernlund0f8aa152010-01-19 14:41:56 +0100369 GET_GOT
Joakim Tjernlund39768f72010-12-06 18:35:37 +0100370#if defined(__pic__) && __pic__ == 1
371 /* Needed for upcoming -msingle-pic-base */
372 bl _GLOBAL_OFFSET_TABLE_@local-4
373 mflr r30
374#endif
wdenk0db5bca2003-03-31 17:27:09 +0000375 mr r3, r5 /* Destination Address */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200376 lis r4, CONFIG_SYS_MONITOR_BASE@h /* Source Address */
377 ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
wdenk3b57fe02003-05-30 12:48:29 +0000378 lwz r5, GOT(__init_end)
379 sub r5, r5, r4
wdenk0db5bca2003-03-31 17:27:09 +0000380
381 /*
382 * Fix GOT pointer:
383 *
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200384 * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address
wdenk0db5bca2003-03-31 17:27:09 +0000385 *
386 * Offset:
387 */
388 sub r15, r10, r4
389
390 /* First our own GOT */
Joakim Tjernlund0f8aa152010-01-19 14:41:56 +0100391 add r12, r12, r15
wdenk0db5bca2003-03-31 17:27:09 +0000392 /* the the one used by the C code */
393 add r30, r30, r15
394
395 /*
396 * Now relocate code
397 */
398
399 cmplw cr1,r3,r4
400 addi r0,r5,3
401 srwi. r0,r0,2
402 beq cr1,4f /* In place copy is not necessary */
403 beq 4f /* Protect against 0 count */
404 mtctr r0
405 bge cr1,2f
406
407 la r8,-4(r4)
408 la r7,-4(r3)
4091: lwzu r0,4(r8)
410 stwu r0,4(r7)
411 bdnz 1b
412 b 4f
413
4142: slwi r0,r0,2
415 add r8,r4,r0
416 add r7,r3,r0
4173: lwzu r0,-4(r8)
418 stwu r0,-4(r7)
419 bdnz 3b
420
wdenk8bde7f72003-06-27 21:31:46 +00004214: sync
wdenk0db5bca2003-03-31 17:27:09 +0000422 isync
423
424/*
425 * We are done. Do not return, instead branch to second part of board
426 * initialization, now running from RAM.
427 */
428
429 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
430 mtlr r0
431 blr
432
433in_ram:
434
435 /*
Joakim Tjernlund0f8aa152010-01-19 14:41:56 +0100436 * Relocation Function, r12 point to got2+0x8000
wdenk0db5bca2003-03-31 17:27:09 +0000437 *
wdenk8bde7f72003-06-27 21:31:46 +0000438 * Adjust got2 pointers, no need to check for 0, this code
439 * already puts a few entries in the table.
wdenk0db5bca2003-03-31 17:27:09 +0000440 */
441 li r0,__got2_entries@sectoff@l
442 la r3,GOT(_GOT2_TABLE_)
443 lwz r11,GOT(_GOT2_TABLE_)
444 mtctr r0
445 sub r11,r3,r11
446 addi r3,r3,-4
4471: lwzu r0,4(r3)
Joakim Tjernlundafc3ba02009-10-08 02:03:51 +0200448 cmpwi r0,0
449 beq- 2f
wdenk0db5bca2003-03-31 17:27:09 +0000450 add r0,r0,r11
451 stw r0,0(r3)
Joakim Tjernlundafc3ba02009-10-08 02:03:51 +02004522: bdnz 1b
wdenk0db5bca2003-03-31 17:27:09 +0000453
454 /*
wdenk8bde7f72003-06-27 21:31:46 +0000455 * Now adjust the fixups and the pointers to the fixups
wdenk0db5bca2003-03-31 17:27:09 +0000456 * in case we need to move ourselves again.
457 */
Joakim Tjernlundafc3ba02009-10-08 02:03:51 +0200458 li r0,__fixup_entries@sectoff@l
wdenk0db5bca2003-03-31 17:27:09 +0000459 lwz r3,GOT(_FIXUP_TABLE_)
460 cmpwi r0,0
461 mtctr r0
462 addi r3,r3,-4
463 beq 4f
4643: lwzu r4,4(r3)
465 lwzux r0,r4,r11
Joakim Tjernlundd1e0b102010-10-14 11:51:44 +0200466 cmpwi r0,0
wdenk0db5bca2003-03-31 17:27:09 +0000467 add r0,r0,r11
Joakim Tjernlund34bbf612010-11-04 19:02:00 +0100468 stw r4,0(r3)
Joakim Tjernlundd1e0b102010-10-14 11:51:44 +0200469 beq- 5f
wdenk0db5bca2003-03-31 17:27:09 +0000470 stw r0,0(r4)
Joakim Tjernlundd1e0b102010-10-14 11:51:44 +02004715: bdnz 3b
wdenk0db5bca2003-03-31 17:27:09 +00004724:
473clear_bss:
474 /*
475 * Now clear BSS segment
476 */
wdenk5d232d02003-05-22 22:52:13 +0000477 lwz r3,GOT(__bss_start)
Po-Yu Chuang44c6e652011-03-01 22:59:59 +0000478 lwz r4,GOT(__bss_end__)
wdenk0db5bca2003-03-31 17:27:09 +0000479 cmplw 0, r3, r4
480 beq 6f
481
482 li r0, 0
4835:
484 stw r0, 0(r3)
485 addi r3, r3, 4
486 cmplw 0, r3, r4
487 bne 5b
4886:
489
490 mr r3, r9 /* Global Data pointer */
491 mr r4, r10 /* Destination Address */
492 bl board_init_r
493
wdenk0db5bca2003-03-31 17:27:09 +0000494 /*
495 * Copy exception vector code to low memory
496 *
497 * r3: dest_addr
498 * r7: source address, r8: end address, r9: target address
499 */
500 .globl trap_init
501trap_init:
Joakim Tjernlund0f8aa152010-01-19 14:41:56 +0100502 mflr r4 /* save link register */
503 GET_GOT
wdenk0db5bca2003-03-31 17:27:09 +0000504 lwz r7, GOT(_start)
505 lwz r8, GOT(_end_of_vectors)
506
wdenk682011f2003-06-03 23:54:09 +0000507 li r9, 0x100 /* reset vector always at 0x100 */
wdenk0db5bca2003-03-31 17:27:09 +0000508
509 cmplw 0, r7, r8
510 bgelr /* return if r7>=r8 - just in case */
wdenk0db5bca2003-03-31 17:27:09 +00005111:
512 lwz r0, 0(r7)
513 stw r0, 0(r9)
514 addi r7, r7, 4
515 addi r9, r9, 4
516 cmplw 0, r7, r8
517 bne 1b
518
519 /*
520 * relocate `hdlr' and `int_return' entries
521 */
522 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
523 li r8, Alignment - _start + EXC_OFF_SYS_RESET
5242:
525 bl trap_reloc
526 addi r7, r7, 0x100 /* next exception vector */
527 cmplw 0, r7, r8
528 blt 2b
529
530 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
531 bl trap_reloc
532
533 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
534 bl trap_reloc
535
536 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
537 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
5383:
539 bl trap_reloc
540 addi r7, r7, 0x100 /* next exception vector */
541 cmplw 0, r7, r8
542 blt 3b
543
544 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
545 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
5464:
547 bl trap_reloc
548 addi r7, r7, 0x100 /* next exception vector */
549 cmplw 0, r7, r8
550 blt 4b
551
552 mtlr r4 /* restore link register */
553 blr
554
wdenkb6e4c402004-01-02 16:05:07 +0000555#if defined(CONFIG_PATI)
556/* Program the PLL */
557pll_prog_code_start:
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200558 lis r4, (CONFIG_SYS_IMMR + 0x002fc384)@h
559 ori r4, r4, (CONFIG_SYS_IMMR + 0x002fc384)@l
wdenkb6e4c402004-01-02 16:05:07 +0000560 lis r3, (0x55ccaa33)@h
561 ori r3, r3, (0x55ccaa33)@l
562 stw r3, 0(r4)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200563 lis r4, (CONFIG_SYS_IMMR + 0x002fc284)@h
564 ori r4, r4, (CONFIG_SYS_IMMR + 0x002fc284)@l
565 lis r3, CONFIG_SYS_PLPRCR@h
566 ori r3, r3, CONFIG_SYS_PLPRCR@l
wdenkb6e4c402004-01-02 16:05:07 +0000567 stw r3, 0(r4)
568 addis r3,0,0x0
569 ori r3,r3,0xA000
570 mtctr r3
571..spinlp:
572 bdnz ..spinlp /* spin loop */
573 blr
574pll_prog_code_end:
575 nop
576 blr
577#endif