cpufunc.h revision 1.1 1 /* $NetBSD: cpufunc.h,v 1.1 2001/02/23 21:23:47 reinoud Exp $ */
2
3 /*
4 * Copyright (c) 1997 Mark Brinicombe.
5 * Copyright (c) 1997 Causality Limited
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Causality Limited.
19 * 4. The name of Causality Limited may not be used to endorse or promote
20 * products derived from this software without specific prior written
21 * permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY CAUSALITY LIMITED ``AS IS'' AND ANY EXPRESS
24 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL CAUSALITY LIMITED BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * RiscBSD kernel project
36 *
37 * cpufunc.h
38 *
39 * Prototypes for cpu, mmu and tlb related functions.
40 */
41
42 #ifndef _ARM32_CPUFUNC_H_
43 #define _ARM32_CPUFUNC_H_
44
45 #include <sys/types.h>
46
47 #ifdef _KERNEL
48 #ifndef _LKM
49 #include "opt_cputypes.h"
50 #endif
51
52 struct cpu_functions {
53
54 /* CPU functions */
55
56 u_int (*cf_id) __P((void));
57
58 /* MMU functions */
59
60 u_int (*cf_control) __P((u_int bic, u_int eor));
61 void (*cf_domains) __P((u_int domains));
62 void (*cf_setttb) __P((u_int ttb));
63 u_int (*cf_faultstatus) __P((void));
64 u_int (*cf_faultaddress) __P((void));
65
66 /* TLB functions */
67
68 void (*cf_tlb_flushID) __P((void));
69 void (*cf_tlb_flushID_SE) __P((u_int va));
70 void (*cf_tlb_flushI) __P((void));
71 void (*cf_tlb_flushI_SE) __P((u_int va));
72 void (*cf_tlb_flushD) __P((void));
73 void (*cf_tlb_flushD_SE) __P((u_int va));
74
75 /* Cache functions */
76
77 void (*cf_cache_flushID) __P((void));
78 void (*cf_cache_flushID_SE) __P((u_int va));
79 void (*cf_cache_flushI) __P((void));
80 void (*cf_cache_flushI_SE) __P((u_int va));
81 void (*cf_cache_flushD) __P((void));
82 void (*cf_cache_flushD_SE) __P((u_int va));
83
84 void (*cf_cache_cleanID) __P((void));
85 void (*cf_cache_cleanID_E) __P((u_int imp));
86 void (*cf_cache_cleanD) __P((void));
87 void (*cf_cache_cleanD_E) __P((u_int imp));
88
89 void (*cf_cache_purgeID) __P((void));
90 void (*cf_cache_purgeID_E) __P((u_int imp));
91 void (*cf_cache_purgeD) __P((void));
92 void (*cf_cache_purgeD_E) __P((u_int imp));
93
94 /* Other functions */
95
96 void (*cf_flush_prefetchbuf) __P((void));
97 void (*cf_drain_writebuf) __P((void));
98 void (*cf_flush_brnchtgt_C) __P((void));
99 void (*cf_flush_brnchtgt_E) __P((u_int va));
100
101 void (*cf_sleep) __P((int mode));
102
103 /* Soft functions */
104
105 void (*cf_cache_syncI) __P((void));
106 void (*cf_cache_cleanID_rng) __P((u_int start, u_int len));
107 void (*cf_cache_cleanD_rng) __P((u_int start, u_int len));
108 void (*cf_cache_purgeID_rng) __P((u_int start, u_int len));
109 void (*cf_cache_purgeD_rng) __P((u_int start, u_int len));
110 void (*cf_cache_syncI_rng) __P((u_int start, u_int len));
111
112 int (*cf_dataabt_fixup) __P((void *arg));
113 int (*cf_prefetchabt_fixup) __P((void *arg));
114
115 void (*cf_context_switch) __P((void));
116
117 void (*cf_setup) __P((char *string));
118 };
119
120 extern struct cpu_functions cpufuncs;
121 extern u_int cputype;
122
123 #define cpu_id() cpufuncs.cf_id()
124
125 #define cpu_control(c, e) cpufuncs.cf_control(c, e)
126 #define cpu_domains(d) cpufuncs.cf_domains(d)
127 #define cpu_setttb(t) cpufuncs.cf_setttb(t)
128 #define cpu_faultstatus() cpufuncs.cf_faultstatus()
129 #define cpu_faultaddress() cpufuncs.cf_faultaddress()
130
131 #define cpu_tlb_flushID() cpufuncs.cf_tlb_flushID()
132 #define cpu_tlb_flushID_SE(e) cpufuncs.cf_tlb_flushID_SE(e)
133 #define cpu_tlb_flushI() cpufuncs.cf_tlb_flushI()
134 #define cpu_tlb_flushI_SE(e) cpufuncs.cf_tlb_flushI_SE(e)
135 #define cpu_tlb_flushD() cpufuncs.cf_tlb_flushD()
136 #define cpu_tlb_flushD_SE(e) cpufuncs.cf_tlb_flushD_SE(e)
137
138 #define cpu_cache_flushID() cpufuncs.cf_cache_flushID()
139 #define cpu_cache_flushID_SE(e) cpufuncs.cf_cache_flushID_SE(e)
140 #define cpu_cache_flushI() cpufuncs.cf_cache_flushI()
141 #define cpu_cache_flushI_SE(e) cpufuncs.cf_cache_flushI_SE(e)
142 #define cpu_cache_flushD() cpufuncs.cf_cache_flushD()
143 #define cpu_cache_flushD_SE(e) cpufuncs.cf_cache_flushD_SE(e)
144 #define cpu_cache_cleanID() cpufuncs.cf_cache_cleanID()
145 #define cpu_cache_cleanID_E(e) cpufuncs.cf_cache_cleanID_E(e)
146 #define cpu_cache_cleanD() cpufuncs.cf_cache_cleanD()
147 #define cpu_cache_cleanD_E(e) cpufuncs.cf_cache_cleanD_E(e)
148 #define cpu_cache_purgeID() cpufuncs.cf_cache_purgeID()
149 #define cpu_cache_purgeID_E(e) cpufuncs.cf_cache_purgeID_E(e)
150 #define cpu_cache_purgeD() cpufuncs.cf_cache_purgeD()
151 #define cpu_cache_purgeD_E(e) cpufuncs.cf_cache_purgeD_E(e)
152
153 #define cpu_flush_prefetchbuf() cpufuncs.cf_flush_prefetchbuf()
154 #define cpu_drain_writebuf() cpufuncs.cf_drain_writebuf()
155 #define cpu_flush_brnchtgt_C() cpufuncs.cf_flush_brnchtgt_C()
156 #define cpu_flush_brnchtgt_E(e) cpufuncs.cf_flush_brnchtgt_E(e)
157
158 #define cpu_sleep(m) cpufuncs.cf_sleep(m)
159
160 #define cpu_cache_syncI() cpufuncs.cf_cache_syncI()
161 #define cpu_cache_cleanID_rng(s,l) cpufuncs.cf_cache_cleanID_rng(s,l)
162 #define cpu_cache_cleanD_rng(s,l) cpufuncs.cf_cache_cleanD_rng(s,l)
163 #define cpu_cache_purgeID_rng(s,l) cpufuncs.cf_cache_purgeID_rng(s,l)
164 #define cpu_cache_purgeD_rng(s,l) cpufuncs.cf_cache_purgeD_rng(s,l)
165 #define cpu_cache_syncI_rng(s,l) cpufuncs.cf_cache_syncI_rng(s,l)
166
167 #define cpu_dataabt_fixup(a) cpufuncs.cf_dataabt_fixup(a)
168 #define cpu_prefetchabt_fixup(a) cpufuncs.cf_prefetchabt_fixup(a)
169 #define ABORT_FIXUP_OK 0 /* fixup suceeded */
170 #define ABORT_FIXUP_FAILED 1 /* fixup failed */
171 #define ABORT_FIXUP_RETURN 2 /* abort handler should return */
172
173 #define cpu_setup(a) cpufuncs.cf_setup(a)
174
175 int set_cpufuncs __P((void));
176 #define ARCHITECTURE_NOT_PRESENT 1 /* known but not configured */
177 #define ARCHITECTURE_NOT_SUPPORTED 2 /* not known */
178
179 void cpufunc_nullop __P((void));
180 u_int cpufunc_id __P((void));
181 u_int cpufunc_control __P((u_int clear, u_int bic));
182 void cpufunc_domains __P((u_int domains));
183 u_int cpufunc_faultstatus __P((void));
184 u_int cpufunc_faultaddress __P((void));
185
186 #if defined(CPU_ARM6) || defined(CPU_ARM7)
187 void arm67_setttb __P((u_int ttb));
188 void arm67_tlb_flush __P((void));
189 void arm67_tlb_purge __P((u_int va));
190 void arm67_cache_flush __P((void));
191 void arm67_context_switch __P((void));
192 #endif /* CPU_ARM6 || CPU_ARM7 */
193
194 #ifdef CPU_ARM6
195 int arm6_dataabt_fixup __P((void *arg));
196 int arm6_prefetchabt_fixup __P((void *arg));
197 void arm6_setup __P((char *string));
198 #endif /* CPU_ARM6 */
199
200 #ifdef CPU_ARM7
201 int arm7_dataabt_fixup __P((void *arg));
202 int arm7_prefetchabt_fixup __P((void *arg));
203 void arm7_setup __P((char *string));
204 #endif /* CPU_ARM7 */
205
206 #ifdef CPU_ARM8
207 void arm8_setttb __P((u_int ttb));
208 void arm8_tlb_flushID __P((void));
209 void arm8_tlb_flushID_SE __P((u_int va));
210 void arm8_cache_flushID __P((void));
211 void arm8_cache_flushID_E __P((u_int entry));
212 void arm8_cache_cleanID __P((void));
213 void arm8_cache_cleanID_E __P((u_int entry));
214 void arm8_cache_purgeID __P((void));
215 void arm8_cache_purgeID_E __P((u_int entry));
216
217 void arm8_cache_syncI __P((void));
218 void arm8_cache_cleanID_rng __P((u_int start, u_int end));
219 void arm8_cache_cleanD_rng __P((u_int start, u_int end));
220 void arm8_cache_purgeID_rng __P((u_int start, u_int end));
221 void arm8_cache_purgeD_rng __P((u_int start, u_int end));
222 void arm8_cache_syncI_rng __P((u_int start, u_int end));
223
224 int arm8_dataabt_fixup __P((void *arg));
225 int arm8_prefetchabt_fixup __P((void *arg));
226
227 void arm8_context_switch __P((void));
228
229 void arm8_setup __P((char *string));
230
231 u_int arm8_clock_config __P((u_int, u_int));
232 #endif
233
234 #ifdef CPU_SA110
235 void sa110_setttb __P((u_int ttb));
236 void sa110_tlb_flushID __P((void));
237 void sa110_tlb_flushID_SE __P((u_int va));
238 void sa110_tlb_flushI __P((void));
239 void sa110_tlb_flushD __P((void));
240 void sa110_tlb_flushD_SE __P((u_int va));
241
242 void sa110_cache_flushID __P((void));
243 void sa110_cache_flushI __P((void));
244 void sa110_cache_flushD __P((void));
245 void sa110_cache_flushD_SE __P((u_int entry));
246
247 void sa110_cache_cleanID __P((void));
248 void sa110_cache_cleanD __P((void));
249 void sa110_cache_cleanD_E __P((u_int entry));
250
251 void sa110_cache_purgeID __P((void));
252 void sa110_cache_purgeID_E __P((u_int entry));
253 void sa110_cache_purgeD __P((void));
254 void sa110_cache_purgeD_E __P((u_int entry));
255
256 void sa110_drain_writebuf __P((void));
257
258 void sa110_cache_syncI __P((void));
259 void sa110_cache_cleanID_rng __P((u_int start, u_int end));
260 void sa110_cache_cleanD_rng __P((u_int start, u_int end));
261 void sa110_cache_purgeID_rng __P((u_int start, u_int end));
262 void sa110_cache_purgeD_rng __P((u_int start, u_int end));
263 void sa110_cache_syncI_rng __P((u_int start, u_int end));
264
265 int sa110_dataabt_fixup __P((void *arg));
266 int sa110_prefetchabt_fixup __P((void *arg));
267
268 void sa110_context_switch __P((void));
269
270 void sa110_setup __P((char *string));
271 #endif /* CPU_SA110 */
272
273 #define tlb_flush cpu_tlb_flushID
274 #define setttb cpu_setttb
275 #define cache_clean cpu_cache_purgeID
276 #define sync_caches cpu_cache_syncI
277 #define sync_icache cpu_cache_syncI
278 #define drain_writebuf cpu_drain_writebuf
279
280 /*
281 * Macros for manipulating CPU interrupts
282 */
283
284 #define disable_interrupts(mask) \
285 (SetCPSR((mask) & (I32_bit | F32_bit), (mask) & (I32_bit | F32_bit)))
286
287 #define enable_interrupts(mask) \
288 (SetCPSR((mask) & (I32_bit | F32_bit), 0))
289
290 #define restore_interrupts(old_cpsr) \
291 (SetCPSR((I32_bit | F32_bit), (old_cpsr) & (I32_bit | F32_bit)))
292
293 /*
294 * Functions to manipulate the CPSR
295 * (in arm32/arm32/setcpsr.S)
296 */
297
298 u_int SetCPSR __P((u_int bic, u_int eor));
299 u_int GetCPSR __P((void));
300
301 /*
302 * Functions to manipulate cpu r13
303 * (in arm32/arm32/setstack.S)
304 */
305
306 void set_stackptr __P((u_int mode, u_int address));
307 u_int get_stackptr __P((u_int mode));
308
309 /*
310 * CPU functions from locore.S
311 */
312
313 void cpu_reset __P((void)) __attribute__((__noreturn__));
314
315 #endif /* _KERNEL */
316 #endif /* _ARM32_CPUFUNC_H_ */
317
318 /* End of cpufunc.h */
319