blob: e8e5eb297de7cf97aacac084b5bcf091b1015e01 [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 /* Clear and set up some registers. */
Kumar Gala9772ee72008-01-16 22:38:34 -0600147 li r0,0x0000
wdenk9c53f402003-10-15 23:53:47 +0000148 lis r1,0xffff
149 mtspr DEC,r0 /* prevent dec exceptions */
150 mttbl r0 /* prevent fit & wdt exceptions */
151 mttbu r0
152 mtspr TSR,r1 /* clear all timer exception status */
153 mtspr TCR,r0 /* disable all */
154 mtspr ESR,r0 /* clear exception syndrome register */
155 mtspr MCSR,r0 /* machine check syndrome register */
156 mtxer r0 /* clear integer exception register */
wdenk9c53f402003-10-15 23:53:47 +0000157
158 /* Enable Time Base and Select Time Base Clock */
wdenk13eb2212004-07-09 23:27:13 +0000159 lis r0,HID0_EMCP@h /* Enable machine check */
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500160#if defined(CONFIG_ENABLE_36BIT_PHYS)
Kumar Gala9772ee72008-01-16 22:38:34 -0600161 ori r0,r0,HID0_ENMAS7@l /* Enable MAS7 */
Jon Loeliger77a4f6e2005-07-25 14:05:07 -0500162#endif
Kumar Gala9772ee72008-01-16 22:38:34 -0600163 ori r0,r0,HID0_TBEN@l /* Enable Timebase */
wdenk9c53f402003-10-15 23:53:47 +0000164 mtspr HID0,r0
wdenk9c53f402003-10-15 23:53:47 +0000165
Andy Flemingf08233c2007-08-14 01:34:21 -0500166 li r0,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */
wdenk9c53f402003-10-15 23:53:47 +0000167 mtspr HID1,r0
wdenk9c53f402003-10-15 23:53:47 +0000168
169 /* Enable Branch Prediction */
170#if defined(CONFIG_BTB)
171 li r0,0x201 /* BBFI = 1, BPEN = 1 */
172 mtspr BUCSR,r0
wdenk9c53f402003-10-15 23:53:47 +0000173#endif
174
175#if defined(CFG_INIT_DBCR)
176 lis r1,0xffff
177 ori r1,r1,0xffff
wdenk13eb2212004-07-09 23:27:13 +0000178 mtspr DBSR,r1 /* Clear all status bits */
wdenk9c53f402003-10-15 23:53:47 +0000179 lis r0,CFG_INIT_DBCR@h /* DBCR0[IDM] must be set */
180 ori r0,r0,CFG_INIT_DBCR@l
wdenk13eb2212004-07-09 23:27:13 +0000181 mtspr DBCR0,r0
wdenk9c53f402003-10-15 23:53:47 +0000182#endif
183
Kumar Gala9772ee72008-01-16 22:38:34 -0600184 /* create a temp mapping in AS=1 to the boot window */
185 lis r6,FSL_BOOKE_MAS0(1, 15, 0)@h
186 ori r6,r6,FSL_BOOKE_MAS0(1, 15, 0)@l
187
188 lis r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_16M)@h
189 ori r7,r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_16M)@l
190
191 lis r8,FSL_BOOKE_MAS2(TEXT_BASE, (MAS2_I|MAS2_G))@h
192 ori r8,r8,FSL_BOOKE_MAS2(TEXT_BASE, (MAS2_I|MAS2_G))@l
193
194 lis r9,FSL_BOOKE_MAS3(0xff800000, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@h
195 ori r9,r9,FSL_BOOKE_MAS3(0xff800000, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@l
196
197 mtspr MAS0,r6
198 mtspr MAS1,r7
199 mtspr MAS2,r8
200 mtspr MAS3,r9
201 isync
202 msync
203 tlbwe
204
205 /* create a temp mapping in AS=1 to the stack */
206 lis r6,FSL_BOOKE_MAS0(1, 14, 0)@h
207 ori r6,r6,FSL_BOOKE_MAS0(1, 14, 0)@l
208
209 lis r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_16K)@h
210 ori r7,r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_16K)@l
211
212 lis r8,FSL_BOOKE_MAS2(CFG_INIT_RAM_ADDR, 0)@h
213 ori r8,r8,FSL_BOOKE_MAS2(CFG_INIT_RAM_ADDR, 0)@l
214
215 lis r9,FSL_BOOKE_MAS3(CFG_INIT_RAM_ADDR, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@h
216 ori r9,r9,FSL_BOOKE_MAS3(CFG_INIT_RAM_ADDR, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@l
217
218 mtspr MAS0,r6
219 mtspr MAS1,r7
220 mtspr MAS2,r8
221 mtspr MAS3,r9
222 isync
223 msync
224 tlbwe
225
226 lis r6,MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS@h
227 ori r6,r6,MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS@l
228 lis r7,switch_as@h
229 ori r7,r7,switch_as@l
230
231 mtspr SPRN_SRR0,r7
232 mtspr SPRN_SRR1,r6
233 rfi
234
235switch_as:
Kumar Gala76e276b2007-08-07 18:07:27 -0500236/* L1 DCache is used for initial RAM */
237
238 /* Allocate Initial RAM in data cache.
239 */
240 lis r3,CFG_INIT_RAM_ADDR@h
241 ori r3,r3,CFG_INIT_RAM_ADDR@l
Kumar Gala938e14e2008-01-08 01:22:21 -0600242 mfspr r2, L1CFG0
243 andi. r2, r2, 0x1ff
244 /* cache size * 1024 / (2 * L1 line size) */
245 slwi r2, r2, (10 - 1 - L1_CACHE_SHIFT)
Kumar Gala76e276b2007-08-07 18:07:27 -0500246 mtctr r2
247 li r0,0
2481:
249 dcbz r0,r3
250 dcbtls 0,r0,r3
Kumar Gala91510e02007-10-02 11:12:27 -0500251 addi r3,r3,CFG_CACHELINE_SIZE
Kumar Gala76e276b2007-08-07 18:07:27 -0500252 bdnz 1b
253
Andy Flemingf08233c2007-08-14 01:34:21 -0500254 /* Jump out the last 4K page and continue to 'normal' start */
Kumar Gala76e276b2007-08-07 18:07:27 -0500255#ifdef CFG_RAMBOOT
Andy Flemingf08233c2007-08-14 01:34:21 -0500256 b _start_cont
Kumar Gala76e276b2007-08-07 18:07:27 -0500257#else
258 /* Calculate absolute address in FLASH and jump there */
259 /*--------------------------------------------------------------*/
260 lis r3,CFG_MONITOR_BASE@h
261 ori r3,r3,CFG_MONITOR_BASE@l
262 addi r3,r3,_start_cont - _start + _START_OFFSET
263 mtlr r3
urwithsughosh@gmail.come9f4e342007-09-24 13:36:01 -0400264 blr
Kumar Gala76e276b2007-08-07 18:07:27 -0500265#endif
Andy Flemingf08233c2007-08-14 01:34:21 -0500266
Andy Flemingf08233c2007-08-14 01:34:21 -0500267 .text
268 .globl _start
269_start:
270 .long 0x27051956 /* U-BOOT Magic Number */
271 .globl version_string
272version_string:
273 .ascii U_BOOT_VERSION
274 .ascii " (", __DATE__, " - ", __TIME__, ")"
275 .ascii CONFIG_IDENT_STRING, "\0"
276
277 .align 4
278 .globl _start_cont
279_start_cont:
wdenk9c53f402003-10-15 23:53:47 +0000280 /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
281 lis r1,CFG_INIT_RAM_ADDR@h
282 ori r1,r1,CFG_INIT_SP_OFFSET@l
283
284 li r0,0
285 stwu r0,-4(r1)
286 stwu r0,-4(r1) /* Terminate call chain */
287
288 stwu r1,-8(r1) /* Save back chain and move SP */
289 lis r0,RESET_VECTOR@h /* Address of reset vector */
Andy Flemingf08233c2007-08-14 01:34:21 -0500290 ori r0,r0,RESET_VECTOR@l
wdenk9c53f402003-10-15 23:53:47 +0000291 stwu r1,-8(r1) /* Save back chain and move SP */
292 stw r0,+12(r1) /* Save return addr (underflow vect) */
293
294 GET_GOT
Kumar Gala9772ee72008-01-16 22:38:34 -0600295 bl cpu_init_early_f
296
297 /* switch back to AS = 0 */
298 lis r3,(MSR_CE|MSR_ME|MSR_DE)@h
299 ori r3,r3,(MSR_CE|MSR_ME|MSR_DE)@l
300 mtmsr r3
301 isync
302
wdenk9c53f402003-10-15 23:53:47 +0000303 bl cpu_init_f
wdenk9c53f402003-10-15 23:53:47 +0000304 bl board_init_f
wdenk13eb2212004-07-09 23:27:13 +0000305 isync
wdenk9c53f402003-10-15 23:53:47 +0000306
Andy Flemingf08233c2007-08-14 01:34:21 -0500307 . = EXC_OFF_SYS_RESET
wdenk9c53f402003-10-15 23:53:47 +0000308 .globl _start_of_vectors
309_start_of_vectors:
Andy Flemingf08233c2007-08-14 01:34:21 -0500310
wdenk9c53f402003-10-15 23:53:47 +0000311/* Critical input. */
Andy Flemingf08233c2007-08-14 01:34:21 -0500312 CRIT_EXCEPTION(0x0100, CriticalInput, CritcalInputException)
313
314/* Machine check */
315 MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException)
wdenk9c53f402003-10-15 23:53:47 +0000316
317/* Data Storage exception. */
318 STD_EXCEPTION(0x0300, DataStorage, UnknownException)
319
320/* Instruction Storage exception. */
321 STD_EXCEPTION(0x0400, InstStorage, UnknownException)
322
323/* External Interrupt exception. */
Andy Flemingf08233c2007-08-14 01:34:21 -0500324 STD_EXCEPTION(0x0500, ExtInterrupt, ExtIntException)
wdenk9c53f402003-10-15 23:53:47 +0000325
326/* Alignment exception. */
327 . = 0x0600
328Alignment:
Rafal Jaworowski06244e42007-06-22 14:58:04 +0200329 EXCEPTION_PROLOG(SRR0, SRR1)
wdenk9c53f402003-10-15 23:53:47 +0000330 mfspr r4,DAR
331 stw r4,_DAR(r21)
332 mfspr r5,DSISR
333 stw r5,_DSISR(r21)
334 addi r3,r1,STACK_FRAME_OVERHEAD
335 li r20,MSR_KERNEL
336 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
337 lwz r6,GOT(transfer_to_handler)
338 mtlr r6
339 blrl
340.L_Alignment:
Andy Flemingf08233c2007-08-14 01:34:21 -0500341 .long AlignmentException - _start + _START_OFFSET
342 .long int_return - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000343
344/* Program check exception */
345 . = 0x0700
346ProgramCheck:
Rafal Jaworowski06244e42007-06-22 14:58:04 +0200347 EXCEPTION_PROLOG(SRR0, SRR1)
wdenk9c53f402003-10-15 23:53:47 +0000348 addi r3,r1,STACK_FRAME_OVERHEAD
349 li r20,MSR_KERNEL
350 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
351 lwz r6,GOT(transfer_to_handler)
352 mtlr r6
353 blrl
354.L_ProgramCheck:
Andy Flemingf08233c2007-08-14 01:34:21 -0500355 .long ProgramCheckException - _start + _START_OFFSET
356 .long int_return - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000357
358 /* No FPU on MPC85xx. This exception is not supposed to happen.
359 */
360 STD_EXCEPTION(0x0800, FPUnavailable, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000361
wdenkf3da7cc2005-05-13 22:49:36 +0000362 . = 0x0900
wdenk9c53f402003-10-15 23:53:47 +0000363/*
364 * r0 - SYSCALL number
365 * r3-... arguments
366 */
367SystemCall:
Andy Flemingf08233c2007-08-14 01:34:21 -0500368 addis r11,r0,0 /* get functions table addr */
369 ori r11,r11,0 /* Note: this code is patched in trap_init */
370 addis r12,r0,0 /* get number of functions */
wdenkf3da7cc2005-05-13 22:49:36 +0000371 ori r12,r12,0
wdenk9c53f402003-10-15 23:53:47 +0000372
Andy Flemingf08233c2007-08-14 01:34:21 -0500373 cmplw 0,r0,r12
wdenkf3da7cc2005-05-13 22:49:36 +0000374 bge 1f
wdenk9c53f402003-10-15 23:53:47 +0000375
Andy Flemingf08233c2007-08-14 01:34:21 -0500376 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */
wdenkf3da7cc2005-05-13 22:49:36 +0000377 add r11,r11,r0
378 lwz r11,0(r11)
wdenk9c53f402003-10-15 23:53:47 +0000379
Andy Flemingf08233c2007-08-14 01:34:21 -0500380 li r20,0xd00-4 /* Get stack pointer */
wdenkf3da7cc2005-05-13 22:49:36 +0000381 lwz r12,0(r20)
Andy Flemingf08233c2007-08-14 01:34:21 -0500382 subi r12,r12,12 /* Adjust stack pointer */
wdenkf3da7cc2005-05-13 22:49:36 +0000383 li r0,0xc00+_end_back-SystemCall
Andy Flemingf08233c2007-08-14 01:34:21 -0500384 cmplw 0,r0,r12 /* Check stack overflow */
wdenkf3da7cc2005-05-13 22:49:36 +0000385 bgt 1f
386 stw r12,0(r20)
wdenk9c53f402003-10-15 23:53:47 +0000387
wdenkf3da7cc2005-05-13 22:49:36 +0000388 mflr r0
389 stw r0,0(r12)
390 mfspr r0,SRR0
391 stw r0,4(r12)
392 mfspr r0,SRR1
393 stw r0,8(r12)
wdenk9c53f402003-10-15 23:53:47 +0000394
wdenkf3da7cc2005-05-13 22:49:36 +0000395 li r12,0xc00+_back-SystemCall
396 mtlr r12
397 mtspr SRR0,r11
wdenk9c53f402003-10-15 23:53:47 +0000398
wdenkf3da7cc2005-05-13 22:49:36 +00003991: SYNC
wdenk9c53f402003-10-15 23:53:47 +0000400 rfi
401_back:
402
wdenkf3da7cc2005-05-13 22:49:36 +0000403 mfmsr r11 /* Disable interrupts */
404 li r12,0
405 ori r12,r12,MSR_EE
406 andc r11,r11,r12
407 SYNC /* Some chip revs need this... */
408 mtmsr r11
wdenk9c53f402003-10-15 23:53:47 +0000409 SYNC
410
wdenkf3da7cc2005-05-13 22:49:36 +0000411 li r12,0xd00-4 /* restore regs */
412 lwz r12,0(r12)
wdenk9c53f402003-10-15 23:53:47 +0000413
wdenkf3da7cc2005-05-13 22:49:36 +0000414 lwz r11,0(r12)
415 mtlr r11
416 lwz r11,4(r12)
417 mtspr SRR0,r11
418 lwz r11,8(r12)
419 mtspr SRR1,r11
wdenk9c53f402003-10-15 23:53:47 +0000420
wdenkf3da7cc2005-05-13 22:49:36 +0000421 addi r12,r12,12 /* Adjust stack pointer */
422 li r20,0xd00-4
423 stw r12,0(r20)
wdenk9c53f402003-10-15 23:53:47 +0000424
425 SYNC
426 rfi
427_end_back:
428
wdenkf3da7cc2005-05-13 22:49:36 +0000429 STD_EXCEPTION(0x0a00, Decrementer, timer_interrupt)
430 STD_EXCEPTION(0x0b00, IntervalTimer, UnknownException)
431 STD_EXCEPTION(0x0c00, WatchdogTimer, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000432
wdenkf3da7cc2005-05-13 22:49:36 +0000433 STD_EXCEPTION(0x0d00, DataTLBError, UnknownException)
434 STD_EXCEPTION(0x0e00, InstructionTLBError, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000435
wdenkf3da7cc2005-05-13 22:49:36 +0000436 CRIT_EXCEPTION(0x0f00, DebugBreakpoint, DebugException )
wdenk9c53f402003-10-15 23:53:47 +0000437
wdenkf3da7cc2005-05-13 22:49:36 +0000438 .globl _end_of_vectors
wdenk9c53f402003-10-15 23:53:47 +0000439_end_of_vectors:
440
441
Andy Flemingf08233c2007-08-14 01:34:21 -0500442 . = . + (0x100 - ( . & 0xff )) /* align for debug */
wdenk9c53f402003-10-15 23:53:47 +0000443
444/*
445 * This code finishes saving the registers to the exception frame
446 * and jumps to the appropriate handler for the exception.
447 * Register r21 is pointer into trap frame, r1 has new stack pointer.
448 */
449 .globl transfer_to_handler
450transfer_to_handler:
451 stw r22,_NIP(r21)
452 lis r22,MSR_POW@h
453 andc r23,r23,r22
454 stw r23,_MSR(r21)
455 SAVE_GPR(7, r21)
456 SAVE_4GPRS(8, r21)
457 SAVE_8GPRS(12, r21)
458 SAVE_8GPRS(24, r21)
459
460 mflr r23
461 andi. r24,r23,0x3f00 /* get vector offset */
462 stw r24,TRAP(r21)
463 li r22,0
464 stw r22,RESULT(r21)
465 mtspr SPRG2,r22 /* r1 is now kernel sp */
466
467 lwz r24,0(r23) /* virtual address of handler */
468 lwz r23,4(r23) /* where to go when done */
469 mtspr SRR0,r24
470 mtspr SRR1,r20
471 mtlr r23
472 SYNC
473 rfi /* jump to handler, enable MMU */
474
475int_return:
476 mfmsr r28 /* Disable interrupts */
477 li r4,0
478 ori r4,r4,MSR_EE
479 andc r28,r28,r4
480 SYNC /* Some chip revs need this... */
481 mtmsr r28
482 SYNC
483 lwz r2,_CTR(r1)
484 lwz r0,_LINK(r1)
485 mtctr r2
486 mtlr r0
487 lwz r2,_XER(r1)
488 lwz r0,_CCR(r1)
489 mtspr XER,r2
490 mtcrf 0xFF,r0
491 REST_10GPRS(3, r1)
492 REST_10GPRS(13, r1)
493 REST_8GPRS(23, r1)
494 REST_GPR(31, r1)
495 lwz r2,_NIP(r1) /* Restore environment */
496 lwz r0,_MSR(r1)
497 mtspr SRR0,r2
498 mtspr SRR1,r0
499 lwz r0,GPR0(r1)
500 lwz r2,GPR2(r1)
501 lwz r1,GPR1(r1)
502 SYNC
503 rfi
504
505crit_return:
506 mfmsr r28 /* Disable interrupts */
507 li r4,0
508 ori r4,r4,MSR_EE
509 andc r28,r28,r4
510 SYNC /* Some chip revs need this... */
511 mtmsr r28
512 SYNC
513 lwz r2,_CTR(r1)
514 lwz r0,_LINK(r1)
515 mtctr r2
516 mtlr r0
517 lwz r2,_XER(r1)
518 lwz r0,_CCR(r1)
519 mtspr XER,r2
520 mtcrf 0xFF,r0
521 REST_10GPRS(3, r1)
522 REST_10GPRS(13, r1)
523 REST_8GPRS(23, r1)
524 REST_GPR(31, r1)
525 lwz r2,_NIP(r1) /* Restore environment */
526 lwz r0,_MSR(r1)
Andy Flemingf08233c2007-08-14 01:34:21 -0500527 mtspr SPRN_CSRR0,r2
528 mtspr SPRN_CSRR1,r0
wdenk9c53f402003-10-15 23:53:47 +0000529 lwz r0,GPR0(r1)
530 lwz r2,GPR2(r1)
531 lwz r1,GPR1(r1)
532 SYNC
533 rfci
534
Andy Flemingf08233c2007-08-14 01:34:21 -0500535mck_return:
536 mfmsr r28 /* Disable interrupts */
537 li r4,0
538 ori r4,r4,MSR_EE
539 andc r28,r28,r4
540 SYNC /* Some chip revs need this... */
541 mtmsr r28
542 SYNC
543 lwz r2,_CTR(r1)
544 lwz r0,_LINK(r1)
545 mtctr r2
546 mtlr r0
547 lwz r2,_XER(r1)
548 lwz r0,_CCR(r1)
549 mtspr XER,r2
550 mtcrf 0xFF,r0
551 REST_10GPRS(3, r1)
552 REST_10GPRS(13, r1)
553 REST_8GPRS(23, r1)
554 REST_GPR(31, r1)
555 lwz r2,_NIP(r1) /* Restore environment */
556 lwz r0,_MSR(r1)
557 mtspr SPRN_MCSRR0,r2
558 mtspr SPRN_MCSRR1,r0
559 lwz r0,GPR0(r1)
560 lwz r2,GPR2(r1)
561 lwz r1,GPR1(r1)
562 SYNC
563 rfmci
564
wdenk9c53f402003-10-15 23:53:47 +0000565/* Cache functions.
566*/
567invalidate_icache:
568 mfspr r0,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500569 ori r0,r0,L1CSR1_ICFI
570 msync
571 isync
wdenk9c53f402003-10-15 23:53:47 +0000572 mtspr L1CSR1,r0
573 isync
Andy Flemingf08233c2007-08-14 01:34:21 -0500574 blr /* entire I cache */
wdenk9c53f402003-10-15 23:53:47 +0000575
576invalidate_dcache:
577 mfspr r0,L1CSR0
Andy Flemingf08233c2007-08-14 01:34:21 -0500578 ori r0,r0,L1CSR0_DCFI
wdenk9c53f402003-10-15 23:53:47 +0000579 msync
580 isync
581 mtspr L1CSR0,r0
582 isync
583 blr
584
585 .globl icache_enable
586icache_enable:
587 mflr r8
588 bl invalidate_icache
589 mtlr r8
590 isync
591 mfspr r4,L1CSR1
592 ori r4,r4,0x0001
593 oris r4,r4,0x0001
594 mtspr L1CSR1,r4
595 isync
596 blr
597
598 .globl icache_disable
599icache_disable:
600 mfspr r0,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500601 lis r3,0
602 ori r3,r3,L1CSR1_ICE
603 andc r0,r0,r3
wdenk9c53f402003-10-15 23:53:47 +0000604 mtspr L1CSR1,r0
605 isync
606 blr
607
608 .globl icache_status
609icache_status:
610 mfspr r3,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500611 andi. r3,r3,L1CSR1_ICE
wdenk9c53f402003-10-15 23:53:47 +0000612 blr
613
614 .globl dcache_enable
615dcache_enable:
616 mflr r8
617 bl invalidate_dcache
618 mtlr r8
619 isync
620 mfspr r0,L1CSR0
621 ori r0,r0,0x0001
622 oris r0,r0,0x0001
623 msync
624 isync
625 mtspr L1CSR0,r0
626 isync
627 blr
628
629 .globl dcache_disable
630dcache_disable:
Andy Flemingf08233c2007-08-14 01:34:21 -0500631 mfspr r3,L1CSR0
632 lis r4,0
633 ori r4,r4,L1CSR0_DCE
634 andc r3,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000635 mtspr L1CSR0,r0
636 isync
637 blr
638
639 .globl dcache_status
640dcache_status:
641 mfspr r3,L1CSR0
Andy Flemingf08233c2007-08-14 01:34:21 -0500642 andi. r3,r3,L1CSR0_DCE
wdenk9c53f402003-10-15 23:53:47 +0000643 blr
644
645 .globl get_pir
646get_pir:
Andy Flemingf08233c2007-08-14 01:34:21 -0500647 mfspr r3,PIR
wdenk9c53f402003-10-15 23:53:47 +0000648 blr
649
650 .globl get_pvr
651get_pvr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500652 mfspr r3,PVR
wdenk9c53f402003-10-15 23:53:47 +0000653 blr
654
wdenka445ddf2004-06-09 00:34:46 +0000655 .globl get_svr
656get_svr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500657 mfspr r3,SVR
wdenka445ddf2004-06-09 00:34:46 +0000658 blr
659
wdenk9c53f402003-10-15 23:53:47 +0000660 .globl wr_tcr
661wr_tcr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500662 mtspr TCR,r3
wdenk9c53f402003-10-15 23:53:47 +0000663 blr
664
665/*------------------------------------------------------------------------------- */
666/* Function: in8 */
667/* Description: Input 8 bits */
668/*------------------------------------------------------------------------------- */
669 .globl in8
670in8:
671 lbz r3,0x0000(r3)
672 blr
673
674/*------------------------------------------------------------------------------- */
675/* Function: out8 */
676/* Description: Output 8 bits */
677/*------------------------------------------------------------------------------- */
678 .globl out8
679out8:
680 stb r4,0x0000(r3)
Ed Swarthout7d6be302007-09-26 16:35:54 -0500681 sync
wdenk9c53f402003-10-15 23:53:47 +0000682 blr
683
684/*------------------------------------------------------------------------------- */
685/* Function: out16 */
686/* Description: Output 16 bits */
687/*------------------------------------------------------------------------------- */
688 .globl out16
689out16:
690 sth r4,0x0000(r3)
Ed Swarthout7d6be302007-09-26 16:35:54 -0500691 sync
wdenk9c53f402003-10-15 23:53:47 +0000692 blr
693
694/*------------------------------------------------------------------------------- */
695/* Function: out16r */
696/* Description: Byte reverse and output 16 bits */
697/*------------------------------------------------------------------------------- */
698 .globl out16r
699out16r:
700 sthbrx r4,r0,r3
Ed Swarthout7d6be302007-09-26 16:35:54 -0500701 sync
wdenk9c53f402003-10-15 23:53:47 +0000702 blr
703
704/*------------------------------------------------------------------------------- */
705/* Function: out32 */
706/* Description: Output 32 bits */
707/*------------------------------------------------------------------------------- */
708 .globl out32
709out32:
710 stw r4,0x0000(r3)
Ed Swarthout7d6be302007-09-26 16:35:54 -0500711 sync
wdenk9c53f402003-10-15 23:53:47 +0000712 blr
713
714/*------------------------------------------------------------------------------- */
715/* Function: out32r */
716/* Description: Byte reverse and output 32 bits */
717/*------------------------------------------------------------------------------- */
718 .globl out32r
719out32r:
720 stwbrx r4,r0,r3
Ed Swarthout7d6be302007-09-26 16:35:54 -0500721 sync
wdenk9c53f402003-10-15 23:53:47 +0000722 blr
723
724/*------------------------------------------------------------------------------- */
725/* Function: in16 */
726/* Description: Input 16 bits */
727/*------------------------------------------------------------------------------- */
728 .globl in16
729in16:
730 lhz r3,0x0000(r3)
731 blr
732
733/*------------------------------------------------------------------------------- */
734/* Function: in16r */
735/* Description: Input 16 bits and byte reverse */
736/*------------------------------------------------------------------------------- */
737 .globl in16r
738in16r:
739 lhbrx r3,r0,r3
740 blr
741
742/*------------------------------------------------------------------------------- */
743/* Function: in32 */
744/* Description: Input 32 bits */
745/*------------------------------------------------------------------------------- */
746 .globl in32
747in32:
748 lwz 3,0x0000(3)
749 blr
750
751/*------------------------------------------------------------------------------- */
752/* Function: in32r */
753/* Description: Input 32 bits and byte reverse */
754/*------------------------------------------------------------------------------- */
755 .globl in32r
756in32r:
757 lwbrx r3,r0,r3
758 blr
759
760/*------------------------------------------------------------------------------- */
761/* Function: ppcDcbf */
762/* Description: Data Cache block flush */
763/* Input: r3 = effective address */
764/* Output: none. */
765/*------------------------------------------------------------------------------- */
766 .globl ppcDcbf
767ppcDcbf:
768 dcbf r0,r3
769 blr
770
771/*------------------------------------------------------------------------------- */
772/* Function: ppcDcbi */
773/* Description: Data Cache block Invalidate */
774/* Input: r3 = effective address */
775/* Output: none. */
776/*------------------------------------------------------------------------------- */
777 .globl ppcDcbi
778ppcDcbi:
779 dcbi r0,r3
780 blr
781
wdenk13eb2212004-07-09 23:27:13 +0000782/*--------------------------------------------------------------------------
783 * Function: ppcDcbz
784 * Description: Data Cache block zero.
785 * Input: r3 = effective address
786 * Output: none.
787 *-------------------------------------------------------------------------- */
788
789 .globl ppcDcbz
790ppcDcbz:
791 dcbz r0,r3
792 blr
793
wdenk9c53f402003-10-15 23:53:47 +0000794/*------------------------------------------------------------------------------- */
795/* Function: ppcSync */
796/* Description: Processor Synchronize */
797/* Input: none. */
798/* Output: none. */
799/*------------------------------------------------------------------------------- */
800 .globl ppcSync
801ppcSync:
802 sync
803 blr
804
805/*------------------------------------------------------------------------------*/
806
807/*
808 * void relocate_code (addr_sp, gd, addr_moni)
809 *
810 * This "function" does not return, instead it continues in RAM
811 * after relocating the monitor code.
812 *
813 * r3 = dest
814 * r4 = src
815 * r5 = length in bytes
816 * r6 = cachelinesize
817 */
818 .globl relocate_code
819relocate_code:
Andy Flemingf08233c2007-08-14 01:34:21 -0500820 mr r1,r3 /* Set new stack pointer */
821 mr r9,r4 /* Save copy of Init Data pointer */
822 mr r10,r5 /* Save copy of Destination Address */
wdenk9c53f402003-10-15 23:53:47 +0000823
Andy Flemingf08233c2007-08-14 01:34:21 -0500824 mr r3,r5 /* Destination Address */
825 lis r4,CFG_MONITOR_BASE@h /* Source Address */
826 ori r4,r4,CFG_MONITOR_BASE@l
wdenk9c53f402003-10-15 23:53:47 +0000827 lwz r5,GOT(__init_end)
828 sub r5,r5,r4
Andy Flemingf08233c2007-08-14 01:34:21 -0500829 li r6,CFG_CACHELINE_SIZE /* Cache Line Size */
wdenk9c53f402003-10-15 23:53:47 +0000830
831 /*
832 * Fix GOT pointer:
833 *
834 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
835 *
836 * Offset:
837 */
Andy Flemingf08233c2007-08-14 01:34:21 -0500838 sub r15,r10,r4
wdenk9c53f402003-10-15 23:53:47 +0000839
840 /* First our own GOT */
Andy Flemingf08233c2007-08-14 01:34:21 -0500841 add r14,r14,r15
wdenk9c53f402003-10-15 23:53:47 +0000842 /* the the one used by the C code */
Andy Flemingf08233c2007-08-14 01:34:21 -0500843 add r30,r30,r15
wdenk9c53f402003-10-15 23:53:47 +0000844
845 /*
846 * Now relocate code
847 */
848
849 cmplw cr1,r3,r4
850 addi r0,r5,3
851 srwi. r0,r0,2
852 beq cr1,4f /* In place copy is not necessary */
853 beq 7f /* Protect against 0 count */
854 mtctr r0
855 bge cr1,2f
856
857 la r8,-4(r4)
858 la r7,-4(r3)
8591: lwzu r0,4(r8)
860 stwu r0,4(r7)
861 bdnz 1b
862 b 4f
863
8642: slwi r0,r0,2
865 add r8,r4,r0
866 add r7,r3,r0
8673: lwzu r0,-4(r8)
868 stwu r0,-4(r7)
869 bdnz 3b
870
871/*
872 * Now flush the cache: note that we must start from a cache aligned
873 * address. Otherwise we might miss one cache line.
874 */
8754: cmpwi r6,0
876 add r5,r3,r5
877 beq 7f /* Always flush prefetch queue in any case */
878 subi r0,r6,1
879 andc r3,r3,r0
880 mr r4,r3
8815: dcbst 0,r4
882 add r4,r4,r6
883 cmplw r4,r5
884 blt 5b
885 sync /* Wait for all dcbst to complete on bus */
886 mr r4,r3
8876: icbi 0,r4
888 add r4,r4,r6
889 cmplw r4,r5
890 blt 6b
8917: sync /* Wait for all icbi to complete on bus */
892 isync
893
Wolfgang Denk29dcbd42005-10-05 00:00:54 +0200894 /*
895 * Re-point the IVPR at RAM
896 */
897 mtspr IVPR,r10
Wolfgang Denk9da240c2005-10-05 00:19:34 +0200898
wdenk9c53f402003-10-15 23:53:47 +0000899/*
900 * We are done. Do not return, instead branch to second part of board
901 * initialization, now running from RAM.
902 */
903
Andy Flemingf08233c2007-08-14 01:34:21 -0500904 addi r0,r10,in_ram - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000905 mtlr r0
906 blr /* NEVER RETURNS! */
Andy Flemingf08233c2007-08-14 01:34:21 -0500907 .globl in_ram
wdenk9c53f402003-10-15 23:53:47 +0000908in_ram:
909
910 /*
911 * Relocation Function, r14 point to got2+0x8000
912 *
913 * Adjust got2 pointers, no need to check for 0, this code
914 * already puts a few entries in the table.
915 */
916 li r0,__got2_entries@sectoff@l
917 la r3,GOT(_GOT2_TABLE_)
918 lwz r11,GOT(_GOT2_TABLE_)
919 mtctr r0
920 sub r11,r3,r11
921 addi r3,r3,-4
9221: lwzu r0,4(r3)
923 add r0,r0,r11
924 stw r0,0(r3)
925 bdnz 1b
926
927 /*
928 * Now adjust the fixups and the pointers to the fixups
929 * in case we need to move ourselves again.
930 */
9312: li r0,__fixup_entries@sectoff@l
932 lwz r3,GOT(_FIXUP_TABLE_)
933 cmpwi r0,0
934 mtctr r0
935 addi r3,r3,-4
936 beq 4f
9373: lwzu r4,4(r3)
938 lwzux r0,r4,r11
939 add r0,r0,r11
940 stw r10,0(r3)
941 stw r0,0(r4)
942 bdnz 3b
9434:
944clear_bss:
945 /*
946 * Now clear BSS segment
947 */
948 lwz r3,GOT(__bss_start)
949 lwz r4,GOT(_end)
950
Andy Flemingf08233c2007-08-14 01:34:21 -0500951 cmplw 0,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000952 beq 6f
953
Andy Flemingf08233c2007-08-14 01:34:21 -0500954 li r0,0
wdenk9c53f402003-10-15 23:53:47 +00009555:
Andy Flemingf08233c2007-08-14 01:34:21 -0500956 stw r0,0(r3)
957 addi r3,r3,4
958 cmplw 0,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000959 bne 5b
9606:
961
Andy Flemingf08233c2007-08-14 01:34:21 -0500962 mr r3,r9 /* Init Data pointer */
963 mr r4,r10 /* Destination Address */
wdenk9c53f402003-10-15 23:53:47 +0000964 bl board_init_r
965
966 /*
967 * Copy exception vector code to low memory
968 *
969 * r3: dest_addr
970 * r7: source address, r8: end address, r9: target address
971 */
wdenkf3da7cc2005-05-13 22:49:36 +0000972 .globl trap_init
wdenk9c53f402003-10-15 23:53:47 +0000973trap_init:
Andy Flemingf08233c2007-08-14 01:34:21 -0500974 lwz r7,GOT(_start_of_vectors)
975 lwz r8,GOT(_end_of_vectors)
wdenk9c53f402003-10-15 23:53:47 +0000976
Andy Flemingf08233c2007-08-14 01:34:21 -0500977 li r9,0x100 /* reset vector always at 0x100 */
wdenk9c53f402003-10-15 23:53:47 +0000978
Andy Flemingf08233c2007-08-14 01:34:21 -0500979 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +0000980 bgelr /* return if r7>=r8 - just in case */
wdenk9c53f402003-10-15 23:53:47 +0000981
wdenkf3da7cc2005-05-13 22:49:36 +0000982 mflr r4 /* save link register */
wdenk9c53f402003-10-15 23:53:47 +00009831:
Andy Flemingf08233c2007-08-14 01:34:21 -0500984 lwz r0,0(r7)
985 stw r0,0(r9)
986 addi r7,r7,4
987 addi r9,r9,4
988 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +0000989 bne 1b
wdenk9c53f402003-10-15 23:53:47 +0000990
991 /*
992 * relocate `hdlr' and `int_return' entries
993 */
Andy Flemingf08233c2007-08-14 01:34:21 -0500994 li r7,.L_CriticalInput - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000995 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500996 li r7,.L_MachineCheck - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000997 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500998 li r7,.L_DataStorage - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000999 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001000 li r7,.L_InstStorage - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001001 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001002 li r7,.L_ExtInterrupt - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001003 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001004 li r7,.L_Alignment - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001005 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001006 li r7,.L_ProgramCheck - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001007 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001008 li r7,.L_FPUnavailable - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +00001009 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001010 li r7,.L_Decrementer - _start + _START_OFFSET
1011 bl trap_reloc
1012 li r7,.L_IntervalTimer - _start + _START_OFFSET
1013 li r8,_end_of_vectors - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +000010142:
wdenkf3da7cc2005-05-13 22:49:36 +00001015 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -05001016 addi r7,r7,0x100 /* next exception vector */
1017 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +00001018 blt 2b
wdenk9c53f402003-10-15 23:53:47 +00001019
wdenkf3da7cc2005-05-13 22:49:36 +00001020 lis r7,0x0
Andy Flemingf08233c2007-08-14 01:34:21 -05001021 mtspr IVPR,r7
wdenk9c53f402003-10-15 23:53:47 +00001022
wdenkf3da7cc2005-05-13 22:49:36 +00001023 mtlr r4 /* restore link register */
wdenk9c53f402003-10-15 23:53:47 +00001024 blr
1025
1026 /*
1027 * Function: relocate entries for one exception vector
1028 */
1029trap_reloc:
Andy Flemingf08233c2007-08-14 01:34:21 -05001030 lwz r0,0(r7) /* hdlr ... */
1031 add r0,r0,r3 /* ... += dest_addr */
1032 stw r0,0(r7)
wdenk9c53f402003-10-15 23:53:47 +00001033
Andy Flemingf08233c2007-08-14 01:34:21 -05001034 lwz r0,4(r7) /* int_return ... */
1035 add r0,r0,r3 /* ... += dest_addr */
1036 stw r0,4(r7)
wdenk9c53f402003-10-15 23:53:47 +00001037
1038 blr
1039
1040#ifdef CFG_INIT_RAM_LOCK
1041.globl unlock_ram_in_cache
1042unlock_ram_in_cache:
1043 /* invalidate the INIT_RAM section */
Andy Flemingf08233c2007-08-14 01:34:21 -05001044 lis r3,(CFG_INIT_RAM_ADDR & ~31)@h
1045 ori r3,r3,(CFG_INIT_RAM_ADDR & ~31)@l
Kumar Gala938e14e2008-01-08 01:22:21 -06001046 mfspr r4,L1CFG0
1047 andi. r4,r4,0x1ff
1048 slwi r4,r4,(10 - 1 - L1_CACHE_SHIFT)
Andy Flemingf08233c2007-08-14 01:34:21 -05001049 mtctr r4
10501: icbi r0,r3
1051 dcbi r0,r3
Kumar Gala91510e02007-10-02 11:12:27 -05001052 addi r3,r3,CFG_CACHELINE_SIZE
wdenk9c53f402003-10-15 23:53:47 +00001053 bdnz 1b
wdenkf3da7cc2005-05-13 22:49:36 +00001054 sync /* Wait for all icbi to complete on bus */
wdenk9c53f402003-10-15 23:53:47 +00001055 isync
1056 blr
1057#endif