cpu.h revision 1.25 1 /* $NetBSD: cpu.h,v 1.25 2003/10/05 22:00:25 mycroft Exp $ */
2
3 /*
4 * Copyright (c) 1982, 1990, 1993
5 * The Regents of the University of California. 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 8.4 (Berkeley) 1/5/94
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 8.4 (Berkeley) 1/5/94
77 */
78
79
80 #ifndef _MACHINE_CPU_H_
81 #define _MACHINE_CPU_H_
82
83 #if defined(_KERNEL_OPT)
84 #include "opt_lockdebug.h"
85 #endif
86
87 /*
88 * Exported definitions unique to next68k/68k cpu support.
89 */
90
91 /*
92 * Get common m68k definitions.
93 */
94 #include <m68k/cpu.h>
95
96 #define M68K_MMU_MOTOROLA
97
98 /*
99 * Get interrupt glue.
100 */
101 #include <machine/intr.h>
102
103 #include <sys/sched.h>
104 struct cpu_info {
105 struct schedstate_percpu ci_schedstate; /* scheduler state */
106 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
107 u_long ci_spin_locks; /* # of spin locks held */
108 u_long ci_simple_locks; /* # of simple locks held */
109 #endif
110 };
111
112 #ifdef _KERNEL
113 extern struct cpu_info cpu_info_store;
114
115 #define curcpu() (&cpu_info_store)
116
117 /*
118 * definitions of cpu-dependent requirements
119 * referenced in generic code
120 */
121 #define cpu_swapin(p) /* nothing */
122 #define cpu_wait(p) /* nothing */
123 #define cpu_swapout(p) /* nothing */
124 #define cpu_number() 0
125
126 void cpu_proc_fork(struct proc *, struct proc *);
127
128
129 /*
130 * Arguments to hardclock and gatherstats encapsulate the previous
131 * machine state in an opaque clockframe. One the hp300, we use
132 * what the hardware pushes on an interrupt (frame format 0).
133 */
134 struct clockframe {
135 u_short sr; /* sr at time of interrupt */
136 u_long pc; /* pc at time of interrupt */
137 u_short fmt:4,
138 vec:12; /* vector offset (4-word frame) */
139 } __attribute__((packed));
140
141 #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0)
142 #define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0)
143 #define CLKF_PC(framep) ((framep)->pc)
144
145 /*
146 * The clock interrupt handler can determine if it's a nested
147 * interrupt by checking for interrupt_depth > 1.
148 * (Remember, the clock interrupt handler itself will cause the
149 * depth counter to be incremented).
150 */
151 extern volatile unsigned int interrupt_depth;
152 #define CLKF_INTR(framep) (interrupt_depth > 1)
153
154 /*
155 * Preempt the current process if in interrupt from user mode,
156 * or after the current trap/syscall if in system mode.
157 */
158 extern int want_resched; /* resched() was called */
159 #define need_resched(ci) { want_resched = 1; aston(); }
160
161 /*
162 * Give a profiling tick to the current process when the user profiling
163 * buffer pages are invalid. On the sun3, request an ast to send us
164 * through trap, marking the proc as needing a profiling tick.
165 */
166 #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, aston())
167
168 /*
169 * Notify the current process (p) that it has a signal pending,
170 * process as soon as possible.
171 */
172 #define signotify(p) aston()
173
174 #define aston() (astpending++)
175
176 extern int astpending; /* need to trap before returning to user mode */
177 extern int want_resched; /* resched() was called */
178
179 extern void (*vectab[]) __P((void));
180
181 struct frame;
182 struct fpframe;
183 struct pcb;
184
185 /* locore.s functions */
186 void m68881_save __P((struct fpframe *));
187 void m68881_restore __P((struct fpframe *));
188
189 int suline __P((caddr_t, caddr_t));
190 void savectx __P((struct pcb *));
191 void switch_exit __P((struct lwp *));
192 void switch_lwp_exit __P((struct lwp *));
193 void proc_trampoline __P((void));
194 void loadustp __P((int));
195
196 void doboot __P((void)) __attribute__((__noreturn__));
197 int nmihand __P((void *));
198
199 /* sys_machdep.c functions */
200 int cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
201
202 /* vm_machdep.c functions */
203 void physaccess __P((caddr_t, caddr_t, int, int));
204 void physunaccess __P((caddr_t, int));
205 int kvtop __P((caddr_t));
206
207 /* clock.c functions */
208 void next68k_calibrate_delay __P((void));
209
210 #endif /* _KERNEL */
211
212 #define NEXT_RAMBASE (0x4000000) /* really depends on slot, but... */
213 #define NEXT_BANKSIZE (0x1000000) /* Size of a memory bank in physical address */
214
215 #if 0
216 /* @@@ this needs to be fixed to work on 030's */
217 #define NEXT_SLOT_ID 0x0
218 #ifdef M68030
219 #define NEXT_SLOT_ID_BMAP 0x0
220 #endif /* M68030 */
221 #endif
222 #ifdef M68040
223 #ifdef DISABLE_NEXT_BMAP_CHIP /* @@@ For turbo testing */
224 #define NEXT_SLOT_ID_BMAP 0x0
225 #else
226 #define NEXT_SLOT_ID_BMAP 0x00100000
227 #endif
228 #define NEXT_SLOT_ID 0x0
229 #endif /* M68040 */
230
231 /****************************************************************/
232
233 /* Eventually, I'd like to move these defines off into
234 * configure somewhere
235 * Darrin B Jewell <jewell (at) mit.edu> Thu Feb 5 03:50:58 1998
236 */
237 /* ROM */
238 #define NEXT_P_EPROM (NEXT_SLOT_ID+0x00000000)
239 #define NEXT_P_EPROM_BMAP (NEXT_SLOT_ID+0x01000000)
240 #define NEXT_P_EPROM_SIZE (128 * 1024)
241
242 /* device space */
243 #define NEXT_P_DEV_SPACE (NEXT_SLOT_ID+0x02000000)
244 #define NEXT_P_DEV_BMAP (NEXT_SLOT_ID+0x02100000)
245 #define NEXT_DEV_SPACE_SIZE 0x0001c000
246
247 /* DMA control/status (writes MUST be 32-bit) */
248 #define NEXT_P_SCSI_CSR (NEXT_SLOT_ID+0x02000010)
249 #define NEXT_P_SOUNDOUT_CSR (NEXT_SLOT_ID+0x02000040)
250 #define NEXT_P_DISK_CSR (NEXT_SLOT_ID+0x02000050)
251 #define NEXT_P_SOUNDIN_CSR (NEXT_SLOT_ID+0x02000080)
252 #define NEXT_P_PRINTER_CSR (NEXT_SLOT_ID+0x02000090)
253 #define NEXT_P_SCC_CSR (NEXT_SLOT_ID+0x020000c0)
254 #define NEXT_P_DSP_CSR (NEXT_SLOT_ID+0x020000d0)
255 #define NEXT_P_ENETX_CSR (NEXT_SLOT_ID+0x02000110)
256 #define NEXT_P_ENETR_CSR (NEXT_SLOT_ID+0x02000150)
257 #define NEXT_P_VIDEO_CSR (NEXT_SLOT_ID+0x02000180)
258 #define NEXT_P_M2R_CSR (NEXT_SLOT_ID+0x020001d0)
259 #define NEXT_P_R2M_CSR (NEXT_SLOT_ID+0x020001c0)
260
261 /* DMA scratch pad (writes MUST be 32-bit) */
262 #define NEXT_P_VIDEO_SPAD (NEXT_SLOT_ID+0x02004180)
263 #define NEXT_P_EVENT_SPAD (NEXT_SLOT_ID+0x0200418c)
264 #define NEXT_P_M2M_SPAD (NEXT_SLOT_ID+0x020041e0)
265
266 /* device registers */
267 #define NEXT_P_ENET (NEXT_SLOT_ID_BMAP+0x02006000)
268 #define NEXT_P_DSP (NEXT_SLOT_ID_BMAP+0x02008000)
269 #define NEXT_P_MON (NEXT_SLOT_ID+0x0200e000)
270 #define NEXT_P_PRINTER (NEXT_SLOT_ID+0x0200f000)
271 #define NEXT_P_DISK (NEXT_SLOT_ID_BMAP+0x02012000)
272 #define NEXT_P_SCSI (NEXT_SLOT_ID_BMAP+0x02014000)
273 #define NEXT_P_FLOPPY (NEXT_SLOT_ID_BMAP+0x02014100)
274 #define NEXT_P_TIMER (NEXT_SLOT_ID_BMAP+0x02016000)
275 #define NEXT_P_TIMER_CSR (NEXT_SLOT_ID_BMAP+0x02016004)
276 #define NEXT_P_SCC (NEXT_SLOT_ID_BMAP+0x02018000)
277 #define NEXT_P_SCC_CLK (NEXT_SLOT_ID_BMAP+0x02018004)
278 #define NEXT_P_EVENTC (NEXT_SLOT_ID_BMAP+0x0201a000)
279 #define NEXT_P_BMAP (NEXT_SLOT_ID+0x020c0000)
280 /* All COLOR_FB registers are 1 byte wide */
281 #define NEXT_P_C16_DAC_0 (NEXT_SLOT_ID_BMAP+0x02018100) /* COLOR_FB - RAMDAC */
282 #define NEXT_P_C16_DAC_1 (NEXT_SLOT_ID_BMAP+0x02018101)
283 #define NEXT_P_C16_DAC_2 (NEXT_SLOT_ID_BMAP+0x02018102)
284 #define NEXT_P_C16_DAC_3 (NEXT_SLOT_ID_BMAP+0x02018103)
285 #define NEXT_P_C16_CMD_REG (NEXT_SLOT_ID_BMAP+0x02018180) /* COLOR_FB - CSR */
286
287 /* system control registers */
288 #define NEXT_P_MEMTIMING (NEXT_SLOT_ID_BMAP+0x02006010)
289 #define NEXT_P_INTRSTAT (NEXT_SLOT_ID+0x02007000)
290 #define NEXT_P_INTRSTAT_CON 0x02007000
291 /* #define NEXT_P_INTRSTAT_0 (NEXT_SLOT_ID+0x02008000) */
292 #define NEXT_P_INTRMASK (NEXT_SLOT_ID+0x02007800)
293 #define NEXT_P_INTRMASK_CON 0x02007800
294 /* #define NEXT_P_INTRMASK_0 (NEXT_SLOT_ID+0x0200a000) */
295 #define NEXT_P_SCR1 (NEXT_SLOT_ID+0x0200c000)
296 #define NEXT_P_SCR1_CON 0x0200c000
297 #define NEXT_P_SID 0x0200c800 /* NOT slot-relative */
298 #define NEXT_P_SCR2 (NEXT_SLOT_ID+0x0200d000)
299 #define NEXT_P_SCR2_CON 0x0200d000
300 #define NEXT_P_RMTINT (NEXT_SLOT_ID+0x0200d800)
301 #define NEXT_P_BRIGHTNESS (NEXT_SLOT_ID_BMAP+0x02010000)
302 #define NEXT_P_DRAM_TIMING (NEXT_SLOT_ID_BMAP+0x02018190) /* Warp 9C memory ctlr */
303 #define NEXT_P_VRAM_TIMING (NEXT_SLOT_ID_BMAP+0x02018198) /* Warp 9C memory ctlr */
304
305 /* memory */
306 #define NEXT_P_MAINMEM (NEXT_SLOT_ID+0x04000000)
307 #define NEXT_P_MEMSIZE 0x04000000
308 #define NEXT_P_VIDEOMEM (NEXT_SLOT_ID+0x0b000000)
309 #define NEXT_P_VIDEOSIZE 0x0003a800
310 #if 0
311 #define NEXT_P_C16_VIDEOMEM (NEXT_SLOT_ID+0x06000000) /* COLOR_FB */
312 #endif
313 #define NEXT_P_C16_VIDEOMEM (0x2c000000)
314 #define NEXT_P_C16_VIDEOSIZE 0x001D4000 /* COLOR_FB */
315 #define NEXT_P_WF4VIDEO (NEXT_SLOT_ID+0x0c000000) /* w A+B-AB function */
316 #define NEXT_P_WF3VIDEO (NEXT_SLOT_ID+0x0d000000) /* w (1-A)B function */
317 #define NEXT_P_WF2VIDEO (NEXT_SLOT_ID+0x0e000000) /* w ceil(A+B) function */
318 #define NEXT_P_WF1VIDEO (NEXT_SLOT_ID+0x0f000000) /* w AB function */
319 #define NEXT_P_WF4MEM (NEXT_SLOT_ID+0x10000000) /* w A+B-AB function */
320 #define NEXT_P_WF3MEM (NEXT_SLOT_ID+0x14000000) /* w (1-A)B function */
321 #define NEXT_P_WF2MEM (NEXT_SLOT_ID+0x18000000) /* w ceil(A+B) function */
322 #define NEXT_P_WF1MEM (NEXT_SLOT_ID+0x1c000000) /* w AB function */
323 #define NEXT_NMWF 4 /* # of memory write funcs */
324
325 /*
326 * Interrupt structure.
327 * BASE and BITS define the origin and length of the bit field in the
328 * interrupt status/mask register for the particular interrupt level.
329 * The first component of the interrupt device name indicates the bit
330 * position in the interrupt status and mask registers; the second is the
331 * interrupt level; the third is the bit index relative to the start of the
332 * bit field.
333 */
334 #define NEXT_I(l,i,b) (((b) << 8) | ((l) << 4) | (i))
335 #define NEXT_I_INDEX(i) ((i) & 0xf)
336 #define NEXT_I_IPL(i) (((i) >> 4) & 7)
337 #define NEXT_I_BIT(i) ( 1 << (((i) >> 8) & 0x1f))
338
339 #define NEXT_I_IPL7_BASE 0
340 #define NEXT_I_IPL7_BITS 2
341 #define NEXT_I_NMI NEXT_I(7,0,31)
342 #define NEXT_I_PFAIL NEXT_I(7,1,30)
343
344 #define NEXT_I_IPL6_BASE 2
345 #define NEXT_I_IPL6_BITS 12
346 #define NEXT_I_TIMER NEXT_I(6,0,29)
347 #define NEXT_I_ENETX_DMA NEXT_I(6,1,28)
348 #define NEXT_I_ENETR_DMA NEXT_I(6,2,27)
349 #define NEXT_I_SCSI_DMA NEXT_I(6,3,26)
350 #define NEXT_I_DISK_DMA NEXT_I(6,4,25)
351 #define NEXT_I_PRINTER_DMA NEXT_I(6,5,24)
352 #define NEXT_I_SOUND_OUT_DMA NEXT_I(6,6,23)
353 #define NEXT_I_SOUND_IN_DMA NEXT_I(6,7,22)
354 #define NEXT_I_SCC_DMA NEXT_I(6,8,21)
355 #define NEXT_I_DSP_DMA NEXT_I(6,9,20)
356 #define NEXT_I_M2R_DMA NEXT_I(6,10,19)
357 #define NEXT_I_R2M_DMA NEXT_I(6,11,18)
358
359 #define NEXT_I_IPL5_BASE 14
360 #define NEXT_I_IPL5_BITS 3
361 #define NEXT_I_SCC NEXT_I(5,0,17)
362 #define NEXT_I_REMOTE NEXT_I(5,1,16)
363 #define NEXT_I_BUS NEXT_I(5,2,15)
364
365 #define NEXT_I_IPL4_BASE 17
366 #define NEXT_I_IPL4_BITS 1
367 #define NEXT_I_DSP_4 NEXT_I(4,0,14)
368
369 #define NEXT_I_IPL3_BASE 18
370 #define NEXT_I_IPL3_BITS 12
371 #define NEXT_I_DISK NEXT_I(3,0,13)
372 #define NEXT_I_C16_VIDEO NEXT_I(3,0,13) /* COLOR_FB - Steals old ESDI interrupt */
373 #define NEXT_I_SCSI NEXT_I(3,1,12)
374 #define NEXT_I_PRINTER NEXT_I(3,2,11)
375 #define NEXT_I_ENETX NEXT_I(3,3,10)
376 #define NEXT_I_ENETR NEXT_I(3,4,9)
377 #define NEXT_I_SOUND_OVRUN NEXT_I(3,5,8)
378 #define NEXT_I_PHONE NEXT_I(3,6,7)
379 #define NEXT_I_DSP_3 NEXT_I(3,7,6)
380 #define NEXT_I_VIDEO NEXT_I(3,8,5)
381 #define NEXT_I_MONITOR NEXT_I(3,9,4)
382 #define NEXT_I_KYBD_MOUSE NEXT_I(3,10,3)
383 #define NEXT_I_POWER NEXT_I(3,11,2)
384
385 #define NEXT_I_IPL2_BASE 30
386 #define NEXT_I_IPL2_BITS 1
387 #define NEXT_I_SOFTINT1 NEXT_I(2,0,1)
388
389 #define NEXT_I_IPL1_BASE 31
390 #define NEXT_I_IPL1_BITS 1
391 #define NEXT_I_SOFTINT0 NEXT_I(1,0,0)
392
393 /****************************************************************/
394
395 /* physical memory sections */
396 #if 0
397 #define ROMBASE (0x00000000)
398 #endif
399
400 #define INTIOBASE (0x02000000)
401 #define INTIOTOP (0x02120000)
402 #define MONOBASE (0x0b000000)
403 #define MONOTOP (0x0b03a800)
404 #define COLORBASE (0x2c000000)
405 #define COLORTOP (0x2c1D4000)
406
407 #define NEXT_INTR_BITS \
408 "\20\40NMI\37PFAIL\36TIMER\35ENETX_DMA\34ENETR_DMA\33SCSI_DMA\32DISK_DMA\31PRINTER_DMA\30SOUND_OUT_DMA\27SOUND_IN_DMA\26SCC_DMA\25DSP_DMA\24M2R_DMA\23R2M_DMA\22SCC\21REMOTE\20BUS\17DSP_4\16DISK|C16_VIDEO\15SCSI\14PRINTER\13ENETX\12ENETR\11SOUND_OVRUN\10PHONE\07DSP_3\06VIDEO\05MONITOR\04KYBD_MOUSE\03POWER\02SOFTINT1\01SOFTINT0"
409
410 /*
411 * Internal IO space:
412 *
413 * Ranges from 0x400000 to 0x600000 (IIOMAPSIZE).
414 *
415 * Internal IO space is mapped in the kernel from ``intiobase'' to
416 * ``intiolimit'' (defined in locore.s). Since it is always mapped,
417 * conversion between physical and kernel virtual addresses is easy.
418 */
419 #define IIOV(pa) ((int)(pa)-INTIOBASE+intiobase)
420 #define IIOP(va) ((int)(va)-intiobase+INTIOBASE)
421 #define IIOMAPSIZE btoc(INTIOTOP-INTIOBASE) /* 2mb */
422
423 /* mono fb space */
424 #define MONOMAPSIZE btoc(MONOTOP-MONOBASE) /* who cares */
425
426 /* color fb space */
427 #define COLORMAPSIZE btoc(COLORTOP-COLORBASE) /* who cares */
428
429 #endif /* _MACHINE_CPU_H_ */
430