cpu.h revision 1.27 1 1.27 tsutsui /* $NetBSD: cpu.h,v 1.27 2007/05/18 10:13:25 tsutsui Exp $ */
2 1.1 tsutsui
3 1.1 tsutsui /*
4 1.1 tsutsui * Copyright (c) 1982, 1990, 1993
5 1.1 tsutsui * The Regents of the University of California. All rights reserved.
6 1.16 agc *
7 1.16 agc * This code is derived from software contributed to Berkeley by
8 1.16 agc * the Systems Programming Group of the University of Utah Computer
9 1.16 agc * Science Department.
10 1.16 agc *
11 1.16 agc * Redistribution and use in source and binary forms, with or without
12 1.16 agc * modification, are permitted provided that the following conditions
13 1.16 agc * are met:
14 1.16 agc * 1. Redistributions of source code must retain the above copyright
15 1.16 agc * notice, this list of conditions and the following disclaimer.
16 1.16 agc * 2. Redistributions in binary form must reproduce the above copyright
17 1.16 agc * notice, this list of conditions and the following disclaimer in the
18 1.16 agc * documentation and/or other materials provided with the distribution.
19 1.16 agc * 3. Neither the name of the University nor the names of its contributors
20 1.16 agc * may be used to endorse or promote products derived from this software
21 1.16 agc * without specific prior written permission.
22 1.16 agc *
23 1.16 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.16 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.16 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.16 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.16 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.16 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.16 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.16 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.16 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.16 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.16 agc * SUCH DAMAGE.
34 1.16 agc *
35 1.16 agc * from: Utah $Hdr: cpu.h 1.16 91/03/25$
36 1.16 agc *
37 1.16 agc * @(#)cpu.h 8.4 (Berkeley) 1/5/94
38 1.16 agc */
39 1.16 agc /*
40 1.16 agc * Copyright (c) 1988 University of Utah.
41 1.1 tsutsui *
42 1.1 tsutsui * This code is derived from software contributed to Berkeley by
43 1.1 tsutsui * the Systems Programming Group of the University of Utah Computer
44 1.1 tsutsui * Science Department.
45 1.1 tsutsui *
46 1.1 tsutsui * Redistribution and use in source and binary forms, with or without
47 1.1 tsutsui * modification, are permitted provided that the following conditions
48 1.1 tsutsui * are met:
49 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright
50 1.1 tsutsui * notice, this list of conditions and the following disclaimer.
51 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright
52 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the
53 1.1 tsutsui * documentation and/or other materials provided with the distribution.
54 1.1 tsutsui * 3. All advertising materials mentioning features or use of this software
55 1.1 tsutsui * must display the following acknowledgement:
56 1.1 tsutsui * This product includes software developed by the University of
57 1.1 tsutsui * California, Berkeley and its contributors.
58 1.1 tsutsui * 4. Neither the name of the University nor the names of its contributors
59 1.1 tsutsui * may be used to endorse or promote products derived from this software
60 1.1 tsutsui * without specific prior written permission.
61 1.1 tsutsui *
62 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 1.1 tsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 1.1 tsutsui * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 1.1 tsutsui * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 1.1 tsutsui * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 1.1 tsutsui * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 1.1 tsutsui * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 1.1 tsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 1.1 tsutsui * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 1.1 tsutsui * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 1.1 tsutsui * SUCH DAMAGE.
73 1.1 tsutsui *
74 1.1 tsutsui * from: Utah $Hdr: cpu.h 1.16 91/03/25$
75 1.1 tsutsui *
76 1.1 tsutsui * @(#)cpu.h 8.4 (Berkeley) 1/5/94
77 1.1 tsutsui */
78 1.1 tsutsui
79 1.1 tsutsui #ifndef _NEWS68K_CPU_H_
80 1.2 tsutsui #define _NEWS68K_CPU_H_
81 1.1 tsutsui
82 1.19 yamt #if defined(_KERNEL)
83 1.19 yamt
84 1.1 tsutsui /*
85 1.1 tsutsui * Exported definitions unique to news68k cpu support.
86 1.1 tsutsui */
87 1.1 tsutsui
88 1.10 mrg #if defined(_KERNEL_OPT)
89 1.4 thorpej #include "opt_lockdebug.h"
90 1.4 thorpej #endif
91 1.4 thorpej
92 1.1 tsutsui /*
93 1.1 tsutsui * Get common m68k CPU definitions.
94 1.1 tsutsui */
95 1.1 tsutsui #include <m68k/cpu.h>
96 1.1 tsutsui
97 1.1 tsutsui /*
98 1.1 tsutsui * XXX news1700 L2 cache would be corrupted with DC_BE and IC_BE...
99 1.1 tsutsui * XXX Should these be defined in machine/cpu.h?
100 1.1 tsutsui */
101 1.1 tsutsui #undef CACHE_ON
102 1.1 tsutsui #undef CACHE_CLR
103 1.1 tsutsui #undef IC_CLEAR
104 1.1 tsutsui #undef DC_CLEAR
105 1.1 tsutsui #define CACHE_ON (DC_WA|DC_CLR|DC_ENABLE|IC_CLR|IC_ENABLE)
106 1.1 tsutsui #define CACHE_CLR CACHE_ON
107 1.1 tsutsui #define IC_CLEAR (DC_WA|DC_ENABLE|IC_CLR|IC_ENABLE)
108 1.1 tsutsui #define DC_CLEAR (DC_WA|DC_CLR|DC_ENABLE|IC_ENABLE)
109 1.1 tsutsui
110 1.7 tsutsui #define DCIC_CLR (DC_CLR|IC_CLR)
111 1.7 tsutsui #define CACHE_BE (DC_BE|IC_BE)
112 1.2 tsutsui
113 1.1 tsutsui /*
114 1.1 tsutsui * Get interrupt glue.
115 1.1 tsutsui */
116 1.1 tsutsui #include <machine/intr.h>
117 1.1 tsutsui
118 1.18 yamt #include <sys/cpu_data.h>
119 1.4 thorpej struct cpu_info {
120 1.18 yamt struct cpu_data ci_data; /* MI per-cpu data */
121 1.24 tsutsui int ci_mtx_count;
122 1.24 tsutsui int ci_mtx_oldspl;
123 1.27 tsutsui int ci_want_resched;
124 1.4 thorpej };
125 1.4 thorpej
126 1.4 thorpej extern struct cpu_info cpu_info_store;
127 1.4 thorpej
128 1.4 thorpej #define curcpu() (&cpu_info_store)
129 1.4 thorpej
130 1.1 tsutsui /*
131 1.1 tsutsui * definitions of cpu-dependent requirements
132 1.1 tsutsui * referenced in generic code
133 1.1 tsutsui */
134 1.2 tsutsui #define cpu_swapin(p) /* nothing */
135 1.2 tsutsui #define cpu_swapout(p) /* nothing */
136 1.2 tsutsui #define cpu_number() 0
137 1.1 tsutsui
138 1.14 thorpej void cpu_proc_fork(struct proc *, struct proc *);
139 1.14 thorpej
140 1.1 tsutsui /*
141 1.1 tsutsui * Arguments to hardclock and gatherstats encapsulate the previous
142 1.1 tsutsui * machine state in an opaque clockframe. One the hp300, we use
143 1.1 tsutsui * what the hardware pushes on an interrupt (frame format 0).
144 1.1 tsutsui */
145 1.1 tsutsui struct clockframe {
146 1.1 tsutsui u_short sr; /* sr at time of interrupt */
147 1.1 tsutsui u_long pc; /* pc at time of interrupt */
148 1.1 tsutsui u_short vo; /* vector offset (4-word frame) */
149 1.1 tsutsui };
150 1.1 tsutsui
151 1.2 tsutsui #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0)
152 1.2 tsutsui #define CLKF_PC(framep) ((framep)->pc)
153 1.1 tsutsui #if 0
154 1.1 tsutsui /* We would like to do it this way... */
155 1.2 tsutsui #define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0)
156 1.1 tsutsui #else
157 1.1 tsutsui /* but until we start using PSL_M, we have to do this instead */
158 1.2 tsutsui #define CLKF_INTR(framep) (0) /* XXX */
159 1.1 tsutsui #endif
160 1.1 tsutsui
161 1.1 tsutsui
162 1.1 tsutsui /*
163 1.1 tsutsui * Preempt the current process if in interrupt from user mode,
164 1.1 tsutsui * or after the current trap/syscall if in system mode.
165 1.1 tsutsui */
166 1.27 tsutsui #define cpu_need_resched(ci, flags) \
167 1.27 tsutsui do { ci->ci_want_resched = 1; aston(); } while (/* CONSTCOND */0)
168 1.1 tsutsui
169 1.1 tsutsui /*
170 1.1 tsutsui * Give a profiling tick to the current process when the user profiling
171 1.1 tsutsui * buffer pages are invalid. On the hp300, request an ast to send us
172 1.1 tsutsui * through trap, marking the proc as needing a profiling tick.
173 1.1 tsutsui */
174 1.24 tsutsui #define cpu_need_proftick(l) \
175 1.27 tsutsui do { (l)->l_flag |= LP_OWEUPC; aston(); } while (/* CONSTCOND */0)
176 1.1 tsutsui
177 1.1 tsutsui /*
178 1.1 tsutsui * Notify the current process (p) that it has a signal pending,
179 1.1 tsutsui * process as soon as possible.
180 1.1 tsutsui */
181 1.24 tsutsui #define cpu_signotify(l) aston()
182 1.1 tsutsui
183 1.1 tsutsui extern int astpending; /* need to trap before returning to user mode */
184 1.3 tsutsui extern volatile u_char *ctrl_ast;
185 1.27 tsutsui #define aston() \
186 1.27 tsutsui do { astpending++; *ctrl_ast = 0xff; } while (/* CONSTCOND */0)
187 1.4 thorpej
188 1.4 thorpej #endif /* _KERNEL */
189 1.1 tsutsui
190 1.1 tsutsui /*
191 1.1 tsutsui * CTL_MACHDEP definitions.
192 1.1 tsutsui */
193 1.2 tsutsui #define CPU_CONSDEV 1 /* dev_t: console terminal device */
194 1.2 tsutsui #define CPU_MAXID 2 /* number of valid machdep ids */
195 1.1 tsutsui
196 1.1 tsutsui #define CTL_MACHDEP_NAMES { \
197 1.1 tsutsui { 0, 0 }, \
198 1.1 tsutsui { "console_device", CTLTYPE_STRUCT }, \
199 1.1 tsutsui }
200 1.1 tsutsui
201 1.1 tsutsui #ifdef _KERNEL
202 1.1 tsutsui
203 1.2 tsutsui #if defined(news1700) || defined(news1200)
204 1.2 tsutsui #ifndef M68030
205 1.1 tsutsui #define M68030
206 1.1 tsutsui #endif
207 1.2 tsutsui #define M68K_MMU_MOTOROLA
208 1.2 tsutsui #endif
209 1.2 tsutsui
210 1.2 tsutsui #if defined(news1700)
211 1.2 tsutsui #define CACHE_HAVE_PAC
212 1.2 tsutsui #endif
213 1.1 tsutsui
214 1.1 tsutsui #endif
215 1.1 tsutsui
216 1.1 tsutsui #ifdef _KERNEL
217 1.2 tsutsui extern int systype;
218 1.2 tsutsui #define NEWS1700 0
219 1.2 tsutsui #define NEWS1200 1
220 1.2 tsutsui
221 1.2 tsutsui extern int cpuspeed;
222 1.7 tsutsui extern char *intiobase, *intiolimit, *extiobase;
223 1.2 tsutsui extern u_int intiobase_phys, intiotop_phys;
224 1.2 tsutsui extern u_int extiobase_phys, extiotop_phys;
225 1.2 tsutsui extern u_int intrcnt[];
226 1.1 tsutsui
227 1.13 tsutsui extern void (*vectab[])(void);
228 1.1 tsutsui
229 1.1 tsutsui struct frame;
230 1.1 tsutsui struct fpframe;
231 1.1 tsutsui struct pcb;
232 1.1 tsutsui
233 1.1 tsutsui /* locore.s functions */
234 1.13 tsutsui void m68881_save(struct fpframe *);
235 1.13 tsutsui void m68881_restore(struct fpframe *);
236 1.2 tsutsui
237 1.26 christos int suline(void *, void *);
238 1.13 tsutsui void savectx(struct pcb *);
239 1.13 tsutsui void proc_trampoline(void);
240 1.13 tsutsui void loadustp(int);
241 1.13 tsutsui void badtrap(void);
242 1.13 tsutsui void intrhand_vectored(void);
243 1.13 tsutsui int getsr(void);
244 1.1 tsutsui
245 1.1 tsutsui
246 1.13 tsutsui void doboot(int)
247 1.1 tsutsui __attribute__((__noreturn__));
248 1.13 tsutsui void nmihand(struct frame *);
249 1.13 tsutsui void ecacheon(void);
250 1.13 tsutsui void ecacheoff(void);
251 1.1 tsutsui
252 1.1 tsutsui /* machdep.c functions */
253 1.26 christos int badaddr(void *, int);
254 1.26 christos int badbaddr(void *);
255 1.1 tsutsui
256 1.1 tsutsui /* sys_machdep.c functions */
257 1.13 tsutsui int cachectl1(unsigned long, vaddr_t, size_t, struct proc *);
258 1.1 tsutsui
259 1.1 tsutsui /* vm_machdep.c functions */
260 1.26 christos void physaccess(void *, void *, int, int);
261 1.26 christos void physunaccess(void *, int);
262 1.26 christos int kvtop(void *);
263 1.1 tsutsui
264 1.1 tsutsui #endif
265 1.1 tsutsui
266 1.1 tsutsui /* physical memory sections */
267 1.22 tsutsui #define ROMBASE 0xe0000000
268 1.2 tsutsui
269 1.22 tsutsui #define INTIOBASE1700 0xe0c00000
270 1.22 tsutsui #define INTIOTOP1700 0xe1d00000 /* XXX */
271 1.22 tsutsui #define EXTIOBASE1700 0xf0f00000
272 1.22 tsutsui #define EXTIOTOP1700 0xf1000000 /* XXX */
273 1.22 tsutsui #define CTRL_POWER1700 0xe1380000
274 1.22 tsutsui #define CTRL_LED1700 0xe0dc0000
275 1.22 tsutsui
276 1.22 tsutsui #define INTIOBASE1200 0xe1000000
277 1.22 tsutsui #define INTIOTOP1200 0xe1d00000 /* XXX */
278 1.22 tsutsui #define EXTIOBASE1200 0xe4000000
279 1.22 tsutsui #define EXTIOTOP1200 0xe4020000 /* XXX */
280 1.22 tsutsui #define CTRL_POWER1200 0xe1000000
281 1.22 tsutsui #define CTRL_LED1200 0xe1500001
282 1.2 tsutsui
283 1.22 tsutsui #define MAXADDR 0xfffff000
284 1.1 tsutsui
285 1.1 tsutsui /*
286 1.1 tsutsui * Internal IO space:
287 1.1 tsutsui *
288 1.1 tsutsui * Internal IO space is mapped in the kernel from ``intiobase'' to
289 1.1 tsutsui * ``intiolimit'' (defined in locore.s). Since it is always mapped,
290 1.1 tsutsui * conversion between physical and kernel virtual addresses is easy.
291 1.1 tsutsui */
292 1.2 tsutsui #define ISIIOVA(va) \
293 1.1 tsutsui ((char *)(va) >= intiobase && (char *)(va) < intiolimit)
294 1.2 tsutsui #define IIOV(pa) (((u_int)(pa) - intiobase_phys) + (u_int)intiobase)
295 1.2 tsutsui #define ISIIOPA(pa) \
296 1.2 tsutsui ((u_int)(pa) >= intiobase_phys && (u_int)(pa) < intiotop_phys)
297 1.2 tsutsui #define IIOP(va) (((u_int)(va) - (u_int)intiobase) + intiobase_phys)
298 1.2 tsutsui #define IIOPOFF(pa) ((u_int)(pa) - intiobase_phys)
299 1.6 tsutsui
300 1.6 tsutsui /* XXX EIO space mapping should be modified like hp300 XXX */
301 1.6 tsutsui #define EIOSIZE (extiotop_phys - extiobase_phys)
302 1.6 tsutsui #define ISEIOVA(va) \
303 1.6 tsutsui ((char *)(va) >= extiobase && (char *)(va) < (char *)EIOSIZE)
304 1.6 tsutsui #define EIOV(pa) (((u_int)(pa) - extiobase_phys) + (u_int)extiobase)
305 1.12 chs
306 1.12 chs #if defined(CACHE_HAVE_PAC) || defined(CACHE_HAVE_VAC)
307 1.12 chs #define M68K_CACHEOPS_MACHDEP
308 1.12 chs #endif
309 1.12 chs
310 1.12 chs #ifdef CACHE_HAVE_PAC
311 1.12 chs #define M68K_CACHEOPS_MACHDEP_PCIA
312 1.12 chs #endif
313 1.12 chs
314 1.12 chs #ifdef CACHE_HAVE_VAC
315 1.12 chs #define M68K_CACHEOPS_MACHDEP_DCIA
316 1.12 chs #define M68K_CACHEOPS_MACHDEP_DCIS
317 1.12 chs #define M68K_CACHEOPS_MACHDEP_DCIU
318 1.12 chs #endif
319 1.1 tsutsui
320 1.1 tsutsui #endif /* !_NEWS68K_CPU_H_ */
321