blob: 2c98c2ad8a0cbfa0d9e473fec8daa73d2b950c67 [file] [log] [blame]
wdenk9c53f402003-10-15 23:53:47 +00001/*
Andy Flemingf08233c2007-08-14 01:34:21 -05002 * Copyright 2004, 2007 Freescale Semiconductor.
wdenk9c53f402003-10-15 23:53:47 +00003 * Copyright (C) 2003 Motorola,Inc.
wdenk9c53f402003-10-15 23:53:47 +00004 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/* U-Boot Startup Code for Motorola 85xx PowerPC based Embedded Boards
25 *
26 * The processor starts at 0xfffffffc and the code is first executed in the
27 * last 4K page(0xfffff000-0xffffffff) in flash/rom.
28 *
29 */
30
31#include <config.h>
32#include <mpc85xx.h>
33#include <version.h>
34
35#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
36
37#include <ppc_asm.tmpl>
38#include <ppc_defs.h>
39
40#include <asm/cache.h>
41#include <asm/mmu.h>
42
43#ifndef CONFIG_IDENT_STRING
44#define CONFIG_IDENT_STRING ""
45#endif
46
47#undef MSR_KERNEL
Andy Flemingf08233c2007-08-14 01:34:21 -050048#define MSR_KERNEL ( MSR_ME ) /* Machine Check */
wdenk9c53f402003-10-15 23:53:47 +000049
50/*
51 * Set up GOT: Global Offset Table
52 *
53 * Use r14 to access the GOT
54 */
55 START_GOT
56 GOT_ENTRY(_GOT2_TABLE_)
57 GOT_ENTRY(_FIXUP_TABLE_)
58
59 GOT_ENTRY(_start)
60 GOT_ENTRY(_start_of_vectors)
61 GOT_ENTRY(_end_of_vectors)
62 GOT_ENTRY(transfer_to_handler)
63
64 GOT_ENTRY(__init_end)
65 GOT_ENTRY(_end)
66 GOT_ENTRY(__bss_start)
67 END_GOT
68
69/*
70 * e500 Startup -- after reset only the last 4KB of the effective
71 * address space is mapped in the MMU L2 TLB1 Entry0. The .bootpg
72 * section is located at THIS LAST page and basically does three
73 * things: clear some registers, set up exception tables and
74 * add more TLB entries for 'larger spaces'(e.g. the boot rom) to
75 * continue the boot procedure.
76
77 * Once the boot rom is mapped by TLB entries we can proceed
78 * with normal startup.
79 *
80 */
81
Andy Flemingf08233c2007-08-14 01:34:21 -050082 .section .bootpg,"ax"
83 .globl _start_e500
wdenk9c53f402003-10-15 23:53:47 +000084
85_start_e500:
wdenka445ddf2004-06-09 00:34:46 +000086
Andy Flemingf08233c2007-08-14 01:34:21 -050087/* clear registers/arrays not reset by hardware */
wdenk9c53f402003-10-15 23:53:47 +000088
Andy Flemingf08233c2007-08-14 01:34:21 -050089 /* L1 */
90 li r0,2
91 mtspr L1CSR0,r0 /* invalidate d-cache */
92 mtspr L1CSR1,r0 /* invalidate i-cache */
wdenk9c53f402003-10-15 23:53:47 +000093
94 mfspr r1,DBSR
95 mtspr DBSR,r1 /* Clear all valid bits */
96
Andy Flemingf08233c2007-08-14 01:34:21 -050097 /*
98 * Enable L1 Caches early
99 *
100 */
wdenk9c53f402003-10-15 23:53:47 +0000101
Andy Flemingf08233c2007-08-14 01:34:21 -0500102 lis r2,L1CSR0_CPE@H /* enable parity */
103 ori r2,r2,L1CSR0_DCE
104 mtspr L1CSR0,r2 /* enable L1 Dcache */
105 isync
106 mtspr L1CSR1,r2 /* enable L1 Icache */
wdenk9c53f402003-10-15 23:53:47 +0000107 isync
Andy Flemingf08233c2007-08-14 01:34:21 -0500108 msync
wdenk9c53f402003-10-15 23:53:47 +0000109
110 /* Setup interrupt vectors */
wdenkf3da7cc2005-05-13 22:49:36 +0000111 lis r1,TEXT_BASE@h
Andy Flemingf08233c2007-08-14 01:34:21 -0500112 mtspr IVPR,r1
wdenk9c53f402003-10-15 23:53:47 +0000113
wdenkf3da7cc2005-05-13 22:49:36 +0000114 li r1,0x0100
wdenk9c53f402003-10-15 23:53:47 +0000115 mtspr IVOR0,r1 /* 0: Critical input */
wdenkf3da7cc2005-05-13 22:49:36 +0000116 li r1,0x0200
wdenk9c53f402003-10-15 23:53:47 +0000117 mtspr IVOR1,r1 /* 1: Machine check */
wdenkf3da7cc2005-05-13 22:49:36 +0000118 li r1,0x0300
wdenk9c53f402003-10-15 23:53:47 +0000119 mtspr IVOR2,r1 /* 2: Data storage */
wdenkf3da7cc2005-05-13 22:49:36 +0000120 li r1,0x0400
wdenk9c53f402003-10-15 23:53:47 +0000121 mtspr IVOR3,r1 /* 3: Instruction storage */
122 li r1,0x0500
123 mtspr IVOR4,r1 /* 4: External interrupt */
124 li r1,0x0600
125 mtspr IVOR5,r1 /* 5: Alignment */
126 li r1,0x0700
127 mtspr IVOR6,r1 /* 6: Program check */
128 li r1,0x0800
129 mtspr IVOR7,r1 /* 7: floating point unavailable */
wdenkf3da7cc2005-05-13 22:49:36 +0000130 li r1,0x0900
wdenk9c53f402003-10-15 23:53:47 +0000131 mtspr IVOR8,r1 /* 8: System call */
132 /* 9: Auxiliary processor unavailable(unsupported) */
wdenkf3da7cc2005-05-13 22:49:36 +0000133 li r1,0x0a00
wdenk9c53f402003-10-15 23:53:47 +0000134 mtspr IVOR10,r1 /* 10: Decrementer */
wdenkf3da7cc2005-05-13 22:49:36 +0000135 li r1,0x0b00
136 mtspr IVOR11,r1 /* 11: Interval timer */
137 li r1,0x0c00
Wolfgang Denkc94dea22005-08-04 01:24:19 +0200138 mtspr IVOR12,r1 /* 12: Watchdog timer */
139 li r1,0x0d00
wdenk9c53f402003-10-15 23:53:47 +0000140 mtspr IVOR13,r1 /* 13: Data TLB error */
wdenkf3da7cc2005-05-13 22:49:36 +0000141 li r1,0x0e00
wdenk9c53f402003-10-15 23:53:47 +0000142 mtspr IVOR14,r1 /* 14: Instruction TLB error */
wdenkf3da7cc2005-05-13 22:49:36 +0000143 li r1,0x0f00
wdenk9c53f402003-10-15 23:53:47 +0000144 mtspr IVOR15,r1 /* 15: Debug */
145
wdenk9c53f402003-10-15 23:53:47 +0000146
wdenk492b9e72004-08-01 23:02:45 +0000147 /*
wdenk492b9e72004-08-01 23:02:45 +0000148 * After reset, CCSRBAR is located at CFG_CCSRBAR_DEFAULT, i.e.
wdenk9c53f402003-10-15 23:53:47 +0000149 * 0xff700000-0xff800000. We need add a TLB1 entry for this 1MB
150 * region before we can access any CCSR registers such as L2
151 * registers, Local Access Registers,etc. We will also re-allocate
152 * CFG_CCSRBAR_DEFAULT to CFG_CCSRBAR immediately after TLB1 setup.
153 *
154 * Please refer to board-specif directory for TLB1 entry configuration.
155 * (e.g. board/<yourboard>/init.S)
156 *
157 */
wdenkf3da7cc2005-05-13 22:49:36 +0000158 bl tlb1_entry
wdenk9c53f402003-10-15 23:53:47 +0000159 mr r5,r0
wdenk9c53f402003-10-15 23:53:47 +0000160 lwzu r4,0(r5) /* how many TLB1 entries we actually use */
Zang Roy-r61911077fb1a2006-12-20 11:01:00 +0800161 mtctr r4
wdenk9c53f402003-10-15 23:53:47 +0000162
Andy Flemingf08233c2007-08-14 01:34:21 -05001630: lwzu r6,4(r5)
164 lwzu r7,4(r5)
165 lwzu r8,4(r5)
166 lwzu r9,4(r5)
167 mtspr MAS0,r6
168 mtspr MAS1,r7
169 mtspr MAS2,r8
170 mtspr MAS3,r9
wdenk9c53f402003-10-15 23:53:47 +0000171 isync
172 msync
173 tlbwe
174 isync
wdenk9c53f402003-10-15 23:53:47 +0000175 bdnz 0b
176
1771:
178#if (CFG_CCSRBAR_DEFAULT != CFG_CCSRBAR)
179 /* Special sequence needed to update CCSRBAR itself */
Andy Flemingf08233c2007-08-14 01:34:21 -0500180 lis r4,CFG_CCSRBAR_DEFAULT@h
181 ori r4,r4,CFG_CCSRBAR_DEFAULT@l
wdenk9c53f402003-10-15 23:53:47 +0000182
Andy Flemingf08233c2007-08-14 01:34:21 -0500183 lis r5,CFG_CCSRBAR@h
184 ori r5,r5,CFG_CCSRBAR@l
wdenk9c53f402003-10-15 23:53:47 +0000185 srwi r6,r5,12
Andy Flemingf08233c2007-08-14 01:34:21 -0500186 stw r6,0(r4)
wdenk9c53f402003-10-15 23:53:47 +0000187 isync
188
Andy Flemingf08233c2007-08-14 01:34:21 -0500189 lis r5,0xffff
wdenk9c53f402003-10-15 23:53:47 +0000190 ori r5,r5,0xf000
Andy Flemingf08233c2007-08-14 01:34:21 -0500191 lwz r5,0(r5)
wdenk9c53f402003-10-15 23:53:47 +0000192 isync
193
Andy Flemingf08233c2007-08-14 01:34:21 -0500194 lis r3,CFG_CCSRBAR@h
195 lwz r5,CFG_CCSRBAR@l(r3)
wdenk9c53f402003-10-15 23:53:47 +0000196 isync
197#endif
198
wdenk9c53f402003-10-15 23:53:47 +0000199
200 /* set up local access windows, defined at board/<boardname>/init.S */
201 lis r7,CFG_CCSRBAR@h
202 ori r7,r7,CFG_CCSRBAR@l
203
wdenkf3da7cc2005-05-13 22:49:36 +0000204 bl law_entry
wdenk9c53f402003-10-15 23:53:47 +0000205 mr r6,r0
wdenk9c53f402003-10-15 23:53:47 +0000206 lwzu r5,0(r6) /* how many windows we actually use */
Zang Roy-r61911077fb1a2006-12-20 11:01:00 +0800207 mtctr r5
wdenk9c53f402003-10-15 23:53:47 +0000208
Andy Flemingf08233c2007-08-14 01:34:21 -0500209 li r2,0x0c28 /* the first pair is reserved for */
210 li r1,0x0c30 /* boot-over-rio-or-pci */
wdenk9c53f402003-10-15 23:53:47 +0000211
Zang Roy-r61911077fb1a2006-12-20 11:01:00 +08002120: lwzu r4,4(r6)
wdenk9c53f402003-10-15 23:53:47 +0000213 lwzu r3,4(r6)
214 stwx r4,r7,r2
215 stwx r3,r7,r1
wdenk9c53f402003-10-15 23:53:47 +0000216 addi r2,r2,0x0020
217 addi r1,r1,0x0020
218 bdnz 0b
219
wdenk9c53f402003-10-15 23:53:47 +0000220 /* Clear and set up some registers. */
221 li r0,0x0000
222 lis r1,0xffff
223 mtspr DEC,r0 /* prevent dec exceptions */
224 mttbl r0 /* prevent fit & wdt exceptions */
225 mttbu r0
226 mtspr TSR,r1 /* clear all timer exception status */
227 mtspr TCR,r0 /* disable all */
228 mtspr ESR,r0 /* clear exception syndrome register */
229 mtspr MCSR,r0 /* machine check syndrome register */
230 mtxer r0 /* clear integer exception register */
231 lis r1,0x0002 /* set CE bit (Critical Exceptions) */
232 ori r1,r1,0x1200 /* set ME/DE bit */
233 mtmsr r1 /* change MSR */
234 isync
235
236 /* Enable Time Base and Select Time Base Clock */
wdenk13eb2212004-07-09 23:27:13 +0000237 lis r0,HID0_EMCP@h /* Enable machine check */
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500238#if defined(CONFIG_ENABLE_36BIT_PHYS)
Andy Flemingf08233c2007-08-14 01:34:21 -0500239 ori r0,r0,(HID0_TBEN|HID0_ENMAS7)@l /* Enable Timebase & MAS7 */
240#else
241 ori r0,r0,HID0_TBEN@l /* enable Timebase */
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500242#endif
wdenk9c53f402003-10-15 23:53:47 +0000243 mtspr HID0,r0
wdenk9c53f402003-10-15 23:53:47 +0000244
Andy Flemingf08233c2007-08-14 01:34:21 -0500245 li r0,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */
wdenk9c53f402003-10-15 23:53:47 +0000246 mtspr HID1,r0
wdenk9c53f402003-10-15 23:53:47 +0000247
248 /* Enable Branch Prediction */
249#if defined(CONFIG_BTB)
250 li r0,0x201 /* BBFI = 1, BPEN = 1 */
251 mtspr BUCSR,r0
wdenk9c53f402003-10-15 23:53:47 +0000252#endif
253
254#if defined(CFG_INIT_DBCR)
255 lis r1,0xffff
256 ori r1,r1,0xffff
wdenk13eb2212004-07-09 23:27:13 +0000257 mtspr DBSR,r1 /* Clear all status bits */
wdenk9c53f402003-10-15 23:53:47 +0000258 lis r0,CFG_INIT_DBCR@h /* DBCR0[IDM] must be set */
259 ori r0,r0,CFG_INIT_DBCR@l
wdenk13eb2212004-07-09 23:27:13 +0000260 mtspr DBCR0,r0
wdenk9c53f402003-10-15 23:53:47 +0000261#endif
262
Kumar Gala76e276b2007-08-07 18:07:27 -0500263/* L1 DCache is used for initial RAM */
264
265 /* Allocate Initial RAM in data cache.
266 */
267 lis r3,CFG_INIT_RAM_ADDR@h
268 ori r3,r3,CFG_INIT_RAM_ADDR@l
269 li r2,512 /* 512*32=16K */
270 mtctr r2
271 li r0,0
2721:
273 dcbz r0,r3
274 dcbtls 0,r0,r3
275 addi r3,r3,32
276 bdnz 1b
277
Andy Flemingf08233c2007-08-14 01:34:21 -0500278 /* Jump out the last 4K page and continue to 'normal' start */
Kumar Gala76e276b2007-08-07 18:07:27 -0500279#ifdef CFG_RAMBOOT
Andy Flemingf08233c2007-08-14 01:34:21 -0500280 bl 3f
281 b _start_cont
Kumar Gala76e276b2007-08-07 18:07:27 -0500282#else
283 /* Calculate absolute address in FLASH and jump there */
284 /*--------------------------------------------------------------*/
285 lis r3,CFG_MONITOR_BASE@h
286 ori r3,r3,CFG_MONITOR_BASE@l
287 addi r3,r3,_start_cont - _start + _START_OFFSET
288 mtlr r3
289#endif
Andy Flemingf08233c2007-08-14 01:34:21 -0500290
2913: li r0,0
292 mtspr SRR1,r0 /* Keep things disabled for now */
293 mflr r1
294 mtspr SRR0,r1
295 rfi
wdenk9c53f402003-10-15 23:53:47 +0000296 isync
297
Andy Flemingf08233c2007-08-14 01:34:21 -0500298 .text
299 .globl _start
300_start:
301 .long 0x27051956 /* U-BOOT Magic Number */
302 .globl version_string
303version_string:
304 .ascii U_BOOT_VERSION
305 .ascii " (", __DATE__, " - ", __TIME__, ")"
306 .ascii CONFIG_IDENT_STRING, "\0"
307
308 .align 4
309 .globl _start_cont
310_start_cont:
wdenk9c53f402003-10-15 23:53:47 +0000311 /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
312 lis r1,CFG_INIT_RAM_ADDR@h
313 ori r1,r1,CFG_INIT_SP_OFFSET@l
314
315 li r0,0
316 stwu r0,-4(r1)
317 stwu r0,-4(r1) /* Terminate call chain */
318
319 stwu r1,-8(r1) /* Save back chain and move SP */
320 lis r0,RESET_VECTOR@h /* Address of reset vector */
Andy Flemingf08233c2007-08-14 01:34:21 -0500321 ori r0,r0,RESET_VECTOR@l
wdenk9c53f402003-10-15 23:53:47 +0000322 stwu r1,-8(r1) /* Save back chain and move SP */
323 stw r0,+12(r1) /* Save return addr (underflow vect) */
324
325 GET_GOT
326 bl cpu_init_f
wdenk9c53f402003-10-15 23:53:47 +0000327 bl board_init_f
wdenk13eb2212004-07-09 23:27:13 +0000328 isync
wdenk9c53f402003-10-15 23:53:47 +0000329
Andy Flemingf08233c2007-08-14 01:34:21 -0500330 . = EXC_OFF_SYS_RESET
wdenk9c53f402003-10-15 23:53:47 +0000331 .globl _start_of_vectors
332_start_of_vectors:
Andy Flemingf08233c2007-08-14 01:34:21 -0500333
wdenk9c53f402003-10-15 23:53:47 +0000334/* Critical input. */
Andy Flemingf08233c2007-08-14 01:34:21 -0500335 CRIT_EXCEPTION(0x0100, CriticalInput, CritcalInputException)
336
337/* Machine check */
338 MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException)
wdenk9c53f402003-10-15 23:53:47 +0000339
340/* Data Storage exception. */
341 STD_EXCEPTION(0x0300, DataStorage, UnknownException)
342
343/* Instruction Storage exception. */
344 STD_EXCEPTION(0x0400, InstStorage, UnknownException)
345
346/* External Interrupt exception. */
Andy Flemingf08233c2007-08-14 01:34:21 -0500347 STD_EXCEPTION(0x0500, ExtInterrupt, ExtIntException)
wdenk9c53f402003-10-15 23:53:47 +0000348
349/* Alignment exception. */
350 . = 0x0600
351Alignment:
Rafal Jaworowski06244e42007-06-22 14:58:04 +0200352 EXCEPTION_PROLOG(SRR0, SRR1)
wdenk9c53f402003-10-15 23:53:47 +0000353 mfspr r4,DAR
354 stw r4,_DAR(r21)
355 mfspr r5,DSISR
356 stw r5,_DSISR(r21)
357 addi r3,r1,STACK_FRAME_OVERHEAD
358 li r20,MSR_KERNEL
359 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
360 lwz r6,GOT(transfer_to_handler)
361 mtlr r6
362 blrl
363.L_Alignment:
Andy Flemingf08233c2007-08-14 01:34:21 -0500364 .long AlignmentException - _start + _START_OFFSET
365 .long int_return - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000366
367/* Program check exception */
368 . = 0x0700
369ProgramCheck:
Rafal Jaworowski06244e42007-06-22 14:58:04 +0200370 EXCEPTION_PROLOG(SRR0, SRR1)
wdenk9c53f402003-10-15 23:53:47 +0000371 addi r3,r1,STACK_FRAME_OVERHEAD
372 li r20,MSR_KERNEL
373 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
374 lwz r6,GOT(transfer_to_handler)
375 mtlr r6
376 blrl
377.L_ProgramCheck:
Andy Flemingf08233c2007-08-14 01:34:21 -0500378 .long ProgramCheckException - _start + _START_OFFSET
379 .long int_return - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000380
381 /* No FPU on MPC85xx. This exception is not supposed to happen.
382 */
383 STD_EXCEPTION(0x0800, FPUnavailable, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000384
wdenkf3da7cc2005-05-13 22:49:36 +0000385 . = 0x0900
wdenk9c53f402003-10-15 23:53:47 +0000386/*
387 * r0 - SYSCALL number
388 * r3-... arguments
389 */
390SystemCall:
Andy Flemingf08233c2007-08-14 01:34:21 -0500391 addis r11,r0,0 /* get functions table addr */
392 ori r11,r11,0 /* Note: this code is patched in trap_init */
393 addis r12,r0,0 /* get number of functions */
wdenkf3da7cc2005-05-13 22:49:36 +0000394 ori r12,r12,0
wdenk9c53f402003-10-15 23:53:47 +0000395
Andy Flemingf08233c2007-08-14 01:34:21 -0500396 cmplw 0,r0,r12
wdenkf3da7cc2005-05-13 22:49:36 +0000397 bge 1f
wdenk9c53f402003-10-15 23:53:47 +0000398
Andy Flemingf08233c2007-08-14 01:34:21 -0500399 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */
wdenkf3da7cc2005-05-13 22:49:36 +0000400 add r11,r11,r0
401 lwz r11,0(r11)
wdenk9c53f402003-10-15 23:53:47 +0000402
Andy Flemingf08233c2007-08-14 01:34:21 -0500403 li r20,0xd00-4 /* Get stack pointer */
wdenkf3da7cc2005-05-13 22:49:36 +0000404 lwz r12,0(r20)
Andy Flemingf08233c2007-08-14 01:34:21 -0500405 subi r12,r12,12 /* Adjust stack pointer */
wdenkf3da7cc2005-05-13 22:49:36 +0000406 li r0,0xc00+_end_back-SystemCall
Andy Flemingf08233c2007-08-14 01:34:21 -0500407 cmplw 0,r0,r12 /* Check stack overflow */
wdenkf3da7cc2005-05-13 22:49:36 +0000408 bgt 1f
409 stw r12,0(r20)
wdenk9c53f402003-10-15 23:53:47 +0000410
wdenkf3da7cc2005-05-13 22:49:36 +0000411 mflr r0
412 stw r0,0(r12)
413 mfspr r0,SRR0
414 stw r0,4(r12)
415 mfspr r0,SRR1
416 stw r0,8(r12)
wdenk9c53f402003-10-15 23:53:47 +0000417
wdenkf3da7cc2005-05-13 22:49:36 +0000418 li r12,0xc00+_back-SystemCall
419 mtlr r12
420 mtspr SRR0,r11
wdenk9c53f402003-10-15 23:53:47 +0000421
wdenkf3da7cc2005-05-13 22:49:36 +00004221: SYNC
wdenk9c53f402003-10-15 23:53:47 +0000423 rfi
424_back:
425
wdenkf3da7cc2005-05-13 22:49:36 +0000426 mfmsr r11 /* Disable interrupts */
427 li r12,0
428 ori r12,r12,MSR_EE
429 andc r11,r11,r12
430 SYNC /* Some chip revs need this... */
431 mtmsr r11
wdenk9c53f402003-10-15 23:53:47 +0000432 SYNC
433
wdenkf3da7cc2005-05-13 22:49:36 +0000434 li r12,0xd00-4 /* restore regs */
435 lwz r12,0(r12)
wdenk9c53f402003-10-15 23:53:47 +0000436
wdenkf3da7cc2005-05-13 22:49:36 +0000437 lwz r11,0(r12)
438 mtlr r11
439 lwz r11,4(r12)
440 mtspr SRR0,r11
441 lwz r11,8(r12)
442 mtspr SRR1,r11
wdenk9c53f402003-10-15 23:53:47 +0000443
wdenkf3da7cc2005-05-13 22:49:36 +0000444 addi r12,r12,12 /* Adjust stack pointer */
445 li r20,0xd00-4
446 stw r12,0(r20)
wdenk9c53f402003-10-15 23:53:47 +0000447
448 SYNC
449 rfi
450_end_back:
451
wdenkf3da7cc2005-05-13 22:49:36 +0000452 STD_EXCEPTION(0x0a00, Decrementer, timer_interrupt)
453 STD_EXCEPTION(0x0b00, IntervalTimer, UnknownException)
454 STD_EXCEPTION(0x0c00, WatchdogTimer, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000455
wdenkf3da7cc2005-05-13 22:49:36 +0000456 STD_EXCEPTION(0x0d00, DataTLBError, UnknownException)
457 STD_EXCEPTION(0x0e00, InstructionTLBError, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000458
wdenkf3da7cc2005-05-13 22:49:36 +0000459 CRIT_EXCEPTION(0x0f00, DebugBreakpoint, DebugException )
wdenk9c53f402003-10-15 23:53:47 +0000460
wdenkf3da7cc2005-05-13 22:49:36 +0000461 .globl _end_of_vectors
wdenk9c53f402003-10-15 23:53:47 +0000462_end_of_vectors:
463
464
Andy Flemingf08233c2007-08-14 01:34:21 -0500465 . = . + (0x100 - ( . & 0xff )) /* align for debug */
wdenk9c53f402003-10-15 23:53:47 +0000466
467/*
468 * This code finishes saving the registers to the exception frame
469 * and jumps to the appropriate handler for the exception.
470 * Register r21 is pointer into trap frame, r1 has new stack pointer.
471 */
472 .globl transfer_to_handler
473transfer_to_handler:
474 stw r22,_NIP(r21)
475 lis r22,MSR_POW@h
476 andc r23,r23,r22
477 stw r23,_MSR(r21)
478 SAVE_GPR(7, r21)
479 SAVE_4GPRS(8, r21)
480 SAVE_8GPRS(12, r21)
481 SAVE_8GPRS(24, r21)
482
483 mflr r23
484 andi. r24,r23,0x3f00 /* get vector offset */
485 stw r24,TRAP(r21)
486 li r22,0
487 stw r22,RESULT(r21)
488 mtspr SPRG2,r22 /* r1 is now kernel sp */
489
490 lwz r24,0(r23) /* virtual address of handler */
491 lwz r23,4(r23) /* where to go when done */
492 mtspr SRR0,r24
493 mtspr SRR1,r20
494 mtlr r23
495 SYNC
496 rfi /* jump to handler, enable MMU */
497
498int_return:
499 mfmsr r28 /* Disable interrupts */
500 li r4,0
501 ori r4,r4,MSR_EE
502 andc r28,r28,r4
503 SYNC /* Some chip revs need this... */
504 mtmsr r28
505 SYNC
506 lwz r2,_CTR(r1)
507 lwz r0,_LINK(r1)
508 mtctr r2
509 mtlr r0
510 lwz r2,_XER(r1)
511 lwz r0,_CCR(r1)
512 mtspr XER,r2
513 mtcrf 0xFF,r0
514 REST_10GPRS(3, r1)
515 REST_10GPRS(13, r1)
516 REST_8GPRS(23, r1)
517 REST_GPR(31, r1)
518 lwz r2,_NIP(r1) /* Restore environment */
519 lwz r0,_MSR(r1)
520 mtspr SRR0,r2
521 mtspr SRR1,r0
522 lwz r0,GPR0(r1)
523 lwz r2,GPR2(r1)
524 lwz r1,GPR1(r1)
525 SYNC
526 rfi
527
528crit_return:
529 mfmsr r28 /* Disable interrupts */
530 li r4,0
531 ori r4,r4,MSR_EE
532 andc r28,r28,r4
533 SYNC /* Some chip revs need this... */
534 mtmsr r28
535 SYNC
536 lwz r2,_CTR(r1)
537 lwz r0,_LINK(r1)
538 mtctr r2
539 mtlr r0
540 lwz r2,_XER(r1)
541 lwz r0,_CCR(r1)
542 mtspr XER,r2
543 mtcrf 0xFF,r0
544 REST_10GPRS(3, r1)
545 REST_10GPRS(13, r1)
546 REST_8GPRS(23, r1)
547 REST_GPR(31, r1)
548 lwz r2,_NIP(r1) /* Restore environment */
549 lwz r0,_MSR(r1)
Andy Flemingf08233c2007-08-14 01:34:21 -0500550 mtspr SPRN_CSRR0,r2
551 mtspr SPRN_CSRR1,r0
wdenk9c53f402003-10-15 23:53:47 +0000552 lwz r0,GPR0(r1)
553 lwz r2,GPR2(r1)
554 lwz r1,GPR1(r1)
555 SYNC
556 rfci
557
Andy Flemingf08233c2007-08-14 01:34:21 -0500558mck_return:
559 mfmsr r28 /* Disable interrupts */
560 li r4,0
561 ori r4,r4,MSR_EE
562 andc r28,r28,r4
563 SYNC /* Some chip revs need this... */
564 mtmsr r28
565 SYNC
566 lwz r2,_CTR(r1)
567 lwz r0,_LINK(r1)
568 mtctr r2
569 mtlr r0
570 lwz r2,_XER(r1)
571 lwz r0,_CCR(r1)
572 mtspr XER,r2
573 mtcrf 0xFF,r0
574 REST_10GPRS(3, r1)
575 REST_10GPRS(13, r1)
576 REST_8GPRS(23, r1)
577 REST_GPR(31, r1)
578 lwz r2,_NIP(r1) /* Restore environment */
579 lwz r0,_MSR(r1)
580 mtspr SPRN_MCSRR0,r2
581 mtspr SPRN_MCSRR1,r0
582 lwz r0,GPR0(r1)
583 lwz r2,GPR2(r1)
584 lwz r1,GPR1(r1)
585 SYNC
586 rfmci
587
wdenk9c53f402003-10-15 23:53:47 +0000588/* Cache functions.
589*/
590invalidate_icache:
591 mfspr r0,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500592 ori r0,r0,L1CSR1_ICFI
593 msync
594 isync
wdenk9c53f402003-10-15 23:53:47 +0000595 mtspr L1CSR1,r0
596 isync
Andy Flemingf08233c2007-08-14 01:34:21 -0500597 blr /* entire I cache */
wdenk9c53f402003-10-15 23:53:47 +0000598
599invalidate_dcache:
600 mfspr r0,L1CSR0
Andy Flemingf08233c2007-08-14 01:34:21 -0500601 ori r0,r0,L1CSR0_DCFI
wdenk9c53f402003-10-15 23:53:47 +0000602 msync
603 isync
604 mtspr L1CSR0,r0
605 isync
606 blr
607
608 .globl icache_enable
609icache_enable:
610 mflr r8
611 bl invalidate_icache
612 mtlr r8
613 isync
614 mfspr r4,L1CSR1
615 ori r4,r4,0x0001
616 oris r4,r4,0x0001
617 mtspr L1CSR1,r4
618 isync
619 blr
620
621 .globl icache_disable
622icache_disable:
623 mfspr r0,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500624 lis r3,0
625 ori r3,r3,L1CSR1_ICE
626 andc r0,r0,r3
wdenk9c53f402003-10-15 23:53:47 +0000627 mtspr L1CSR1,r0
628 isync
629 blr
630
631 .globl icache_status
632icache_status:
633 mfspr r3,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500634 andi. r3,r3,L1CSR1_ICE
wdenk9c53f402003-10-15 23:53:47 +0000635 blr
636
637 .globl dcache_enable
638dcache_enable:
639 mflr r8
640 bl invalidate_dcache
641 mtlr r8
642 isync
643 mfspr r0,L1CSR0
644 ori r0,r0,0x0001
645 oris r0,r0,0x0001
646 msync
647 isync
648 mtspr L1CSR0,r0
649 isync
650 blr
651
652 .globl dcache_disable
653dcache_disable:
Andy Flemingf08233c2007-08-14 01:34:21 -0500654 mfspr r3,L1CSR0
655 lis r4,0
656 ori r4,r4,L1CSR0_DCE
657 andc r3,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000658 mtspr L1CSR0,r0
659 isync
660 blr
661
662 .globl dcache_status
663dcache_status:
664 mfspr r3,L1CSR0
Andy Flemingf08233c2007-08-14 01:34:21 -0500665 andi. r3,r3,L1CSR0_DCE
wdenk9c53f402003-10-15 23:53:47 +0000666 blr
667
668 .globl get_pir
669get_pir:
Andy Flemingf08233c2007-08-14 01:34:21 -0500670 mfspr r3,PIR
wdenk9c53f402003-10-15 23:53:47 +0000671 blr
672
673 .globl get_pvr
674get_pvr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500675 mfspr r3,PVR
wdenk9c53f402003-10-15 23:53:47 +0000676 blr
677
wdenka445ddf2004-06-09 00:34:46 +0000678 .globl get_svr
679get_svr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500680 mfspr r3,SVR
wdenka445ddf2004-06-09 00:34:46 +0000681 blr
682
wdenk9c53f402003-10-15 23:53:47 +0000683 .globl wr_tcr
684wr_tcr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500685 mtspr TCR,r3
wdenk9c53f402003-10-15 23:53:47 +0000686 blr
687
688/*------------------------------------------------------------------------------- */
689/* Function: in8 */
690/* Description: Input 8 bits */
691/*------------------------------------------------------------------------------- */
692 .globl in8
693in8:
694 lbz r3,0x0000(r3)
695 blr
696
697/*------------------------------------------------------------------------------- */
698/* Function: out8 */
699/* Description: Output 8 bits */
700/*------------------------------------------------------------------------------- */
701 .globl out8
702out8:
703 stb r4,0x0000(r3)
704 blr
705
706/*------------------------------------------------------------------------------- */
707/* Function: out16 */
708/* Description: Output 16 bits */
709/*------------------------------------------------------------------------------- */
710 .globl out16
711out16:
712 sth r4,0x0000(r3)
713 blr
714
715/*------------------------------------------------------------------------------- */
716/* Function: out16r */
717/* Description: Byte reverse and output 16 bits */
718/*------------------------------------------------------------------------------- */
719 .globl out16r
720out16r:
721 sthbrx r4,r0,r3
722 blr
723
724/*------------------------------------------------------------------------------- */
725/* Function: out32 */
726/* Description: Output 32 bits */
727/*------------------------------------------------------------------------------- */
728 .globl out32
729out32:
730 stw r4,0x0000(r3)
731 blr
732
733/*------------------------------------------------------------------------------- */
734/* Function: out32r */
735/* Description: Byte reverse and output 32 bits */
736/*------------------------------------------------------------------------------- */
737 .globl out32r
738out32r:
739 stwbrx r4,r0,r3
740 blr
741
742/*------------------------------------------------------------------------------- */
743/* Function: in16 */
744/* Description: Input 16 bits */
745/*------------------------------------------------------------------------------- */
746 .globl in16
747in16:
748 lhz r3,0x0000(r3)
749 blr
750
751/*------------------------------------------------------------------------------- */
752/* Function: in16r */
753/* Description: Input 16 bits and byte reverse */
754/*------------------------------------------------------------------------------- */
755 .globl in16r
756in16r:
757 lhbrx r3,r0,r3
758 blr
759
760/*------------------------------------------------------------------------------- */
761/* Function: in32 */
762/* Description: Input 32 bits */
763/*------------------------------------------------------------------------------- */
764 .globl in32
765in32:
766 lwz 3,0x0000(3)
767 blr
768
769/*------------------------------------------------------------------------------- */
770/* Function: in32r */
771/* Description: Input 32 bits and byte reverse */
772/*------------------------------------------------------------------------------- */
773 .globl in32r
774in32r:
775 lwbrx r3,r0,r3
776 blr
777
778/*------------------------------------------------------------------------------- */
779/* Function: ppcDcbf */
780/* Description: Data Cache block flush */
781/* Input: r3 = effective address */
782/* Output: none. */
783/*------------------------------------------------------------------------------- */
784 .globl ppcDcbf
785ppcDcbf:
786 dcbf r0,r3
787 blr
788
789/*------------------------------------------------------------------------------- */
790/* Function: ppcDcbi */
791/* Description: Data Cache block Invalidate */
792/* Input: r3 = effective address */
793/* Output: none. */
794/*------------------------------------------------------------------------------- */
795 .globl ppcDcbi
796ppcDcbi:
797 dcbi r0,r3
798 blr
799
wdenk13eb2212004-07-09 23:27:13 +0000800/*--------------------------------------------------------------------------
801 * Function: ppcDcbz
802 * Description: Data Cache block zero.
803 * Input: r3 = effective address
804 * Output: none.
805 *-------------------------------------------------------------------------- */
806
807 .globl ppcDcbz
808ppcDcbz:
809 dcbz r0,r3
810 blr
811
wdenk9c53f402003-10-15 23:53:47 +0000812/*------------------------------------------------------------------------------- */
813/* Function: ppcSync */
814/* Description: Processor Synchronize */
815/* Input: none. */
816/* Output: none. */
817/*------------------------------------------------------------------------------- */
818 .globl ppcSync
819ppcSync:
820 sync
821 blr
822
823/*------------------------------------------------------------------------------*/
824
825/*
826 * void relocate_code (addr_sp, gd, addr_moni)
827 *
828 * This "function" does not return, instead it continues in RAM
829 * after relocating the monitor code.
830 *
831 * r3 = dest
832 * r4 = src
833 * r5 = length in bytes
834 * r6 = cachelinesize
835 */
836 .globl relocate_code
837relocate_code:
Andy Flemingf08233c2007-08-14 01:34:21 -0500838 mr r1,r3 /* Set new stack pointer */
839 mr r9,r4 /* Save copy of Init Data pointer */
840 mr r10,r5 /* Save copy of Destination Address */
wdenk9c53f402003-10-15 23:53:47 +0000841
Andy Flemingf08233c2007-08-14 01:34:21 -0500842 mr r3,r5 /* Destination Address */
843 lis r4,CFG_MONITOR_BASE@h /* Source Address */
844 ori r4,r4,CFG_MONITOR_BASE@l
wdenk9c53f402003-10-15 23:53:47 +0000845 lwz r5,GOT(__init_end)
846 sub r5,r5,r4
Andy Flemingf08233c2007-08-14 01:34:21 -0500847 li r6,CFG_CACHELINE_SIZE /* Cache Line Size */
wdenk9c53f402003-10-15 23:53:47 +0000848
849 /*
850 * Fix GOT pointer:
851 *
852 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
853 *
854 * Offset:
855 */
Andy Flemingf08233c2007-08-14 01:34:21 -0500856 sub r15,r10,r4
wdenk9c53f402003-10-15 23:53:47 +0000857
858 /* First our own GOT */
Andy Flemingf08233c2007-08-14 01:34:21 -0500859 add r14,r14,r15
wdenk9c53f402003-10-15 23:53:47 +0000860 /* the the one used by the C code */
Andy Flemingf08233c2007-08-14 01:34:21 -0500861 add r30,r30,r15
wdenk9c53f402003-10-15 23:53:47 +0000862
863 /*
864 * Now relocate code
865 */
866
867 cmplw cr1,r3,r4
868 addi r0,r5,3
869 srwi. r0,r0,2
870 beq cr1,4f /* In place copy is not necessary */
871 beq 7f /* Protect against 0 count */
872 mtctr r0
873 bge cr1,2f
874
875 la r8,-4(r4)
876 la r7,-4(r3)
8771: lwzu r0,4(r8)
878 stwu r0,4(r7)
879 bdnz 1b
880 b 4f
881
8822: slwi r0,r0,2
883 add r8,r4,r0
884 add r7,r3,r0
8853: lwzu r0,-4(r8)
886 stwu r0,-4(r7)
887 bdnz 3b
888
889/*
890 * Now flush the cache: note that we must start from a cache aligned
891 * address. Otherwise we might miss one cache line.
892 */
8934: cmpwi r6,0
894 add r5,r3,r5
895 beq 7f /* Always flush prefetch queue in any case */
896 subi r0,r6,1
897 andc r3,r3,r0
898 mr r4,r3
8995: dcbst 0,r4
900 add r4,r4,r6
901 cmplw r4,r5
902 blt 5b
903 sync /* Wait for all dcbst to complete on bus */
904 mr r4,r3
9056: icbi 0,r4
906 add r4,r4,r6
907 cmplw r4,r5
908 blt 6b
9097: sync /* Wait for all icbi to complete on bus */
910 isync
911
Wolfgang Denk29dcbd42005-10-05 00:00:54 +0200912 /*
913 * Re-point the IVPR at RAM
914 */
915 mtspr IVPR,r10
Wolfgang Denk9da240c2005-10-05 00:19:34 +0200916
wdenk9c53f402003-10-15 23:53:47 +0000917/*
918 * We are done. Do not return, instead branch to second part of board
919 * initialization, now running from RAM.
920 */
921
Andy Flemingf08233c2007-08-14 01:34:21 -0500922 addi r0,r10,in_ram - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000923 mtlr r0
924 blr /* NEVER RETURNS! */
Andy Flemingf08233c2007-08-14 01:34:21 -0500925 .globl in_ram
wdenk9c53f402003-10-15 23:53:47 +0000926in_ram:
927
928 /*
929 * Relocation Function, r14 point to got2+0x8000
930 *
931 * Adjust got2 pointers, no need to check for 0, this code
932 * already puts a few entries in the table.
933 */
934 li r0,__got2_entries@sectoff@l
935 la r3,GOT(_GOT2_TABLE_)
936 lwz r11,GOT(_GOT2_TABLE_)
937 mtctr r0
938 sub r11,r3,r11
939 addi r3,r3,-4
9401: lwzu r0,4(r3)
941 add r0,r0,r11
942 stw r0,0(r3)
943 bdnz 1b
944
945 /*
946 * Now adjust the fixups and the pointers to the fixups
947 * in case we need to move ourselves again.
948 */
9492: li r0,__fixup_entries@sectoff@l
950 lwz r3,GOT(_FIXUP_TABLE_)
951 cmpwi r0,0
952 mtctr r0
953 addi r3,r3,-4
954 beq 4f
9553: lwzu r4,4(r3)
956 lwzux r0,r4,r11
957 add r0,r0,r11
958 stw r10,0(r3)
959 stw r0,0(r4)
960 bdnz 3b
9614:
962clear_bss:
963 /*
964 * Now clear BSS segment
965 */
966 lwz r3,GOT(__bss_start)
967 lwz r4,GOT(_end)
968
Andy Flemingf08233c2007-08-14 01:34:21 -0500969 cmplw 0,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000970 beq 6f
971
Andy Flemingf08233c2007-08-14 01:34:21 -0500972 li r0,0
wdenk9c53f402003-10-15 23:53:47 +00009735:
Andy Flemingf08233c2007-08-14 01:34:21 -0500974 stw r0,0(r3)
975 addi r3,r3,4
976 cmplw 0,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000977 bne 5b
9786:
979
Andy Flemingf08233c2007-08-14 01:34:21 -0500980 mr r3,r9 /* Init Data pointer */
981 mr r4,r10 /* Destination Address */
wdenk9c53f402003-10-15 23:53:47 +0000982 bl board_init_r
983
984 /*
985 * Copy exception vector code to low memory
986 *
987 * r3: dest_addr
988 * r7: source address, r8: end address, r9: target address
989 */
wdenkf3da7cc2005-05-13 22:49:36 +0000990 .globl trap_init
wdenk9c53f402003-10-15 23:53:47 +0000991trap_init:
Andy Flemingf08233c2007-08-14 01:34:21 -0500992 lwz r7,GOT(_start_of_vectors)
993 lwz r8,GOT(_end_of_vectors)
wdenk9c53f402003-10-15 23:53:47 +0000994
Andy Flemingf08233c2007-08-14 01:34:21 -0500995 li r9,0x100 /* reset vector always at 0x100 */
wdenk9c53f402003-10-15 23:53:47 +0000996
Andy Flemingf08233c2007-08-14 01:34:21 -0500997 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +0000998 bgelr /* return if r7>=r8 - just in case */
wdenk9c53f402003-10-15 23:53:47 +0000999
wdenkf3da7cc2005-05-13 22:49:36 +00001000 mflr r4 /* save link register */
wdenk9c53f402003-10-15 23:53:47 +000010011:
Andy Flemingf08233c2007-08-14 01:34:21 -05001002 lwz r0,0(r7)
1003 stw r0,0(r9)
1004 addi r7,r7,4
1005 addi r9,r9,4
1006 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +00001007 bne 1b
wdenk9c53f402003-10-15 23:53:47 +00001008
1009 /*
1010 * relocate `hdlr' and `int_return' entries
1011 */
Andy Flemingf08233c2007-08-14 01:34:21 -05001012 li r7,.L_CriticalInput - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001013 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001014 li r7,.L_MachineCheck - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001015 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001016 li r7,.L_DataStorage - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001017 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001018 li r7,.L_InstStorage - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001019 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001020 li r7,.L_ExtInterrupt - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001021 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001022 li r7,.L_Alignment - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001023 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001024 li r7,.L_ProgramCheck - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001025 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001026 li r7,.L_FPUnavailable - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001027 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001028 li r7,.L_Decrementer - _start + _START_OFFSET
1029 bl trap_reloc
1030 li r7,.L_IntervalTimer - _start + _START_OFFSET
1031 li r8,_end_of_vectors - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +000010322:
wdenkf3da7cc2005-05-13 22:49:36 +00001033 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001034 addi r7,r7,0x100 /* next exception vector */
1035 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +00001036 blt 2b
wdenk9c53f402003-10-15 23:53:47 +00001037
wdenkf3da7cc2005-05-13 22:49:36 +00001038 lis r7,0x0
Andy Flemingf08233c2007-08-14 01:34:21 -05001039 mtspr IVPR,r7
wdenk9c53f402003-10-15 23:53:47 +00001040
wdenkf3da7cc2005-05-13 22:49:36 +00001041 mtlr r4 /* restore link register */
wdenk9c53f402003-10-15 23:53:47 +00001042 blr
1043
1044 /*
1045 * Function: relocate entries for one exception vector
1046 */
1047trap_reloc:
Andy Flemingf08233c2007-08-14 01:34:21 -05001048 lwz r0,0(r7) /* hdlr ... */
1049 add r0,r0,r3 /* ... += dest_addr */
1050 stw r0,0(r7)
wdenk9c53f402003-10-15 23:53:47 +00001051
Andy Flemingf08233c2007-08-14 01:34:21 -05001052 lwz r0,4(r7) /* int_return ... */
1053 add r0,r0,r3 /* ... += dest_addr */
1054 stw r0,4(r7)
wdenk9c53f402003-10-15 23:53:47 +00001055
1056 blr
1057
1058#ifdef CFG_INIT_RAM_LOCK
1059.globl unlock_ram_in_cache
1060unlock_ram_in_cache:
1061 /* invalidate the INIT_RAM section */
Andy Flemingf08233c2007-08-14 01:34:21 -05001062 lis r3,(CFG_INIT_RAM_ADDR & ~31)@h
1063 ori r3,r3,(CFG_INIT_RAM_ADDR & ~31)@l
1064 li r4,512
1065 mtctr r4
10661: icbi r0,r3
1067 dcbi r0,r3
1068 addi r3,r3,32
wdenk9c53f402003-10-15 23:53:47 +00001069 bdnz 1b
wdenkf3da7cc2005-05-13 22:49:36 +00001070 sync /* Wait for all icbi to complete on bus */
wdenk9c53f402003-10-15 23:53:47 +00001071 isync
1072 blr
1073#endif