cpu.h revision 1.2 1 1.2 oki /* $NetBSD: cpu.h,v 1.2 1996/05/21 15:32:53 oki Exp $ */
2 1.1 oki
3 1.1 oki /*
4 1.1 oki * Copyright (c) 1988 University of Utah.
5 1.1 oki * Copyright (c) 1982, 1990, 1993
6 1.1 oki * The Regents of the University of California. All rights reserved.
7 1.1 oki *
8 1.1 oki * This code is derived from software contributed to Berkeley by
9 1.1 oki * the Systems Programming Group of the University of Utah Computer
10 1.1 oki * Science Department.
11 1.1 oki *
12 1.1 oki * Redistribution and use in source and binary forms, with or without
13 1.1 oki * modification, are permitted provided that the following conditions
14 1.1 oki * are met:
15 1.1 oki * 1. Redistributions of source code must retain the above copyright
16 1.1 oki * notice, this list of conditions and the following disclaimer.
17 1.1 oki * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 oki * notice, this list of conditions and the following disclaimer in the
19 1.1 oki * documentation and/or other materials provided with the distribution.
20 1.1 oki * 3. All advertising materials mentioning features or use of this software
21 1.1 oki * must display the following acknowledgement:
22 1.1 oki * This product includes software developed by the University of
23 1.1 oki * California, Berkeley and its contributors.
24 1.1 oki * 4. Neither the name of the University nor the names of its contributors
25 1.1 oki * may be used to endorse or promote products derived from this software
26 1.1 oki * without specific prior written permission.
27 1.1 oki *
28 1.1 oki * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 1.1 oki * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 1.1 oki * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 1.1 oki * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 1.1 oki * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 1.1 oki * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 1.1 oki * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 1.1 oki * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 1.1 oki * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 1.1 oki * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 1.1 oki * SUCH DAMAGE.
39 1.1 oki *
40 1.1 oki * from: Utah $Hdr: cpu.h 1.16 91/03/25$
41 1.1 oki *
42 1.1 oki * @(#)cpu.h 8.4 (Berkeley) 1/5/94
43 1.1 oki */
44 1.1 oki
45 1.1 oki #ifndef _X68K_CPU_H_
46 1.1 oki #define _X68K_CPU_H_
47 1.1 oki
48 1.1 oki /*
49 1.1 oki * Exported definitions unique to x68k/68k cpu support.
50 1.1 oki */
51 1.1 oki
52 1.1 oki /*
53 1.1 oki * definitions of cpu-dependent requirements
54 1.1 oki * referenced in generic code
55 1.1 oki */
56 1.1 oki #define cpu_swapin(p) /* nothing */
57 1.1 oki #define cpu_wait(p) /* nothing */
58 1.1 oki #define cpu_swapout(p) /* nothing */
59 1.1 oki
60 1.1 oki /*
61 1.1 oki * Arguments to hardclock and gatherstats encapsulate the previous
62 1.1 oki * machine state in an opaque clockframe. One the x68k, we use
63 1.1 oki * what the hardware pushes on an interrupt (frame format 0).
64 1.1 oki */
65 1.1 oki struct clockframe {
66 1.1 oki u_short sr; /* sr at time of interrupt */
67 1.1 oki u_long pc; /* pc at time of interrupt */
68 1.1 oki u_short vo; /* vector offset (4-word frame) */
69 1.1 oki };
70 1.1 oki
71 1.1 oki #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0)
72 1.1 oki #define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0)
73 1.1 oki #define CLKF_PC(framep) ((framep)->pc)
74 1.1 oki #if 0
75 1.1 oki /* We would like to do it this way... */
76 1.1 oki #define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0)
77 1.1 oki #else
78 1.1 oki /* but until we start using PSL_M, we have to do this instead */
79 1.1 oki #define CLKF_INTR(framep) (0) /* XXX */
80 1.1 oki #endif
81 1.1 oki
82 1.1 oki
83 1.1 oki /*
84 1.1 oki * Preempt the current process if in interrupt from user mode,
85 1.1 oki * or after the current trap/syscall if in system mode.
86 1.1 oki */
87 1.1 oki #define need_resched() { want_resched++; aston(); }
88 1.1 oki
89 1.1 oki /*
90 1.1 oki * Give a profiling tick to the current process when the user profiling
91 1.1 oki * buffer pages are invalid. On the x68k, request an ast to send us
92 1.1 oki * through trap, marking the proc as needing a profiling tick.
93 1.1 oki */
94 1.1 oki #define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
95 1.1 oki
96 1.1 oki /*
97 1.1 oki * Notify the current process (p) that it has a signal pending,
98 1.1 oki * process as soon as possible.
99 1.1 oki */
100 1.1 oki #define signotify(p) aston()
101 1.1 oki
102 1.1 oki #define aston() (astpending++)
103 1.1 oki
104 1.1 oki int astpending; /* need to trap before returning to user mode */
105 1.1 oki int want_resched; /* resched() was called */
106 1.1 oki
107 1.1 oki
108 1.1 oki /*
109 1.1 oki * simulated software interrupt register
110 1.1 oki */
111 1.1 oki extern unsigned char ssir;
112 1.1 oki
113 1.1 oki #define SIR_NET 0x1
114 1.1 oki #define SIR_CLOCK 0x2
115 1.1 oki #define SIR_SERIAL 0x4
116 1.1 oki #define SIR_KBD 0x8
117 1.1 oki
118 1.1 oki #define siroff(x) ssir &= ~(x)
119 1.1 oki #define setsoftnet() ssir |= SIR_NET
120 1.1 oki #define setsoftclock() ssir |= SIR_CLOCK
121 1.1 oki #define setsoftserial() ssir |= SIR_SERIAL
122 1.1 oki #define setsoftkbd() ssir |= SIR_KBD
123 1.1 oki
124 1.1 oki /*
125 1.1 oki * CTL_MACHDEP definitions.
126 1.1 oki */
127 1.1 oki #define CPU_CONSDEV 1 /* dev_t: console terminal device */
128 1.1 oki #define CPU_MAXID 2 /* number of valid machdep ids */
129 1.1 oki
130 1.1 oki #define CTL_MACHDEP_NAMES { \
131 1.1 oki { 0, 0 }, \
132 1.1 oki { "console_device", CTLTYPE_STRUCT }, \
133 1.1 oki }
134 1.1 oki
135 1.1 oki /*
136 1.1 oki * The rest of this should probably be moved to ../x68k/x68kcpu.h,
137 1.1 oki * although some of it could probably be put into generic 68k headers.
138 1.1 oki */
139 1.1 oki
140 1.1 oki /* values for machineid */
141 1.1 oki
142 1.1 oki /* values for mmutype (assigned for quick testing) */
143 1.1 oki #define MMU_68040 -2 /* 68040 on-chip MMU */
144 1.1 oki #define MMU_68030 -1 /* 68030 on-chip subset of 68851 */
145 1.1 oki #define MMU_68851 1 /* Motorola 68851 */
146 1.1 oki
147 1.1 oki /* values for ectype */
148 1.1 oki #define EC_PHYS -1 /* external physical address cache */
149 1.1 oki #define EC_NONE 0 /* no external cache */
150 1.1 oki #define EC_VIRT 1 /* external virtual address cache */
151 1.1 oki
152 1.1 oki /* values for cpuspeed (not really related to clock speed due to caches) */
153 1.1 oki #define MHZ_8 1
154 1.1 oki #define MHZ_16 2
155 1.1 oki #define MHZ_25 3
156 1.1 oki #define MHZ_33 4
157 1.1 oki #define MHZ_50 6
158 1.1 oki
159 1.1 oki #ifdef _KERNEL
160 1.1 oki extern int machineid, mmutype;
161 1.1 oki extern char *intiolimit;
162 1.2 oki
163 1.2 oki /* autoconf.c */
164 1.2 oki void configure __P((void));
165 1.2 oki
166 1.2 oki /* machdep.c */
167 1.2 oki void dumpconf __P((void));
168 1.2 oki void dumpsys __P((void));
169 1.2 oki
170 1.2 oki /* locore.s */
171 1.2 oki struct pcb;
172 1.2 oki struct fpframe;
173 1.2 oki void savectx __P((struct pcb *));
174 1.2 oki void switch_exit __P((struct proc *));
175 1.2 oki void proc_trampoline __P((void));
176 1.2 oki u_long getdfc __P((void));
177 1.2 oki u_long getsfc __P((void));
178 1.2 oki void loadustp __P((int));
179 1.2 oki void m68881_save __P((struct fpframe *));
180 1.2 oki void m68881_restore __P((struct fpframe *));
181 1.2 oki void DCIS __P((void));
182 1.2 oki void DCIU __P((void));
183 1.2 oki void ICIA __P((void));
184 1.2 oki void ICPA __P((void));
185 1.2 oki void PCIA __P((void));
186 1.2 oki void TBIA __P((void));
187 1.2 oki void TBIS __P((vm_offset_t));
188 1.2 oki void TBIAS __P((void));
189 1.2 oki void TBIAU __P((void));
190 1.2 oki #if defined(M68040) || defined(M68060)
191 1.2 oki void DCFA __P((void));
192 1.2 oki void DCFP __P((vm_offset_t));
193 1.2 oki void DCFL __P((vm_offset_t));
194 1.2 oki void DCPL __P((vm_offset_t));
195 1.2 oki void DCPP __P((vm_offset_t));
196 1.2 oki void ICPL __P((vm_offset_t));
197 1.2 oki void ICPP __P((vm_offset_t));
198 1.2 oki #endif
199 1.2 oki
200 1.2 oki /* sys_machdep.c */
201 1.2 oki int cachectl __P((int, caddr_t, int));
202 1.2 oki int dma_cachectl __P((caddr_t, int));
203 1.2 oki
204 1.2 oki /* vm_machdep.c */
205 1.2 oki int kvtop __P((caddr_t));
206 1.2 oki
207 1.2 oki #ifdef GENERIC
208 1.2 oki /* swapgeneric.c */
209 1.2 oki void setconf __P((void));
210 1.2 oki #endif /* GENERIC */
211 1.2 oki
212 1.1 oki #endif
213 1.1 oki
214 1.1 oki /* physical memory sections */
215 1.1 oki #define INTIOBASE (0x00C00000)
216 1.1 oki #define INTIOTOP (0x01000000)
217 1.1 oki
218 1.1 oki /*
219 1.1 oki * Internal IO space:
220 1.1 oki *
221 1.1 oki * Ranges from 0xC00000 to 0x1000000 (IIOMAPSIZE).
222 1.1 oki *
223 1.1 oki * Internal IO space is mapped in the kernel from ``IODEVbase'' to
224 1.1 oki * ``intiolimit'' (defined in locore.s). Since it is always mapped,
225 1.1 oki * conversion between physical and kernel virtual addresses is easy.
226 1.1 oki */
227 1.1 oki #define IIOPOFF(pa) ((int)(pa)-INTIOBASE)
228 1.1 oki #define IIOMAPSIZE btoc(INTIOTOP-INTIOBASE) /* 4mb */
229 1.1 oki
230 1.1 oki /*
231 1.1 oki * External IO space:
232 1.1 oki */
233 1.1 oki
234 1.1 oki /*
235 1.1 oki * 68851 and 68030 MMU
236 1.1 oki */
237 1.1 oki #define PMMU_LVLMASK 0x0007
238 1.1 oki #define PMMU_INV 0x0400
239 1.1 oki #define PMMU_WP 0x0800
240 1.1 oki #define PMMU_ALV 0x1000
241 1.1 oki #define PMMU_SO 0x2000
242 1.1 oki #define PMMU_LV 0x4000
243 1.1 oki #define PMMU_BE 0x8000
244 1.1 oki #define PMMU_FAULT (PMMU_WP|PMMU_INV)
245 1.1 oki
246 1.1 oki /*
247 1.1 oki * 68040 MMU
248 1.1 oki */
249 1.1 oki #define MMU4_RES 0x001
250 1.1 oki #define MMU4_TTR 0x002
251 1.1 oki #define MMU4_WP 0x004
252 1.1 oki #define MMU4_MOD 0x010
253 1.1 oki #define MMU4_CMMASK 0x060
254 1.1 oki #define MMU4_SUP 0x080
255 1.1 oki #define MMU4_U0 0x100
256 1.1 oki #define MMU4_U1 0x200
257 1.1 oki #define MMU4_GLB 0x400
258 1.1 oki #define MMU4_BE 0x800
259 1.1 oki
260 1.1 oki /* 680X0 function codes */
261 1.1 oki #define FC_USERD 1 /* user data space */
262 1.1 oki #define FC_USERP 2 /* user program space */
263 1.1 oki #define FC_SUPERD 5 /* supervisor data space */
264 1.1 oki #define FC_SUPERP 6 /* supervisor program space */
265 1.1 oki #define FC_CPU 7 /* CPU space */
266 1.1 oki
267 1.1 oki /* fields in the 68020 cache control register */
268 1.1 oki #define IC_ENABLE 0x0001 /* enable instruction cache */
269 1.1 oki #define IC_FREEZE 0x0002 /* freeze instruction cache */
270 1.1 oki #define IC_CE 0x0004 /* clear instruction cache entry */
271 1.1 oki #define IC_CLR 0x0008 /* clear entire instruction cache */
272 1.1 oki
273 1.1 oki /* additional fields in the 68030 cache control register */
274 1.1 oki #define IC_BE 0x0010 /* instruction burst enable */
275 1.1 oki #define DC_ENABLE 0x0100 /* data cache enable */
276 1.1 oki #define DC_FREEZE 0x0200 /* data cache freeze */
277 1.1 oki #define DC_CE 0x0400 /* clear data cache entry */
278 1.1 oki #define DC_CLR 0x0800 /* clear entire data cache */
279 1.1 oki #define DC_BE 0x1000 /* data burst enable */
280 1.1 oki #define DC_WA 0x2000 /* write allocate */
281 1.1 oki
282 1.1 oki #define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE)
283 1.1 oki #define CACHE_OFF (DC_CLR|IC_CLR)
284 1.1 oki #define CACHE_CLR (CACHE_ON)
285 1.1 oki #define IC_CLEAR (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE)
286 1.1 oki #define DC_CLEAR (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE)
287 1.1 oki
288 1.1 oki /* 68040 cache control register */
289 1.1 oki #define IC4_ENABLE 0x8000 /* instruction cache enable bit */
290 1.1 oki #define DC4_ENABLE 0x80000000 /* data cache enable bit */
291 1.1 oki
292 1.1 oki #define CACHE4_ON (IC4_ENABLE|DC4_ENABLE)
293 1.1 oki #define CACHE4_OFF (0)
294 1.1 oki
295 1.1 oki #endif /* _X68K_CPU_H_ */
296