cpufunc.h revision 1.87 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.65 matt #ifndef _ARM_CPUFUNC_H_
43 1.65 matt #define _ARM_CPUFUNC_H_
44 1.1 reinoud
45 1.84 skrll #ifdef _ARM_ARCH_7
46 1.83 skrll /*
47 1.83 skrll * Options for DMB and DSB:
48 1.83 skrll * oshld Outer Shareable, load
49 1.83 skrll * oshst Outer Shareable, store
50 1.83 skrll * osh Outer Shareable, all
51 1.83 skrll * nshld Non-shareable, load
52 1.83 skrll * nshst Non-shareable, store
53 1.83 skrll * nsh Non-shareable, all
54 1.83 skrll * ishld Inner Shareable, load
55 1.83 skrll * ishst Inner Shareable, store
56 1.83 skrll * ish Inner Shareable, all
57 1.83 skrll * ld Full system, load
58 1.83 skrll * st Full system, store
59 1.83 skrll * sy Full system, all
60 1.83 skrll */
61 1.83 skrll #define dsb(opt) __asm __volatile("dsb " __STRING(opt) : : : "memory")
62 1.83 skrll #define dmb(opt) __asm __volatile("dmb " __STRING(opt) : : : "memory")
63 1.85 skrll #define isb() __asm __volatile("isb" : : : "memory")
64 1.86 skrll #define sev() __asm __volatile("sev" : : : "memory")
65 1.85 skrll
66 1.84 skrll #else
67 1.84 skrll
68 1.84 skrll #define dsb(opt) \
69 1.84 skrll __asm __volatile("mcr p15, 0, %0, c7, c10, 4" :: "r" (0) : "memory")
70 1.84 skrll #define dmb(opt) \
71 1.84 skrll __asm __volatile("mcr p15, 0, %0, c7, c10, 5" :: "r" (0) : "memory")
72 1.85 skrll #define isb() \
73 1.85 skrll __asm __volatile("mcr p15, 0, %0, c7, c5, 4" :: "r" (0) : "memory")
74 1.86 skrll #define sev() __nothing
75 1.84 skrll
76 1.84 skrll #endif
77 1.83 skrll
78 1.79 ryo #ifdef __arm__
79 1.79 ryo
80 1.21 thorpej #ifdef _KERNEL
81 1.21 thorpej
82 1.1 reinoud #include <sys/types.h>
83 1.79 ryo
84 1.45 matt #include <arm/armreg.h>
85 1.21 thorpej #include <arm/cpuconf.h>
86 1.74 christos #include <arm/cpufunc_proto.h>
87 1.1 reinoud
88 1.1 reinoud struct cpu_functions {
89 1.1 reinoud
90 1.1 reinoud /* CPU functions */
91 1.32 uwe
92 1.39 bjh21 u_int (*cf_id) (void);
93 1.39 bjh21 void (*cf_cpwait) (void);
94 1.1 reinoud
95 1.1 reinoud /* MMU functions */
96 1.1 reinoud
97 1.39 bjh21 u_int (*cf_control) (u_int, u_int);
98 1.39 bjh21 void (*cf_domains) (u_int);
99 1.69 matt #if defined(ARM_MMU_EXTENDED)
100 1.69 matt void (*cf_setttb) (u_int, tlb_asid_t);
101 1.69 matt #else
102 1.60 matt void (*cf_setttb) (u_int, bool);
103 1.69 matt #endif
104 1.39 bjh21 u_int (*cf_faultstatus) (void);
105 1.39 bjh21 u_int (*cf_faultaddress) (void);
106 1.1 reinoud
107 1.1 reinoud /* TLB functions */
108 1.1 reinoud
109 1.39 bjh21 void (*cf_tlb_flushID) (void);
110 1.66 matt void (*cf_tlb_flushID_SE) (vaddr_t);
111 1.39 bjh21 void (*cf_tlb_flushI) (void);
112 1.66 matt void (*cf_tlb_flushI_SE) (vaddr_t);
113 1.39 bjh21 void (*cf_tlb_flushD) (void);
114 1.66 matt void (*cf_tlb_flushD_SE) (vaddr_t);
115 1.1 reinoud
116 1.17 thorpej /*
117 1.17 thorpej * Cache operations:
118 1.17 thorpej *
119 1.17 thorpej * We define the following primitives:
120 1.17 thorpej *
121 1.17 thorpej * icache_sync_all Synchronize I-cache
122 1.17 thorpej * icache_sync_range Synchronize I-cache range
123 1.17 thorpej *
124 1.17 thorpej * dcache_wbinv_all Write-back and Invalidate D-cache
125 1.17 thorpej * dcache_wbinv_range Write-back and Invalidate D-cache range
126 1.17 thorpej * dcache_inv_range Invalidate D-cache range
127 1.17 thorpej * dcache_wb_range Write-back D-cache range
128 1.17 thorpej *
129 1.17 thorpej * idcache_wbinv_all Write-back and Invalidate D-cache,
130 1.17 thorpej * Invalidate I-cache
131 1.17 thorpej * idcache_wbinv_range Write-back and Invalidate D-cache,
132 1.17 thorpej * Invalidate I-cache range
133 1.17 thorpej *
134 1.17 thorpej * Note that the ARM term for "write-back" is "clean". We use
135 1.17 thorpej * the term "write-back" since it's a more common way to describe
136 1.17 thorpej * the operation.
137 1.17 thorpej *
138 1.17 thorpej * There are some rules that must be followed:
139 1.17 thorpej *
140 1.17 thorpej * I-cache Synch (all or range):
141 1.17 thorpej * The goal is to synchronize the instruction stream,
142 1.17 thorpej * so you may beed to write-back dirty D-cache blocks
143 1.17 thorpej * first. If a range is requested, and you can't
144 1.17 thorpej * synchronize just a range, you have to hit the whole
145 1.17 thorpej * thing.
146 1.17 thorpej *
147 1.17 thorpej * D-cache Write-Back and Invalidate range:
148 1.17 thorpej * If you can't WB-Inv a range, you must WB-Inv the
149 1.17 thorpej * entire D-cache.
150 1.17 thorpej *
151 1.17 thorpej * D-cache Invalidate:
152 1.17 thorpej * If you can't Inv the D-cache, you must Write-Back
153 1.17 thorpej * and Invalidate. Code that uses this operation
154 1.17 thorpej * MUST NOT assume that the D-cache will not be written
155 1.17 thorpej * back to memory.
156 1.17 thorpej *
157 1.17 thorpej * D-cache Write-Back:
158 1.17 thorpej * If you can't Write-back without doing an Inv,
159 1.17 thorpej * that's fine. Then treat this as a WB-Inv.
160 1.17 thorpej * Skipping the invalidate is merely an optimization.
161 1.17 thorpej *
162 1.17 thorpej * All operations:
163 1.17 thorpej * Valid virtual addresses must be passed to each
164 1.17 thorpej * cache operation.
165 1.17 thorpej */
166 1.39 bjh21 void (*cf_icache_sync_all) (void);
167 1.39 bjh21 void (*cf_icache_sync_range) (vaddr_t, vsize_t);
168 1.17 thorpej
169 1.39 bjh21 void (*cf_dcache_wbinv_all) (void);
170 1.39 bjh21 void (*cf_dcache_wbinv_range)(vaddr_t, vsize_t);
171 1.39 bjh21 void (*cf_dcache_inv_range) (vaddr_t, vsize_t);
172 1.39 bjh21 void (*cf_dcache_wb_range) (vaddr_t, vsize_t);
173 1.1 reinoud
174 1.59 matt void (*cf_sdcache_wbinv_range)(vaddr_t, paddr_t, psize_t);
175 1.59 matt void (*cf_sdcache_inv_range) (vaddr_t, paddr_t, psize_t);
176 1.59 matt void (*cf_sdcache_wb_range) (vaddr_t, paddr_t, psize_t);
177 1.59 matt
178 1.39 bjh21 void (*cf_idcache_wbinv_all) (void);
179 1.39 bjh21 void (*cf_idcache_wbinv_range)(vaddr_t, vsize_t);
180 1.1 reinoud
181 1.1 reinoud /* Other functions */
182 1.1 reinoud
183 1.39 bjh21 void (*cf_flush_prefetchbuf) (void);
184 1.39 bjh21 void (*cf_drain_writebuf) (void);
185 1.39 bjh21 void (*cf_flush_brnchtgt_C) (void);
186 1.39 bjh21 void (*cf_flush_brnchtgt_E) (u_int);
187 1.1 reinoud
188 1.39 bjh21 void (*cf_sleep) (int mode);
189 1.1 reinoud
190 1.1 reinoud /* Soft functions */
191 1.1 reinoud
192 1.39 bjh21 int (*cf_dataabt_fixup) (void *);
193 1.39 bjh21 int (*cf_prefetchabt_fixup) (void *);
194 1.1 reinoud
195 1.69 matt #if defined(ARM_MMU_EXTENDED)
196 1.69 matt void (*cf_context_switch) (u_int, tlb_asid_t);
197 1.69 matt #else
198 1.41 scw void (*cf_context_switch) (u_int);
199 1.69 matt #endif
200 1.1 reinoud
201 1.39 bjh21 void (*cf_setup) (char *);
202 1.1 reinoud };
203 1.1 reinoud
204 1.1 reinoud extern struct cpu_functions cpufuncs;
205 1.1 reinoud extern u_int cputype;
206 1.1 reinoud
207 1.76 christos #define cpu_idnum() cpufuncs.cf_id()
208 1.1 reinoud
209 1.1 reinoud #define cpu_control(c, e) cpufuncs.cf_control(c, e)
210 1.1 reinoud #define cpu_domains(d) cpufuncs.cf_domains(d)
211 1.60 matt #define cpu_setttb(t, f) cpufuncs.cf_setttb(t, f)
212 1.1 reinoud #define cpu_faultstatus() cpufuncs.cf_faultstatus()
213 1.1 reinoud #define cpu_faultaddress() cpufuncs.cf_faultaddress()
214 1.1 reinoud
215 1.1 reinoud #define cpu_tlb_flushID() cpufuncs.cf_tlb_flushID()
216 1.1 reinoud #define cpu_tlb_flushID_SE(e) cpufuncs.cf_tlb_flushID_SE(e)
217 1.1 reinoud #define cpu_tlb_flushI() cpufuncs.cf_tlb_flushI()
218 1.1 reinoud #define cpu_tlb_flushI_SE(e) cpufuncs.cf_tlb_flushI_SE(e)
219 1.1 reinoud #define cpu_tlb_flushD() cpufuncs.cf_tlb_flushD()
220 1.1 reinoud #define cpu_tlb_flushD_SE(e) cpufuncs.cf_tlb_flushD_SE(e)
221 1.1 reinoud
222 1.17 thorpej #define cpu_icache_sync_all() cpufuncs.cf_icache_sync_all()
223 1.17 thorpej #define cpu_icache_sync_range(a, s) cpufuncs.cf_icache_sync_range((a), (s))
224 1.17 thorpej
225 1.17 thorpej #define cpu_dcache_wbinv_all() cpufuncs.cf_dcache_wbinv_all()
226 1.17 thorpej #define cpu_dcache_wbinv_range(a, s) cpufuncs.cf_dcache_wbinv_range((a), (s))
227 1.17 thorpej #define cpu_dcache_inv_range(a, s) cpufuncs.cf_dcache_inv_range((a), (s))
228 1.17 thorpej #define cpu_dcache_wb_range(a, s) cpufuncs.cf_dcache_wb_range((a), (s))
229 1.17 thorpej
230 1.59 matt #define cpu_sdcache_wbinv_range(a, b, s) cpufuncs.cf_sdcache_wbinv_range((a), (b), (s))
231 1.59 matt #define cpu_sdcache_inv_range(a, b, s) cpufuncs.cf_sdcache_inv_range((a), (b), (s))
232 1.59 matt #define cpu_sdcache_wb_range(a, b, s) cpufuncs.cf_sdcache_wb_range((a), (b), (s))
233 1.59 matt
234 1.17 thorpej #define cpu_idcache_wbinv_all() cpufuncs.cf_idcache_wbinv_all()
235 1.17 thorpej #define cpu_idcache_wbinv_range(a, s) cpufuncs.cf_idcache_wbinv_range((a), (s))
236 1.1 reinoud
237 1.1 reinoud #define cpu_flush_prefetchbuf() cpufuncs.cf_flush_prefetchbuf()
238 1.1 reinoud #define cpu_drain_writebuf() cpufuncs.cf_drain_writebuf()
239 1.1 reinoud #define cpu_flush_brnchtgt_C() cpufuncs.cf_flush_brnchtgt_C()
240 1.1 reinoud #define cpu_flush_brnchtgt_E(e) cpufuncs.cf_flush_brnchtgt_E(e)
241 1.1 reinoud
242 1.1 reinoud #define cpu_sleep(m) cpufuncs.cf_sleep(m)
243 1.1 reinoud
244 1.1 reinoud #define cpu_dataabt_fixup(a) cpufuncs.cf_dataabt_fixup(a)
245 1.1 reinoud #define cpu_prefetchabt_fixup(a) cpufuncs.cf_prefetchabt_fixup(a)
246 1.7 wiz #define ABORT_FIXUP_OK 0 /* fixup succeeded */
247 1.1 reinoud #define ABORT_FIXUP_FAILED 1 /* fixup failed */
248 1.1 reinoud #define ABORT_FIXUP_RETURN 2 /* abort handler should return */
249 1.1 reinoud
250 1.41 scw #define cpu_context_switch(a) cpufuncs.cf_context_switch(a)
251 1.1 reinoud #define cpu_setup(a) cpufuncs.cf_setup(a)
252 1.1 reinoud
253 1.39 bjh21 int set_cpufuncs (void);
254 1.40 bjh21 int set_cpufuncs_id (u_int);
255 1.1 reinoud #define ARCHITECTURE_NOT_PRESENT 1 /* known but not configured */
256 1.1 reinoud #define ARCHITECTURE_NOT_SUPPORTED 2 /* not known */
257 1.1 reinoud
258 1.39 bjh21 void cpufunc_nullop (void);
259 1.39 bjh21 int cpufunc_null_fixup (void *);
260 1.39 bjh21 int early_abort_fixup (void *);
261 1.39 bjh21 int late_abort_fixup (void *);
262 1.39 bjh21 u_int cpufunc_id (void);
263 1.39 bjh21 u_int cpufunc_control (u_int, u_int);
264 1.39 bjh21 void cpufunc_domains (u_int);
265 1.39 bjh21 u_int cpufunc_faultstatus (void);
266 1.39 bjh21 u_int cpufunc_faultaddress (void);
267 1.3 bjh21
268 1.1 reinoud #define setttb cpu_setttb
269 1.1 reinoud #define drain_writebuf cpu_drain_writebuf
270 1.1 reinoud
271 1.73 matt
272 1.73 matt #if defined(CPU_XSCALE)
273 1.73 matt #define cpu_cpwait() cpufuncs.cf_cpwait()
274 1.73 matt #endif
275 1.73 matt
276 1.43 chris #ifndef cpu_cpwait
277 1.43 chris #define cpu_cpwait()
278 1.43 chris #endif
279 1.43 chris
280 1.1 reinoud /*
281 1.1 reinoud * Macros for manipulating CPU interrupts
282 1.1 reinoud */
283 1.62 skrll static __inline uint32_t __set_cpsr_c(uint32_t bic, uint32_t eor) __attribute__((__unused__));
284 1.62 skrll static __inline uint32_t disable_interrupts(uint32_t mask) __attribute__((__unused__));
285 1.62 skrll static __inline uint32_t enable_interrupts(uint32_t mask) __attribute__((__unused__));
286 1.25 briggs
287 1.43 chris static __inline uint32_t
288 1.43 chris __set_cpsr_c(uint32_t bic, uint32_t eor)
289 1.25 briggs {
290 1.43 chris uint32_t tmp, ret;
291 1.25 briggs
292 1.36 perry __asm volatile(
293 1.25 briggs "mrs %0, cpsr\n" /* Get the CPSR */
294 1.25 briggs "bic %1, %0, %2\n" /* Clear bits */
295 1.25 briggs "eor %1, %1, %3\n" /* XOR bits */
296 1.25 briggs "msr cpsr_c, %1\n" /* Set the control field of CPSR */
297 1.25 briggs : "=&r" (ret), "=&r" (tmp)
298 1.31 rearnsha : "r" (bic), "r" (eor) : "memory");
299 1.25 briggs
300 1.25 briggs return ret;
301 1.25 briggs }
302 1.25 briggs
303 1.43 chris static __inline uint32_t
304 1.43 chris disable_interrupts(uint32_t mask)
305 1.43 chris {
306 1.43 chris uint32_t tmp, ret;
307 1.43 chris mask &= (I32_bit | F32_bit);
308 1.43 chris
309 1.43 chris __asm volatile(
310 1.43 chris "mrs %0, cpsr\n" /* Get the CPSR */
311 1.43 chris "orr %1, %0, %2\n" /* set bits */
312 1.43 chris "msr cpsr_c, %1\n" /* Set the control field of CPSR */
313 1.43 chris : "=&r" (ret), "=&r" (tmp)
314 1.43 chris : "r" (mask)
315 1.43 chris : "memory");
316 1.43 chris
317 1.43 chris return ret;
318 1.43 chris }
319 1.43 chris
320 1.43 chris static __inline uint32_t
321 1.43 chris enable_interrupts(uint32_t mask)
322 1.43 chris {
323 1.69 matt uint32_t ret;
324 1.43 chris mask &= (I32_bit | F32_bit);
325 1.43 chris
326 1.69 matt /* Get the CPSR */
327 1.69 matt __asm __volatile("mrs\t%0, cpsr\n" : "=r"(ret));
328 1.69 matt #ifdef _ARM_ARCH_6
329 1.69 matt if (__builtin_constant_p(mask)) {
330 1.69 matt switch (mask) {
331 1.69 matt case I32_bit | F32_bit:
332 1.69 matt __asm __volatile("cpsie\tif");
333 1.69 matt break;
334 1.69 matt case I32_bit:
335 1.69 matt __asm __volatile("cpsie\ti");
336 1.69 matt break;
337 1.69 matt case F32_bit:
338 1.69 matt __asm __volatile("cpsie\tf");
339 1.69 matt break;
340 1.69 matt default:
341 1.69 matt break;
342 1.69 matt }
343 1.69 matt return ret;
344 1.69 matt }
345 1.69 matt #endif /* _ARM_ARCH_6 */
346 1.69 matt
347 1.69 matt /* Set the control field of CPSR */
348 1.69 matt __asm volatile("msr\tcpsr_c, %0" :: "r"(ret & ~mask));
349 1.1 reinoud
350 1.43 chris return ret;
351 1.43 chris }
352 1.1 reinoud
353 1.15 thorpej #define restore_interrupts(old_cpsr) \
354 1.25 briggs (__set_cpsr_c((I32_bit | F32_bit), (old_cpsr) & (I32_bit | F32_bit)))
355 1.45 matt
356 1.87 jmcneill #define ENABLE_INTERRUPT() cpsie(I32_bit)
357 1.87 jmcneill #define DISABLE_INTERRUPT() cpsid(I32_bit)
358 1.87 jmcneill
359 1.45 matt static inline void cpsie(register_t psw) __attribute__((__unused__));
360 1.45 matt static inline register_t cpsid(register_t psw) __attribute__((__unused__));
361 1.45 matt
362 1.45 matt static inline void
363 1.45 matt cpsie(register_t psw)
364 1.45 matt {
365 1.49 matt #ifdef _ARM_ARCH_6
366 1.45 matt if (!__builtin_constant_p(psw)) {
367 1.45 matt enable_interrupts(psw);
368 1.45 matt return;
369 1.45 matt }
370 1.45 matt switch (psw & (I32_bit|F32_bit)) {
371 1.45 matt case I32_bit: __asm("cpsie\ti"); break;
372 1.45 matt case F32_bit: __asm("cpsie\tf"); break;
373 1.45 matt case I32_bit|F32_bit: __asm("cpsie\tif"); break;
374 1.45 matt }
375 1.48 cliff #else
376 1.48 cliff enable_interrupts(psw);
377 1.48 cliff #endif
378 1.45 matt }
379 1.45 matt
380 1.45 matt static inline register_t
381 1.45 matt cpsid(register_t psw)
382 1.45 matt {
383 1.49 matt #ifdef _ARM_ARCH_6
384 1.45 matt register_t oldpsw;
385 1.45 matt if (!__builtin_constant_p(psw))
386 1.45 matt return disable_interrupts(psw);
387 1.45 matt
388 1.45 matt __asm("mrs %0, cpsr" : "=r"(oldpsw));
389 1.45 matt switch (psw & (I32_bit|F32_bit)) {
390 1.45 matt case I32_bit: __asm("cpsid\ti"); break;
391 1.45 matt case F32_bit: __asm("cpsid\tf"); break;
392 1.45 matt case I32_bit|F32_bit: __asm("cpsid\tif"); break;
393 1.45 matt }
394 1.45 matt return oldpsw;
395 1.80 skrll #else
396 1.48 cliff return disable_interrupts(psw);
397 1.48 cliff #endif
398 1.45 matt }
399 1.45 matt
400 1.15 thorpej
401 1.15 thorpej /* Functions to manipulate the CPSR. */
402 1.32 uwe u_int SetCPSR(u_int, u_int);
403 1.15 thorpej u_int GetCPSR(void);
404 1.1 reinoud
405 1.1 reinoud
406 1.1 reinoud /*
407 1.1 reinoud * CPU functions from locore.S
408 1.1 reinoud */
409 1.1 reinoud
410 1.58 matt void cpu_reset (void) __dead;
411 1.14 thorpej
412 1.14 thorpej /*
413 1.14 thorpej * Cache info variables.
414 1.14 thorpej */
415 1.67 matt #define CACHE_TYPE_VIVT 0
416 1.67 matt #define CACHE_TYPE_xxPT 1
417 1.67 matt #define CACHE_TYPE_VIPT 1
418 1.67 matt #define CACHE_TYPE_PIxx 2
419 1.67 matt #define CACHE_TYPE_PIPT 3
420 1.14 thorpej
421 1.14 thorpej /* PRIMARY CACHE VARIABLES */
422 1.58 matt struct arm_cache_info {
423 1.58 matt u_int icache_size;
424 1.58 matt u_int icache_line_size;
425 1.58 matt u_int icache_ways;
426 1.68 matt u_int icache_way_size;
427 1.58 matt u_int icache_sets;
428 1.58 matt
429 1.58 matt u_int dcache_size;
430 1.58 matt u_int dcache_line_size;
431 1.58 matt u_int dcache_ways;
432 1.68 matt u_int dcache_way_size;
433 1.58 matt u_int dcache_sets;
434 1.58 matt
435 1.69 matt uint8_t cache_type;
436 1.58 matt bool cache_unified;
437 1.67 matt uint8_t icache_type;
438 1.67 matt uint8_t dcache_type;
439 1.58 matt };
440 1.58 matt
441 1.77 mrg #if (ARM_MMU_V6 + ARM_MMU_V7) != 0
442 1.58 matt extern u_int arm_cache_prefer_mask;
443 1.77 mrg #endif
444 1.58 matt extern u_int arm_dcache_align;
445 1.58 matt extern u_int arm_dcache_align_mask;
446 1.1 reinoud
447 1.58 matt extern struct arm_cache_info arm_pcache;
448 1.58 matt extern struct arm_cache_info arm_scache;
449 1.79 ryo
450 1.81 skrll extern uint32_t cpu_ttb;
451 1.81 skrll
452 1.1 reinoud #endif /* _KERNEL */
453 1.55 christos
454 1.55 christos #if defined(_KERNEL) || defined(_KMEMUSER)
455 1.55 christos /*
456 1.55 christos * Miscellany
457 1.55 christos */
458 1.55 christos
459 1.55 christos int get_pc_str_offset (void);
460 1.55 christos
461 1.79 ryo bool cpu_gtmr_exists_p(void);
462 1.79 ryo u_int cpu_clusterid(void);
463 1.79 ryo bool cpu_earlydevice_va_p(void);
464 1.79 ryo
465 1.55 christos /*
466 1.55 christos * Functions to manipulate cpu r13
467 1.55 christos * (in arm/arm32/setstack.S)
468 1.55 christos */
469 1.55 christos
470 1.55 christos void set_stackptr (u_int, u_int);
471 1.55 christos u_int get_stackptr (u_int);
472 1.55 christos
473 1.55 christos #endif /* _KERNEL || _KMEMUSER */
474 1.55 christos
475 1.79 ryo #elif defined(__aarch64__)
476 1.79 ryo
477 1.79 ryo #include <aarch64/cpufunc.h>
478 1.79 ryo
479 1.79 ryo #endif /* __arm__/__aarch64__ */
480 1.79 ryo
481 1.65 matt #endif /* _ARM_CPUFUNC_H_ */
482 1.1 reinoud
483 1.1 reinoud /* End of cpufunc.h */
484