blob: 10fe93629c3badfec8d7c3189e47faac7da122ec [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 */
Wolfgang Denka1be4762008-05-20 16:00:29 +020092 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
Andrew Klossner0470c522008-07-02 07:03:53 -0700191 /* Align the mapping to 16MB */
192 lis r8,FSL_BOOKE_MAS2(TEXT_BASE & 0xff000000, (MAS2_I|MAS2_G))@h
193 ori r8,r8,FSL_BOOKE_MAS2(TEXT_BASE & 0xff000000, (MAS2_I|MAS2_G))@l
Kumar Gala9772ee72008-01-16 22:38:34 -0600194
Andrew Klossner0470c522008-07-02 07:03:53 -0700195 lis r9,FSL_BOOKE_MAS3(0xff000000, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@h
196 ori r9,r9,FSL_BOOKE_MAS3(0xff000000, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@l
Kumar Gala9772ee72008-01-16 22:38:34 -0600197
198 mtspr MAS0,r6
199 mtspr MAS1,r7
200 mtspr MAS2,r8
201 mtspr MAS3,r9
202 isync
203 msync
204 tlbwe
205
206 /* create a temp mapping in AS=1 to the stack */
207 lis r6,FSL_BOOKE_MAS0(1, 14, 0)@h
208 ori r6,r6,FSL_BOOKE_MAS0(1, 14, 0)@l
209
210 lis r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_16K)@h
211 ori r7,r7,FSL_BOOKE_MAS1(1, 1, 0, 1, BOOKE_PAGESZ_16K)@l
212
213 lis r8,FSL_BOOKE_MAS2(CFG_INIT_RAM_ADDR, 0)@h
214 ori r8,r8,FSL_BOOKE_MAS2(CFG_INIT_RAM_ADDR, 0)@l
215
216 lis r9,FSL_BOOKE_MAS3(CFG_INIT_RAM_ADDR, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@h
217 ori r9,r9,FSL_BOOKE_MAS3(CFG_INIT_RAM_ADDR, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@l
218
219 mtspr MAS0,r6
220 mtspr MAS1,r7
221 mtspr MAS2,r8
222 mtspr MAS3,r9
223 isync
224 msync
225 tlbwe
226
227 lis r6,MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS@h
228 ori r6,r6,MSR_CE|MSR_ME|MSR_DE|MSR_IS|MSR_DS@l
229 lis r7,switch_as@h
230 ori r7,r7,switch_as@l
231
232 mtspr SPRN_SRR0,r7
233 mtspr SPRN_SRR1,r6
234 rfi
235
236switch_as:
Kumar Gala76e276b2007-08-07 18:07:27 -0500237/* L1 DCache is used for initial RAM */
238
239 /* Allocate Initial RAM in data cache.
240 */
241 lis r3,CFG_INIT_RAM_ADDR@h
242 ori r3,r3,CFG_INIT_RAM_ADDR@l
Kumar Gala938e14e2008-01-08 01:22:21 -0600243 mfspr r2, L1CFG0
244 andi. r2, r2, 0x1ff
245 /* cache size * 1024 / (2 * L1 line size) */
246 slwi r2, r2, (10 - 1 - L1_CACHE_SHIFT)
Kumar Gala76e276b2007-08-07 18:07:27 -0500247 mtctr r2
248 li r0,0
2491:
250 dcbz r0,r3
251 dcbtls 0,r0,r3
Kumar Gala91510e02007-10-02 11:12:27 -0500252 addi r3,r3,CFG_CACHELINE_SIZE
Kumar Gala76e276b2007-08-07 18:07:27 -0500253 bdnz 1b
254
Andy Flemingf08233c2007-08-14 01:34:21 -0500255 /* Jump out the last 4K page and continue to 'normal' start */
Kumar Gala76e276b2007-08-07 18:07:27 -0500256#ifdef CFG_RAMBOOT
Andy Flemingf08233c2007-08-14 01:34:21 -0500257 b _start_cont
Kumar Gala76e276b2007-08-07 18:07:27 -0500258#else
259 /* Calculate absolute address in FLASH and jump there */
260 /*--------------------------------------------------------------*/
261 lis r3,CFG_MONITOR_BASE@h
262 ori r3,r3,CFG_MONITOR_BASE@l
263 addi r3,r3,_start_cont - _start + _START_OFFSET
264 mtlr r3
urwithsughosh@gmail.come9f4e342007-09-24 13:36:01 -0400265 blr
Kumar Gala76e276b2007-08-07 18:07:27 -0500266#endif
Andy Flemingf08233c2007-08-14 01:34:21 -0500267
Andy Flemingf08233c2007-08-14 01:34:21 -0500268 .text
269 .globl _start
270_start:
271 .long 0x27051956 /* U-BOOT Magic Number */
272 .globl version_string
273version_string:
274 .ascii U_BOOT_VERSION
275 .ascii " (", __DATE__, " - ", __TIME__, ")"
276 .ascii CONFIG_IDENT_STRING, "\0"
277
278 .align 4
279 .globl _start_cont
280_start_cont:
wdenk9c53f402003-10-15 23:53:47 +0000281 /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
282 lis r1,CFG_INIT_RAM_ADDR@h
283 ori r1,r1,CFG_INIT_SP_OFFSET@l
284
285 li r0,0
286 stwu r0,-4(r1)
287 stwu r0,-4(r1) /* Terminate call chain */
288
289 stwu r1,-8(r1) /* Save back chain and move SP */
290 lis r0,RESET_VECTOR@h /* Address of reset vector */
Andy Flemingf08233c2007-08-14 01:34:21 -0500291 ori r0,r0,RESET_VECTOR@l
wdenk9c53f402003-10-15 23:53:47 +0000292 stwu r1,-8(r1) /* Save back chain and move SP */
293 stw r0,+12(r1) /* Save return addr (underflow vect) */
294
295 GET_GOT
Kumar Gala9772ee72008-01-16 22:38:34 -0600296 bl cpu_init_early_f
297
298 /* switch back to AS = 0 */
299 lis r3,(MSR_CE|MSR_ME|MSR_DE)@h
300 ori r3,r3,(MSR_CE|MSR_ME|MSR_DE)@l
301 mtmsr r3
302 isync
303
wdenk9c53f402003-10-15 23:53:47 +0000304 bl cpu_init_f
wdenk9c53f402003-10-15 23:53:47 +0000305 bl board_init_f
wdenk13eb2212004-07-09 23:27:13 +0000306 isync
wdenk9c53f402003-10-15 23:53:47 +0000307
Andy Flemingf08233c2007-08-14 01:34:21 -0500308 . = EXC_OFF_SYS_RESET
wdenk9c53f402003-10-15 23:53:47 +0000309 .globl _start_of_vectors
310_start_of_vectors:
Andy Flemingf08233c2007-08-14 01:34:21 -0500311
wdenk9c53f402003-10-15 23:53:47 +0000312/* Critical input. */
Andy Flemingf08233c2007-08-14 01:34:21 -0500313 CRIT_EXCEPTION(0x0100, CriticalInput, CritcalInputException)
314
315/* Machine check */
316 MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException)
wdenk9c53f402003-10-15 23:53:47 +0000317
318/* Data Storage exception. */
319 STD_EXCEPTION(0x0300, DataStorage, UnknownException)
320
321/* Instruction Storage exception. */
322 STD_EXCEPTION(0x0400, InstStorage, UnknownException)
323
324/* External Interrupt exception. */
Andy Flemingf08233c2007-08-14 01:34:21 -0500325 STD_EXCEPTION(0x0500, ExtInterrupt, ExtIntException)
wdenk9c53f402003-10-15 23:53:47 +0000326
327/* Alignment exception. */
328 . = 0x0600
329Alignment:
Rafal Jaworowski06244e42007-06-22 14:58:04 +0200330 EXCEPTION_PROLOG(SRR0, SRR1)
wdenk9c53f402003-10-15 23:53:47 +0000331 mfspr r4,DAR
332 stw r4,_DAR(r21)
333 mfspr r5,DSISR
334 stw r5,_DSISR(r21)
335 addi r3,r1,STACK_FRAME_OVERHEAD
336 li r20,MSR_KERNEL
337 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
338 lwz r6,GOT(transfer_to_handler)
339 mtlr r6
340 blrl
341.L_Alignment:
Andy Flemingf08233c2007-08-14 01:34:21 -0500342 .long AlignmentException - _start + _START_OFFSET
343 .long int_return - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000344
345/* Program check exception */
346 . = 0x0700
347ProgramCheck:
Rafal Jaworowski06244e42007-06-22 14:58:04 +0200348 EXCEPTION_PROLOG(SRR0, SRR1)
wdenk9c53f402003-10-15 23:53:47 +0000349 addi r3,r1,STACK_FRAME_OVERHEAD
350 li r20,MSR_KERNEL
351 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
352 lwz r6,GOT(transfer_to_handler)
353 mtlr r6
354 blrl
355.L_ProgramCheck:
Andy Flemingf08233c2007-08-14 01:34:21 -0500356 .long ProgramCheckException - _start + _START_OFFSET
357 .long int_return - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000358
359 /* No FPU on MPC85xx. This exception is not supposed to happen.
360 */
361 STD_EXCEPTION(0x0800, FPUnavailable, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000362
wdenkf3da7cc2005-05-13 22:49:36 +0000363 . = 0x0900
wdenk9c53f402003-10-15 23:53:47 +0000364/*
365 * r0 - SYSCALL number
366 * r3-... arguments
367 */
368SystemCall:
Andy Flemingf08233c2007-08-14 01:34:21 -0500369 addis r11,r0,0 /* get functions table addr */
370 ori r11,r11,0 /* Note: this code is patched in trap_init */
371 addis r12,r0,0 /* get number of functions */
wdenkf3da7cc2005-05-13 22:49:36 +0000372 ori r12,r12,0
wdenk9c53f402003-10-15 23:53:47 +0000373
Andy Flemingf08233c2007-08-14 01:34:21 -0500374 cmplw 0,r0,r12
wdenkf3da7cc2005-05-13 22:49:36 +0000375 bge 1f
wdenk9c53f402003-10-15 23:53:47 +0000376
Andy Flemingf08233c2007-08-14 01:34:21 -0500377 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */
wdenkf3da7cc2005-05-13 22:49:36 +0000378 add r11,r11,r0
379 lwz r11,0(r11)
wdenk9c53f402003-10-15 23:53:47 +0000380
Andy Flemingf08233c2007-08-14 01:34:21 -0500381 li r20,0xd00-4 /* Get stack pointer */
wdenkf3da7cc2005-05-13 22:49:36 +0000382 lwz r12,0(r20)
Andy Flemingf08233c2007-08-14 01:34:21 -0500383 subi r12,r12,12 /* Adjust stack pointer */
wdenkf3da7cc2005-05-13 22:49:36 +0000384 li r0,0xc00+_end_back-SystemCall
Andy Flemingf08233c2007-08-14 01:34:21 -0500385 cmplw 0,r0,r12 /* Check stack overflow */
wdenkf3da7cc2005-05-13 22:49:36 +0000386 bgt 1f
387 stw r12,0(r20)
wdenk9c53f402003-10-15 23:53:47 +0000388
wdenkf3da7cc2005-05-13 22:49:36 +0000389 mflr r0
390 stw r0,0(r12)
391 mfspr r0,SRR0
392 stw r0,4(r12)
393 mfspr r0,SRR1
394 stw r0,8(r12)
wdenk9c53f402003-10-15 23:53:47 +0000395
wdenkf3da7cc2005-05-13 22:49:36 +0000396 li r12,0xc00+_back-SystemCall
397 mtlr r12
398 mtspr SRR0,r11
wdenk9c53f402003-10-15 23:53:47 +0000399
wdenkf3da7cc2005-05-13 22:49:36 +00004001: SYNC
wdenk9c53f402003-10-15 23:53:47 +0000401 rfi
402_back:
403
wdenkf3da7cc2005-05-13 22:49:36 +0000404 mfmsr r11 /* Disable interrupts */
405 li r12,0
406 ori r12,r12,MSR_EE
407 andc r11,r11,r12
408 SYNC /* Some chip revs need this... */
409 mtmsr r11
wdenk9c53f402003-10-15 23:53:47 +0000410 SYNC
411
wdenkf3da7cc2005-05-13 22:49:36 +0000412 li r12,0xd00-4 /* restore regs */
413 lwz r12,0(r12)
wdenk9c53f402003-10-15 23:53:47 +0000414
wdenkf3da7cc2005-05-13 22:49:36 +0000415 lwz r11,0(r12)
416 mtlr r11
417 lwz r11,4(r12)
418 mtspr SRR0,r11
419 lwz r11,8(r12)
420 mtspr SRR1,r11
wdenk9c53f402003-10-15 23:53:47 +0000421
wdenkf3da7cc2005-05-13 22:49:36 +0000422 addi r12,r12,12 /* Adjust stack pointer */
423 li r20,0xd00-4
424 stw r12,0(r20)
wdenk9c53f402003-10-15 23:53:47 +0000425
426 SYNC
427 rfi
428_end_back:
429
wdenkf3da7cc2005-05-13 22:49:36 +0000430 STD_EXCEPTION(0x0a00, Decrementer, timer_interrupt)
431 STD_EXCEPTION(0x0b00, IntervalTimer, UnknownException)
432 STD_EXCEPTION(0x0c00, WatchdogTimer, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000433
wdenkf3da7cc2005-05-13 22:49:36 +0000434 STD_EXCEPTION(0x0d00, DataTLBError, UnknownException)
435 STD_EXCEPTION(0x0e00, InstructionTLBError, UnknownException)
wdenk9c53f402003-10-15 23:53:47 +0000436
wdenkf3da7cc2005-05-13 22:49:36 +0000437 CRIT_EXCEPTION(0x0f00, DebugBreakpoint, DebugException )
wdenk9c53f402003-10-15 23:53:47 +0000438
wdenkf3da7cc2005-05-13 22:49:36 +0000439 .globl _end_of_vectors
wdenk9c53f402003-10-15 23:53:47 +0000440_end_of_vectors:
441
442
Andy Flemingf08233c2007-08-14 01:34:21 -0500443 . = . + (0x100 - ( . & 0xff )) /* align for debug */
wdenk9c53f402003-10-15 23:53:47 +0000444
445/*
446 * This code finishes saving the registers to the exception frame
447 * and jumps to the appropriate handler for the exception.
448 * Register r21 is pointer into trap frame, r1 has new stack pointer.
449 */
450 .globl transfer_to_handler
451transfer_to_handler:
452 stw r22,_NIP(r21)
453 lis r22,MSR_POW@h
454 andc r23,r23,r22
455 stw r23,_MSR(r21)
456 SAVE_GPR(7, r21)
457 SAVE_4GPRS(8, r21)
458 SAVE_8GPRS(12, r21)
459 SAVE_8GPRS(24, r21)
460
461 mflr r23
462 andi. r24,r23,0x3f00 /* get vector offset */
463 stw r24,TRAP(r21)
464 li r22,0
465 stw r22,RESULT(r21)
466 mtspr SPRG2,r22 /* r1 is now kernel sp */
467
468 lwz r24,0(r23) /* virtual address of handler */
469 lwz r23,4(r23) /* where to go when done */
470 mtspr SRR0,r24
471 mtspr SRR1,r20
472 mtlr r23
473 SYNC
474 rfi /* jump to handler, enable MMU */
475
476int_return:
477 mfmsr r28 /* Disable interrupts */
478 li r4,0
479 ori r4,r4,MSR_EE
480 andc r28,r28,r4
481 SYNC /* Some chip revs need this... */
482 mtmsr r28
483 SYNC
484 lwz r2,_CTR(r1)
485 lwz r0,_LINK(r1)
486 mtctr r2
487 mtlr r0
488 lwz r2,_XER(r1)
489 lwz r0,_CCR(r1)
490 mtspr XER,r2
491 mtcrf 0xFF,r0
492 REST_10GPRS(3, r1)
493 REST_10GPRS(13, r1)
494 REST_8GPRS(23, r1)
495 REST_GPR(31, r1)
496 lwz r2,_NIP(r1) /* Restore environment */
497 lwz r0,_MSR(r1)
498 mtspr SRR0,r2
499 mtspr SRR1,r0
500 lwz r0,GPR0(r1)
501 lwz r2,GPR2(r1)
502 lwz r1,GPR1(r1)
503 SYNC
504 rfi
505
506crit_return:
507 mfmsr r28 /* Disable interrupts */
508 li r4,0
509 ori r4,r4,MSR_EE
510 andc r28,r28,r4
511 SYNC /* Some chip revs need this... */
512 mtmsr r28
513 SYNC
514 lwz r2,_CTR(r1)
515 lwz r0,_LINK(r1)
516 mtctr r2
517 mtlr r0
518 lwz r2,_XER(r1)
519 lwz r0,_CCR(r1)
520 mtspr XER,r2
521 mtcrf 0xFF,r0
522 REST_10GPRS(3, r1)
523 REST_10GPRS(13, r1)
524 REST_8GPRS(23, r1)
525 REST_GPR(31, r1)
526 lwz r2,_NIP(r1) /* Restore environment */
527 lwz r0,_MSR(r1)
Andy Flemingf08233c2007-08-14 01:34:21 -0500528 mtspr SPRN_CSRR0,r2
529 mtspr SPRN_CSRR1,r0
wdenk9c53f402003-10-15 23:53:47 +0000530 lwz r0,GPR0(r1)
531 lwz r2,GPR2(r1)
532 lwz r1,GPR1(r1)
533 SYNC
534 rfci
535
Andy Flemingf08233c2007-08-14 01:34:21 -0500536mck_return:
537 mfmsr r28 /* Disable interrupts */
538 li r4,0
539 ori r4,r4,MSR_EE
540 andc r28,r28,r4
541 SYNC /* Some chip revs need this... */
542 mtmsr r28
543 SYNC
544 lwz r2,_CTR(r1)
545 lwz r0,_LINK(r1)
546 mtctr r2
547 mtlr r0
548 lwz r2,_XER(r1)
549 lwz r0,_CCR(r1)
550 mtspr XER,r2
551 mtcrf 0xFF,r0
552 REST_10GPRS(3, r1)
553 REST_10GPRS(13, r1)
554 REST_8GPRS(23, r1)
555 REST_GPR(31, r1)
556 lwz r2,_NIP(r1) /* Restore environment */
557 lwz r0,_MSR(r1)
558 mtspr SPRN_MCSRR0,r2
559 mtspr SPRN_MCSRR1,r0
560 lwz r0,GPR0(r1)
561 lwz r2,GPR2(r1)
562 lwz r1,GPR1(r1)
563 SYNC
564 rfmci
565
wdenk9c53f402003-10-15 23:53:47 +0000566/* Cache functions.
567*/
568invalidate_icache:
569 mfspr r0,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500570 ori r0,r0,L1CSR1_ICFI
571 msync
572 isync
wdenk9c53f402003-10-15 23:53:47 +0000573 mtspr L1CSR1,r0
574 isync
Andy Flemingf08233c2007-08-14 01:34:21 -0500575 blr /* entire I cache */
wdenk9c53f402003-10-15 23:53:47 +0000576
577invalidate_dcache:
578 mfspr r0,L1CSR0
Andy Flemingf08233c2007-08-14 01:34:21 -0500579 ori r0,r0,L1CSR0_DCFI
wdenk9c53f402003-10-15 23:53:47 +0000580 msync
581 isync
582 mtspr L1CSR0,r0
583 isync
584 blr
585
586 .globl icache_enable
587icache_enable:
588 mflr r8
589 bl invalidate_icache
590 mtlr r8
591 isync
592 mfspr r4,L1CSR1
593 ori r4,r4,0x0001
594 oris r4,r4,0x0001
595 mtspr L1CSR1,r4
596 isync
597 blr
598
599 .globl icache_disable
600icache_disable:
601 mfspr r0,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500602 lis r3,0
603 ori r3,r3,L1CSR1_ICE
604 andc r0,r0,r3
wdenk9c53f402003-10-15 23:53:47 +0000605 mtspr L1CSR1,r0
606 isync
607 blr
608
609 .globl icache_status
610icache_status:
611 mfspr r3,L1CSR1
Andy Flemingf08233c2007-08-14 01:34:21 -0500612 andi. r3,r3,L1CSR1_ICE
wdenk9c53f402003-10-15 23:53:47 +0000613 blr
614
615 .globl dcache_enable
616dcache_enable:
617 mflr r8
618 bl invalidate_dcache
619 mtlr r8
620 isync
621 mfspr r0,L1CSR0
622 ori r0,r0,0x0001
623 oris r0,r0,0x0001
624 msync
625 isync
626 mtspr L1CSR0,r0
627 isync
628 blr
629
630 .globl dcache_disable
631dcache_disable:
Andy Flemingf08233c2007-08-14 01:34:21 -0500632 mfspr r3,L1CSR0
633 lis r4,0
634 ori r4,r4,L1CSR0_DCE
635 andc r3,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000636 mtspr L1CSR0,r0
637 isync
638 blr
639
640 .globl dcache_status
641dcache_status:
642 mfspr r3,L1CSR0
Andy Flemingf08233c2007-08-14 01:34:21 -0500643 andi. r3,r3,L1CSR0_DCE
wdenk9c53f402003-10-15 23:53:47 +0000644 blr
645
646 .globl get_pir
647get_pir:
Andy Flemingf08233c2007-08-14 01:34:21 -0500648 mfspr r3,PIR
wdenk9c53f402003-10-15 23:53:47 +0000649 blr
650
651 .globl get_pvr
652get_pvr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500653 mfspr r3,PVR
wdenk9c53f402003-10-15 23:53:47 +0000654 blr
655
wdenka445ddf2004-06-09 00:34:46 +0000656 .globl get_svr
657get_svr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500658 mfspr r3,SVR
wdenka445ddf2004-06-09 00:34:46 +0000659 blr
660
wdenk9c53f402003-10-15 23:53:47 +0000661 .globl wr_tcr
662wr_tcr:
Andy Flemingf08233c2007-08-14 01:34:21 -0500663 mtspr TCR,r3
wdenk9c53f402003-10-15 23:53:47 +0000664 blr
665
666/*------------------------------------------------------------------------------- */
667/* Function: in8 */
668/* Description: Input 8 bits */
669/*------------------------------------------------------------------------------- */
670 .globl in8
671in8:
672 lbz r3,0x0000(r3)
673 blr
674
675/*------------------------------------------------------------------------------- */
676/* Function: out8 */
677/* Description: Output 8 bits */
678/*------------------------------------------------------------------------------- */
679 .globl out8
680out8:
681 stb r4,0x0000(r3)
Ed Swarthout7d6be302007-09-26 16:35:54 -0500682 sync
wdenk9c53f402003-10-15 23:53:47 +0000683 blr
684
685/*------------------------------------------------------------------------------- */
686/* Function: out16 */
687/* Description: Output 16 bits */
688/*------------------------------------------------------------------------------- */
689 .globl out16
690out16:
691 sth r4,0x0000(r3)
Ed Swarthout7d6be302007-09-26 16:35:54 -0500692 sync
wdenk9c53f402003-10-15 23:53:47 +0000693 blr
694
695/*------------------------------------------------------------------------------- */
696/* Function: out16r */
697/* Description: Byte reverse and output 16 bits */
698/*------------------------------------------------------------------------------- */
699 .globl out16r
700out16r:
701 sthbrx r4,r0,r3
Ed Swarthout7d6be302007-09-26 16:35:54 -0500702 sync
wdenk9c53f402003-10-15 23:53:47 +0000703 blr
704
705/*------------------------------------------------------------------------------- */
706/* Function: out32 */
707/* Description: Output 32 bits */
708/*------------------------------------------------------------------------------- */
709 .globl out32
710out32:
711 stw r4,0x0000(r3)
Ed Swarthout7d6be302007-09-26 16:35:54 -0500712 sync
wdenk9c53f402003-10-15 23:53:47 +0000713 blr
714
715/*------------------------------------------------------------------------------- */
716/* Function: out32r */
717/* Description: Byte reverse and output 32 bits */
718/*------------------------------------------------------------------------------- */
719 .globl out32r
720out32r:
721 stwbrx r4,r0,r3
Ed Swarthout7d6be302007-09-26 16:35:54 -0500722 sync
wdenk9c53f402003-10-15 23:53:47 +0000723 blr
724
725/*------------------------------------------------------------------------------- */
726/* Function: in16 */
727/* Description: Input 16 bits */
728/*------------------------------------------------------------------------------- */
729 .globl in16
730in16:
731 lhz r3,0x0000(r3)
732 blr
733
734/*------------------------------------------------------------------------------- */
735/* Function: in16r */
736/* Description: Input 16 bits and byte reverse */
737/*------------------------------------------------------------------------------- */
738 .globl in16r
739in16r:
740 lhbrx r3,r0,r3
741 blr
742
743/*------------------------------------------------------------------------------- */
744/* Function: in32 */
745/* Description: Input 32 bits */
746/*------------------------------------------------------------------------------- */
747 .globl in32
748in32:
749 lwz 3,0x0000(3)
750 blr
751
752/*------------------------------------------------------------------------------- */
753/* Function: in32r */
754/* Description: Input 32 bits and byte reverse */
755/*------------------------------------------------------------------------------- */
756 .globl in32r
757in32r:
758 lwbrx r3,r0,r3
759 blr
760
wdenk9c53f402003-10-15 23:53:47 +0000761/*------------------------------------------------------------------------------*/
762
763/*
764 * void relocate_code (addr_sp, gd, addr_moni)
765 *
766 * This "function" does not return, instead it continues in RAM
767 * after relocating the monitor code.
768 *
769 * r3 = dest
770 * r4 = src
771 * r5 = length in bytes
772 * r6 = cachelinesize
773 */
774 .globl relocate_code
775relocate_code:
Andy Flemingf08233c2007-08-14 01:34:21 -0500776 mr r1,r3 /* Set new stack pointer */
777 mr r9,r4 /* Save copy of Init Data pointer */
778 mr r10,r5 /* Save copy of Destination Address */
wdenk9c53f402003-10-15 23:53:47 +0000779
Andy Flemingf08233c2007-08-14 01:34:21 -0500780 mr r3,r5 /* Destination Address */
781 lis r4,CFG_MONITOR_BASE@h /* Source Address */
782 ori r4,r4,CFG_MONITOR_BASE@l
wdenk9c53f402003-10-15 23:53:47 +0000783 lwz r5,GOT(__init_end)
784 sub r5,r5,r4
Andy Flemingf08233c2007-08-14 01:34:21 -0500785 li r6,CFG_CACHELINE_SIZE /* Cache Line Size */
wdenk9c53f402003-10-15 23:53:47 +0000786
787 /*
788 * Fix GOT pointer:
789 *
790 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
791 *
792 * Offset:
793 */
Andy Flemingf08233c2007-08-14 01:34:21 -0500794 sub r15,r10,r4
wdenk9c53f402003-10-15 23:53:47 +0000795
796 /* First our own GOT */
Andy Flemingf08233c2007-08-14 01:34:21 -0500797 add r14,r14,r15
wdenk9c53f402003-10-15 23:53:47 +0000798 /* the the one used by the C code */
Andy Flemingf08233c2007-08-14 01:34:21 -0500799 add r30,r30,r15
wdenk9c53f402003-10-15 23:53:47 +0000800
801 /*
802 * Now relocate code
803 */
804
805 cmplw cr1,r3,r4
806 addi r0,r5,3
807 srwi. r0,r0,2
808 beq cr1,4f /* In place copy is not necessary */
809 beq 7f /* Protect against 0 count */
810 mtctr r0
811 bge cr1,2f
812
813 la r8,-4(r4)
814 la r7,-4(r3)
8151: lwzu r0,4(r8)
816 stwu r0,4(r7)
817 bdnz 1b
818 b 4f
819
8202: slwi r0,r0,2
821 add r8,r4,r0
822 add r7,r3,r0
8233: lwzu r0,-4(r8)
824 stwu r0,-4(r7)
825 bdnz 3b
826
827/*
828 * Now flush the cache: note that we must start from a cache aligned
829 * address. Otherwise we might miss one cache line.
830 */
8314: cmpwi r6,0
832 add r5,r3,r5
833 beq 7f /* Always flush prefetch queue in any case */
834 subi r0,r6,1
835 andc r3,r3,r0
836 mr r4,r3
8375: dcbst 0,r4
838 add r4,r4,r6
839 cmplw r4,r5
840 blt 5b
841 sync /* Wait for all dcbst to complete on bus */
842 mr r4,r3
8436: icbi 0,r4
844 add r4,r4,r6
845 cmplw r4,r5
846 blt 6b
8477: sync /* Wait for all icbi to complete on bus */
848 isync
849
Wolfgang Denk29dcbd42005-10-05 00:00:54 +0200850 /*
851 * Re-point the IVPR at RAM
852 */
853 mtspr IVPR,r10
Wolfgang Denk9da240c2005-10-05 00:19:34 +0200854
wdenk9c53f402003-10-15 23:53:47 +0000855/*
856 * We are done. Do not return, instead branch to second part of board
857 * initialization, now running from RAM.
858 */
859
Andy Flemingf08233c2007-08-14 01:34:21 -0500860 addi r0,r10,in_ram - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +0000861 mtlr r0
862 blr /* NEVER RETURNS! */
Andy Flemingf08233c2007-08-14 01:34:21 -0500863 .globl in_ram
wdenk9c53f402003-10-15 23:53:47 +0000864in_ram:
865
866 /*
867 * Relocation Function, r14 point to got2+0x8000
868 *
869 * Adjust got2 pointers, no need to check for 0, this code
870 * already puts a few entries in the table.
871 */
872 li r0,__got2_entries@sectoff@l
873 la r3,GOT(_GOT2_TABLE_)
874 lwz r11,GOT(_GOT2_TABLE_)
875 mtctr r0
876 sub r11,r3,r11
877 addi r3,r3,-4
8781: lwzu r0,4(r3)
879 add r0,r0,r11
880 stw r0,0(r3)
881 bdnz 1b
882
883 /*
884 * Now adjust the fixups and the pointers to the fixups
885 * in case we need to move ourselves again.
886 */
8872: li r0,__fixup_entries@sectoff@l
888 lwz r3,GOT(_FIXUP_TABLE_)
889 cmpwi r0,0
890 mtctr r0
891 addi r3,r3,-4
892 beq 4f
8933: lwzu r4,4(r3)
894 lwzux r0,r4,r11
895 add r0,r0,r11
896 stw r10,0(r3)
897 stw r0,0(r4)
898 bdnz 3b
8994:
900clear_bss:
901 /*
902 * Now clear BSS segment
903 */
904 lwz r3,GOT(__bss_start)
905 lwz r4,GOT(_end)
906
Andy Flemingf08233c2007-08-14 01:34:21 -0500907 cmplw 0,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000908 beq 6f
909
Andy Flemingf08233c2007-08-14 01:34:21 -0500910 li r0,0
wdenk9c53f402003-10-15 23:53:47 +00009115:
Andy Flemingf08233c2007-08-14 01:34:21 -0500912 stw r0,0(r3)
913 addi r3,r3,4
914 cmplw 0,r3,r4
wdenk9c53f402003-10-15 23:53:47 +0000915 bne 5b
9166:
917
Andy Flemingf08233c2007-08-14 01:34:21 -0500918 mr r3,r9 /* Init Data pointer */
919 mr r4,r10 /* Destination Address */
wdenk9c53f402003-10-15 23:53:47 +0000920 bl board_init_r
921
922 /*
923 * Copy exception vector code to low memory
924 *
925 * r3: dest_addr
926 * r7: source address, r8: end address, r9: target address
927 */
wdenkf3da7cc2005-05-13 22:49:36 +0000928 .globl trap_init
wdenk9c53f402003-10-15 23:53:47 +0000929trap_init:
Andy Flemingf08233c2007-08-14 01:34:21 -0500930 lwz r7,GOT(_start_of_vectors)
931 lwz r8,GOT(_end_of_vectors)
wdenk9c53f402003-10-15 23:53:47 +0000932
Andy Flemingf08233c2007-08-14 01:34:21 -0500933 li r9,0x100 /* reset vector always at 0x100 */
wdenk9c53f402003-10-15 23:53:47 +0000934
Andy Flemingf08233c2007-08-14 01:34:21 -0500935 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +0000936 bgelr /* return if r7>=r8 - just in case */
wdenk9c53f402003-10-15 23:53:47 +0000937
wdenkf3da7cc2005-05-13 22:49:36 +0000938 mflr r4 /* save link register */
wdenk9c53f402003-10-15 23:53:47 +00009391:
Andy Flemingf08233c2007-08-14 01:34:21 -0500940 lwz r0,0(r7)
941 stw r0,0(r9)
942 addi r7,r7,4
943 addi r9,r9,4
944 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +0000945 bne 1b
wdenk9c53f402003-10-15 23:53:47 +0000946
947 /*
948 * relocate `hdlr' and `int_return' entries
949 */
Andy Flemingf08233c2007-08-14 01:34:21 -0500950 li r7,.L_CriticalInput - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000951 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500952 li r7,.L_MachineCheck - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000953 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500954 li r7,.L_DataStorage - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000955 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500956 li r7,.L_InstStorage - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000957 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500958 li r7,.L_ExtInterrupt - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000959 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500960 li r7,.L_Alignment - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000961 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500962 li r7,.L_ProgramCheck - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000963 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500964 li r7,.L_FPUnavailable - _start + _START_OFFSET
wdenkf3da7cc2005-05-13 22:49:36 +0000965 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500966 li r7,.L_Decrementer - _start + _START_OFFSET
967 bl trap_reloc
968 li r7,.L_IntervalTimer - _start + _START_OFFSET
969 li r8,_end_of_vectors - _start + _START_OFFSET
wdenk9c53f402003-10-15 23:53:47 +00009702:
wdenkf3da7cc2005-05-13 22:49:36 +0000971 bl trap_reloc
Andy Flemingf08233c2007-08-14 01:34:21 -0500972 addi r7,r7,0x100 /* next exception vector */
973 cmplw 0,r7,r8
wdenkf3da7cc2005-05-13 22:49:36 +0000974 blt 2b
wdenk9c53f402003-10-15 23:53:47 +0000975
wdenkf3da7cc2005-05-13 22:49:36 +0000976 lis r7,0x0
Andy Flemingf08233c2007-08-14 01:34:21 -0500977 mtspr IVPR,r7
wdenk9c53f402003-10-15 23:53:47 +0000978
wdenkf3da7cc2005-05-13 22:49:36 +0000979 mtlr r4 /* restore link register */
wdenk9c53f402003-10-15 23:53:47 +0000980 blr
981
982 /*
983 * Function: relocate entries for one exception vector
984 */
985trap_reloc:
Andy Flemingf08233c2007-08-14 01:34:21 -0500986 lwz r0,0(r7) /* hdlr ... */
987 add r0,r0,r3 /* ... += dest_addr */
988 stw r0,0(r7)
wdenk9c53f402003-10-15 23:53:47 +0000989
Andy Flemingf08233c2007-08-14 01:34:21 -0500990 lwz r0,4(r7) /* int_return ... */
991 add r0,r0,r3 /* ... += dest_addr */
992 stw r0,4(r7)
wdenk9c53f402003-10-15 23:53:47 +0000993
994 blr
995
wdenk9c53f402003-10-15 23:53:47 +0000996.globl unlock_ram_in_cache
997unlock_ram_in_cache:
998 /* invalidate the INIT_RAM section */
Andy Flemingf08233c2007-08-14 01:34:21 -0500999 lis r3,(CFG_INIT_RAM_ADDR & ~31)@h
1000 ori r3,r3,(CFG_INIT_RAM_ADDR & ~31)@l
Kumar Gala938e14e2008-01-08 01:22:21 -06001001 mfspr r4,L1CFG0
1002 andi. r4,r4,0x1ff
1003 slwi r4,r4,(10 - 1 - L1_CACHE_SHIFT)
Andy Flemingf08233c2007-08-14 01:34:21 -05001004 mtctr r4
Kumar Gala2a441212008-02-27 16:30:47 -060010051: dcbi r0,r3
Kumar Gala91510e02007-10-02 11:12:27 -05001006 addi r3,r3,CFG_CACHELINE_SIZE
wdenk9c53f402003-10-15 23:53:47 +00001007 bdnz 1b
Kumar Gala2a441212008-02-27 16:30:47 -06001008 sync
Andy Fleming5ba61fe2008-02-27 14:29:58 -06001009
1010 /* Invalidate the TLB entries for the cache */
1011 lis r3,CFG_INIT_RAM_ADDR@h
1012 ori r3,r3,CFG_INIT_RAM_ADDR@l
1013 tlbivax 0,r3
1014 addi r3,r3,0x1000
1015 tlbivax 0,r3
1016 addi r3,r3,0x1000
1017 tlbivax 0,r3
1018 addi r3,r3,0x1000
1019 tlbivax 0,r3
wdenk9c53f402003-10-15 23:53:47 +00001020 isync
1021 blr