xref: /netbsd-src/sys/arch/next68k/include/cpu.h (revision 89c5a767f8fc7a4633b2d409966e2becbb98ff92)
1 /*	$NetBSD: cpu.h,v 1.11 1999/08/10 21:08:08 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. All advertising materials mentioning features or use of this software
21  *    must display the following acknowledgement:
22  *	This product includes software developed by the University of
23  *	California, Berkeley and its contributors.
24  * 4. Neither the name of the University nor the names of its contributors
25  *    may be used to endorse or promote products derived from this software
26  *    without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38  * SUCH DAMAGE.
39  *
40  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
41  *
42  *	@(#)cpu.h	8.4 (Berkeley) 1/5/94
43  */
44 
45 
46 #ifndef _CPU_MACHINE_
47 #define _CPU_MACHINE_
48 
49 /*
50  * Exported definitions unique to next68k/68k cpu support.
51  */
52 
53 /*
54  * Get common m68k definitions.
55  */
56 #include <m68k/cpu.h>
57 
58 #define	M68K_MMU_MOTOROLA
59 
60 /*
61  * Get interrupt glue.
62  */
63 #include <machine/intr.h>
64 
65 /*
66  * definitions of cpu-dependent requirements
67  * referenced in generic code
68  */
69 #define	cpu_swapin(p)			/* nothing */
70 #define	cpu_wait(p)			/* nothing */
71 #define cpu_swapout(p)			/* nothing */
72 #define	cpu_number()			0
73 
74 /*
75  * Arguments to hardclock and gatherstats encapsulate the previous
76  * machine state in an opaque clockframe.  One the hp300, we use
77  * what the hardware pushes on an interrupt (frame format 0).
78  */
79 struct clockframe {
80 	u_short	sr;		/* sr at time of interrupt */
81 	u_long	pc;		/* pc at time of interrupt */
82 	u_short	vo;		/* vector offset (4-word frame) */
83 };
84 
85 #define	CLKF_USERMODE(framep)	(((framep)->sr & PSL_S) == 0)
86 #define	CLKF_BASEPRI(framep)	(((framep)->sr & PSL_IPL) == 0)
87 #define	CLKF_PC(framep)		((framep)->pc)
88 #if 0
89 /* We would like to do it this way... */
90 #define	CLKF_INTR(framep)	(((framep)->sr & PSL_M) == 0)
91 #else
92 /* but until we start using PSL_M, we have to do this instead */
93 #define	CLKF_INTR(framep)	(0)	/* XXX */
94 #endif
95 
96 /*
97  * Preempt the current process if in interrupt from user mode,
98  * or after the current trap/syscall if in system mode.
99  */
100 extern int want_resched; /* resched() was called */
101 #define	need_resched()	{ want_resched = 1; aston(); }
102 
103 /*
104  * Give a profiling tick to the current process when the user profiling
105  * buffer pages are invalid.  On the sun3, request an ast to send us
106  * through trap, marking the proc as needing a profiling tick.
107  */
108 #define	need_proftick(p)	((p)->p_flag |= P_OWEUPC, aston())
109 
110 /*
111  * Notify the current process (p) that it has a signal pending,
112  * process as soon as possible.
113  */
114 #define	signotify(p)	aston()
115 
116 #define aston() (astpending++)
117 
118 int	astpending;	/* need to trap before returning to user mode */
119 int	want_resched;	/* resched() was called */
120 
121 #ifdef _KERNEL
122 extern	volatile char *intiobase;
123 extern  volatile char *intiolimit;
124 extern	volatile char *monobase;
125 extern  volatile char *monolimit;
126 extern	volatile char *colorbase;
127 extern  volatile char *colorlimit;
128 extern	void (*vectab[]) __P((void));
129 
130 struct frame;
131 struct fpframe;
132 struct pcb;
133 
134 /* locore.s functions */
135 void	m68881_save __P((struct fpframe *));
136 void	m68881_restore __P((struct fpframe *));
137 #if 0                           /* it's already in m68k/m68k.h */
138 u_long	getdfc __P((void));
139 u_long	getsfc __P((void));
140 #endif
141 
142 #if 0 /* {@@@ Use cacheops.h? */
143 
144 void	DCIA __P((void));
145 void	DCIS __P((void));
146 void	DCIU __P((void));
147 void	ICIA __P((void));
148 void	ICPA __P((void));
149 void	PCIA __P((void));
150 void	TBIA __P((void));
151 void	TBIS __P((vm_offset_t));
152 void	TBIAS __P((void));
153 void	TBIAU __P((void));
154 #if defined(M68040)
155 void	DCFA __P((void));
156 void	DCFP __P((vm_offset_t));
157 void	DCFL __P((vm_offset_t));
158 void	DCPL __P((vm_offset_t));
159 void	DCPP __P((vm_offset_t));
160 void	ICPL __P((vm_offset_t));
161 void	ICPP __P((vm_offset_t));
162 #endif
163 #endif /* }@@@ use m68k/cacheops.c */
164 
165 int	suline __P((caddr_t, caddr_t));
166 void	savectx __P((struct pcb *));
167 void	switch_exit __P((struct proc *));
168 void	proc_trampoline __P((void));
169 void	loadustp __P((int));
170 
171 void	doboot __P((void)) __attribute__((__noreturn__));
172 
173 /* sys_machdep.c functions */
174 int	cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
175 
176 /* vm_machdep.c functions */
177 void	physaccess __P((caddr_t, caddr_t, int, int));
178 void	physunaccess __P((caddr_t, int));
179 int	kvtop __P((caddr_t));
180 
181 /* clock.c functions */
182 void	next68k_calibrate_delay __P((void));
183 
184 /* trap.c function */
185 void	child_return __P((void *));
186 
187 #endif /* _KERNEL */
188 
189 #define NEXT_RAMBASE  (0x4000000) /* really depends on slot, but... */
190 #define NEXT_BANKSIZE (0x1000000) /* Size of a memory bank in physical address */
191 
192 #if 0
193 /* @@@ this needs to be fixed to work on 030's */
194 #define	NEXT_SLOT_ID		0x0
195 #ifdef	M68030
196 #define	NEXT_SLOT_ID_BMAP	0x0
197 #endif	M68030
198 #endif
199 #ifdef	M68040
200 #ifdef DISABLE_NEXT_BMAP_CHIP		/* @@@ For turbo testing */
201 #define	NEXT_SLOT_ID_BMAP	0x0
202 #else
203 #define	NEXT_SLOT_ID_BMAP	0x00100000
204 #endif
205 #define NEXT_SLOT_ID            0x0
206 #endif	M68040
207 
208 /****************************************************************/
209 
210 /* Eventually, I'd like to move these defines off into
211  * configure somewhere
212  * Darrin B Jewell <jewell@mit.edu>  Thu Feb  5 03:50:58 1998
213  */
214 /* ROM */
215 #define NEXT_P_EPROM		(NEXT_SLOT_ID+0x00000000)
216 #define NEXT_P_EPROM_BMAP	(NEXT_SLOT_ID+0x01000000)
217 #define NEXT_P_EPROM_SIZE	(128 * 1024)
218 
219 /* device space */
220 #define NEXT_P_DEV_SPACE	(NEXT_SLOT_ID+0x02000000)
221 #define NEXT_P_DEV_BMAP		(NEXT_SLOT_ID+0x02100000)
222 #define NEXT_DEV_SPACE_SIZE	0x0001c000
223 
224 /* DMA control/status (writes MUST be 32-bit) */
225 #define NEXT_P_SCSI_CSR		(NEXT_SLOT_ID+0x02000010)
226 #define NEXT_P_SOUNDOUT_CSR	(NEXT_SLOT_ID+0x02000040)
227 #define NEXT_P_DISK_CSR		(NEXT_SLOT_ID+0x02000050)
228 #define NEXT_P_SOUNDIN_CSR	(NEXT_SLOT_ID+0x02000080)
229 #define NEXT_P_PRINTER_CSR	(NEXT_SLOT_ID+0x02000090)
230 #define NEXT_P_SCC_CSR		(NEXT_SLOT_ID+0x020000c0)
231 #define NEXT_P_DSP_CSR		(NEXT_SLOT_ID+0x020000d0)
232 #define NEXT_P_ENETX_CSR	(NEXT_SLOT_ID+0x02000110)
233 #define NEXT_P_ENETR_CSR	(NEXT_SLOT_ID+0x02000150)
234 #define NEXT_P_VIDEO_CSR	(NEXT_SLOT_ID+0x02000180)
235 #define NEXT_P_M2R_CSR		(NEXT_SLOT_ID+0x020001d0)
236 #define NEXT_P_R2M_CSR		(NEXT_SLOT_ID+0x020001c0)
237 
238 /* DMA scratch pad (writes MUST be 32-bit) */
239 #define NEXT_P_VIDEO_SPAD	(NEXT_SLOT_ID+0x02004180)
240 #define NEXT_P_EVENT_SPAD	(NEXT_SLOT_ID+0x0200418c)
241 #define NEXT_P_M2M_SPAD		(NEXT_SLOT_ID+0x020041e0)
242 
243 /* device registers */
244 #define NEXT_P_ENET		(NEXT_SLOT_ID_BMAP+0x02006000)
245 #define NEXT_P_DSP		(NEXT_SLOT_ID_BMAP+0x02008000)
246 #define NEXT_P_MON		(NEXT_SLOT_ID+0x0200e000)
247 #define NEXT_P_PRINTER		(NEXT_SLOT_ID+0x0200f000)
248 #define NEXT_P_DISK		(NEXT_SLOT_ID_BMAP+0x02012000)
249 #define NEXT_P_SCSI		(NEXT_SLOT_ID_BMAP+0x02014000)
250 #define NEXT_P_FLOPPY		(NEXT_SLOT_ID_BMAP+0x02014100)
251 #define NEXT_P_TIMER		(NEXT_SLOT_ID_BMAP+0x02016000)
252 #define NEXT_P_TIMER_CSR	(NEXT_SLOT_ID_BMAP+0x02016004)
253 #define NEXT_P_SCC		(NEXT_SLOT_ID_BMAP+0x02018000)
254 #define NEXT_P_SCC_CLK		(NEXT_SLOT_ID_BMAP+0x02018004)
255 #define NEXT_P_EVENTC		(NEXT_SLOT_ID_BMAP+0x0201a000)
256 #define NEXT_P_BMAP		(NEXT_SLOT_ID+0x020c0000)
257 /* All COLOR_FB registers are 1 byte wide */
258 #define NEXT_P_C16_DAC_0	(NEXT_SLOT_ID_BMAP+0x02018100)	/* COLOR_FB - RAMDAC */
259 #define NEXT_P_C16_DAC_1	(NEXT_SLOT_ID_BMAP+0x02018101)
260 #define NEXT_P_C16_DAC_2	(NEXT_SLOT_ID_BMAP+0x02018102)
261 #define NEXT_P_C16_DAC_3	(NEXT_SLOT_ID_BMAP+0x02018103)
262 #define NEXT_P_C16_CMD_REG	(NEXT_SLOT_ID_BMAP+0x02018180)	/* COLOR_FB - CSR */
263 
264 /* system control registers */
265 #define NEXT_P_MEMTIMING	(NEXT_SLOT_ID_BMAP+0x02006010)
266 #define NEXT_P_INTRSTAT		(NEXT_SLOT_ID+0x02007000)
267 #define NEXT_P_INTRSTAT_CON	0x02007000
268 #define NEXT_P_INTRMASK		(NEXT_SLOT_ID+0x02007800)
269 #define NEXT_P_INTRMASK_CON	0x02007800
270 #define NEXT_P_SCR1		(NEXT_SLOT_ID+0x0200c000)
271 #define NEXT_P_SCR1_CON	0x0200c000
272 #define NEXT_P_SID		0x0200c800		/* NOT slot-relative */
273 #define NEXT_P_SCR2		(NEXT_SLOT_ID+0x0200d000)
274 #define NEXT_P_SCR2_CON	0x0200d000
275 #define NEXT_P_RMTINT		(NEXT_SLOT_ID+0x0200d800)
276 #define NEXT_P_BRIGHTNESS	(NEXT_SLOT_ID_BMAP+0x02010000)
277 #define NEXT_P_DRAM_TIMING	(NEXT_SLOT_ID_BMAP+0x02018190) /* Warp 9C memory ctlr */
278 #define NEXT_P_VRAM_TIMING	(NEXT_SLOT_ID_BMAP+0x02018198) /* Warp 9C memory ctlr */
279 
280 /* memory */
281 #define NEXT_P_MAINMEM		(NEXT_SLOT_ID+0x04000000)
282 #define NEXT_P_MEMSIZE		0x04000000
283 #define NEXT_P_VIDEOMEM		(NEXT_SLOT_ID+0x0b000000)
284 #define NEXT_P_VIDEOSIZE	0x0003a800
285 #define NEXT_P_C16_VIDEOMEM	(NEXT_SLOT_ID+0x06000000)	/* COLOR_FB */
286 #define NEXT_P_C16_VIDEOSIZE	0x001D4000		/* COLOR_FB */
287 #define NEXT_P_WF4VIDEO		(NEXT_SLOT_ID+0x0c000000)	/* w A+B-AB function */
288 #define NEXT_P_WF3VIDEO		(NEXT_SLOT_ID+0x0d000000)	/* w (1-A)B function */
289 #define NEXT_P_WF2VIDEO		(NEXT_SLOT_ID+0x0e000000)	/* w ceil(A+B) function */
290 #define NEXT_P_WF1VIDEO		(NEXT_SLOT_ID+0x0f000000)	/* w AB function */
291 #define NEXT_P_WF4MEM		(NEXT_SLOT_ID+0x10000000)	/* w A+B-AB function */
292 #define NEXT_P_WF3MEM		(NEXT_SLOT_ID+0x14000000)	/* w (1-A)B function */
293 #define NEXT_P_WF2MEM		(NEXT_SLOT_ID+0x18000000)	/* w ceil(A+B) function */
294 #define NEXT_P_WF1MEM		(NEXT_SLOT_ID+0x1c000000)	/* w AB function */
295 #define NEXT_NMWF		4			/* # of memory write funcs */
296 
297 /*
298  * Interrupt structure.
299  * BASE and BITS define the origin and length of the bit field in the
300  * interrupt status/mask register for the particular interrupt level.
301  * The first component of the interrupt device name indicates the bit
302  * position in the interrupt status and mask registers; the second is the
303  * interrupt level; the third is the bit index relative to the start of the
304  * bit field.
305  */
306 #define	NEXT_I(l,i,b)	(((b) << 8) | ((l) << 4) | (i))
307 #define	NEXT_I_INDEX(i)	((i) & 0xf)
308 #define	NEXT_I_IPL(i)	(((i) >> 4) & 7)
309 #define	NEXT_I_BIT(i)	( 1 << (((i) >> 8) & 0x1f))
310 
311 #define	NEXT_I_IPL7_BASE	0
312 #define	NEXT_I_IPL7_BITS	2
313 #define	NEXT_I_NMI		NEXT_I(7,0,31)
314 #define	NEXT_I_PFAIL		NEXT_I(7,1,30)
315 
316 #define	NEXT_I_IPL6_BASE	2
317 #define	NEXT_I_IPL6_BITS	12
318 #define	NEXT_I_TIMER		NEXT_I(6,0,29)
319 #define	NEXT_I_ENETX_DMA	NEXT_I(6,1,28)
320 #define	NEXT_I_ENETR_DMA	NEXT_I(6,2,27)
321 #define	NEXT_I_SCSI_DMA		NEXT_I(6,3,26)
322 #define	NEXT_I_DISK_DMA	        NEXT_I(6,4,25)
323 #define	NEXT_I_PRINTER_DMA	NEXT_I(6,5,24)
324 #define	NEXT_I_SOUND_OUT_DMA	NEXT_I(6,6,23)
325 #define	NEXT_I_SOUND_IN_DMA	NEXT_I(6,7,22)
326 #define	NEXT_I_SCC_DMA	        NEXT_I(6,8,21)
327 #define	NEXT_I_DSP_DMA		NEXT_I(6,9,20)
328 #define	NEXT_I_M2R_DMA		NEXT_I(6,10,19)
329 #define	NEXT_I_R2M_DMA		NEXT_I(6,11,18)
330 
331 #define	NEXT_I_IPL5_BASE	14
332 #define	NEXT_I_IPL5_BITS	3
333 #define	NEXT_I_SCC		NEXT_I(5,0,17)
334 #define	NEXT_I_REMOTE		NEXT_I(5,1,16)
335 #define	NEXT_I_BUS		NEXT_I(5,2,15)
336 
337 #define	NEXT_I_IPL4_BASE	17
338 #define	NEXT_I_IPL4_BITS	1
339 #define	NEXT_I_DSP_4		NEXT_I(4,0,14)
340 
341 #define	NEXT_I_IPL3_BASE	18
342 #define	NEXT_I_IPL3_BITS	12
343 #define	NEXT_I_DISK		NEXT_I(3,0,13)
344 #define	NEXT_I_C16_VIDEO	NEXT_I(3,0,13)	/* COLOR_FB - Steals old ESDI interrupt */
345 #define	NEXT_I_SCSI		NEXT_I(3,1,12)
346 #define	NEXT_I_PRINTER		NEXT_I(3,2,11)
347 #define	NEXT_I_ENETX		NEXT_I(3,3,10)
348 #define	NEXT_I_ENETR		NEXT_I(3,4,9)
349 #define	NEXT_I_SOUND_OVRUN	NEXT_I(3,5,8)
350 #define	NEXT_I_PHONE		NEXT_I(3,6,7)
351 #define	NEXT_I_DSP_3		NEXT_I(3,7,6)
352 #define	NEXT_I_VIDEO		NEXT_I(3,8,5)
353 #define	NEXT_I_MONITOR		NEXT_I(3,9,4)
354 #define	NEXT_I_KYBD_MOUSE	NEXT_I(3,10,3)
355 #define	NEXT_I_POWER		NEXT_I(3,11,2)
356 
357 #define	NEXT_I_IPL2_BASE	30
358 #define	NEXT_I_IPL2_BITS	1
359 #define	NEXT_I_SOFTINT1		NEXT_I(2,0,1)
360 
361 #define	NEXT_I_IPL1_BASE	31
362 #define	NEXT_I_IPL1_BITS	1
363 #define	NEXT_I_SOFTINT0		NEXT_I(1,0,0)
364 
365 /****************************************************************/
366 
367 /* physical memory sections */
368 #if 0
369 #define	ROMBASE		(0x00000000)
370 #endif
371 
372 #define	INTIOBASE	(0x02000000)
373 #define	INTIOTOP	(0x02120000)
374 #define MONOBASE        (0x0b000000)
375 #define MONOTOP         (0x0b03a800)
376 #define COLORBASE	(0x06000000)
377 #define COLORTOP	(0x061D4000)
378 
379 #define NEXT_INTR_BITS \
380 "\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"
381 
382 /*
383  * Internal IO space:
384  *
385  * Ranges from 0x400000 to 0x600000 (IIOMAPSIZE).
386  *
387  * Internal IO space is mapped in the kernel from ``intiobase'' to
388  * ``intiolimit'' (defined in locore.s).  Since it is always mapped,
389  * conversion between physical and kernel virtual addresses is easy.
390  */
391 #define	ISIIOVA(va) \
392 	((char *)(va) >= intiobase && (char *)(va) < intiolimit)
393 #define	IIOV(pa)	((int)(pa)-INTIOBASE+(int)intiobase)
394 #define	IIOP(va)	((int)(va)-(int)intiobase+INTIOBASE)
395 #define	IIOPOFF(pa)	((int)(pa)-INTIOBASE)
396 #define	IIOMAPSIZE	btoc(INTIOTOP-INTIOBASE)	/* 2mb */
397 
398 /* mono fb space */
399 #define	ISMONOVA(va) \
400 	((char *)(va) >= monobase && (char *)(va) < monolimit)
401 #define	MONOV(pa)	((int)(pa)-MONOBASE+(int)monobase)
402 #define	MONOP(va)	((int)(va)-(int)monobase+MONOBASE)
403 #define	MONOPOFF(pa)	((int)(pa)-MONOBASE)
404 #define	MONOMAPSIZE	btoc(MONOTOP-MONOBASE)	/* who cares */
405 
406 /* color fb space */
407 #define	ISCOLORVA(va) \
408 	((char *)(va) >= colorbase && (char *)(va) < colorlimit)
409 #define	COLORV(pa)	((int)(pa)-COLORBASE+(int)colorbase)
410 #define	COLORP(va)	((int)(va)-(int)colorbase+COLORBASE)
411 #define	COLORPOFF(pa)	((int)(pa)-COLORBASE)
412 #define	COLORMAPSIZE	btoc(COLORTOP-COLORBASE)	/* who cares */
413 
414 #endif	/* _CPU_MACHINE_ */
415