2 * linux/arch/arm/mm/cache-v4wt.S
4 * Copyright (C) 1997-2002 Russell king
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * ARMv4 write through cache operations support.
12 * We assume that the write buffer is not enabled.
14 #include <linux/linkage.h>
15 #include <linux/init.h>
16 #include <asm/hardware.h>
18 #include "proc-macros.S"
21 * The size of one data cache line.
23 // following mask by Victor Yu. 06-06-2005
25 #define CACHE_DLINESIZE 32
26 // following add by Victor Yu. 06-06-2005
28 #define CACHE_DLINESIZE 16
32 * The number of data cache segments.
34 #define CACHE_DSEGMENTS 8
37 * The number of lines in a cache segment.
39 #define CACHE_DENTRIES 64
42 * This is the size at which it becomes more efficient to
43 * clean the whole cache, rather than using the individual
44 * cache line maintainence instructions.
46 * *** This needs benchmarking
48 #define CACHE_DLIMIT 16384
51 * flush_user_cache_all()
53 * Invalidate all cache entries in a particular address
56 ENTRY(v4wt_flush_user_cache_all)
59 * flush_kern_cache_all()
61 * Clean and invalidate the entire cache.
63 ENTRY(v4wt_flush_kern_cache_all)
68 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
69 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
73 * flush_user_cache_range(start, end, flags)
75 * Clean and invalidate a range of cache entries in the specified
78 * - start - start address (inclusive, page aligned)
79 * - end - end address (exclusive, page aligned)
80 * - flags - vma_area_struct flags describing address space
82 ENTRY(v4wt_flush_user_cache_range)
83 sub r3, r1, r0 @ calculate total size
85 bhs __flush_whole_cache
87 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
89 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
90 add r0, r0, #CACHE_DLINESIZE
96 * coherent_kern_range(start, end)
98 * Ensure coherency between the Icache and the Dcache in the
99 * region described by start. If you have non-snooping
100 * Harvard caches, you need to implement this function.
102 * - start - virtual start address
103 * - end - virtual end address
105 ENTRY(v4wt_coherent_kern_range)
109 * coherent_user_range(start, end)
111 * Ensure coherency between the Icache and the Dcache in the
112 * region described by start. If you have non-snooping
113 * Harvard caches, you need to implement this function.
115 * - start - virtual start address
116 * - end - virtual end address
118 ENTRY(v4wt_coherent_user_range)
119 bic r0, r0, #CACHE_DLINESIZE - 1
120 1: mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
121 add r0, r0, #CACHE_DLINESIZE
127 * flush_kern_dcache_page(void *page)
129 * Ensure no D cache aliasing occurs, either with itself or
132 * - addr - page aligned address
134 ENTRY(v4wt_flush_kern_dcache_page)
136 mcr p15, 0, r2, c7, c5, 0 @ invalidate I cache
141 * dma_inv_range(start, end)
143 * Invalidate (discard) the specified virtual address range.
144 * May not write back any entries. If 'start' or 'end'
145 * are not cache line aligned, those lines must be written
148 * - start - virtual start address
149 * - end - virtual end address
151 ENTRY(v4wt_dma_inv_range)
152 bic r0, r0, #CACHE_DLINESIZE - 1
153 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
154 add r0, r0, #CACHE_DLINESIZE
160 * dma_clean_range(start, end)
162 * Clean the specified virtual address range.
164 * - start - virtual start address
165 * - end - virtual end address
167 ENTRY(v4wt_dma_clean_range)
171 * dma_flush_range(start, end)
173 * Clean and invalidate the specified virtual address range.
175 * - start - virtual start address
176 * - end - virtual end address
178 .globl v4wt_dma_flush_range
179 .equ v4wt_dma_flush_range, v4wt_dma_inv_range
183 .type v4wt_cache_fns, #object
184 ENTRY(v4wt_cache_fns)
185 .long v4wt_flush_kern_cache_all
186 .long v4wt_flush_user_cache_all
187 .long v4wt_flush_user_cache_range
188 .long v4wt_coherent_kern_range
189 .long v4wt_coherent_user_range
190 .long v4wt_flush_kern_dcache_page
191 .long v4wt_dma_inv_range
192 .long v4wt_dma_clean_range
193 .long v4wt_dma_flush_range
194 .size v4wt_cache_fns, . - v4wt_cache_fns