cpufunc.h revision 1.44 1 1.44 dogcow /* $NetBSD: cpufunc.h,v 1.44 2008/02/25 06:32:29 dogcow 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.21 thorpej #include <arm/cpuconf.h>
49 1.44 dogcow #include <arm/armreg.h>
50 1.1 reinoud
51 1.1 reinoud struct cpu_functions {
52 1.1 reinoud
53 1.1 reinoud /* CPU functions */
54 1.32 uwe
55 1.39 bjh21 u_int (*cf_id) (void);
56 1.39 bjh21 void (*cf_cpwait) (void);
57 1.1 reinoud
58 1.1 reinoud /* MMU functions */
59 1.1 reinoud
60 1.39 bjh21 u_int (*cf_control) (u_int, u_int);
61 1.39 bjh21 void (*cf_domains) (u_int);
62 1.39 bjh21 void (*cf_setttb) (u_int);
63 1.39 bjh21 u_int (*cf_faultstatus) (void);
64 1.39 bjh21 u_int (*cf_faultaddress) (void);
65 1.1 reinoud
66 1.1 reinoud /* TLB functions */
67 1.1 reinoud
68 1.39 bjh21 void (*cf_tlb_flushID) (void);
69 1.39 bjh21 void (*cf_tlb_flushID_SE) (u_int);
70 1.39 bjh21 void (*cf_tlb_flushI) (void);
71 1.39 bjh21 void (*cf_tlb_flushI_SE) (u_int);
72 1.39 bjh21 void (*cf_tlb_flushD) (void);
73 1.39 bjh21 void (*cf_tlb_flushD_SE) (u_int);
74 1.1 reinoud
75 1.17 thorpej /*
76 1.17 thorpej * Cache operations:
77 1.17 thorpej *
78 1.17 thorpej * We define the following primitives:
79 1.17 thorpej *
80 1.17 thorpej * icache_sync_all Synchronize I-cache
81 1.17 thorpej * icache_sync_range Synchronize I-cache range
82 1.17 thorpej *
83 1.17 thorpej * dcache_wbinv_all Write-back and Invalidate D-cache
84 1.17 thorpej * dcache_wbinv_range Write-back and Invalidate D-cache range
85 1.17 thorpej * dcache_inv_range Invalidate D-cache range
86 1.17 thorpej * dcache_wb_range Write-back D-cache range
87 1.17 thorpej *
88 1.17 thorpej * idcache_wbinv_all Write-back and Invalidate D-cache,
89 1.17 thorpej * Invalidate I-cache
90 1.17 thorpej * idcache_wbinv_range Write-back and Invalidate D-cache,
91 1.17 thorpej * Invalidate I-cache range
92 1.17 thorpej *
93 1.17 thorpej * Note that the ARM term for "write-back" is "clean". We use
94 1.17 thorpej * the term "write-back" since it's a more common way to describe
95 1.17 thorpej * the operation.
96 1.17 thorpej *
97 1.17 thorpej * There are some rules that must be followed:
98 1.17 thorpej *
99 1.17 thorpej * I-cache Synch (all or range):
100 1.17 thorpej * The goal is to synchronize the instruction stream,
101 1.17 thorpej * so you may beed to write-back dirty D-cache blocks
102 1.17 thorpej * first. If a range is requested, and you can't
103 1.17 thorpej * synchronize just a range, you have to hit the whole
104 1.17 thorpej * thing.
105 1.17 thorpej *
106 1.17 thorpej * D-cache Write-Back and Invalidate range:
107 1.17 thorpej * If you can't WB-Inv a range, you must WB-Inv the
108 1.17 thorpej * entire D-cache.
109 1.17 thorpej *
110 1.17 thorpej * D-cache Invalidate:
111 1.17 thorpej * If you can't Inv the D-cache, you must Write-Back
112 1.17 thorpej * and Invalidate. Code that uses this operation
113 1.17 thorpej * MUST NOT assume that the D-cache will not be written
114 1.17 thorpej * back to memory.
115 1.17 thorpej *
116 1.17 thorpej * D-cache Write-Back:
117 1.17 thorpej * If you can't Write-back without doing an Inv,
118 1.17 thorpej * that's fine. Then treat this as a WB-Inv.
119 1.17 thorpej * Skipping the invalidate is merely an optimization.
120 1.17 thorpej *
121 1.17 thorpej * All operations:
122 1.17 thorpej * Valid virtual addresses must be passed to each
123 1.17 thorpej * cache operation.
124 1.17 thorpej */
125 1.39 bjh21 void (*cf_icache_sync_all) (void);
126 1.39 bjh21 void (*cf_icache_sync_range) (vaddr_t, vsize_t);
127 1.17 thorpej
128 1.39 bjh21 void (*cf_dcache_wbinv_all) (void);
129 1.39 bjh21 void (*cf_dcache_wbinv_range)(vaddr_t, vsize_t);
130 1.39 bjh21 void (*cf_dcache_inv_range) (vaddr_t, vsize_t);
131 1.39 bjh21 void (*cf_dcache_wb_range) (vaddr_t, vsize_t);
132 1.1 reinoud
133 1.39 bjh21 void (*cf_idcache_wbinv_all) (void);
134 1.39 bjh21 void (*cf_idcache_wbinv_range)(vaddr_t, vsize_t);
135 1.1 reinoud
136 1.1 reinoud /* Other functions */
137 1.1 reinoud
138 1.39 bjh21 void (*cf_flush_prefetchbuf) (void);
139 1.39 bjh21 void (*cf_drain_writebuf) (void);
140 1.39 bjh21 void (*cf_flush_brnchtgt_C) (void);
141 1.39 bjh21 void (*cf_flush_brnchtgt_E) (u_int);
142 1.1 reinoud
143 1.39 bjh21 void (*cf_sleep) (int mode);
144 1.1 reinoud
145 1.1 reinoud /* Soft functions */
146 1.1 reinoud
147 1.39 bjh21 int (*cf_dataabt_fixup) (void *);
148 1.39 bjh21 int (*cf_prefetchabt_fixup) (void *);
149 1.1 reinoud
150 1.41 scw void (*cf_context_switch) (u_int);
151 1.1 reinoud
152 1.39 bjh21 void (*cf_setup) (char *);
153 1.1 reinoud };
154 1.1 reinoud
155 1.1 reinoud extern struct cpu_functions cpufuncs;
156 1.1 reinoud extern u_int cputype;
157 1.1 reinoud
158 1.1 reinoud #define cpu_id() cpufuncs.cf_id()
159 1.1 reinoud
160 1.1 reinoud #define cpu_control(c, e) cpufuncs.cf_control(c, e)
161 1.1 reinoud #define cpu_domains(d) cpufuncs.cf_domains(d)
162 1.1 reinoud #define cpu_setttb(t) cpufuncs.cf_setttb(t)
163 1.1 reinoud #define cpu_faultstatus() cpufuncs.cf_faultstatus()
164 1.1 reinoud #define cpu_faultaddress() cpufuncs.cf_faultaddress()
165 1.1 reinoud
166 1.1 reinoud #define cpu_tlb_flushID() cpufuncs.cf_tlb_flushID()
167 1.1 reinoud #define cpu_tlb_flushID_SE(e) cpufuncs.cf_tlb_flushID_SE(e)
168 1.1 reinoud #define cpu_tlb_flushI() cpufuncs.cf_tlb_flushI()
169 1.1 reinoud #define cpu_tlb_flushI_SE(e) cpufuncs.cf_tlb_flushI_SE(e)
170 1.1 reinoud #define cpu_tlb_flushD() cpufuncs.cf_tlb_flushD()
171 1.1 reinoud #define cpu_tlb_flushD_SE(e) cpufuncs.cf_tlb_flushD_SE(e)
172 1.1 reinoud
173 1.17 thorpej #define cpu_icache_sync_all() cpufuncs.cf_icache_sync_all()
174 1.17 thorpej #define cpu_icache_sync_range(a, s) cpufuncs.cf_icache_sync_range((a), (s))
175 1.17 thorpej
176 1.17 thorpej #define cpu_dcache_wbinv_all() cpufuncs.cf_dcache_wbinv_all()
177 1.17 thorpej #define cpu_dcache_wbinv_range(a, s) cpufuncs.cf_dcache_wbinv_range((a), (s))
178 1.17 thorpej #define cpu_dcache_inv_range(a, s) cpufuncs.cf_dcache_inv_range((a), (s))
179 1.17 thorpej #define cpu_dcache_wb_range(a, s) cpufuncs.cf_dcache_wb_range((a), (s))
180 1.17 thorpej
181 1.17 thorpej #define cpu_idcache_wbinv_all() cpufuncs.cf_idcache_wbinv_all()
182 1.17 thorpej #define cpu_idcache_wbinv_range(a, s) cpufuncs.cf_idcache_wbinv_range((a), (s))
183 1.1 reinoud
184 1.1 reinoud #define cpu_flush_prefetchbuf() cpufuncs.cf_flush_prefetchbuf()
185 1.1 reinoud #define cpu_drain_writebuf() cpufuncs.cf_drain_writebuf()
186 1.1 reinoud #define cpu_flush_brnchtgt_C() cpufuncs.cf_flush_brnchtgt_C()
187 1.1 reinoud #define cpu_flush_brnchtgt_E(e) cpufuncs.cf_flush_brnchtgt_E(e)
188 1.1 reinoud
189 1.1 reinoud #define cpu_sleep(m) cpufuncs.cf_sleep(m)
190 1.1 reinoud
191 1.1 reinoud #define cpu_dataabt_fixup(a) cpufuncs.cf_dataabt_fixup(a)
192 1.1 reinoud #define cpu_prefetchabt_fixup(a) cpufuncs.cf_prefetchabt_fixup(a)
193 1.7 wiz #define ABORT_FIXUP_OK 0 /* fixup succeeded */
194 1.1 reinoud #define ABORT_FIXUP_FAILED 1 /* fixup failed */
195 1.1 reinoud #define ABORT_FIXUP_RETURN 2 /* abort handler should return */
196 1.1 reinoud
197 1.41 scw #define cpu_context_switch(a) cpufuncs.cf_context_switch(a)
198 1.1 reinoud #define cpu_setup(a) cpufuncs.cf_setup(a)
199 1.1 reinoud
200 1.39 bjh21 int set_cpufuncs (void);
201 1.40 bjh21 int set_cpufuncs_id (u_int);
202 1.1 reinoud #define ARCHITECTURE_NOT_PRESENT 1 /* known but not configured */
203 1.1 reinoud #define ARCHITECTURE_NOT_SUPPORTED 2 /* not known */
204 1.1 reinoud
205 1.39 bjh21 void cpufunc_nullop (void);
206 1.39 bjh21 int cpufunc_null_fixup (void *);
207 1.39 bjh21 int early_abort_fixup (void *);
208 1.39 bjh21 int late_abort_fixup (void *);
209 1.39 bjh21 u_int cpufunc_id (void);
210 1.39 bjh21 u_int cpufunc_control (u_int, u_int);
211 1.39 bjh21 void cpufunc_domains (u_int);
212 1.39 bjh21 u_int cpufunc_faultstatus (void);
213 1.39 bjh21 u_int cpufunc_faultaddress (void);
214 1.3 bjh21
215 1.40 bjh21 #ifdef CPU_ARM2
216 1.40 bjh21 u_int arm2_id (void);
217 1.40 bjh21 #endif /* CPU_ARM2 */
218 1.40 bjh21
219 1.40 bjh21 #ifdef CPU_ARM250
220 1.40 bjh21 u_int arm250_id (void);
221 1.40 bjh21 #endif
222 1.40 bjh21
223 1.3 bjh21 #ifdef CPU_ARM3
224 1.39 bjh21 u_int arm3_control (u_int, u_int);
225 1.39 bjh21 void arm3_cache_flush (void);
226 1.3 bjh21 #endif /* CPU_ARM3 */
227 1.1 reinoud
228 1.1 reinoud #if defined(CPU_ARM6) || defined(CPU_ARM7)
229 1.39 bjh21 void arm67_setttb (u_int);
230 1.39 bjh21 void arm67_tlb_flush (void);
231 1.39 bjh21 void arm67_tlb_purge (u_int);
232 1.39 bjh21 void arm67_cache_flush (void);
233 1.41 scw void arm67_context_switch (u_int);
234 1.1 reinoud #endif /* CPU_ARM6 || CPU_ARM7 */
235 1.1 reinoud
236 1.1 reinoud #ifdef CPU_ARM6
237 1.39 bjh21 void arm6_setup (char *);
238 1.1 reinoud #endif /* CPU_ARM6 */
239 1.1 reinoud
240 1.1 reinoud #ifdef CPU_ARM7
241 1.39 bjh21 void arm7_setup (char *);
242 1.1 reinoud #endif /* CPU_ARM7 */
243 1.5 chris
244 1.5 chris #ifdef CPU_ARM7TDMI
245 1.39 bjh21 int arm7_dataabt_fixup (void *);
246 1.39 bjh21 void arm7tdmi_setup (char *);
247 1.39 bjh21 void arm7tdmi_setttb (u_int);
248 1.39 bjh21 void arm7tdmi_tlb_flushID (void);
249 1.39 bjh21 void arm7tdmi_tlb_flushID_SE (u_int);
250 1.39 bjh21 void arm7tdmi_cache_flushID (void);
251 1.41 scw void arm7tdmi_context_switch (u_int);
252 1.5 chris #endif /* CPU_ARM7TDMI */
253 1.1 reinoud
254 1.1 reinoud #ifdef CPU_ARM8
255 1.39 bjh21 void arm8_setttb (u_int);
256 1.39 bjh21 void arm8_tlb_flushID (void);
257 1.39 bjh21 void arm8_tlb_flushID_SE (u_int);
258 1.39 bjh21 void arm8_cache_flushID (void);
259 1.39 bjh21 void arm8_cache_flushID_E (u_int);
260 1.39 bjh21 void arm8_cache_cleanID (void);
261 1.39 bjh21 void arm8_cache_cleanID_E (u_int);
262 1.39 bjh21 void arm8_cache_purgeID (void);
263 1.39 bjh21 void arm8_cache_purgeID_E (u_int entry);
264 1.39 bjh21
265 1.39 bjh21 void arm8_cache_syncI (void);
266 1.39 bjh21 void arm8_cache_cleanID_rng (vaddr_t, vsize_t);
267 1.39 bjh21 void arm8_cache_cleanD_rng (vaddr_t, vsize_t);
268 1.39 bjh21 void arm8_cache_purgeID_rng (vaddr_t, vsize_t);
269 1.39 bjh21 void arm8_cache_purgeD_rng (vaddr_t, vsize_t);
270 1.39 bjh21 void arm8_cache_syncI_rng (vaddr_t, vsize_t);
271 1.1 reinoud
272 1.41 scw void arm8_context_switch (u_int);
273 1.1 reinoud
274 1.39 bjh21 void arm8_setup (char *);
275 1.1 reinoud
276 1.39 bjh21 u_int arm8_clock_config (u_int, u_int);
277 1.1 reinoud #endif
278 1.1 reinoud
279 1.23 rjs #ifdef CPU_SA110
280 1.39 bjh21 void sa110_setup (char *);
281 1.41 scw void sa110_context_switch (u_int);
282 1.23 rjs #endif /* CPU_SA110 */
283 1.23 rjs
284 1.23 rjs #if defined(CPU_SA1100) || defined(CPU_SA1110)
285 1.39 bjh21 void sa11x0_drain_readbuf (void);
286 1.23 rjs
287 1.41 scw void sa11x0_context_switch (u_int);
288 1.39 bjh21 void sa11x0_cpu_sleep (int);
289 1.32 uwe
290 1.39 bjh21 void sa11x0_setup (char *);
291 1.23 rjs #endif
292 1.23 rjs
293 1.23 rjs #if defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110)
294 1.39 bjh21 void sa1_setttb (u_int);
295 1.23 rjs
296 1.39 bjh21 void sa1_tlb_flushID_SE (u_int);
297 1.23 rjs
298 1.39 bjh21 void sa1_cache_flushID (void);
299 1.39 bjh21 void sa1_cache_flushI (void);
300 1.39 bjh21 void sa1_cache_flushD (void);
301 1.39 bjh21 void sa1_cache_flushD_SE (u_int);
302 1.39 bjh21
303 1.39 bjh21 void sa1_cache_cleanID (void);
304 1.39 bjh21 void sa1_cache_cleanD (void);
305 1.39 bjh21 void sa1_cache_cleanD_E (u_int);
306 1.39 bjh21
307 1.39 bjh21 void sa1_cache_purgeID (void);
308 1.39 bjh21 void sa1_cache_purgeID_E (u_int);
309 1.39 bjh21 void sa1_cache_purgeD (void);
310 1.39 bjh21 void sa1_cache_purgeD_E (u_int);
311 1.39 bjh21
312 1.39 bjh21 void sa1_cache_syncI (void);
313 1.39 bjh21 void sa1_cache_cleanID_rng (vaddr_t, vsize_t);
314 1.39 bjh21 void sa1_cache_cleanD_rng (vaddr_t, vsize_t);
315 1.39 bjh21 void sa1_cache_purgeID_rng (vaddr_t, vsize_t);
316 1.39 bjh21 void sa1_cache_purgeD_rng (vaddr_t, vsize_t);
317 1.39 bjh21 void sa1_cache_syncI_rng (vaddr_t, vsize_t);
318 1.23 rjs
319 1.23 rjs #endif
320 1.23 rjs
321 1.10 rearnsha #ifdef CPU_ARM9
322 1.39 bjh21 void arm9_setttb (u_int);
323 1.10 rearnsha
324 1.39 bjh21 void arm9_tlb_flushID_SE (u_int);
325 1.10 rearnsha
326 1.39 bjh21 void arm9_icache_sync_all (void);
327 1.39 bjh21 void arm9_icache_sync_range (vaddr_t, vsize_t);
328 1.30 rearnsha
329 1.39 bjh21 void arm9_dcache_wbinv_all (void);
330 1.39 bjh21 void arm9_dcache_wbinv_range (vaddr_t, vsize_t);
331 1.39 bjh21 void arm9_dcache_inv_range (vaddr_t, vsize_t);
332 1.39 bjh21 void arm9_dcache_wb_range (vaddr_t, vsize_t);
333 1.30 rearnsha
334 1.39 bjh21 void arm9_idcache_wbinv_all (void);
335 1.39 bjh21 void arm9_idcache_wbinv_range (vaddr_t, vsize_t);
336 1.10 rearnsha
337 1.41 scw void arm9_context_switch (u_int);
338 1.10 rearnsha
339 1.39 bjh21 void arm9_setup (char *);
340 1.30 rearnsha
341 1.30 rearnsha extern unsigned arm9_dcache_sets_max;
342 1.30 rearnsha extern unsigned arm9_dcache_sets_inc;
343 1.30 rearnsha extern unsigned arm9_dcache_index_max;
344 1.30 rearnsha extern unsigned arm9_dcache_index_inc;
345 1.10 rearnsha #endif
346 1.10 rearnsha
347 1.38 christos #if defined(CPU_ARM9E) || defined(CPU_ARM10)
348 1.39 bjh21 void arm10_tlb_flushID_SE (u_int);
349 1.39 bjh21 void arm10_tlb_flushI_SE (u_int);
350 1.29 rearnsha
351 1.41 scw void arm10_context_switch (u_int);
352 1.33 rearnsha
353 1.39 bjh21 void arm10_setup (char *);
354 1.33 rearnsha #endif
355 1.29 rearnsha
356 1.33 rearnsha #ifdef CPU_ARM11
357 1.39 bjh21 void arm11_setttb (u_int);
358 1.29 rearnsha
359 1.39 bjh21 void arm11_tlb_flushID_SE (u_int);
360 1.39 bjh21 void arm11_tlb_flushI_SE (u_int);
361 1.29 rearnsha
362 1.41 scw void arm11_context_switch (u_int);
363 1.33 rearnsha
364 1.39 bjh21 void arm11_setup (char *string);
365 1.39 bjh21 void arm11_tlb_flushID (void);
366 1.39 bjh21 void arm11_tlb_flushI (void);
367 1.39 bjh21 void arm11_tlb_flushD (void);
368 1.39 bjh21 void arm11_tlb_flushD_SE (u_int va);
369 1.29 rearnsha
370 1.39 bjh21 void arm11_drain_writebuf (void);
371 1.33 rearnsha #endif
372 1.29 rearnsha
373 1.38 christos #if defined(CPU_ARM9E) || defined (CPU_ARM10)
374 1.39 bjh21 void armv5_ec_setttb (u_int);
375 1.38 christos
376 1.39 bjh21 void armv5_ec_icache_sync_all (void);
377 1.39 bjh21 void armv5_ec_icache_sync_range (vaddr_t, vsize_t);
378 1.38 christos
379 1.39 bjh21 void armv5_ec_dcache_wbinv_all (void);
380 1.39 bjh21 void armv5_ec_dcache_wbinv_range (vaddr_t, vsize_t);
381 1.39 bjh21 void armv5_ec_dcache_inv_range (vaddr_t, vsize_t);
382 1.39 bjh21 void armv5_ec_dcache_wb_range (vaddr_t, vsize_t);
383 1.38 christos
384 1.39 bjh21 void armv5_ec_idcache_wbinv_all (void);
385 1.39 bjh21 void armv5_ec_idcache_wbinv_range (vaddr_t, vsize_t);
386 1.38 christos #endif
387 1.38 christos
388 1.33 rearnsha #if defined (CPU_ARM10) || defined (CPU_ARM11)
389 1.39 bjh21 void armv5_setttb (u_int);
390 1.38 christos
391 1.39 bjh21 void armv5_icache_sync_all (void);
392 1.39 bjh21 void armv5_icache_sync_range (vaddr_t, vsize_t);
393 1.33 rearnsha
394 1.39 bjh21 void armv5_dcache_wbinv_all (void);
395 1.39 bjh21 void armv5_dcache_wbinv_range (vaddr_t, vsize_t);
396 1.39 bjh21 void armv5_dcache_inv_range (vaddr_t, vsize_t);
397 1.39 bjh21 void armv5_dcache_wb_range (vaddr_t, vsize_t);
398 1.33 rearnsha
399 1.39 bjh21 void armv5_idcache_wbinv_all (void);
400 1.39 bjh21 void armv5_idcache_wbinv_range (vaddr_t, vsize_t);
401 1.33 rearnsha
402 1.33 rearnsha extern unsigned armv5_dcache_sets_max;
403 1.33 rearnsha extern unsigned armv5_dcache_sets_inc;
404 1.33 rearnsha extern unsigned armv5_dcache_index_max;
405 1.33 rearnsha extern unsigned armv5_dcache_index_inc;
406 1.29 rearnsha #endif
407 1.29 rearnsha
408 1.38 christos #if defined(CPU_ARM9) || defined(CPU_ARM9E) || defined(CPU_ARM10) || \
409 1.38 christos defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110) || \
410 1.29 rearnsha defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \
411 1.34 bsh defined(__CPU_XSCALE_PXA2XX) || defined(CPU_XSCALE_IXP425)
412 1.23 rjs
413 1.39 bjh21 void armv4_tlb_flushID (void);
414 1.39 bjh21 void armv4_tlb_flushI (void);
415 1.39 bjh21 void armv4_tlb_flushD (void);
416 1.39 bjh21 void armv4_tlb_flushD_SE (u_int);
417 1.10 rearnsha
418 1.39 bjh21 void armv4_drain_writebuf (void);
419 1.24 ichiro #endif
420 1.24 ichiro
421 1.24 ichiro #if defined(CPU_IXP12X0)
422 1.39 bjh21 void ixp12x0_drain_readbuf (void);
423 1.41 scw void ixp12x0_context_switch (u_int);
424 1.39 bjh21 void ixp12x0_setup (char *);
425 1.10 rearnsha #endif
426 1.1 reinoud
427 1.22 thorpej #if defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \
428 1.34 bsh defined(__CPU_XSCALE_PXA2XX) || defined(CPU_XSCALE_IXP425)
429 1.43 chris
430 1.39 bjh21 void xscale_cpwait (void);
431 1.43 chris #define cpu_cpwait() cpufuncs.cf_cpwait()
432 1.16 briggs
433 1.39 bjh21 void xscale_cpu_sleep (int);
434 1.12 thorpej
435 1.39 bjh21 u_int xscale_control (u_int, u_int);
436 1.11 thorpej
437 1.39 bjh21 void xscale_setttb (u_int);
438 1.10 rearnsha
439 1.39 bjh21 void xscale_tlb_flushID_SE (u_int);
440 1.8 matt
441 1.39 bjh21 void xscale_cache_flushID (void);
442 1.39 bjh21 void xscale_cache_flushI (void);
443 1.39 bjh21 void xscale_cache_flushD (void);
444 1.39 bjh21 void xscale_cache_flushD_SE (u_int);
445 1.8 matt
446 1.39 bjh21 void xscale_cache_cleanID (void);
447 1.39 bjh21 void xscale_cache_cleanD (void);
448 1.39 bjh21 void xscale_cache_cleanD_E (u_int);
449 1.20 thorpej
450 1.39 bjh21 void xscale_cache_clean_minidata (void);
451 1.8 matt
452 1.39 bjh21 void xscale_cache_purgeID (void);
453 1.39 bjh21 void xscale_cache_purgeID_E (u_int);
454 1.39 bjh21 void xscale_cache_purgeD (void);
455 1.39 bjh21 void xscale_cache_purgeD_E (u_int);
456 1.8 matt
457 1.39 bjh21 void xscale_cache_syncI (void);
458 1.39 bjh21 void xscale_cache_cleanID_rng (vaddr_t, vsize_t);
459 1.39 bjh21 void xscale_cache_cleanD_rng (vaddr_t, vsize_t);
460 1.39 bjh21 void xscale_cache_purgeID_rng (vaddr_t, vsize_t);
461 1.39 bjh21 void xscale_cache_purgeD_rng (vaddr_t, vsize_t);
462 1.39 bjh21 void xscale_cache_syncI_rng (vaddr_t, vsize_t);
463 1.39 bjh21 void xscale_cache_flushD_rng (vaddr_t, vsize_t);
464 1.8 matt
465 1.41 scw void xscale_context_switch (u_int);
466 1.8 matt
467 1.39 bjh21 void xscale_setup (char *);
468 1.34 bsh #endif /* CPU_XSCALE_80200 || CPU_XSCALE_80321 || __CPU_XSCALE_PXA2XX || CPU_XSCALE_IXP425 */
469 1.8 matt
470 1.1 reinoud #define tlb_flush cpu_tlb_flushID
471 1.1 reinoud #define setttb cpu_setttb
472 1.1 reinoud #define drain_writebuf cpu_drain_writebuf
473 1.1 reinoud
474 1.43 chris #ifndef cpu_cpwait
475 1.43 chris #define cpu_cpwait()
476 1.43 chris #endif
477 1.43 chris
478 1.1 reinoud /*
479 1.1 reinoud * Macros for manipulating CPU interrupts
480 1.1 reinoud */
481 1.15 thorpej #ifdef __PROG32
482 1.43 chris static __inline u_int32_t __set_cpsr_c(uint32_t bic, uint32_t eor) __attribute__((__unused__));
483 1.43 chris static __inline u_int32_t disable_interrupts(uint32_t mask) __attribute__((__unused__));
484 1.43 chris static __inline u_int32_t enable_interrupts(uint32_t mask) __attribute__((__unused__));
485 1.25 briggs
486 1.43 chris static __inline uint32_t
487 1.43 chris __set_cpsr_c(uint32_t bic, uint32_t eor)
488 1.25 briggs {
489 1.43 chris uint32_t tmp, ret;
490 1.25 briggs
491 1.36 perry __asm volatile(
492 1.25 briggs "mrs %0, cpsr\n" /* Get the CPSR */
493 1.25 briggs "bic %1, %0, %2\n" /* Clear bits */
494 1.25 briggs "eor %1, %1, %3\n" /* XOR bits */
495 1.25 briggs "msr cpsr_c, %1\n" /* Set the control field of CPSR */
496 1.25 briggs : "=&r" (ret), "=&r" (tmp)
497 1.31 rearnsha : "r" (bic), "r" (eor) : "memory");
498 1.25 briggs
499 1.25 briggs return ret;
500 1.25 briggs }
501 1.25 briggs
502 1.43 chris static __inline uint32_t
503 1.43 chris disable_interrupts(uint32_t mask)
504 1.43 chris {
505 1.43 chris uint32_t tmp, ret;
506 1.43 chris mask &= (I32_bit | F32_bit);
507 1.43 chris
508 1.43 chris __asm volatile(
509 1.43 chris "mrs %0, cpsr\n" /* Get the CPSR */
510 1.43 chris "orr %1, %0, %2\n" /* set bits */
511 1.43 chris "msr cpsr_c, %1\n" /* Set the control field of CPSR */
512 1.43 chris : "=&r" (ret), "=&r" (tmp)
513 1.43 chris : "r" (mask)
514 1.43 chris : "memory");
515 1.43 chris
516 1.43 chris return ret;
517 1.43 chris }
518 1.43 chris
519 1.43 chris static __inline uint32_t
520 1.43 chris enable_interrupts(uint32_t mask)
521 1.43 chris {
522 1.43 chris uint32_t ret, tmp;
523 1.43 chris mask &= (I32_bit | F32_bit);
524 1.43 chris
525 1.43 chris __asm volatile(
526 1.43 chris "mrs %0, cpsr\n" /* Get the CPSR */
527 1.43 chris "bic %1, %0, %2\n" /* Clear bits */
528 1.43 chris "msr cpsr_c, %1\n" /* Set the control field of CPSR */
529 1.43 chris : "=&r" (ret), "=&r" (tmp)
530 1.43 chris : "r" (mask)
531 1.43 chris : "memory");
532 1.1 reinoud
533 1.43 chris return ret;
534 1.43 chris }
535 1.1 reinoud
536 1.15 thorpej #define restore_interrupts(old_cpsr) \
537 1.25 briggs (__set_cpsr_c((I32_bit | F32_bit), (old_cpsr) & (I32_bit | F32_bit)))
538 1.15 thorpej #else /* ! __PROG32 */
539 1.15 thorpej #define disable_interrupts(mask) \
540 1.15 thorpej (set_r15((mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE), \
541 1.15 thorpej (mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE)))
542 1.15 thorpej
543 1.15 thorpej #define enable_interrupts(mask) \
544 1.15 thorpej (set_r15((mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE), 0))
545 1.15 thorpej
546 1.15 thorpej #define restore_interrupts(old_r15) \
547 1.15 thorpej (set_r15((R15_IRQ_DISABLE | R15_FIQ_DISABLE), \
548 1.15 thorpej (old_r15) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE)))
549 1.15 thorpej #endif /* __PROG32 */
550 1.15 thorpej
551 1.15 thorpej #ifdef __PROG32
552 1.15 thorpej /* Functions to manipulate the CPSR. */
553 1.32 uwe u_int SetCPSR(u_int, u_int);
554 1.15 thorpej u_int GetCPSR(void);
555 1.15 thorpej #else
556 1.15 thorpej /* Functions to manipulate the processor control bits in r15. */
557 1.32 uwe u_int set_r15(u_int, u_int);
558 1.15 thorpej u_int get_r15(void);
559 1.15 thorpej #endif /* __PROG32 */
560 1.1 reinoud
561 1.1 reinoud /*
562 1.1 reinoud * Functions to manipulate cpu r13
563 1.8 matt * (in arm/arm32/setstack.S)
564 1.1 reinoud */
565 1.1 reinoud
566 1.39 bjh21 void set_stackptr (u_int, u_int);
567 1.39 bjh21 u_int get_stackptr (u_int);
568 1.6 bjh21
569 1.6 bjh21 /*
570 1.6 bjh21 * Miscellany
571 1.6 bjh21 */
572 1.6 bjh21
573 1.39 bjh21 int get_pc_str_offset (void);
574 1.1 reinoud
575 1.1 reinoud /*
576 1.1 reinoud * CPU functions from locore.S
577 1.1 reinoud */
578 1.1 reinoud
579 1.39 bjh21 void cpu_reset (void) __attribute__((__noreturn__));
580 1.14 thorpej
581 1.14 thorpej /*
582 1.14 thorpej * Cache info variables.
583 1.14 thorpej */
584 1.14 thorpej
585 1.14 thorpej /* PRIMARY CACHE VARIABLES */
586 1.28 rearnsha extern int arm_picache_size;
587 1.28 rearnsha extern int arm_picache_line_size;
588 1.28 rearnsha extern int arm_picache_ways;
589 1.28 rearnsha
590 1.28 rearnsha extern int arm_pdcache_size; /* and unified */
591 1.28 rearnsha extern int arm_pdcache_line_size;
592 1.32 uwe extern int arm_pdcache_ways;
593 1.14 thorpej
594 1.28 rearnsha extern int arm_pcache_type;
595 1.28 rearnsha extern int arm_pcache_unified;
596 1.14 thorpej
597 1.28 rearnsha extern int arm_dcache_align;
598 1.28 rearnsha extern int arm_dcache_align_mask;
599 1.1 reinoud
600 1.1 reinoud #endif /* _KERNEL */
601 1.1 reinoud #endif /* _ARM32_CPUFUNC_H_ */
602 1.1 reinoud
603 1.1 reinoud /* End of cpufunc.h */
604