2 * linux/arch/arm/mm/cache-v6.S
4 * Copyright (C) 2001 Deep Blue Solutions Ltd.
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 * This is the "shell" of the ARMv6 processor support.
12 #include <linux/linkage.h>
13 #include <linux/init.h>
14 #include <asm/assembler.h>
16 #include "proc-macros.S"
19 #define CACHE_LINE_SIZE 32
20 #define D_CACHE_LINE_SIZE 32
21 #define BTB_FLUSH_SIZE 8
24 * v6_flush_cache_all()
26 * Flush the entire cache.
30 ENTRY(v6_flush_kern_cache_all)
33 mcr p15, 0, r0, c7, c14, 0 @ D cache clean+invalidate
34 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
36 mcr p15, 0, r0, c7, c15, 0 @ Cache clean+invalidate
41 * v6_flush_cache_all()
43 * Flush all TLB entries in a particular address space
45 * - mm - mm_struct describing address space
47 ENTRY(v6_flush_user_cache_all)
51 * v6_flush_cache_range(start, end, flags)
53 * Flush a range of TLB entries in the specified address space.
55 * - start - start address (may not be aligned)
56 * - end - end address (exclusive, may not be aligned)
57 * - flags - vm_area_struct flags describing address space
60 * - we have a VIPT cache.
62 ENTRY(v6_flush_user_cache_range)
66 * v6_coherent_kern_range(start,end)
68 * Ensure that the I and D caches are coherent within specified
69 * region. This is typically used when code has been written to
70 * a memory region, and will be executed.
72 * - start - virtual start address of region
73 * - end - virtual end address of region
76 * - the Icache does not read data from the write buffer
78 ENTRY(v6_coherent_kern_range)
82 * v6_coherent_user_range(start,end)
84 * Ensure that the I and D caches are coherent within specified
85 * region. This is typically used when code has been written to
86 * a memory region, and will be executed.
88 * - start - virtual start address of region
89 * - end - virtual end address of region
92 * - the Icache does not read data from the write buffer
94 ENTRY(v6_coherent_user_range)
97 bic r0, r0, #CACHE_LINE_SIZE - 1
98 1: mcr p15, 0, r0, c7, c10, 1 @ clean D line
99 mcr p15, 0, r0, c7, c5, 1 @ invalidate I line
100 add r0, r0, #CACHE_LINE_SIZE
104 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB
107 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
112 * v6_flush_kern_dcache_page(kaddr)
114 * Ensure that the data held in the page kaddr is written back
115 * to the page in question.
117 * - kaddr - kernel address (guaranteed to be page aligned)
119 ENTRY(v6_flush_kern_dcache_page)
123 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
125 mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate unified line
127 add r0, r0, #D_CACHE_LINE_SIZE
132 mcr p15, 0, r0, c7, c10, 4
138 * v6_dma_inv_range(start,end)
140 * Invalidate the data cache within the specified region; we will
141 * be performing a DMA operation in this region and we want to
142 * purge old data in the cache.
144 * - start - virtual start address of region
145 * - end - virtual end address of region
147 ENTRY(v6_dma_inv_range)
148 tst r0, #D_CACHE_LINE_SIZE - 1
149 bic r0, r0, #D_CACHE_LINE_SIZE - 1
151 mcrne p15, 0, r0, c7, c10, 1 @ clean D line
153 mcrne p15, 0, r0, c7, c11, 1 @ clean unified line
155 tst r1, #D_CACHE_LINE_SIZE - 1
156 bic r1, r1, #D_CACHE_LINE_SIZE - 1
158 mcrne p15, 0, r1, c7, c14, 1 @ clean & invalidate D line
160 mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line
164 mcr p15, 0, r0, c7, c6, 1 @ invalidate D line
166 mcr p15, 0, r0, c7, c7, 1 @ invalidate unified line
168 add r0, r0, #D_CACHE_LINE_SIZE
172 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
176 * v6_dma_clean_range(start,end)
177 * - start - virtual start address of region
178 * - end - virtual end address of region
180 ENTRY(v6_dma_clean_range)
181 bic r0, r0, #D_CACHE_LINE_SIZE - 1
184 mcr p15, 0, r0, c7, c10, 1 @ clean D line
186 mcr p15, 0, r0, c7, c11, 1 @ clean unified line
188 add r0, r0, #D_CACHE_LINE_SIZE
192 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
196 * v6_dma_flush_range(start,end)
197 * - start - virtual start address of region
198 * - end - virtual end address of region
200 ENTRY(v6_dma_flush_range)
201 bic r0, r0, #D_CACHE_LINE_SIZE - 1
204 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
206 mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate line
208 add r0, r0, #D_CACHE_LINE_SIZE
212 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
217 .type v6_cache_fns, #object
219 .long v6_flush_kern_cache_all
220 .long v6_flush_user_cache_all
221 .long v6_flush_user_cache_range
222 .long v6_coherent_kern_range
223 .long v6_coherent_user_range
224 .long v6_flush_kern_dcache_page
225 .long v6_dma_inv_range
226 .long v6_dma_clean_range
227 .long v6_dma_flush_range
228 .size v6_cache_fns, . - v6_cache_fns