cpufunc.h revision 1.62 1 1.45 matt /* cpufunc.h,v 1.40.22.4 2007/11/08 10:59:33 matt Exp */
2 1.1 reinoud
3 1.1 reinoud /*
4 1.1 reinoud * Copyright (c) 1997 Mark Brinicombe.
5 1.1 reinoud * Copyright (c) 1997 Causality Limited
6 1.1 reinoud * All rights reserved.
7 1.1 reinoud *
8 1.1 reinoud * Redistribution and use in source and binary forms, with or without
9 1.1 reinoud * modification, are permitted provided that the following conditions
10 1.1 reinoud * are met:
11 1.1 reinoud * 1. Redistributions of source code must retain the above copyright
12 1.1 reinoud * notice, this list of conditions and the following disclaimer.
13 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 reinoud * notice, this list of conditions and the following disclaimer in the
15 1.1 reinoud * documentation and/or other materials provided with the distribution.
16 1.1 reinoud * 3. All advertising materials mentioning features or use of this software
17 1.1 reinoud * must display the following acknowledgement:
18 1.1 reinoud * This product includes software developed by Causality Limited.
19 1.1 reinoud * 4. The name of Causality Limited may not be used to endorse or promote
20 1.1 reinoud * products derived from this software without specific prior written
21 1.1 reinoud * permission.
22 1.1 reinoud *
23 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY CAUSALITY LIMITED ``AS IS'' AND ANY EXPRESS
24 1.1 reinoud * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 1.1 reinoud * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 1.1 reinoud * DISCLAIMED. IN NO EVENT SHALL CAUSALITY LIMITED BE LIABLE FOR ANY DIRECT,
27 1.1 reinoud * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 1.1 reinoud * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 1.1 reinoud * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 reinoud * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 reinoud * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 reinoud * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 reinoud * SUCH DAMAGE.
34 1.1 reinoud *
35 1.1 reinoud * RiscBSD kernel project
36 1.1 reinoud *
37 1.1 reinoud * cpufunc.h
38 1.1 reinoud *
39 1.1 reinoud * Prototypes for cpu, mmu and tlb related functions.
40 1.1 reinoud */
41 1.1 reinoud
42 1.1 reinoud #ifndef _ARM32_CPUFUNC_H_
43 1.1 reinoud #define _ARM32_CPUFUNC_H_
44 1.1 reinoud
45 1.21 thorpej #ifdef _KERNEL
46 1.21 thorpej
47 1.1 reinoud #include <sys/types.h>
48 1.45 matt #include <arm/armreg.h>
49 1.21 thorpej #include <arm/cpuconf.h>
50 1.44 dogcow #include <arm/armreg.h>
51 1.1 reinoud
52 1.1 reinoud struct cpu_functions {
53 1.1 reinoud
54 1.1 reinoud /* CPU functions */
55 1.32 uwe
56 1.39 bjh21 u_int (*cf_id) (void);
57 1.39 bjh21 void (*cf_cpwait) (void);
58 1.1 reinoud
59 1.1 reinoud /* MMU functions */
60 1.1 reinoud
61 1.39 bjh21 u_int (*cf_control) (u_int, u_int);
62 1.39 bjh21 void (*cf_domains) (u_int);
63 1.60 matt void (*cf_setttb) (u_int, bool);
64 1.39 bjh21 u_int (*cf_faultstatus) (void);
65 1.39 bjh21 u_int (*cf_faultaddress) (void);
66 1.1 reinoud
67 1.1 reinoud /* TLB functions */
68 1.1 reinoud
69 1.39 bjh21 void (*cf_tlb_flushID) (void);
70 1.39 bjh21 void (*cf_tlb_flushID_SE) (u_int);
71 1.39 bjh21 void (*cf_tlb_flushI) (void);
72 1.39 bjh21 void (*cf_tlb_flushI_SE) (u_int);
73 1.39 bjh21 void (*cf_tlb_flushD) (void);
74 1.39 bjh21 void (*cf_tlb_flushD_SE) (u_int);
75 1.1 reinoud
76 1.17 thorpej /*
77 1.17 thorpej * Cache operations:
78 1.17 thorpej *
79 1.17 thorpej * We define the following primitives:
80 1.17 thorpej *
81 1.17 thorpej * icache_sync_all Synchronize I-cache
82 1.17 thorpej * icache_sync_range Synchronize I-cache range
83 1.17 thorpej *
84 1.17 thorpej * dcache_wbinv_all Write-back and Invalidate D-cache
85 1.17 thorpej * dcache_wbinv_range Write-back and Invalidate D-cache range
86 1.17 thorpej * dcache_inv_range Invalidate D-cache range
87 1.17 thorpej * dcache_wb_range Write-back D-cache range
88 1.17 thorpej *
89 1.17 thorpej * idcache_wbinv_all Write-back and Invalidate D-cache,
90 1.17 thorpej * Invalidate I-cache
91 1.17 thorpej * idcache_wbinv_range Write-back and Invalidate D-cache,
92 1.17 thorpej * Invalidate I-cache range
93 1.17 thorpej *
94 1.17 thorpej * Note that the ARM term for "write-back" is "clean". We use
95 1.17 thorpej * the term "write-back" since it's a more common way to describe
96 1.17 thorpej * the operation.
97 1.17 thorpej *
98 1.17 thorpej * There are some rules that must be followed:
99 1.17 thorpej *
100 1.17 thorpej * I-cache Synch (all or range):
101 1.17 thorpej * The goal is to synchronize the instruction stream,
102 1.17 thorpej * so you may beed to write-back dirty D-cache blocks
103 1.17 thorpej * first. If a range is requested, and you can't
104 1.17 thorpej * synchronize just a range, you have to hit the whole
105 1.17 thorpej * thing.
106 1.17 thorpej *
107 1.17 thorpej * D-cache Write-Back and Invalidate range:
108 1.17 thorpej * If you can't WB-Inv a range, you must WB-Inv the
109 1.17 thorpej * entire D-cache.
110 1.17 thorpej *
111 1.17 thorpej * D-cache Invalidate:
112 1.17 thorpej * If you can't Inv the D-cache, you must Write-Back
113 1.17 thorpej * and Invalidate. Code that uses this operation
114 1.17 thorpej * MUST NOT assume that the D-cache will not be written
115 1.17 thorpej * back to memory.
116 1.17 thorpej *
117 1.17 thorpej * D-cache Write-Back:
118 1.17 thorpej * If you can't Write-back without doing an Inv,
119 1.17 thorpej * that's fine. Then treat this as a WB-Inv.
120 1.17 thorpej * Skipping the invalidate is merely an optimization.
121 1.17 thorpej *
122 1.17 thorpej * All operations:
123 1.17 thorpej * Valid virtual addresses must be passed to each
124 1.17 thorpej * cache operation.
125 1.17 thorpej */
126 1.39 bjh21 void (*cf_icache_sync_all) (void);
127 1.39 bjh21 void (*cf_icache_sync_range) (vaddr_t, vsize_t);
128 1.17 thorpej
129 1.39 bjh21 void (*cf_dcache_wbinv_all) (void);
130 1.39 bjh21 void (*cf_dcache_wbinv_range)(vaddr_t, vsize_t);
131 1.39 bjh21 void (*cf_dcache_inv_range) (vaddr_t, vsize_t);
132 1.39 bjh21 void (*cf_dcache_wb_range) (vaddr_t, vsize_t);
133 1.1 reinoud
134 1.59 matt void (*cf_sdcache_wbinv_range)(vaddr_t, paddr_t, psize_t);
135 1.59 matt void (*cf_sdcache_inv_range) (vaddr_t, paddr_t, psize_t);
136 1.59 matt void (*cf_sdcache_wb_range) (vaddr_t, paddr_t, psize_t);
137 1.59 matt
138 1.39 bjh21 void (*cf_idcache_wbinv_all) (void);
139 1.39 bjh21 void (*cf_idcache_wbinv_range)(vaddr_t, vsize_t);
140 1.1 reinoud
141 1.1 reinoud /* Other functions */
142 1.1 reinoud
143 1.39 bjh21 void (*cf_flush_prefetchbuf) (void);
144 1.39 bjh21 void (*cf_drain_writebuf) (void);
145 1.39 bjh21 void (*cf_flush_brnchtgt_C) (void);
146 1.39 bjh21 void (*cf_flush_brnchtgt_E) (u_int);
147 1.1 reinoud
148 1.39 bjh21 void (*cf_sleep) (int mode);
149 1.1 reinoud
150 1.1 reinoud /* Soft functions */
151 1.1 reinoud
152 1.39 bjh21 int (*cf_dataabt_fixup) (void *);
153 1.39 bjh21 int (*cf_prefetchabt_fixup) (void *);
154 1.1 reinoud
155 1.41 scw void (*cf_context_switch) (u_int);
156 1.1 reinoud
157 1.39 bjh21 void (*cf_setup) (char *);
158 1.1 reinoud };
159 1.1 reinoud
160 1.1 reinoud extern struct cpu_functions cpufuncs;
161 1.1 reinoud extern u_int cputype;
162 1.1 reinoud
163 1.1 reinoud #define cpu_id() cpufuncs.cf_id()
164 1.1 reinoud
165 1.1 reinoud #define cpu_control(c, e) cpufuncs.cf_control(c, e)
166 1.1 reinoud #define cpu_domains(d) cpufuncs.cf_domains(d)
167 1.60 matt #define cpu_setttb(t, f) cpufuncs.cf_setttb(t, f)
168 1.1 reinoud #define cpu_faultstatus() cpufuncs.cf_faultstatus()
169 1.1 reinoud #define cpu_faultaddress() cpufuncs.cf_faultaddress()
170 1.1 reinoud
171 1.1 reinoud #define cpu_tlb_flushID() cpufuncs.cf_tlb_flushID()
172 1.1 reinoud #define cpu_tlb_flushID_SE(e) cpufuncs.cf_tlb_flushID_SE(e)
173 1.1 reinoud #define cpu_tlb_flushI() cpufuncs.cf_tlb_flushI()
174 1.1 reinoud #define cpu_tlb_flushI_SE(e) cpufuncs.cf_tlb_flushI_SE(e)
175 1.1 reinoud #define cpu_tlb_flushD() cpufuncs.cf_tlb_flushD()
176 1.1 reinoud #define cpu_tlb_flushD_SE(e) cpufuncs.cf_tlb_flushD_SE(e)
177 1.1 reinoud
178 1.17 thorpej #define cpu_icache_sync_all() cpufuncs.cf_icache_sync_all()
179 1.17 thorpej #define cpu_icache_sync_range(a, s) cpufuncs.cf_icache_sync_range((a), (s))
180 1.17 thorpej
181 1.17 thorpej #define cpu_dcache_wbinv_all() cpufuncs.cf_dcache_wbinv_all()
182 1.17 thorpej #define cpu_dcache_wbinv_range(a, s) cpufuncs.cf_dcache_wbinv_range((a), (s))
183 1.17 thorpej #define cpu_dcache_inv_range(a, s) cpufuncs.cf_dcache_inv_range((a), (s))
184 1.17 thorpej #define cpu_dcache_wb_range(a, s) cpufuncs.cf_dcache_wb_range((a), (s))
185 1.17 thorpej
186 1.59 matt #define cpu_sdcache_wbinv_range(a, b, s) cpufuncs.cf_sdcache_wbinv_range((a), (b), (s))
187 1.59 matt #define cpu_sdcache_inv_range(a, b, s) cpufuncs.cf_sdcache_inv_range((a), (b), (s))
188 1.59 matt #define cpu_sdcache_wb_range(a, b, s) cpufuncs.cf_sdcache_wb_range((a), (b), (s))
189 1.59 matt
190 1.17 thorpej #define cpu_idcache_wbinv_all() cpufuncs.cf_idcache_wbinv_all()
191 1.17 thorpej #define cpu_idcache_wbinv_range(a, s) cpufuncs.cf_idcache_wbinv_range((a), (s))
192 1.1 reinoud
193 1.1 reinoud #define cpu_flush_prefetchbuf() cpufuncs.cf_flush_prefetchbuf()
194 1.1 reinoud #define cpu_drain_writebuf() cpufuncs.cf_drain_writebuf()
195 1.1 reinoud #define cpu_flush_brnchtgt_C() cpufuncs.cf_flush_brnchtgt_C()
196 1.1 reinoud #define cpu_flush_brnchtgt_E(e) cpufuncs.cf_flush_brnchtgt_E(e)
197 1.1 reinoud
198 1.1 reinoud #define cpu_sleep(m) cpufuncs.cf_sleep(m)
199 1.1 reinoud
200 1.1 reinoud #define cpu_dataabt_fixup(a) cpufuncs.cf_dataabt_fixup(a)
201 1.1 reinoud #define cpu_prefetchabt_fixup(a) cpufuncs.cf_prefetchabt_fixup(a)
202 1.7 wiz #define ABORT_FIXUP_OK 0 /* fixup succeeded */
203 1.1 reinoud #define ABORT_FIXUP_FAILED 1 /* fixup failed */
204 1.1 reinoud #define ABORT_FIXUP_RETURN 2 /* abort handler should return */
205 1.1 reinoud
206 1.41 scw #define cpu_context_switch(a) cpufuncs.cf_context_switch(a)
207 1.1 reinoud #define cpu_setup(a) cpufuncs.cf_setup(a)
208 1.1 reinoud
209 1.39 bjh21 int set_cpufuncs (void);
210 1.40 bjh21 int set_cpufuncs_id (u_int);
211 1.1 reinoud #define ARCHITECTURE_NOT_PRESENT 1 /* known but not configured */
212 1.1 reinoud #define ARCHITECTURE_NOT_SUPPORTED 2 /* not known */
213 1.1 reinoud
214 1.39 bjh21 void cpufunc_nullop (void);
215 1.39 bjh21 int cpufunc_null_fixup (void *);
216 1.39 bjh21 int early_abort_fixup (void *);
217 1.39 bjh21 int late_abort_fixup (void *);
218 1.39 bjh21 u_int cpufunc_id (void);
219 1.39 bjh21 u_int cpufunc_control (u_int, u_int);
220 1.39 bjh21 void cpufunc_domains (u_int);
221 1.39 bjh21 u_int cpufunc_faultstatus (void);
222 1.39 bjh21 u_int cpufunc_faultaddress (void);
223 1.3 bjh21
224 1.54 kiyohara #if defined(CPU_ARM2) || defined(CPU_ARM250) || defined(CPU_ARM3)
225 1.54 kiyohara void arm3_cache_flush (void);
226 1.54 kiyohara #endif /* CPU_ARM2 || CPU_ARM250 || CPU_ARM3 */
227 1.54 kiyohara
228 1.40 bjh21 #ifdef CPU_ARM2
229 1.40 bjh21 u_int arm2_id (void);
230 1.40 bjh21 #endif /* CPU_ARM2 */
231 1.40 bjh21
232 1.40 bjh21 #ifdef CPU_ARM250
233 1.40 bjh21 u_int arm250_id (void);
234 1.40 bjh21 #endif
235 1.40 bjh21
236 1.3 bjh21 #ifdef CPU_ARM3
237 1.39 bjh21 u_int arm3_control (u_int, u_int);
238 1.3 bjh21 #endif /* CPU_ARM3 */
239 1.1 reinoud
240 1.1 reinoud #if defined(CPU_ARM6) || defined(CPU_ARM7)
241 1.60 matt void arm67_setttb (u_int, bool);
242 1.39 bjh21 void arm67_tlb_flush (void);
243 1.39 bjh21 void arm67_tlb_purge (u_int);
244 1.39 bjh21 void arm67_cache_flush (void);
245 1.41 scw void arm67_context_switch (u_int);
246 1.1 reinoud #endif /* CPU_ARM6 || CPU_ARM7 */
247 1.1 reinoud
248 1.1 reinoud #ifdef CPU_ARM6
249 1.39 bjh21 void arm6_setup (char *);
250 1.1 reinoud #endif /* CPU_ARM6 */
251 1.1 reinoud
252 1.1 reinoud #ifdef CPU_ARM7
253 1.39 bjh21 void arm7_setup (char *);
254 1.1 reinoud #endif /* CPU_ARM7 */
255 1.5 chris
256 1.5 chris #ifdef CPU_ARM7TDMI
257 1.39 bjh21 int arm7_dataabt_fixup (void *);
258 1.39 bjh21 void arm7tdmi_setup (char *);
259 1.60 matt void arm7tdmi_setttb (u_int, bool);
260 1.39 bjh21 void arm7tdmi_tlb_flushID (void);
261 1.39 bjh21 void arm7tdmi_tlb_flushID_SE (u_int);
262 1.39 bjh21 void arm7tdmi_cache_flushID (void);
263 1.41 scw void arm7tdmi_context_switch (u_int);
264 1.5 chris #endif /* CPU_ARM7TDMI */
265 1.1 reinoud
266 1.1 reinoud #ifdef CPU_ARM8
267 1.60 matt void arm8_setttb (u_int, bool);
268 1.39 bjh21 void arm8_tlb_flushID (void);
269 1.39 bjh21 void arm8_tlb_flushID_SE (u_int);
270 1.39 bjh21 void arm8_cache_flushID (void);
271 1.39 bjh21 void arm8_cache_flushID_E (u_int);
272 1.39 bjh21 void arm8_cache_cleanID (void);
273 1.39 bjh21 void arm8_cache_cleanID_E (u_int);
274 1.39 bjh21 void arm8_cache_purgeID (void);
275 1.39 bjh21 void arm8_cache_purgeID_E (u_int entry);
276 1.39 bjh21
277 1.39 bjh21 void arm8_cache_syncI (void);
278 1.39 bjh21 void arm8_cache_cleanID_rng (vaddr_t, vsize_t);
279 1.39 bjh21 void arm8_cache_cleanD_rng (vaddr_t, vsize_t);
280 1.39 bjh21 void arm8_cache_purgeID_rng (vaddr_t, vsize_t);
281 1.39 bjh21 void arm8_cache_purgeD_rng (vaddr_t, vsize_t);
282 1.39 bjh21 void arm8_cache_syncI_rng (vaddr_t, vsize_t);
283 1.1 reinoud
284 1.41 scw void arm8_context_switch (u_int);
285 1.1 reinoud
286 1.39 bjh21 void arm8_setup (char *);
287 1.1 reinoud
288 1.39 bjh21 u_int arm8_clock_config (u_int, u_int);
289 1.1 reinoud #endif
290 1.1 reinoud
291 1.46 matt #ifdef CPU_FA526
292 1.46 matt void fa526_setup (char *);
293 1.60 matt void fa526_setttb (u_int, bool);
294 1.46 matt void fa526_context_switch (u_int);
295 1.46 matt void fa526_cpu_sleep (int);
296 1.46 matt void fa526_tlb_flushI_SE (u_int);
297 1.46 matt void fa526_tlb_flushID_SE (u_int);
298 1.47 matt void fa526_flush_prefetchbuf (void);
299 1.46 matt void fa526_flush_brnchtgt_E (u_int);
300 1.46 matt
301 1.46 matt void fa526_icache_sync_all (void);
302 1.46 matt void fa526_icache_sync_range(vaddr_t, vsize_t);
303 1.46 matt void fa526_dcache_wbinv_all (void);
304 1.46 matt void fa526_dcache_wbinv_range(vaddr_t, vsize_t);
305 1.46 matt void fa526_dcache_inv_range (vaddr_t, vsize_t);
306 1.46 matt void fa526_dcache_wb_range (vaddr_t, vsize_t);
307 1.46 matt void fa526_idcache_wbinv_all(void);
308 1.46 matt void fa526_idcache_wbinv_range(vaddr_t, vsize_t);
309 1.46 matt #endif
310 1.46 matt
311 1.23 rjs #ifdef CPU_SA110
312 1.39 bjh21 void sa110_setup (char *);
313 1.41 scw void sa110_context_switch (u_int);
314 1.23 rjs #endif /* CPU_SA110 */
315 1.23 rjs
316 1.23 rjs #if defined(CPU_SA1100) || defined(CPU_SA1110)
317 1.39 bjh21 void sa11x0_drain_readbuf (void);
318 1.23 rjs
319 1.41 scw void sa11x0_context_switch (u_int);
320 1.39 bjh21 void sa11x0_cpu_sleep (int);
321 1.32 uwe
322 1.39 bjh21 void sa11x0_setup (char *);
323 1.23 rjs #endif
324 1.23 rjs
325 1.23 rjs #if defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110)
326 1.60 matt void sa1_setttb (u_int, bool);
327 1.23 rjs
328 1.39 bjh21 void sa1_tlb_flushID_SE (u_int);
329 1.23 rjs
330 1.39 bjh21 void sa1_cache_flushID (void);
331 1.39 bjh21 void sa1_cache_flushI (void);
332 1.39 bjh21 void sa1_cache_flushD (void);
333 1.39 bjh21 void sa1_cache_flushD_SE (u_int);
334 1.39 bjh21
335 1.39 bjh21 void sa1_cache_cleanID (void);
336 1.39 bjh21 void sa1_cache_cleanD (void);
337 1.39 bjh21 void sa1_cache_cleanD_E (u_int);
338 1.39 bjh21
339 1.39 bjh21 void sa1_cache_purgeID (void);
340 1.39 bjh21 void sa1_cache_purgeID_E (u_int);
341 1.39 bjh21 void sa1_cache_purgeD (void);
342 1.39 bjh21 void sa1_cache_purgeD_E (u_int);
343 1.39 bjh21
344 1.39 bjh21 void sa1_cache_syncI (void);
345 1.39 bjh21 void sa1_cache_cleanID_rng (vaddr_t, vsize_t);
346 1.39 bjh21 void sa1_cache_cleanD_rng (vaddr_t, vsize_t);
347 1.39 bjh21 void sa1_cache_purgeID_rng (vaddr_t, vsize_t);
348 1.39 bjh21 void sa1_cache_purgeD_rng (vaddr_t, vsize_t);
349 1.39 bjh21 void sa1_cache_syncI_rng (vaddr_t, vsize_t);
350 1.23 rjs
351 1.23 rjs #endif
352 1.23 rjs
353 1.10 rearnsha #ifdef CPU_ARM9
354 1.60 matt void arm9_setttb (u_int, bool);
355 1.10 rearnsha
356 1.39 bjh21 void arm9_tlb_flushID_SE (u_int);
357 1.10 rearnsha
358 1.39 bjh21 void arm9_icache_sync_all (void);
359 1.39 bjh21 void arm9_icache_sync_range (vaddr_t, vsize_t);
360 1.30 rearnsha
361 1.39 bjh21 void arm9_dcache_wbinv_all (void);
362 1.39 bjh21 void arm9_dcache_wbinv_range (vaddr_t, vsize_t);
363 1.39 bjh21 void arm9_dcache_inv_range (vaddr_t, vsize_t);
364 1.39 bjh21 void arm9_dcache_wb_range (vaddr_t, vsize_t);
365 1.30 rearnsha
366 1.39 bjh21 void arm9_idcache_wbinv_all (void);
367 1.39 bjh21 void arm9_idcache_wbinv_range (vaddr_t, vsize_t);
368 1.10 rearnsha
369 1.41 scw void arm9_context_switch (u_int);
370 1.10 rearnsha
371 1.39 bjh21 void arm9_setup (char *);
372 1.30 rearnsha
373 1.30 rearnsha extern unsigned arm9_dcache_sets_max;
374 1.30 rearnsha extern unsigned arm9_dcache_sets_inc;
375 1.30 rearnsha extern unsigned arm9_dcache_index_max;
376 1.30 rearnsha extern unsigned arm9_dcache_index_inc;
377 1.10 rearnsha #endif
378 1.10 rearnsha
379 1.52 kiyohara #if defined(CPU_ARM9E) || defined(CPU_ARM10) || defined(CPU_SHEEVA)
380 1.39 bjh21 void arm10_tlb_flushID_SE (u_int);
381 1.39 bjh21 void arm10_tlb_flushI_SE (u_int);
382 1.29 rearnsha
383 1.41 scw void arm10_context_switch (u_int);
384 1.33 rearnsha
385 1.39 bjh21 void arm10_setup (char *);
386 1.33 rearnsha #endif
387 1.29 rearnsha
388 1.52 kiyohara #if defined(CPU_ARM9E) || defined (CPU_ARM10) || defined(CPU_SHEEVA)
389 1.60 matt void armv5_ec_setttb (u_int, bool);
390 1.38 christos
391 1.39 bjh21 void armv5_ec_icache_sync_all (void);
392 1.39 bjh21 void armv5_ec_icache_sync_range (vaddr_t, vsize_t);
393 1.38 christos
394 1.39 bjh21 void armv5_ec_dcache_wbinv_all (void);
395 1.39 bjh21 void armv5_ec_dcache_wbinv_range (vaddr_t, vsize_t);
396 1.39 bjh21 void armv5_ec_dcache_inv_range (vaddr_t, vsize_t);
397 1.39 bjh21 void armv5_ec_dcache_wb_range (vaddr_t, vsize_t);
398 1.38 christos
399 1.39 bjh21 void armv5_ec_idcache_wbinv_all (void);
400 1.39 bjh21 void armv5_ec_idcache_wbinv_range (vaddr_t, vsize_t);
401 1.38 christos #endif
402 1.38 christos
403 1.53 bsh #if defined (CPU_ARM10) || defined (CPU_ARM11MPCORE)
404 1.60 matt void armv5_setttb (u_int, bool);
405 1.38 christos
406 1.39 bjh21 void armv5_icache_sync_all (void);
407 1.39 bjh21 void armv5_icache_sync_range (vaddr_t, vsize_t);
408 1.33 rearnsha
409 1.39 bjh21 void armv5_dcache_wbinv_all (void);
410 1.39 bjh21 void armv5_dcache_wbinv_range (vaddr_t, vsize_t);
411 1.39 bjh21 void armv5_dcache_inv_range (vaddr_t, vsize_t);
412 1.39 bjh21 void armv5_dcache_wb_range (vaddr_t, vsize_t);
413 1.33 rearnsha
414 1.39 bjh21 void armv5_idcache_wbinv_all (void);
415 1.39 bjh21 void armv5_idcache_wbinv_range (vaddr_t, vsize_t);
416 1.33 rearnsha
417 1.33 rearnsha extern unsigned armv5_dcache_sets_max;
418 1.33 rearnsha extern unsigned armv5_dcache_sets_inc;
419 1.33 rearnsha extern unsigned armv5_dcache_index_max;
420 1.33 rearnsha extern unsigned armv5_dcache_index_inc;
421 1.29 rearnsha #endif
422 1.29 rearnsha
423 1.53 bsh #if defined(CPU_ARM11MPCORE)
424 1.53 bsh void arm11mpcore_setup (char *);
425 1.53 bsh #endif
426 1.53 bsh
427 1.51 matt #if defined(CPU_ARM11) || defined(CPU_CORTEX)
428 1.60 matt void arm11_setttb (u_int, bool);
429 1.45 matt
430 1.45 matt void arm11_tlb_flushID_SE (u_int);
431 1.45 matt void arm11_tlb_flushI_SE (u_int);
432 1.45 matt
433 1.45 matt void arm11_context_switch (u_int);
434 1.45 matt
435 1.45 matt void arm11_cpu_sleep (int);
436 1.45 matt void arm11_setup (char *string);
437 1.45 matt void arm11_tlb_flushID (void);
438 1.45 matt void arm11_tlb_flushI (void);
439 1.45 matt void arm11_tlb_flushD (void);
440 1.45 matt void arm11_tlb_flushD_SE (u_int va);
441 1.45 matt
442 1.45 matt void armv11_dcache_wbinv_all (void);
443 1.45 matt void armv11_idcache_wbinv_all(void);
444 1.45 matt
445 1.45 matt void arm11_drain_writebuf (void);
446 1.45 matt void arm11_sleep (int);
447 1.45 matt
448 1.60 matt void armv6_setttb (u_int, bool);
449 1.45 matt
450 1.45 matt void armv6_icache_sync_all (void);
451 1.45 matt void armv6_icache_sync_range (vaddr_t, vsize_t);
452 1.45 matt
453 1.45 matt void armv6_dcache_wbinv_all (void);
454 1.45 matt void armv6_dcache_wbinv_range (vaddr_t, vsize_t);
455 1.45 matt void armv6_dcache_inv_range (vaddr_t, vsize_t);
456 1.45 matt void armv6_dcache_wb_range (vaddr_t, vsize_t);
457 1.45 matt
458 1.45 matt void armv6_idcache_wbinv_all (void);
459 1.45 matt void armv6_idcache_wbinv_range (vaddr_t, vsize_t);
460 1.45 matt #endif
461 1.45 matt
462 1.51 matt #if defined(CPU_CORTEX)
463 1.60 matt void armv7_setttb(u_int, bool);
464 1.50 jmcneill
465 1.50 jmcneill void armv7_icache_sync_range(vaddr_t, vsize_t);
466 1.50 jmcneill void armv7_dcache_wb_range(vaddr_t, vsize_t);
467 1.50 jmcneill void armv7_dcache_wbinv_range(vaddr_t, vsize_t);
468 1.50 jmcneill void armv7_dcache_inv_range(vaddr_t, vsize_t);
469 1.50 jmcneill void armv7_idcache_wbinv_range(vaddr_t, vsize_t);
470 1.50 jmcneill
471 1.50 jmcneill void armv7_dcache_wbinv_all (void);
472 1.50 jmcneill void armv7_idcache_wbinv_all(void);
473 1.50 jmcneill void armv7_icache_sync_all(void);
474 1.50 jmcneill void armv7_cpu_sleep(int);
475 1.50 jmcneill void armv7_context_switch(u_int);
476 1.50 jmcneill void armv7_tlb_flushID_SE(u_int);
477 1.61 matt void armv7_drain_writebuf(void);
478 1.61 matt void armv7_setup(char *string);
479 1.50 jmcneill #endif
480 1.50 jmcneill
481 1.50 jmcneill
482 1.57 skrll #if defined(CPU_ARM1136) || defined(CPU_ARM1176)
483 1.60 matt void arm11x6_setttb (u_int, bool);
484 1.57 skrll void arm11x6_idcache_wbinv_all (void);
485 1.57 skrll void arm11x6_dcache_wbinv_all (void);
486 1.57 skrll void arm11x6_icache_sync_all (void);
487 1.57 skrll void arm11x6_flush_prefetchbuf (void);
488 1.57 skrll void arm11x6_icache_sync_range (vaddr_t, vsize_t);
489 1.57 skrll void arm11x6_idcache_wbinv_range (vaddr_t, vsize_t);
490 1.57 skrll void arm11x6_setup (char *string);
491 1.57 skrll void arm11x6_sleep (int); /* no ref. for errata */
492 1.57 skrll #endif
493 1.45 matt #if defined(CPU_ARM1136)
494 1.45 matt void arm1136_sleep_rev0 (int); /* for errata 336501 */
495 1.45 matt #endif
496 1.45 matt
497 1.45 matt
498 1.38 christos #if defined(CPU_ARM9) || defined(CPU_ARM9E) || defined(CPU_ARM10) || \
499 1.38 christos defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110) || \
500 1.46 matt defined(CPU_FA526) || \
501 1.29 rearnsha defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \
502 1.51 matt defined(__CPU_XSCALE_PXA2XX) || defined(CPU_XSCALE_IXP425) || \
503 1.52 kiyohara defined(CPU_CORTEX) || defined(CPU_SHEEVA)
504 1.23 rjs
505 1.39 bjh21 void armv4_tlb_flushID (void);
506 1.39 bjh21 void armv4_tlb_flushI (void);
507 1.39 bjh21 void armv4_tlb_flushD (void);
508 1.39 bjh21 void armv4_tlb_flushD_SE (u_int);
509 1.10 rearnsha
510 1.39 bjh21 void armv4_drain_writebuf (void);
511 1.24 ichiro #endif
512 1.24 ichiro
513 1.24 ichiro #if defined(CPU_IXP12X0)
514 1.39 bjh21 void ixp12x0_drain_readbuf (void);
515 1.41 scw void ixp12x0_context_switch (u_int);
516 1.39 bjh21 void ixp12x0_setup (char *);
517 1.10 rearnsha #endif
518 1.1 reinoud
519 1.22 thorpej #if defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \
520 1.50 jmcneill defined(__CPU_XSCALE_PXA2XX) || defined(CPU_XSCALE_IXP425) || \
521 1.51 matt defined(CPU_CORTEX)
522 1.43 chris
523 1.39 bjh21 void xscale_cpwait (void);
524 1.43 chris #define cpu_cpwait() cpufuncs.cf_cpwait()
525 1.16 briggs
526 1.39 bjh21 void xscale_cpu_sleep (int);
527 1.12 thorpej
528 1.39 bjh21 u_int xscale_control (u_int, u_int);
529 1.11 thorpej
530 1.60 matt void xscale_setttb (u_int, bool);
531 1.10 rearnsha
532 1.39 bjh21 void xscale_tlb_flushID_SE (u_int);
533 1.8 matt
534 1.39 bjh21 void xscale_cache_flushID (void);
535 1.39 bjh21 void xscale_cache_flushI (void);
536 1.39 bjh21 void xscale_cache_flushD (void);
537 1.39 bjh21 void xscale_cache_flushD_SE (u_int);
538 1.8 matt
539 1.39 bjh21 void xscale_cache_cleanID (void);
540 1.39 bjh21 void xscale_cache_cleanD (void);
541 1.39 bjh21 void xscale_cache_cleanD_E (u_int);
542 1.20 thorpej
543 1.39 bjh21 void xscale_cache_clean_minidata (void);
544 1.8 matt
545 1.39 bjh21 void xscale_cache_purgeID (void);
546 1.39 bjh21 void xscale_cache_purgeID_E (u_int);
547 1.39 bjh21 void xscale_cache_purgeD (void);
548 1.39 bjh21 void xscale_cache_purgeD_E (u_int);
549 1.8 matt
550 1.39 bjh21 void xscale_cache_syncI (void);
551 1.39 bjh21 void xscale_cache_cleanID_rng (vaddr_t, vsize_t);
552 1.39 bjh21 void xscale_cache_cleanD_rng (vaddr_t, vsize_t);
553 1.39 bjh21 void xscale_cache_purgeID_rng (vaddr_t, vsize_t);
554 1.39 bjh21 void xscale_cache_purgeD_rng (vaddr_t, vsize_t);
555 1.39 bjh21 void xscale_cache_syncI_rng (vaddr_t, vsize_t);
556 1.39 bjh21 void xscale_cache_flushD_rng (vaddr_t, vsize_t);
557 1.8 matt
558 1.41 scw void xscale_context_switch (u_int);
559 1.8 matt
560 1.39 bjh21 void xscale_setup (char *);
561 1.51 matt #endif /* CPU_XSCALE_80200 || CPU_XSCALE_80321 || __CPU_XSCALE_PXA2XX || CPU_XSCALE_IXP425 || CPU_CORTEX */
562 1.8 matt
563 1.52 kiyohara #if defined(CPU_SHEEVA)
564 1.52 kiyohara void sheeva_dcache_wbinv_range (vaddr_t, vsize_t);
565 1.52 kiyohara void sheeva_dcache_inv_range (vaddr_t, vsize_t);
566 1.52 kiyohara void sheeva_dcache_wb_range (vaddr_t, vsize_t);
567 1.52 kiyohara void sheeva_idcache_wbinv_range (vaddr_t, vsize_t);
568 1.52 kiyohara void sheeva_setup(char *);
569 1.56 hans void sheeva_cpu_sleep(int);
570 1.52 kiyohara #endif
571 1.52 kiyohara
572 1.1 reinoud #define tlb_flush cpu_tlb_flushID
573 1.1 reinoud #define setttb cpu_setttb
574 1.1 reinoud #define drain_writebuf cpu_drain_writebuf
575 1.1 reinoud
576 1.43 chris #ifndef cpu_cpwait
577 1.43 chris #define cpu_cpwait()
578 1.43 chris #endif
579 1.43 chris
580 1.1 reinoud /*
581 1.1 reinoud * Macros for manipulating CPU interrupts
582 1.1 reinoud */
583 1.15 thorpej #ifdef __PROG32
584 1.62 skrll static __inline uint32_t __set_cpsr_c(uint32_t bic, uint32_t eor) __attribute__((__unused__));
585 1.62 skrll static __inline uint32_t disable_interrupts(uint32_t mask) __attribute__((__unused__));
586 1.62 skrll static __inline uint32_t enable_interrupts(uint32_t mask) __attribute__((__unused__));
587 1.25 briggs
588 1.43 chris static __inline uint32_t
589 1.43 chris __set_cpsr_c(uint32_t bic, uint32_t eor)
590 1.25 briggs {
591 1.43 chris uint32_t tmp, ret;
592 1.25 briggs
593 1.36 perry __asm volatile(
594 1.25 briggs "mrs %0, cpsr\n" /* Get the CPSR */
595 1.25 briggs "bic %1, %0, %2\n" /* Clear bits */
596 1.25 briggs "eor %1, %1, %3\n" /* XOR bits */
597 1.25 briggs "msr cpsr_c, %1\n" /* Set the control field of CPSR */
598 1.25 briggs : "=&r" (ret), "=&r" (tmp)
599 1.31 rearnsha : "r" (bic), "r" (eor) : "memory");
600 1.25 briggs
601 1.25 briggs return ret;
602 1.25 briggs }
603 1.25 briggs
604 1.43 chris static __inline uint32_t
605 1.43 chris disable_interrupts(uint32_t mask)
606 1.43 chris {
607 1.43 chris uint32_t tmp, ret;
608 1.43 chris mask &= (I32_bit | F32_bit);
609 1.43 chris
610 1.43 chris __asm volatile(
611 1.43 chris "mrs %0, cpsr\n" /* Get the CPSR */
612 1.43 chris "orr %1, %0, %2\n" /* set bits */
613 1.43 chris "msr cpsr_c, %1\n" /* Set the control field of CPSR */
614 1.43 chris : "=&r" (ret), "=&r" (tmp)
615 1.43 chris : "r" (mask)
616 1.43 chris : "memory");
617 1.43 chris
618 1.43 chris return ret;
619 1.43 chris }
620 1.43 chris
621 1.43 chris static __inline uint32_t
622 1.43 chris enable_interrupts(uint32_t mask)
623 1.43 chris {
624 1.43 chris uint32_t ret, tmp;
625 1.43 chris mask &= (I32_bit | F32_bit);
626 1.43 chris
627 1.43 chris __asm volatile(
628 1.43 chris "mrs %0, cpsr\n" /* Get the CPSR */
629 1.43 chris "bic %1, %0, %2\n" /* Clear bits */
630 1.43 chris "msr cpsr_c, %1\n" /* Set the control field of CPSR */
631 1.43 chris : "=&r" (ret), "=&r" (tmp)
632 1.43 chris : "r" (mask)
633 1.43 chris : "memory");
634 1.1 reinoud
635 1.43 chris return ret;
636 1.43 chris }
637 1.1 reinoud
638 1.15 thorpej #define restore_interrupts(old_cpsr) \
639 1.25 briggs (__set_cpsr_c((I32_bit | F32_bit), (old_cpsr) & (I32_bit | F32_bit)))
640 1.45 matt
641 1.45 matt static inline void cpsie(register_t psw) __attribute__((__unused__));
642 1.45 matt static inline register_t cpsid(register_t psw) __attribute__((__unused__));
643 1.45 matt
644 1.45 matt static inline void
645 1.45 matt cpsie(register_t psw)
646 1.45 matt {
647 1.49 matt #ifdef _ARM_ARCH_6
648 1.45 matt if (!__builtin_constant_p(psw)) {
649 1.45 matt enable_interrupts(psw);
650 1.45 matt return;
651 1.45 matt }
652 1.45 matt switch (psw & (I32_bit|F32_bit)) {
653 1.45 matt case I32_bit: __asm("cpsie\ti"); break;
654 1.45 matt case F32_bit: __asm("cpsie\tf"); break;
655 1.45 matt case I32_bit|F32_bit: __asm("cpsie\tif"); break;
656 1.45 matt }
657 1.48 cliff #else
658 1.48 cliff enable_interrupts(psw);
659 1.48 cliff #endif
660 1.45 matt }
661 1.45 matt
662 1.45 matt static inline register_t
663 1.45 matt cpsid(register_t psw)
664 1.45 matt {
665 1.49 matt #ifdef _ARM_ARCH_6
666 1.45 matt register_t oldpsw;
667 1.45 matt if (!__builtin_constant_p(psw))
668 1.45 matt return disable_interrupts(psw);
669 1.45 matt
670 1.45 matt __asm("mrs %0, cpsr" : "=r"(oldpsw));
671 1.45 matt switch (psw & (I32_bit|F32_bit)) {
672 1.45 matt case I32_bit: __asm("cpsid\ti"); break;
673 1.45 matt case F32_bit: __asm("cpsid\tf"); break;
674 1.45 matt case I32_bit|F32_bit: __asm("cpsid\tif"); break;
675 1.45 matt }
676 1.45 matt return oldpsw;
677 1.48 cliff #else
678 1.48 cliff return disable_interrupts(psw);
679 1.48 cliff #endif
680 1.45 matt }
681 1.45 matt
682 1.15 thorpej #else /* ! __PROG32 */
683 1.15 thorpej #define disable_interrupts(mask) \
684 1.15 thorpej (set_r15((mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE), \
685 1.15 thorpej (mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE)))
686 1.15 thorpej
687 1.15 thorpej #define enable_interrupts(mask) \
688 1.15 thorpej (set_r15((mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE), 0))
689 1.15 thorpej
690 1.15 thorpej #define restore_interrupts(old_r15) \
691 1.15 thorpej (set_r15((R15_IRQ_DISABLE | R15_FIQ_DISABLE), \
692 1.15 thorpej (old_r15) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE)))
693 1.15 thorpej #endif /* __PROG32 */
694 1.15 thorpej
695 1.15 thorpej #ifdef __PROG32
696 1.15 thorpej /* Functions to manipulate the CPSR. */
697 1.32 uwe u_int SetCPSR(u_int, u_int);
698 1.15 thorpej u_int GetCPSR(void);
699 1.15 thorpej #else
700 1.15 thorpej /* Functions to manipulate the processor control bits in r15. */
701 1.32 uwe u_int set_r15(u_int, u_int);
702 1.15 thorpej u_int get_r15(void);
703 1.15 thorpej #endif /* __PROG32 */
704 1.1 reinoud
705 1.1 reinoud
706 1.1 reinoud /*
707 1.1 reinoud * CPU functions from locore.S
708 1.1 reinoud */
709 1.1 reinoud
710 1.58 matt void cpu_reset (void) __dead;
711 1.14 thorpej
712 1.14 thorpej /*
713 1.14 thorpej * Cache info variables.
714 1.14 thorpej */
715 1.14 thorpej
716 1.14 thorpej /* PRIMARY CACHE VARIABLES */
717 1.58 matt struct arm_cache_info {
718 1.58 matt u_int icache_size;
719 1.58 matt u_int icache_line_size;
720 1.58 matt u_int icache_ways;
721 1.58 matt u_int icache_sets;
722 1.58 matt
723 1.58 matt u_int dcache_size;
724 1.58 matt u_int dcache_line_size;
725 1.58 matt u_int dcache_ways;
726 1.58 matt u_int dcache_sets;
727 1.58 matt
728 1.58 matt u_int cache_type;
729 1.58 matt bool cache_unified;
730 1.58 matt };
731 1.58 matt
732 1.58 matt extern u_int arm_cache_prefer_mask;
733 1.58 matt extern u_int arm_dcache_align;
734 1.58 matt extern u_int arm_dcache_align_mask;
735 1.1 reinoud
736 1.58 matt extern struct arm_cache_info arm_pcache;
737 1.58 matt extern struct arm_cache_info arm_scache;
738 1.1 reinoud #endif /* _KERNEL */
739 1.55 christos
740 1.55 christos #if defined(_KERNEL) || defined(_KMEMUSER)
741 1.55 christos /*
742 1.55 christos * Miscellany
743 1.55 christos */
744 1.55 christos
745 1.55 christos int get_pc_str_offset (void);
746 1.55 christos
747 1.55 christos /*
748 1.55 christos * Functions to manipulate cpu r13
749 1.55 christos * (in arm/arm32/setstack.S)
750 1.55 christos */
751 1.55 christos
752 1.55 christos void set_stackptr (u_int, u_int);
753 1.55 christos u_int get_stackptr (u_int);
754 1.55 christos
755 1.55 christos #endif /* _KERNEL || _KMEMUSER */
756 1.55 christos
757 1.1 reinoud #endif /* _ARM32_CPUFUNC_H_ */
758 1.1 reinoud
759 1.1 reinoud /* End of cpufunc.h */
760