cpu.h revision 1.42 1 /* $NetBSD: cpu.h,v 1.42 2003/08/07 16:27:03 agc Exp $ */
2
3 /*
4 * Copyright (c) 1982, 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR 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 * from: Utah $Hdr: cpu.h 1.16 91/03/25$
36 *
37 * @(#)cpu.h 7.7 (Berkeley) 6/27/91
38 */
39 /*
40 * Copyright (c) 1988 University of Utah.
41 *
42 * This code is derived from software contributed to Berkeley by
43 * the Systems Programming Group of the University of Utah Computer
44 * Science Department.
45 *
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
48 * are met:
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 * 3. All advertising materials mentioning features or use of this software
55 * must display the following acknowledgement:
56 * This product includes software developed by the University of
57 * California, Berkeley and its contributors.
58 * 4. Neither the name of the University nor the names of its contributors
59 * may be used to endorse or promote products derived from this software
60 * without specific prior written permission.
61 *
62 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE.
73 *
74 * from: Utah $Hdr: cpu.h 1.16 91/03/25$
75 *
76 * @(#)cpu.h 7.7 (Berkeley) 6/27/91
77 */
78
79 #ifndef _MACHINE_CPU_H_
80 #define _MACHINE_CPU_H_
81
82 /*
83 * Exported definitions unique to atari/68k cpu support.
84 */
85
86 #if defined(_KERNEL_OPT)
87 #include "opt_lockdebug.h"
88 #endif
89
90 /*
91 * Get common m68k CPU definitions.
92 */
93 #include <m68k/cpu.h>
94 #define M68K_MMU_MOTOROLA
95
96 #include <sys/sched.h>
97 struct cpu_info {
98 struct schedstate_percpu ci_schedstate; /* scheduler state */
99 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
100 u_long ci_spin_locks; /* # of spin locks held */
101 u_long ci_simple_locks; /* # of simple locks held */
102 #endif
103 };
104
105 #ifdef _KERNEL
106 extern struct cpu_info cpu_info_store;
107
108 #define curcpu() (&cpu_info_store)
109
110 /*
111 * definitions of cpu-dependent requirements
112 * referenced in generic code
113 */
114 #define cpu_swapin(p) /* nothing */
115 #define cpu_wait(p) /* nothing */
116 #define cpu_swapout(p) /* nothing */
117 #define cpu_number() 0
118
119 void cpu_proc_fork(struct proc *, struct proc *);
120
121 /*
122 * Arguments to hardclock and gatherstats encapsulate the previous
123 * machine state in an opaque clockframe. On the hp300, we use
124 * what the hardware pushes on an interrupt (frame format 0).
125 */
126 struct clockframe {
127 u_int cf_regs[4]; /* d0,d1,a0,a1 (see locore.s) */
128 u_short cf_sr; /* sr at time of interrupt */
129 u_long cf_pc; /* pc at time of interrupt */
130 u_short cf_vo; /* vector offset (4-word frame) */
131 } __attribute__((packed));
132
133 #define CLKF_USERMODE(framep) (((framep)->cf_sr & PSL_S) == 0)
134 #define CLKF_BASEPRI(framep) (((framep)->cf_sr & PSL_IPL) == 0)
135 #define CLKF_PC(framep) ((framep)->cf_pc)
136 #if 0
137 /* We would like to do it this way... */
138 #define CLKF_INTR(framep) (((framep)->cf_sr & PSL_M) == 0)
139 #else
140 /* but until we start using PSL_M, we have to do this instead */
141 #define CLKF_INTR(framep) (0) /* XXX */
142 #endif
143
144
145 /*
146 * Preempt the current process if in interrupt from user mode,
147 * or after the current trap/syscall if in system mode.
148 */
149 #define need_resched(ci) {want_resched = 1; setsoftast();}
150
151 /*
152 * Give a profiling tick to the current process from the softclock
153 * interrupt. On hp300, request an ast to send us through trap(),
154 * marking the proc as needing a profiling tick.
155 */
156 #define profile_tick(p, framep) ((p)->p_flag |= P_OWEUPC, setsoftast())
157 #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, setsoftast())
158
159 /*
160 * Notify the current process (p) that it has a signal pending,
161 * process as soon as possible.
162 */
163 #define signotify(p) setsoftast()
164
165 #define setsoftast() (astpending = 1)
166
167 extern int astpending; /* need trap before returning to user mode */
168 extern int want_resched; /* resched() was called */
169
170 #endif /* _KERNEL */
171
172 /* include support for software interrupts */
173 #include <machine/mtpr.h>
174
175 /*
176 * The rest of this should probably be moved to ../atari/ataricpu.h,
177 * although some of it could probably be put into generic 68k headers.
178 */
179 #define BASEPRI(sr) ((sr & PSL_IPL) == 0)
180
181 /*
182 * Values for machineid.
183 */
184 #define ATARI_68000 1 /* 68000 CPU */
185 #define ATARI_68010 (1<<1) /* 68010 CPU */
186 #define ATARI_68020 (1L<<2) /* 68020 CPU */
187 #define ATARI_68030 (1L<<3) /* 68030 CPU */
188 #define ATARI_68040 (1L<<4) /* 68040 CPU */
189 #define ATARI_68060 (1L<<6) /* 68060 CPU */
190 #define ATARI_TT (1L<<11) /* This is a TT030 */
191 #define ATARI_FALCON (1L<<12) /* Falcon */
192 #define ATARI_HADES (1L<<13) /* Hades */
193 #define ATARI_MILAN (1L<<14) /* Milan */
194
195 #define ATARI_CLKBROKEN (1L<<16)
196
197 #define ATARI_ANYCPU (ATARI_68000|ATARI_68010|ATARI_68020|ATARI_68030 \
198 |ATARI_68040|ATARI_68060)
199
200 #define ATARI_ANYMACH (ATARI_TT|ATARI_FALCON|ATARI_HADES|ATARI_MILAN)
201
202 #ifdef _KERNEL
203 extern int machineid;
204 #endif
205
206 /*
207 * CTL_MACHDEP definitions.
208 */
209 #define CPU_CONSDEV 1 /* dev_t: console terminal device */
210 #define CPU_MAXID 2 /* number of valid machdep ids */
211
212 #define CTL_MACHDEP_NAMES { \
213 { 0, 0 }, \
214 { "console_device", CTLTYPE_STRUCT }, \
215 }
216
217 #ifdef _KERNEL
218 /*
219 * Prototypes from atari_init.c
220 */
221 int cpu_dump __P((int (*)(dev_t, daddr_t, caddr_t, size_t), daddr_t *));
222 int cpu_dumpsize __P((void));
223
224 /*
225 * Prototypes from autoconf.c
226 */
227 void config_console __P((void));
228
229 /*
230 * Prototypes from clock.c
231 */
232 long clkread __P((void));
233
234 /*
235 * Prototypes from fpu.c
236 */
237 char *fpu_describe __P((int));
238 int fpu_probe __P((void));
239
240 /*
241 * Prototypes from vm_machdep.c
242 */
243 int badbaddr __P((caddr_t, int));
244 void consinit __P((void));
245 void dumpconf __P((void));
246 int kvtop __P((caddr_t));
247 void physaccess __P((caddr_t, caddr_t, int, int));
248 void physunaccess __P((caddr_t, int));
249 void setredzone __P((u_int *, caddr_t));
250
251 /*
252 * Prototypes from locore.s
253 */
254 struct fpframe;
255 struct user;
256 struct pcb;
257
258 void clearseg __P((paddr_t));
259 void doboot __P((void));
260 void loadustp __P((int));
261 void m68881_save __P((struct fpframe *));
262 void m68881_restore __P((struct fpframe *));
263 void physcopyseg __P((paddr_t, paddr_t));
264 u_int probeva __P((u_int, u_int));
265 void proc_trampoline __P((void));
266 void savectx __P((struct pcb *));
267 int suline __P((caddr_t, caddr_t));
268 void switch_exit __P((struct lwp *));
269 void switch_lwp_exit __P((struct lwp *));
270
271 /*
272 * Prototypes from machdep.c:
273 */
274 typedef void (*si_farg)(void *, void *); /* XXX */
275 void add_sicallback __P((si_farg, void *, void *));
276 void rem_sicallback __P((si_farg));
277 void cpu_startup __P((void));
278 void dumpsys __P((void));
279 vaddr_t reserve_dumppages __P((vaddr_t));
280 void softint __P((void));
281
282
283 /*
284 * Prototypes from nvram.c:
285 */
286 struct uio;
287 int nvram_uio __P((struct uio *));
288
289 /*
290 * Prototypes from sys_machdep.c:
291 */
292 int cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
293 int dma_cachectl __P((caddr_t, int));
294
295 /*
296 * Prototypes from pci_machdep.c
297 */
298 void init_pci_bus __P((void));
299
300 #endif /* _KERNEL */
301 #endif /* !_MACHINE_CPU_H_ */
302