3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * Author: Igor Lisitsin <igor@emcraft.com>
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <ppc_asm.tmpl>
33 #include <asm/cache.h>
36 #if CONFIG_POST & CFG_POST_CACHE
40 /* void cache_post_disable (int tlb)
44 ori r0, r0, TLB_WORD2_I_ENABLE@l
50 /* void cache_post_wt (int tlb)
54 ori r0, r0, TLB_WORD2_W_ENABLE@l
55 andi. r0, r0, ~TLB_WORD2_I_ENABLE@l
61 /* void cache_post_wb (int tlb)
65 andi. r0, r0, ~TLB_WORD2_W_ENABLE@l
66 andi. r0, r0, ~TLB_WORD2_I_ENABLE@l
72 /* void cache_post_dinvalidate (void *p, int size)
74 cache_post_dinvalidate:
76 addi r3, r3, CFG_CACHELINE_SIZE
77 subic. r4, r4, CFG_CACHELINE_SIZE
78 bgt cache_post_dinvalidate
82 /* void cache_post_dstore (void *p, int size)
86 addi r3, r3, CFG_CACHELINE_SIZE
87 subic. r4, r4, CFG_CACHELINE_SIZE
92 /* void cache_post_dtouch (void *p, int size)
96 addi r3, r3, CFG_CACHELINE_SIZE
97 subic. r4, r4, CFG_CACHELINE_SIZE
102 /* void cache_post_iinvalidate (void)
104 cache_post_iinvalidate:
109 /* void cache_post_memset (void *p, int val, int size)
119 /* int cache_post_check (void *p, int size)
135 #define CACHE_POST_DISABLE() \
137 bl cache_post_disable
139 #define CACHE_POST_WT() \
143 #define CACHE_POST_WB() \
147 #define CACHE_POST_DINVALIDATE() \
150 bl cache_post_dinvalidate
152 #define CACHE_POST_DFLUSH() \
157 #define CACHE_POST_DSTORE() \
162 #define CACHE_POST_DTOUCH() \
167 #define CACHE_POST_IINVALIDATE() \
168 bl cache_post_iinvalidate
170 #define CACHE_POST_MEMSET(val) \
176 #define CACHE_POST_CHECK() \
179 bl cache_post_check; \
183 * Write and read 0xff pattern with caching enabled.
185 .global cache_post_test1
190 mr r12, r5 /* size */
193 CACHE_POST_DINVALIDATE()
195 /* Write the negative pattern to the test area */
196 CACHE_POST_MEMSET(0xff)
198 /* Read the test area */
201 CACHE_POST_DINVALIDATE()
209 * Write zeroes with caching enabled.
210 * Write 0xff pattern with caching disabled.
211 * Read 0xff pattern with caching enabled.
213 .global cache_post_test2
218 mr r12, r5 /* size */
221 CACHE_POST_DINVALIDATE()
223 /* Write the zero pattern to the test area */
226 CACHE_POST_DINVALIDATE()
229 /* Write the negative pattern to the test area */
230 CACHE_POST_MEMSET(0xff)
234 /* Read the test area */
237 CACHE_POST_DINVALIDATE()
245 * Write-through mode test.
246 * Write zeroes, store the cache, write 0xff pattern.
247 * Invalidate the cache.
248 * Check that 0xff pattern is read.
250 .global cache_post_test3
255 mr r12, r5 /* size */
258 CACHE_POST_DINVALIDATE()
260 /* Cache the test area */
263 /* Write the zero pattern to the test area */
268 /* Write the negative pattern to the test area */
269 CACHE_POST_MEMSET(0xff)
271 CACHE_POST_DINVALIDATE()
274 /* Read the test area */
282 * Write-back mode test.
283 * Write 0xff pattern, store the cache, write zeroes.
284 * Invalidate the cache.
285 * Check that 0xff pattern is read.
287 .global cache_post_test4
292 mr r12, r5 /* size */
295 CACHE_POST_DINVALIDATE()
297 /* Cache the test area */
300 /* Write the negative pattern to the test area */
301 CACHE_POST_MEMSET(0xff)
305 /* Write the zero pattern to the test area */
308 CACHE_POST_DINVALIDATE()
311 /* Read the test area */
319 * Load the test instructions into the instruction cache.
320 * Replace the test instructions.
321 * Check that the original instructions are executed.
323 .global cache_post_test5
328 mr r12, r5 /* size */
331 CACHE_POST_IINVALIDATE()
333 /* Compute r13 = cache_post_test_inst */
334 bl cache_post_test5_reloc
335 cache_post_test5_reloc:
337 lis r0, (cache_post_test_inst - cache_post_test5_reloc)@h
338 ori r0, r0, (cache_post_test_inst - cache_post_test5_reloc)@l
341 /* Copy the test instructions to the test area */
348 /* Invalidate the cache line */
353 /* Execute the test instructions */
357 /* Replace the test instruction */
362 /* Do not invalidate the cache line */
365 /* Execute the test instructions */
370 CACHE_POST_IINVALIDATE()
371 CACHE_POST_DINVALIDATE()
379 * Load the test instructions into the instruction cache.
380 * Replace the test instructions and invalidate the cache.
381 * Check that the replaced instructions are executed.
383 .global cache_post_test6
388 mr r12, r5 /* size */
391 CACHE_POST_IINVALIDATE()
393 /* Compute r13 = cache_post_test_inst */
394 bl cache_post_test6_reloc
395 cache_post_test6_reloc:
397 lis r0, (cache_post_test_inst - cache_post_test6_reloc)@h
398 ori r0, r0, (cache_post_test_inst - cache_post_test6_reloc)@l
401 /* Copy the test instructions to the test area */
408 /* Invalidate the cache line */
413 /* Execute the test instructions */
417 /* Replace the test instruction */
422 /* Invalidate the cache line */
427 /* Execute the test instructions */
432 CACHE_POST_IINVALIDATE()
433 CACHE_POST_DINVALIDATE()
440 /* Test instructions.
442 cache_post_test_inst:
447 #endif /* CONFIG_POST & CFG_POST_CACHE */
448 #endif /* CONFIG_POST */