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/assembler.h>
18 #include "proc-macros.S"
21 * The size of one data cache line.
23 #define CACHE_DLINESIZE 32
26 * The number of data cache segments.
28 #define CACHE_DSEGMENTS 8
31 * The number of lines in a cache segment.
33 #define CACHE_DENTRIES 64
36 * This is the size at which it becomes more efficient to
37 * clean the whole cache, rather than using the individual
38 * cache line maintenance instructions.
40 * *** This needs benchmarking
42 #define CACHE_DLIMIT 16384
47 * Unconditionally clean and invalidate the entire icache.
49 ENTRY(v4wt_flush_icache_all)
51 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
53 ENDPROC(v4wt_flush_icache_all)
56 * flush_user_cache_all()
58 * Invalidate all cache entries in a particular address
61 ENTRY(v4wt_flush_user_cache_all)
64 * flush_kern_cache_all()
66 * Clean and invalidate the entire cache.
68 ENTRY(v4wt_flush_kern_cache_all)
73 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
74 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
78 * flush_user_cache_range(start, end, flags)
80 * Clean and invalidate a range of cache entries in the specified
83 * - start - start address (inclusive, page aligned)
84 * - end - end address (exclusive, page aligned)
85 * - flags - vma_area_struct flags describing address space
87 ENTRY(v4wt_flush_user_cache_range)
88 sub r3, r1, r0 @ calculate total size
90 bhs __flush_whole_cache
92 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
94 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
95 add r0, r0, #CACHE_DLINESIZE
101 * coherent_kern_range(start, end)
103 * Ensure coherency between the Icache and the Dcache in the
104 * region described by start. If you have non-snooping
105 * Harvard caches, you need to implement this function.
107 * - start - virtual start address
108 * - end - virtual end address
110 ENTRY(v4wt_coherent_kern_range)
114 * coherent_user_range(start, end)
116 * Ensure coherency between the Icache and the Dcache in the
117 * region described by start. If you have non-snooping
118 * Harvard caches, you need to implement this function.
120 * - start - virtual start address
121 * - end - virtual end address
123 ENTRY(v4wt_coherent_user_range)
124 bic r0, r0, #CACHE_DLINESIZE - 1
125 1: mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
126 add r0, r0, #CACHE_DLINESIZE
133 * flush_kern_dcache_area(void *addr, size_t size)
135 * Ensure no D cache aliasing occurs, either with itself or
138 * - addr - kernel address
139 * - size - region size
141 ENTRY(v4wt_flush_kern_dcache_area)
143 mcr p15, 0, r2, c7, c5, 0 @ invalidate I cache
148 * dma_inv_range(start, end)
150 * Invalidate (discard) the specified virtual address range.
151 * May not write back any entries. If 'start' or 'end'
152 * are not cache line aligned, those lines must be written
155 * - start - virtual start address
156 * - end - virtual end address
159 bic r0, r0, #CACHE_DLINESIZE - 1
160 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
161 add r0, r0, #CACHE_DLINESIZE
167 * dma_flush_range(start, end)
169 * Clean and invalidate the specified virtual address range.
171 * - start - virtual start address
172 * - end - virtual end address
174 .globl v4wt_dma_flush_range
175 .equ v4wt_dma_flush_range, v4wt_dma_inv_range
178 * dma_unmap_area(start, size, dir)
179 * - start - kernel virtual start address
180 * - size - size of region
181 * - dir - DMA direction
183 ENTRY(v4wt_dma_unmap_area)
185 teq r2, #DMA_TO_DEVICE
186 bne v4wt_dma_inv_range
190 * dma_map_area(start, size, dir)
191 * - start - kernel virtual start address
192 * - size - size of region
193 * - dir - DMA direction
195 ENTRY(v4wt_dma_map_area)
197 ENDPROC(v4wt_dma_unmap_area)
198 ENDPROC(v4wt_dma_map_area)
200 .globl v4wt_flush_kern_cache_louis
201 .equ v4wt_flush_kern_cache_louis, v4wt_flush_kern_cache_all
205 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
206 define_cache_functions v4wt