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 add r0, r0, #CACHE_LINE_SIZE
105 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
106 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
108 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB
113 * v6_flush_kern_dcache_page(kaddr)
115 * Ensure that the data held in the page kaddr is written back
116 * to the page in question.
118 * - kaddr - kernel address (guaranteed to be page aligned)
120 ENTRY(v6_flush_kern_dcache_page)
124 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
126 mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate unified line
128 add r0, r0, #D_CACHE_LINE_SIZE
133 mcr p15, 0, r0, c7, c10, 4
139 * v6_dma_inv_range(start,end)
141 * Invalidate the data cache within the specified region; we will
142 * be performing a DMA operation in this region and we want to
143 * purge old data in the cache.
145 * - start - virtual start address of region
146 * - end - virtual end address of region
148 ENTRY(v6_dma_inv_range)
149 tst r0, #D_CACHE_LINE_SIZE - 1
150 bic r0, r0, #D_CACHE_LINE_SIZE - 1
152 mcrne p15, 0, r0, c7, c10, 1 @ clean D line
154 mcrne p15, 0, r0, c7, c11, 1 @ clean unified line
156 tst r1, #D_CACHE_LINE_SIZE - 1
157 bic r1, r1, #D_CACHE_LINE_SIZE - 1
159 mcrne p15, 0, r1, c7, c14, 1 @ clean & invalidate D line
161 mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line
165 mcr p15, 0, r0, c7, c6, 1 @ invalidate D line
167 mcr p15, 0, r0, c7, c7, 1 @ invalidate unified line
169 add r0, r0, #D_CACHE_LINE_SIZE
173 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
177 * v6_dma_clean_range(start,end)
178 * - start - virtual start address of region
179 * - end - virtual end address of region
181 ENTRY(v6_dma_clean_range)
182 bic r0, r0, #D_CACHE_LINE_SIZE - 1
185 mcr p15, 0, r0, c7, c10, 1 @ clean D line
187 mcr p15, 0, r0, c7, c11, 1 @ clean unified line
189 add r0, r0, #D_CACHE_LINE_SIZE
193 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
197 * v6_dma_flush_range(start,end)
198 * - start - virtual start address of region
199 * - end - virtual end address of region
201 ENTRY(v6_dma_flush_range)
202 bic r0, r0, #D_CACHE_LINE_SIZE - 1
205 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
207 mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate line
209 add r0, r0, #D_CACHE_LINE_SIZE
213 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
218 .type v6_cache_fns, #object
220 .long v6_flush_kern_cache_all
221 .long v6_flush_user_cache_all
222 .long v6_flush_user_cache_range
223 .long v6_coherent_kern_range
224 .long v6_coherent_user_range
225 .long v6_flush_kern_dcache_page
226 .long v6_dma_inv_range
227 .long v6_dma_clean_range
228 .long v6_dma_flush_range
229 .size v6_cache_fns, . - v6_cache_fns