cpu.h revision 1.55 1 /* $NetBSD: cpu.h,v 1.55 2024/01/18 13:46:14 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1982, 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: Utah $Hdr: cpu.h 1.16 91/03/25$
37 *
38 * @(#)cpu.h 8.4 (Berkeley) 1/5/94
39 */
40
41 #ifndef _MACHINE_CPU_H_
42 #define _MACHINE_CPU_H_
43
44 #if defined(_KERNEL_OPT)
45 #include "opt_lockdebug.h"
46 #include "opt_m68k_arch.h"
47 #endif
48
49 /*
50 * Get common m68k definitions.
51 */
52 #include <m68k/cpu.h>
53
54 #if defined(_KERNEL)
55 /*
56 * Exported definitions unique to next68k/68k cpu support.
57 */
58 #define M68K_MMU_MOTOROLA
59
60 /*
61 * Get interrupt glue.
62 */
63 #include <machine/intr.h>
64
65 /*
66 * Arguments to hardclock and gatherstats encapsulate the previous
67 * machine state in an opaque clockframe. On the next68k, we use
68 * what the locore.s glue puts on the stack before calling C-code.
69 */
70 struct clockframe {
71 u_int cf_regs[4]; /* d0,d1,a0,a1 */
72 u_short cf_sr; /* sr at time of interrupt */
73 u_long cf_pc; /* pc at time of interrupt */
74 u_short cf_vo; /* vector offset (4-word frame) */
75 } __attribute__((packed));
76
77 #define CLKF_USERMODE(framep) (((framep)->cf_sr & PSL_S) == 0)
78 #define CLKF_PC(framep) ((framep)->cf_pc)
79
80 /*
81 * The clock interrupt handler can determine if it's a nested
82 * interrupt by checking for interrupt_depth > 1.
83 * (Remember, the clock interrupt handler itself will cause the
84 * depth counter to be incremented).
85 */
86 #define CLKF_INTR(framep) (idepth > 1)
87
88 /*
89 * Preempt the current process if in interrupt from user mode,
90 * or after the current trap/syscall if in system mode.
91 */
92 #define cpu_need_resched(ci,l,flags) do { \
93 __USE(flags); \
94 aston(); \
95 } while (/*CONSTCOND*/0)
96
97 /*
98 * Give a profiling tick to the current process when the user profiling
99 * buffer pages are invalid. On the next68k, request an ast to send us
100 * through trap, marking the proc as needing a profiling tick.
101 */
102 #define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, aston())
103
104 /*
105 * Notify the current process (p) that it has a signal pending,
106 * process as soon as possible.
107 */
108 #define cpu_signotify(l) aston()
109
110 #define aston() (astpending++)
111
112 extern int astpending; /* need to trap before returning to user mode */
113
114 /* locore.s functions */
115 void doboot(void) __attribute__((__noreturn__));
116 int nmihand(void *);
117
118 extern int iscolor;
119 #endif /* _KERNEL */
120
121 #define NEXT_RAMBASE (0x4000000) /* really depends on slot, but... */
122 #define NEXT_BANKSIZE (0x1000000) /* Size of a memory bank in physical address */
123
124 #if 0
125 /* @@@ this needs to be fixed to work on 030's */
126 #define NEXT_SLOT_ID 0x0
127 #ifdef M68030
128 #define NEXT_SLOT_ID_BMAP 0x0
129 #endif /* M68030 */
130 #endif
131 #ifdef M68040
132 #ifdef DISABLE_NEXT_BMAP_CHIP /* @@@ For turbo testing */
133 #define NEXT_SLOT_ID_BMAP 0x0
134 #else
135 #define NEXT_SLOT_ID_BMAP 0x00100000
136 #endif
137 #define NEXT_SLOT_ID 0x0
138 #endif /* M68040 */
139
140 /****************************************************************/
141
142 /* Eventually, I'd like to move these defines off into
143 * configure somewhere
144 * Darrin B Jewell <jewell (at) mit.edu> Thu Feb 5 03:50:58 1998
145 */
146 /* ROM */
147 #define NEXT_P_EPROM (NEXT_SLOT_ID+0x00000000)
148 #define NEXT_P_EPROM_BMAP (NEXT_SLOT_ID+0x01000000)
149 #define NEXT_P_EPROM_SIZE (128 * 1024)
150
151 /* device space */
152 #define NEXT_P_DEV_SPACE (NEXT_SLOT_ID+0x02000000)
153 #define NEXT_P_DEV_BMAP (NEXT_SLOT_ID+0x02100000)
154 #define NEXT_DEV_SPACE_SIZE 0x0001c000
155
156 /* DMA control/status (writes MUST be 32-bit) */
157 #define NEXT_P_SCSI_CSR (NEXT_SLOT_ID+0x02000010)
158 #define NEXT_P_SOUNDOUT_CSR (NEXT_SLOT_ID+0x02000040)
159 #define NEXT_P_DISK_CSR (NEXT_SLOT_ID+0x02000050)
160 #define NEXT_P_SOUNDIN_CSR (NEXT_SLOT_ID+0x02000080)
161 #define NEXT_P_PRINTER_CSR (NEXT_SLOT_ID+0x02000090)
162 #define NEXT_P_SCC_CSR (NEXT_SLOT_ID+0x020000c0)
163 #define NEXT_P_DSP_CSR (NEXT_SLOT_ID+0x020000d0)
164 #define NEXT_P_ENETX_CSR (NEXT_SLOT_ID+0x02000110)
165 #define NEXT_P_ENETR_CSR (NEXT_SLOT_ID+0x02000150)
166 #define NEXT_P_VIDEO_CSR (NEXT_SLOT_ID+0x02000180)
167 #define NEXT_P_M2R_CSR (NEXT_SLOT_ID+0x020001d0)
168 #define NEXT_P_R2M_CSR (NEXT_SLOT_ID+0x020001c0)
169
170 /* DMA scratch pad (writes MUST be 32-bit) */
171 #define NEXT_P_VIDEO_SPAD (NEXT_SLOT_ID+0x02004180)
172 #define NEXT_P_EVENT_SPAD (NEXT_SLOT_ID+0x0200418c)
173 #define NEXT_P_M2M_SPAD (NEXT_SLOT_ID+0x020041e0)
174
175 /* device registers */
176 #define NEXT_P_ENET (NEXT_SLOT_ID_BMAP+0x02006000)
177 #define NEXT_P_DSP (NEXT_SLOT_ID_BMAP+0x02008000)
178 #define NEXT_P_MON (NEXT_SLOT_ID+0x0200e000)
179 #define NEXT_P_PRINTER (NEXT_SLOT_ID+0x0200f000)
180 #define NEXT_P_DISK (NEXT_SLOT_ID_BMAP+0x02012000)
181 #define NEXT_P_SCSI (NEXT_SLOT_ID_BMAP+0x02014000)
182 #define NEXT_P_FLOPPY (NEXT_SLOT_ID_BMAP+0x02014100)
183 #define NEXT_P_TIMER (NEXT_SLOT_ID_BMAP+0x02016000)
184 #define NEXT_P_TIMER_CSR (NEXT_SLOT_ID_BMAP+0x02016004)
185 #define NEXT_P_SCC (NEXT_SLOT_ID_BMAP+0x02018000)
186 #define NEXT_P_SCC_CLK (NEXT_SLOT_ID_BMAP+0x02018004)
187 #define NEXT_P_EVENTC (NEXT_SLOT_ID_BMAP+0x0201a000)
188 #define NEXT_P_BMAP (NEXT_SLOT_ID+0x020c0000)
189 /* All COLOR_FB registers are 1 byte wide */
190 #define NEXT_P_C16_DAC_0 (NEXT_SLOT_ID_BMAP+0x02018100) /* COLOR_FB - RAMDAC */
191 #define NEXT_P_C16_DAC_1 (NEXT_SLOT_ID_BMAP+0x02018101)
192 #define NEXT_P_C16_DAC_2 (NEXT_SLOT_ID_BMAP+0x02018102)
193 #define NEXT_P_C16_DAC_3 (NEXT_SLOT_ID_BMAP+0x02018103)
194 #define NEXT_P_C16_CMD_REG (NEXT_SLOT_ID_BMAP+0x02018180) /* COLOR_FB - CSR */
195
196 /* system control registers */
197 #define NEXT_P_MEMTIMING (NEXT_SLOT_ID_BMAP+0x02006010)
198 #define NEXT_P_INTRSTAT (NEXT_SLOT_ID+0x02007000)
199 #define NEXT_P_INTRSTAT_CON 0x02007000
200 /* #define NEXT_P_INTRSTAT_0 (NEXT_SLOT_ID+0x02008000) */
201 #define NEXT_P_INTRMASK (NEXT_SLOT_ID+0x02007800)
202 #define NEXT_P_INTRMASK_CON 0x02007800
203 /* #define NEXT_P_INTRMASK_0 (NEXT_SLOT_ID+0x0200a000) */
204 #define NEXT_P_SCR1 (NEXT_SLOT_ID+0x0200c000)
205 #define NEXT_P_SCR1_CON 0x0200c000
206 #define NEXT_P_SID 0x0200c800 /* NOT slot-relative */
207 #define NEXT_P_SCR2 (NEXT_SLOT_ID+0x0200d000)
208 #define NEXT_P_SCR2_CON 0x0200d000
209 #define NEXT_P_RMTINT (NEXT_SLOT_ID+0x0200d800)
210 #define NEXT_P_BRIGHTNESS (NEXT_SLOT_ID_BMAP+0x02010000)
211 #define NEXT_P_DRAM_TIMING (NEXT_SLOT_ID_BMAP+0x02018190) /* Warp 9C memory ctlr */
212 #define NEXT_P_VRAM_TIMING (NEXT_SLOT_ID_BMAP+0x02018198) /* Warp 9C memory ctlr */
213
214 /* memory */
215 #define NEXT_P_MAINMEM (NEXT_SLOT_ID+0x04000000)
216 #define NEXT_P_MEMSIZE 0x04000000
217 #define NEXT_P_VIDEOMEM (NEXT_SLOT_ID+0x0b000000)
218 #define NEXT_P_VIDEOSIZE 0x0003a800
219 #if 0
220 #define NEXT_P_C16_VIDEOMEM (NEXT_SLOT_ID+0x06000000) /* COLOR_FB */
221 #endif
222 #define NEXT_P_C16_VIDEOMEM (0x2c000000)
223 #define NEXT_P_C16_VIDEOSIZE 0x001D4000 /* COLOR_FB */
224 #define NEXT_P_WF4VIDEO (NEXT_SLOT_ID+0x0c000000) /* w A+B-AB function */
225 #define NEXT_P_WF3VIDEO (NEXT_SLOT_ID+0x0d000000) /* w (1-A)B function */
226 #define NEXT_P_WF2VIDEO (NEXT_SLOT_ID+0x0e000000) /* w ceil(A+B) function */
227 #define NEXT_P_WF1VIDEO (NEXT_SLOT_ID+0x0f000000) /* w AB function */
228 #define NEXT_P_WF4MEM (NEXT_SLOT_ID+0x10000000) /* w A+B-AB function */
229 #define NEXT_P_WF3MEM (NEXT_SLOT_ID+0x14000000) /* w (1-A)B function */
230 #define NEXT_P_WF2MEM (NEXT_SLOT_ID+0x18000000) /* w ceil(A+B) function */
231 #define NEXT_P_WF1MEM (NEXT_SLOT_ID+0x1c000000) /* w AB function */
232 #define NEXT_NMWF 4 /* # of memory write funcs */
233
234 /*
235 * Interrupt structure.
236 * BASE and BITS define the origin and length of the bit field in the
237 * interrupt status/mask register for the particular interrupt level.
238 * The first component of the interrupt device name indicates the bit
239 * position in the interrupt status and mask registers; the second is the
240 * interrupt level; the third is the bit index relative to the start of the
241 * bit field.
242 */
243 #define NEXT_I(l,i,b) (((b) << 8) | ((l) << 4) | (i))
244 #define NEXT_I_INDEX(i) ((i) & 0xf)
245 #define NEXT_I_IPL(i) (((i) >> 4) & 7)
246 #define NEXT_I_BIT(i) ( 1 << (((i) >> 8) & 0x1f))
247
248 #define NEXT_I_IPL7_BASE 0
249 #define NEXT_I_IPL7_BITS 2
250 #define NEXT_I_NMI NEXT_I(7,0,31)
251 #define NEXT_I_PFAIL NEXT_I(7,1,30)
252
253 #define NEXT_I_IPL6_BASE 2
254 #define NEXT_I_IPL6_BITS 12
255 #define NEXT_I_TIMER NEXT_I(6,0,29)
256 #define NEXT_I_ENETX_DMA NEXT_I(6,1,28)
257 #define NEXT_I_ENETR_DMA NEXT_I(6,2,27)
258 #define NEXT_I_SCSI_DMA NEXT_I(6,3,26)
259 #define NEXT_I_DISK_DMA NEXT_I(6,4,25)
260 #define NEXT_I_PRINTER_DMA NEXT_I(6,5,24)
261 #define NEXT_I_SOUND_OUT_DMA NEXT_I(6,6,23)
262 #define NEXT_I_SOUND_IN_DMA NEXT_I(6,7,22)
263 #define NEXT_I_SCC_DMA NEXT_I(6,8,21)
264 #define NEXT_I_DSP_DMA NEXT_I(6,9,20)
265 #define NEXT_I_M2R_DMA NEXT_I(6,10,19)
266 #define NEXT_I_R2M_DMA NEXT_I(6,11,18)
267
268 #define NEXT_I_IPL5_BASE 14
269 #define NEXT_I_IPL5_BITS 3
270 #define NEXT_I_SCC NEXT_I(5,0,17)
271 #define NEXT_I_REMOTE NEXT_I(5,1,16)
272 #define NEXT_I_BUS NEXT_I(5,2,15)
273
274 #define NEXT_I_IPL4_BASE 17
275 #define NEXT_I_IPL4_BITS 1
276 #define NEXT_I_DSP_4 NEXT_I(4,0,14)
277
278 #define NEXT_I_IPL3_BASE 18
279 #define NEXT_I_IPL3_BITS 12
280 #define NEXT_I_DISK NEXT_I(3,0,13)
281 #define NEXT_I_C16_VIDEO NEXT_I(3,0,13) /* COLOR_FB - Steals old ESDI interrupt */
282 #define NEXT_I_SCSI NEXT_I(3,1,12)
283 #define NEXT_I_PRINTER NEXT_I(3,2,11)
284 #define NEXT_I_ENETX NEXT_I(3,3,10)
285 #define NEXT_I_ENETR NEXT_I(3,4,9)
286 #define NEXT_I_SOUND_OVRUN NEXT_I(3,5,8)
287 #define NEXT_I_PHONE NEXT_I(3,6,7)
288 #define NEXT_I_DSP_3 NEXT_I(3,7,6)
289 #define NEXT_I_VIDEO NEXT_I(3,8,5)
290 #define NEXT_I_MONITOR NEXT_I(3,9,4)
291 #define NEXT_I_KYBD_MOUSE NEXT_I(3,10,3)
292 #define NEXT_I_POWER NEXT_I(3,11,2)
293
294 #define NEXT_I_IPL2_BASE 30
295 #define NEXT_I_IPL2_BITS 1
296 #define NEXT_I_SOFTINT1 NEXT_I(2,0,1)
297
298 #define NEXT_I_IPL1_BASE 31
299 #define NEXT_I_IPL1_BITS 1
300 #define NEXT_I_SOFTINT0 NEXT_I(1,0,0)
301
302 /****************************************************************/
303
304 /* physical memory sections */
305 #if 0
306 #define ROMBASE (0x00000000)
307 #endif
308
309 #define INTIOBASE (0x02000000)
310 #define INTIOTOP (0x02120000)
311 #define MONOBASE (0x0b000000)
312 #define MONOTOP (0x0b03a800)
313 #define COLORBASE (0x2c000000)
314 #define COLORTOP (0x2c1d4000)
315 #define TURBOFBBASE (0x0c000000)
316 #define TURBOMONOTOP (0x0c03a800)
317 #define TURBOCOLORTOP (0x0c1d4000)
318
319 #define NEXT_INTR_BITS \
320 "\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"
321
322 /*
323 * Internal IO space:
324 *
325 * Ranges from 0x400000 to 0x600000 (IIOMAPSIZE).
326 *
327 * Internal IO space is mapped in the kernel from ``intiobase'' to
328 * ``intiolimit'' (defined in locore.s). Since it is always mapped,
329 * conversion between physical and kernel virtual addresses is easy.
330 */
331 #define IIOV(pa) ((int)(pa)-INTIOBASE+intiobase)
332 #define IIOP(va) ((int)(va)-intiobase+INTIOBASE)
333 #define IIOMAPSIZE btoc(INTIOTOP-INTIOBASE) /* 2mb */
334
335 #endif /* _MACHINE_CPU_H_ */
336