2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
24 * This source code has been made available to you by IBM on an AS-IS
25 * basis. Anyone receiving this source is licensed under IBM
26 * copyrights to use it in any way he or she deems fit, including
27 * copying it, modifying it, compiling it, and redistributing it either
28 * with or without modifications. No license under IBM patents or
29 * patent applications is to be implied by the copyright license.
31 * Any user of this software should understand that IBM cannot provide
32 * technical support for this software and will not be responsible for
33 * any consequences resulting from the use of this software.
35 * Any person who transfers this source code or any derivative work
36 * must include the IBM copyright notice, this paragraph, and the
37 * preceding two paragraphs in the transferred software.
39 * COPYRIGHT I B M CORPORATION 1995
40 * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
44 #include <ppc_asm.tmpl>
46 #define CACHELINE_SIZE 32 /* 32 bytes (8 words) */
51 .globl invalidate_icache
53 iccci r0,r0 /* for 405, iccci invalidates the */
54 blr /* entire I cache */
56 .globl invalidate_dcache
58 li r6,0x0000 /* clear GPR 6 */
59 /* Do loop for # of dcache congruence classes. */
60 li r7,(CONFIG_DCACHE_RAM_SIZE / CACHELINE_SIZE / 2)
61 /* NOTE: dccci invalidates both */
62 mtctr r7 /* ways in the D cache */
64 dccci 0,r6 /* invalidate line */
65 addi r6,r6, CACHELINE_SIZE /* bump to next line */
71 lis r9,0x0002 /* set mask for EE and CE msr bits */
73 mfmsr r12 /* save msr */
75 mtmsr r9 /* disable EE and CE */
76 li r10,0x0001 /* enable data cache for unused memory */
77 mfdccr r9 /* region 0xF8000000-0xFFFFFFFF via */
78 or r10,r10,r9 /* bit 31 in dccr */
81 /* do loop for # of congruence classes. */
82 li r10,(CONFIG_DCACHE_RAM_SIZE / CACHELINE_SIZE / 2)
83 li r11,(CONFIG_DCACHE_RAM_SIZE / 2) /* D cache set size - 2 way sets */
85 li r10,(0xE000-0x10000) /* start at 0xFFFFE000 */
86 add r11,r10,r11 /* add to get to other side of cache line */
88 lwz r3,0(r10) /* least recently used side */
89 lwz r3,0(r11) /* the other side */
90 dccci r0,r11 /* invalidate both sides */
91 addi r10,r10,CACHELINE_SIZE /* bump to next line */
92 addi r11,r11,CACHELINE_SIZE /* bump to next line */
94 sync /* allow memory access to complete */
95 mtdccr r9 /* restore dccr */
96 mtmsr r12 /* restore msr */
105 lis r3,0x8000 /* set bit 0 */
109 .globl icache_disable
111 lis r3,0x0000 /* clear bit 0 */
119 srwi r3, r3, 31 /* >>31 => select bit 0 */
128 lis r3,0x8000 /* set bit 0 */
132 .globl dcache_disable
137 lis r3,0x0000 /* clear bit 0 */
144 srwi r3, r3, 31 /* >>31 => select bit 0 */
147 /*------------------------------------------------------------------------------- */
148 /* Function: ppcDcbf */
149 /* Description: Data Cache block flush */
150 /* Input: r3 = effective address */
152 /*------------------------------------------------------------------------------- */
158 /*------------------------------------------------------------------------------- */
159 /* Function: ppcDcbi */
160 /* Description: Data Cache block Invalidate */
161 /* Input: r3 = effective address */
163 /*------------------------------------------------------------------------------- */
169 /*------------------------------------------------------------------------------- */
170 /* Function: ppcSync */
171 /* Description: Processor Synchronize */
174 /*------------------------------------------------------------------------------- */