]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/arm/cpufunc_asm_fa526.S
ARM: Remove last unused function, cpu_flush_prefetchbuf(),
[FreeBSD/FreeBSD.git] / sys / arm / arm / cpufunc_asm_fa526.S
1 /*      $NetBSD: cpufunc_asm_fa526.S,v 1.3 2008/10/15 16:56:49 matt Exp $*/
2 /*-
3  * Copyright (c) 2008 The NetBSD Foundation, Inc.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to The NetBSD Foundation
7  * by Matt Thomas <matt@3am-software.com>
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30
31
32 #include <machine/asm.h>
33 __FBSDID("$FreeBSD$");
34
35 #ifdef CPU_FA526
36 #define CACHELINE_SIZE  16
37 #else
38 #define CACHELINE_SIZE  32
39 #endif
40
41 ENTRY(fa526_setttb)
42         mov     r1, #0
43         mcr     p15, 0, r1, c7, c14, 0  /* clean and invalidate D$ */
44         mcr     p15, 0, r1, c7, c5, 0   /* invalidate I$ */
45         mcr     p15, 0, r1, c7, c5, 6   /* invalidate BTB */
46         mcr     p15, 0, r1, c7, c10, 4  /* drain write and fill buffer */
47
48         mcr     p15, 0, r0, c2, c0, 0   /* Write the TTB */
49
50         /* If we have updated the TTB we must flush the TLB */
51         mcr     p15, 0, r1, c8, c7, 0   /* invalidate I+D TLB */
52
53         /* Make sure that pipeline is emptied */
54         mov     r0, r0
55         mov     r0, r0
56         mov     pc, lr
57 END(fa526_setttb)
58
59 /*
60  * TLB functions
61  */
62 ENTRY(fa526_tlb_flushID_SE)
63         mcr     p15, 0, r0, c8, c7, 1   /* flush Utlb single entry */
64         mov     pc, lr
65 END(fa526_tlb_flushID_SE)
66
67 ENTRY(fa526_cpu_sleep)
68         mov     r0, #0
69 /*      nop
70         nop*/
71         mcr     p15, 0, r0, c7, c0, 4   /* Wait for interrupt*/
72         mov     pc, lr
73 END(fa526_cpu_sleep)
74
75 /*
76  * Cache functions
77  */
78 ENTRY(fa526_idcache_wbinv_all)
79         mov     r0, #0
80         mcr     p15, 0, r0, c7, c14, 0  /* clean and invalidate D$ */
81         mcr     p15, 0, r0, c7, c5, 0   /* invalidate I$ */
82         mcr     p15, 0, r0, c7, c10, 4  /* drain write buffer */
83         mov     pc, lr
84 END(fa526_idcache_wbinv_all)
85
86 ENTRY(fa526_icache_sync_all)
87         mov     r0, #0
88         mcr     p15, 0, r0, c7, c5, 0   /* invalidate I$ */
89         mov     pc, lr
90 END(fa526_icache_sync_all)
91
92 ENTRY(fa526_dcache_wbinv_all)
93         mov     r0, #0
94         mcr     p15, 0, r0, c7, c14, 0  /* clean and invalidate D$ */
95         mcr     p15, 0, r0, c7, c10, 4  /* drain write buffer */
96         mov     pc, lr
97 END(fa526_dcache_wbinv_all)
98
99 /*
100  * Soft functions
101  */
102 ENTRY(fa526_dcache_wbinv_range)
103         cmp     r1, #0x4000
104         bhs     _C_LABEL(fa526_dcache_wbinv_all)
105
106         and     r2, r0, #(CACHELINE_SIZE - 1)
107         add     r1, r1, r2
108         bic     r0, r0, #(CACHELINE_SIZE - 1)
109
110 1:      mcr     p15, 0, r0, c7, c14, 1  /* clean and invalidate D$ entry */
111         add     r0, r0, #CACHELINE_SIZE
112         subs    r1, r1, #CACHELINE_SIZE
113         bhi     1b
114
115         mcr     p15, 0, r0, c7, c10, 4  /* drain write buffer */
116         mov     pc, lr
117 END(fa526_dcache_wbinv_range)
118
119 ENTRY(fa526_dcache_wb_range)
120         cmp     r1, #0x4000
121         bls     1f
122
123         mov     r0, #0
124         mcr     p15, 0, r0, c7, c10, 0  /* clean entire D$ */
125         b       3f
126
127 1:      and     r2, r0, #(CACHELINE_SIZE - 1)
128         add     r1, r1, r2
129         bic     r0, r0, #(CACHELINE_SIZE - 1)
130
131 2:      mcr     p15, 0, r0, c7, c10, 1  /* clean D$ entry */
132         add     r0, r0, #CACHELINE_SIZE
133         subs    r1, r1, #CACHELINE_SIZE
134         bhi     2b
135
136 3:      mcr     p15, 0, r0, c7, c10, 4  /* drain write buffer */
137         mov     pc, lr
138 END(fa526_dcache_wb_range)
139
140 ENTRY(fa526_dcache_inv_range)
141         and     r2, r0, #(CACHELINE_SIZE - 1)
142         add     r1, r1, r2
143         bic     r0, r0, #(CACHELINE_SIZE - 1)
144
145 1:      mcr     p15, 0, r0, c7, c6, 1   /* invalidate D$ single entry */
146         add     r0, r0, #CACHELINE_SIZE
147         subs    r1, r1, #CACHELINE_SIZE
148         bhi     1b
149
150         mov     pc, lr
151 END(fa526_dcache_inv_range)
152
153 ENTRY(fa526_idcache_wbinv_range)
154         cmp     r1, #0x4000
155         bhs     _C_LABEL(fa526_idcache_wbinv_all)
156
157         and     r2, r0, #(CACHELINE_SIZE - 1)
158         add     r1, r1, r2
159         bic     r0, r0, #(CACHELINE_SIZE - 1)
160
161 1:      mcr     p15, 0, r0, c7, c14, 1  /* clean and invalidate D$ entry */
162         mcr     p15, 0, r0, c7, c5, 1   /* invalidate I$ entry */
163         add     r0, r0, #CACHELINE_SIZE
164         subs    r1, r1, #CACHELINE_SIZE
165         bhi     1b
166
167 2:      mcr     p15, 0, r0, c7, c10, 4  /* drain write buffer */
168         mov     pc, lr
169 END(fa526_idcache_wbinv_range)
170
171 ENTRY(fa526_icache_sync_range)
172         cmp     r1, #0x4000
173         bhs     _C_LABEL(fa526_icache_sync_all)
174
175         and     r2, r0, #(CACHELINE_SIZE - 1)
176         add     r1, r1, r2
177         bic     r0, r0, #(CACHELINE_SIZE - 1)
178
179 1:      mcr     p15, 0, r0, c7, c10, 1  /* clean D$ entry */
180         mcr     p15, 0, r0, c7, c5, 1   /* invalidate I$ entry */
181         add     r0, r0, #CACHELINE_SIZE
182         subs    r1, r1, #CACHELINE_SIZE
183         bhi     1b
184
185 2:      mcr     p15, 0, r0, c7, c10, 4  /* drain write buffer */
186         mov     pc, lr
187 END(fa526_icache_sync_range)
188
189 ENTRY(fa526_context_switch)
190         /*
191          * CF_CACHE_PURGE_ID will *ALWAYS* be called prior to this.
192          * Thus the data cache will contain only kernel data and the
193          * instruction cache will contain only kernel code, and all
194          * kernel mappings are shared by all processes.
195          */
196
197         mcr     p15, 0, r0, c2, c0, 0   /* Write the TTB */
198
199         /* If we have updated the TTB we must flush the TLB */
200         mov     r0, #0
201         mcr     p15, 0, r0, c8, c7, 0   /* flush the I+D tlb */
202
203         /* Make sure that pipeline is emptied */
204         mov     r0, r0
205         mov     r0, r0
206         mov     pc, lr
207 END(fa526_context_switch)
208