ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / arm / mm / cache-v6.S
1 /*
2  *  linux/arch/arm/mm/cache-v6.S
3  *
4  *  Copyright (C) 2001 Deep Blue Solutions Ltd.
5  *
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.
9  *
10  *  This is the "shell" of the ARMv6 processor support.
11  */
12 #include <linux/linkage.h>
13 #include <linux/init.h>
14 #include <asm/assembler.h>
15
16 #include "proc-macros.S"
17
18 #define HARVARD_CACHE
19 #define CACHE_LINE_SIZE         32
20 #define D_CACHE_LINE_SIZE       32
21
22 /*
23  *      v6_flush_cache_all()
24  *
25  *      Flush the entire cache.
26  *
27  *      It is assumed that:
28  */
29 ENTRY(v6_flush_kern_cache_all)
30         mov     r0, #0
31 #ifdef HARVARD_CACHE
32         mcr     p15, 0, r0, c7, c14, 0          @ D cache clean+invalidate
33         mcr     p15, 0, r0, c7, c5, 0           @ I+BTB cache invalidate
34 #else
35         mcr     p15, 0, r0, c7, c15, 0          @ Cache clean+invalidate
36 #endif
37         mov     pc, lr
38
39 /*
40  *      v6_flush_cache_all()
41  *
42  *      Flush all TLB entries in a particular address space
43  *
44  *      - mm    - mm_struct describing address space
45  */
46 ENTRY(v6_flush_user_cache_all)
47         /*FALLTHROUGH*/
48
49 /*
50  *      v6_flush_cache_range(start, end, flags)
51  *
52  *      Flush a range of TLB entries in the specified address space.
53  *
54  *      - start - start address (may not be aligned)
55  *      - end   - end address (exclusive, may not be aligned)
56  *      - flags - vm_area_struct flags describing address space
57  *
58  *      It is assumed that:
59  *      - we have a VIPT cache.
60  */
61 ENTRY(v6_flush_user_cache_range)
62         mov     pc, lr
63
64 /*
65  *      v6_coherent_kern_range(start,end)
66  *
67  *      Ensure that the I and D caches are coherent within specified
68  *      region.  This is typically used when code has been written to
69  *      a memory region, and will be executed.
70  *
71  *      - start   - virtual start address of region
72  *      - end     - virtual end address of region
73  *
74  *      It is assumed that:
75  *      - the Icache does not read data from the write buffer
76  */
77 ENTRY(v6_coherent_kern_range)
78         bic     r0, r0, #CACHE_LINE_SIZE - 1
79 1:
80 #ifdef HARVARD_CACHE
81         mcr     p15, 0, r0, c7, c10, 1          @ clean D line
82         mcr     p15, 0, r0, c7, c5, 1           @ invalidate I line
83 #endif
84         mcr     p15, 0, r0, c7, c5, 7           @ invalidate BTB entry
85         add     r0, r0, #CACHE_LINE_SIZE
86         cmp     r0, r1
87         blo     1b
88 #ifdef HARVARD_CACHE
89         mov     r0, #0
90         mcr     p15, 0, r0, c7, c10, 4          @ drain write buffer
91 #endif
92         mov     pc, lr
93
94 /*
95  *      v6_flush_kern_dcache_page(kaddr)
96  *
97  *      Ensure that the data held in the page kaddr is written back
98  *      to the page in question.
99  *
100  *      - kaddr   - kernel address (guaranteed to be page aligned)
101  */
102 ENTRY(v6_flush_kern_dcache_page)
103         add     r1, r0, #PAGE_SZ
104 1:
105 #ifdef HARVARD_CACHE
106         mcr     p15, 0, r0, c7, c14, 1          @ clean & invalidate D line
107 #else
108         mcr     p15, 0, r0, c7, c15, 1          @ clean & invalidate unified line
109 #endif  
110         add     r0, r0, #D_CACHE_LINE_SIZE
111         cmp     r0, r1
112         blo     1b
113 #ifdef HARVARD_CACHE
114         mov     r0, #0
115         mcr     p15, 0, r0, c7, c10, 4
116 #endif
117         mov     pc, lr
118
119
120 /*
121  *      v6_dma_inv_range(start,end)
122  *
123  *      Invalidate the data cache within the specified region; we will
124  *      be performing a DMA operation in this region and we want to
125  *      purge old data in the cache.
126  *
127  *      - start   - virtual start address of region
128  *      - end     - virtual end address of region
129  */
130 ENTRY(v6_dma_inv_range)
131         tst     r0, #D_CACHE_LINE_SIZE - 1
132         bic     r0, r0, #D_CACHE_LINE_SIZE - 1
133 #ifdef HARVARD_CACHE
134         mcrne   p15, 0, r0, c7, c10, 1          @ clean D line
135 #else
136         mcrne   p15, 0, r0, c7, c11, 1          @ clean unified line
137 #endif
138         tst     r1, #D_CACHE_LINE_SIZE - 1
139         bic     r1, r1, #D_CACHE_LINE_SIZE - 1
140 #ifdef HARVARD_CACHE
141         mcrne   p15, 0, r1, c7, c14, 1          @ clean & invalidate D line
142 #else
143         mcrne   p15, 0, r1, c7, c15, 1          @ clean & invalidate unified line
144 #endif
145 1:
146 #ifdef HARVARD_CACHE
147         mcr     p15, 0, r0, c7, c6, 1           @ invalidate D line
148 #else
149         mcr     p15, 0, r0, c7, c7, 1           @ invalidate unified line
150 #endif
151         add     r0, r0, #D_CACHE_LINE_SIZE
152         cmp     r0, r1
153         blo     1b
154         mcr     p15, 0, r0, c7, c10, 4          @ drain write buffer
155         mov     pc, lr
156
157 /*
158  *      v6_dma_clean_range(start,end)
159  *      - start   - virtual start address of region
160  *      - end     - virtual end address of region
161  */
162 ENTRY(v6_dma_clean_range)
163         bic     r0, r0, #D_CACHE_LINE_SIZE - 1
164 1:
165 #ifdef HARVARD_CACHE
166         mcr     p15, 0, r0, c7, c10, 1          @ clean D line
167 #else
168         mcr     p15, 0, r0, c7, c11, 1          @ clean unified line
169 #endif
170         add     r0, r0, #D_CACHE_LINE_SIZE
171         cmp     r0, r1
172         blo     1b
173         mov     r0, #0
174         mcr     p15, 0, r0, c7, c10, 4          @ drain write buffer
175         mov     pc, lr
176
177 /*
178  *      v6_dma_flush_range(start,end)
179  *      - start   - virtual start address of region
180  *      - end     - virtual end address of region
181  */
182 ENTRY(v6_dma_flush_range)
183         bic     r0, r0, #D_CACHE_LINE_SIZE - 1
184 1:
185 #ifdef HARVARD_CACHE
186         mcr     p15, 0, r0, c7, c14, 1          @ clean & invalidate D line
187 #else
188         mcr     p15, 0, r0, c7, c15, 1          @ clean & invalidate line
189 #endif
190         add     r0, r0, #D_CACHE_LINE_SIZE
191         blo     1b
192         mov     r0, #0
193         mcr     p15, 0, r0, c7, c10, 4          @ drain write buffer
194         mov     pc, lr
195
196         __INITDATA
197
198         .type   v6_cache_fns, #object
199 ENTRY(v6_cache_fns)
200         .long   v6_flush_kern_cache_all
201         .long   v6_flush_user_cache_all
202         .long   v6_flush_user_cache_range
203         .long   v6_coherent_kern_range
204         .long   v6_flush_kern_dcache_page
205         .long   v6_dma_inv_range
206         .long   v6_dma_clean_range
207         .long   v6_dma_flush_range
208         .size   v6_cache_fns, . - v6_cache_fns