1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <config.h>
16#include <config.h>
17#include <ppc4xx.h>
18#include <ppc_asm.tmpl>
19#include <ppc_defs.h>
20#include <asm/cache.h>
21#include <asm/mmu.h>
22
23
24
25
26_GLOBAL(invalidate_icache)
27 iccci r0,r0
28 isync
29 blr
30
31
32
33
34
35
36
37_GLOBAL(flush_icache_range)
38 li r5,L1_CACHE_BYTES-1
39 andc r3,r3,r5
40 subf r4,r3,r4
41 add r4,r4,r5
42 srwi. r4,r4,L1_CACHE_SHIFT
43 beqlr
44 mtctr r4
45 mr r6,r3
461: dcbst 0,r3
47 addi r3,r3,L1_CACHE_BYTES
48 bdnz 1b
49 sync
50 mtctr r4
512: icbi 0,r6
52 addi r6,r6,L1_CACHE_BYTES
53 bdnz 2b
54 sync
55 isync
56 blr
57
58
59
60
61
62
63
64
65_GLOBAL(clean_dcache_range)
66 li r5,L1_CACHE_BYTES-1
67 andc r3,r3,r5
68 subf r4,r3,r4
69 add r4,r4,r5
70 srwi. r4,r4,L1_CACHE_SHIFT
71 beqlr
72 mtctr r4
73
741: dcbst 0,r3
75 addi r3,r3,L1_CACHE_BYTES
76 bdnz 1b
77 sync
78 blr
79
80
81
82
83
84
85
86_GLOBAL(flush_dcache_range)
87 li r5,L1_CACHE_BYTES-1
88 andc r3,r3,r5
89 subf r4,r3,r4
90 add r4,r4,r5
91 srwi. r4,r4,L1_CACHE_SHIFT
92 beqlr
93 mtctr r4
94
951: dcbf 0,r3
96 addi r3,r3,L1_CACHE_BYTES
97 bdnz 1b
98 sync
99 blr
100
101
102
103
104
105
106
107
108_GLOBAL(invalidate_dcache_range)
109 li r5,L1_CACHE_BYTES-1
110 andc r3,r3,r5
111 subf r4,r3,r4
112 add r4,r4,r5
113 srwi. r4,r4,L1_CACHE_SHIFT
114 beqlr
115 mtctr r4
116
1171: dcbi 0,r3
118 addi r3,r3,L1_CACHE_BYTES
119 bdnz 1b
120 sync
121 blr
122
123
124
125
126
127
128
129
130#define CACHE_NWAYS 64
131#define CACHE_NLINES 32
132
133_GLOBAL(flush_dcache)
134 li r4,(2 * CACHE_NWAYS * CACHE_NLINES)
135 mtctr r4
136 lis r5,0
1371: lwz r3,0(r5)
138 addi r5,r5,L1_CACHE_BYTES
139 bdnz 1b
140 sync
141 blr
142
143_GLOBAL(invalidate_dcache)
144 addi r6,0,0x0000
145
146 lis r7,(CONFIG_SYS_DCACHE_SIZE / L1_CACHE_BYTES / 2)@ha
147 ori r7,r7,(CONFIG_SYS_DCACHE_SIZE / L1_CACHE_BYTES / 2)@l
148
149 mtctr r7
150..dcloop:
151 dccci 0,r6
152 addi r6,r6,L1_CACHE_BYTES
153 bdnz ..dcloop
154 sync
155 blr
156
157
158
159
160
161
162
163
164
165
166#ifdef CONFIG_440
167
168 .globl dcache_disable
169 .globl dcache_enable
170 .globl icache_disable
171 .globl icache_enable
172dcache_disable:
173dcache_enable:
174icache_disable:
175icache_enable:
176 blr
177
178 .globl dcache_status
179 .globl icache_status
180dcache_status:
181icache_status:
182 mr r3, 0
183 blr
184
185#else
186
187 .globl icache_enable
188icache_enable:
189 mflr r8
190 bl invalidate_icache
191 mtlr r8
192 isync
193 addis r3,r0, 0xc000
194 mticcr r3
195 blr
196
197 .globl icache_disable
198icache_disable:
199 addis r3,r0, 0x0000
200 mticcr r3
201 isync
202 blr
203
204 .globl icache_status
205icache_status:
206 mficcr r3
207 srwi r3, r3, 31
208 blr
209
210 .globl dcache_enable
211dcache_enable:
212 mflr r8
213 bl invalidate_dcache
214 mtlr r8
215 isync
216 addis r3,r0, 0x8000
217 mtdccr r3
218 blr
219
220 .globl dcache_disable
221dcache_disable:
222 mflr r8
223 bl flush_dcache
224 mtlr r8
225 addis r3,r0, 0x0000
226 mtdccr r3
227 blr
228
229 .globl dcache_status
230dcache_status:
231 mfdccr r3
232 srwi r3, r3, 31
233 blr
234
235#endif
236