cpu.h revision 1.60.20.1 1 /* $NetBSD: cpu.h,v 1.60.20.1 2007/02/06 19:46:22 ad 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 #ifndef _MACHINE_CPU_H_
79 #define _MACHINE_CPU_H_
80
81 #if defined(_KERNEL)
82
83 /*
84 * Exported definitions unique to amiga/68k cpu support.
85 */
86
87 #if defined(_KERNEL_OPT)
88 #include "opt_lockdebug.h"
89 #endif
90
91 /*
92 * Get common m68k CPU definitions.
93 */
94 #include <m68k/cpu.h>
95 #define M68K_MMU_MOTOROLA
96
97 #include <sys/cpu_data.h>
98 struct cpu_info {
99 struct cpu_data ci_data; /* MI per-cpu data */
100 int ci_mtx_count;
101 int ci_mtx_oldspl;
102 };
103
104 extern struct cpu_info cpu_info_store;
105
106 #define curcpu() (&cpu_info_store)
107
108 /*
109 * definitions of cpu-dependent requirements
110 * referenced in generic code
111 */
112 #define cpu_swapin(p) /* nothing */
113 #define cpu_swapout(p) /* nothing */
114 #define cpu_number() 0
115
116 void cpu_proc_fork(struct proc *, struct proc *);
117
118
119 extern volatile unsigned int interrupt_depth;
120 /*
121 * Arguments to hardclock and gatherstats encapsulate the previous
122 * machine state in an opaque clockframe. One the hp300, we use
123 * what the hardware pushes on an interrupt (frame format 0).
124 */
125 struct clockframe {
126 u_short sr; /* sr at time of interrupt */
127 u_long pc; /* pc at time of interrupt */
128 u_short vo; /* vector offset (4-word frame) */
129 };
130
131 #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0)
132 /*#define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0)*/
133 #define CLKF_BASEPRI(framep) (0)
134 #define CLKF_PC(framep) ((framep)->pc)
135 #define CLKF_INTR(framep) (interrupt_depth > 1)
136
137
138 /*
139 * Preempt the current process if in interrupt from user mode,
140 * or after the current trap/syscall if in system mode.
141 */
142 extern int want_resched; /* resched() was called */
143 #define cpu_need_resched(ci) {want_resched = 1; setsoftast();}
144
145 /*
146 * Give a profiling tick to the current process from the softclock
147 * interrupt. On hp300, request an ast to send us through trap(),
148 * marking the proc as needing a profiling tick.
149 */
150 #define profile_tick(l, framep) ((l)->l_pflag |= LP_OWEUPC, setsoftast())
151 #define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, setsoftast())
152
153 /*
154 * Notify the current process (p) that it has a signal pending,
155 * process as soon as possible.
156 */
157 #define cpu_signotify(l) setsoftast()
158
159 extern int astpending; /* need trap before returning to user mode */
160 #define setsoftast() (astpending = 1)
161
162 /* include support for software interrupts */
163 #include <machine/mtpr.h>
164
165 /*
166 * The rest of this should probably be moved to ../amiga/amigacpu.h,
167 * although some of it could probably be put into generic 68k headers.
168 */
169
170 /* values for machineid (happen to be AFF_* settings of AttnFlags) */
171 #define AMIGA_68020 (1L<<1)
172 #define AMIGA_68030 (1L<<2)
173 #define AMIGA_68040 (1L<<3)
174 #define AMIGA_68881 (1L<<4)
175 #define AMIGA_68882 (1L<<5)
176 #define AMIGA_FPU40 (1L<<6)
177 #define AMIGA_68060 (1L<<7)
178
179 extern int machineid;
180
181 #endif /* _KERNEL */
182
183 /*
184 * CTL_MACHDEP definitions.
185 */
186 #define CPU_CONSDEV 1 /* dev_t: console terminal device */
187 #define CPU_MAXID 2 /* number of valid machdep ids */
188
189 #define CTL_MACHDEP_NAMES { \
190 { 0, 0 }, \
191 { "console_device", CTLTYPE_STRUCT }, \
192 }
193
194 #ifdef _KERNEL
195 /*
196 * Prototypes from amiga_init.c
197 */
198 void *alloc_z2mem __P((long));
199
200 /*
201 * Prototypes from autoconf.c
202 */
203 int is_a1200 __P((void));
204 int is_a3000 __P((void));
205 int is_a4000 __P((void));
206 #ifdef DRACO
207 #define is_draco() ((machineid >> 24) == 0x7d ? (machineid >> 16) & 0xff : 0)
208 #endif
209
210 /*
211 * Prototypes from clock.c
212 */
213 u_long clkread __P((void));
214
215 #ifdef DRACO
216 /*
217 * Prototypes from kbd.c
218 */
219 void drkbdintr __P((void));
220
221 /*
222 * Prototypes from drsc.c
223 */
224 void drsc_handler __P((void));
225 #endif
226
227 /*
228 * Prototypes from locore.s
229 */
230 struct fpframe;
231 struct user;
232 struct pcb;
233
234 void clearseg __P((vm_offset_t));
235 void doboot __P((void)) __attribute__((__noreturn__));
236 void loadustp __P((int));
237 #ifdef FPCOPROC
238 void m68881_save __P((struct fpframe *));
239 void m68881_restore __P((struct fpframe *));
240 #endif
241 void physcopyseg __P((vm_offset_t, vm_offset_t));
242 u_int probeva __P((u_int, u_int));
243 void proc_trampoline __P((void));
244 void savectx __P((struct pcb *));
245 void switch_exit __P((struct lwp *));
246 void switch_lwp_exit __P((struct lwp *));
247
248 /*
249 * Prototypes from machdep.c
250 */
251 int badaddr __P((caddr_t));
252 int badbaddr __P((caddr_t));
253 void bootsync __P((void));
254 void dumpconf __P((void));
255
256 /*
257 * Prototypes from sys_machdep.c:
258 */
259 int cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
260 int dma_cachectl __P((caddr_t, int));
261
262 /*
263 * Prototypes from vm_machdep.c
264 */
265 int kvtop __P((caddr_t));
266 void physaccess __P((caddr_t, caddr_t, int, int));
267 void physunaccess __P((caddr_t, int));
268 void setredzone __P((u_int *, caddr_t));
269
270 /*
271 * Prototypes from pmap.c:
272 */
273 void pmap_bootstrap __P((vm_offset_t, vm_offset_t));
274
275 #endif /* _KERNEL */
276
277 #endif /* !_MACHINE_CPU_H_ */
278