xref: /netbsd-src/sys/arch/news68k/include/cpu.h (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /*	$NetBSD: cpu.h,v 1.43 2016/12/17 14:36:30 flxd 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 _NEWS68K_CPU_H_
42 #define _NEWS68K_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 CPU definitions.
51  */
52 #include <m68k/cpu.h>
53 
54 #if defined(_KERNEL)
55 /*
56  * Exported definitions unique to news68k cpu support.
57  */
58 
59 /*
60  * XXX news1700 L2 cache would be corrupted with DC_BE and IC_BE...
61  * XXX Should these be defined in machine/cpu.h?
62  */
63 #undef CACHE_ON
64 #undef CACHE_CLR
65 #undef IC_CLEAR
66 #undef DC_CLEAR
67 #define CACHE_ON	(DC_WA|DC_CLR|DC_ENABLE|IC_CLR|IC_ENABLE)
68 #define CACHE_CLR	CACHE_ON
69 #define IC_CLEAR	(DC_WA|DC_ENABLE|IC_CLR|IC_ENABLE)
70 #define DC_CLEAR	(DC_WA|DC_CLR|DC_ENABLE|IC_ENABLE)
71 
72 #define DCIC_CLR	(DC_CLR|IC_CLR)
73 #define CACHE_BE	(DC_BE|IC_BE)
74 
75 /*
76  * Get interrupt glue.
77  */
78 #include <machine/intr.h>
79 
80 /*
81  * Arguments to hardclock and gatherstats encapsulate the previous
82  * machine state in an opaque clockframe.  On the news68k, we use
83  * what the hardware pushes on an interrupt (frame format 0).
84  */
85 struct clockframe {
86 	u_short	sr;		/* sr at time of interrupt */
87 	u_long	pc;		/* pc at time of interrupt */
88 	u_short	vo;		/* vector offset (4-word frame) */
89 };
90 
91 #define CLKF_USERMODE(framep)	(((framep)->sr & PSL_S) == 0)
92 #define CLKF_PC(framep)		((framep)->pc)
93 #if 0
94 /* We would like to do it this way... */
95 #define CLKF_INTR(framep)	(((framep)->sr & PSL_M) == 0)
96 #else
97 /* but until we start using PSL_M, we have to do this instead */
98 #include <machine/intr.h>
99 #define CLKF_INTR(framep)	(idepth > 1)	/* XXX */
100 #endif
101 
102 
103 /*
104  * Preempt the current process if in interrupt from user mode,
105  * or after the current trap/syscall if in system mode.
106  */
107 #define	cpu_need_resched(ci,flags)	do {	\
108 	__USE(flags); 				\
109 	ci->ci_want_resched = 1;		\
110 	aston();				\
111 } while (/*CONSTCOND*/0)
112 
113 /*
114  * Give a profiling tick to the current process when the user profiling
115  * buffer pages are invalid.  On the news68k, request an ast to send us
116  * through trap, marking the proc as needing a profiling tick.
117  */
118 #define cpu_need_proftick(l)	\
119 	do { (l)->l_pflag |= LP_OWEUPC; aston(); } while (/* CONSTCOND */0)
120 
121 /*
122  * Notify the current process (p) that it has a signal pending,
123  * process as soon as possible.
124  */
125 #define cpu_signotify(l)	aston()
126 
127 extern int astpending;		/* need to trap before returning to user mode */
128 extern volatile u_char *ctrl_ast;
129 #define aston()		\
130 	do { astpending++; *ctrl_ast = 0xff; } while (/* CONSTCOND */0)
131 
132 #endif /* _KERNEL */
133 
134 /*
135  * CTL_MACHDEP definitions.
136  */
137 #define CPU_CONSDEV		1	/* dev_t: console terminal device */
138 #define CPU_MAXID		2	/* number of valid machdep ids */
139 
140 #ifdef _KERNEL
141 
142 #if defined(news1700) || defined(news1200)
143 #ifndef M68030
144 #define M68030
145 #endif
146 #define M68K_MMU_MOTOROLA
147 #endif
148 
149 #if defined(news1700)
150 #define CACHE_HAVE_PAC
151 #endif
152 
153 #endif
154 
155 #ifdef _KERNEL
156 extern int systype;
157 #define NEWS1700	0
158 #define NEWS1200	1
159 
160 extern int cpuspeed;
161 extern char *intiobase, *intiolimit, *extiobase;
162 extern u_int intiobase_phys, intiotop_phys;
163 extern u_int extiobase_phys, extiotop_phys;
164 extern u_int intrcnt[];
165 
166 extern void (*vectab[])(void);
167 extern void *romcallvec;
168 
169 struct frame;
170 
171 /* locore.s functions */
172 int suline(void *, void *);
173 void loadustp(int);
174 void badtrap(void);
175 void intrhand_vectored(void);
176 int getsr(void);
177 
178 
179 void doboot(int)
180 	__attribute__((__noreturn__));
181 void nmihand(struct frame *);
182 void ecacheon(void);
183 void ecacheoff(void);
184 
185 /* machdep.c functions */
186 int badaddr(void *, int);
187 int badbaddr(void *);
188 
189 #endif
190 
191 /* physical memory sections */
192 #define ROMBASE		0xe0000000
193 
194 #define INTIOBASE1700	0xe0c00000
195 #define INTIOTOP1700	0xe1d00000 /* XXX */
196 #define EXTIOBASE1700	0xf0f00000
197 #define EXTIOTOP1700	0xf1000000 /* XXX */
198 #define CTRL_POWER1700	0xe1380000
199 #define CTRL_LED1700	0xe0dc0000
200 
201 #define INTIOBASE1200	0xe1000000
202 #define INTIOTOP1200	0xe1d00000 /* XXX */
203 #define EXTIOBASE1200	0xe4000000
204 #define EXTIOTOP1200	0xe4020000 /* XXX */
205 #define CTRL_POWER1200	0xe1000000
206 #define CTRL_LED1200	0xe1500001
207 
208 #define MAXADDR		0xfffff000
209 
210 /*
211  * Internal IO space:
212  *
213  * Internal IO space is mapped in the kernel from ``intiobase'' to
214  * ``intiolimit'' (defined in locore.s).  Since it is always mapped,
215  * conversion between physical and kernel virtual addresses is easy.
216  */
217 #define ISIIOVA(va) \
218 	((char *)(va) >= intiobase && (char *)(va) < intiolimit)
219 #define IIOV(pa)	(((u_int)(pa) - intiobase_phys) + (u_int)intiobase)
220 #define ISIIOPA(pa) \
221 	((u_int)(pa) >= intiobase_phys && (u_int)(pa) < intiotop_phys)
222 #define IIOP(va)	(((u_int)(va) - (u_int)intiobase) + intiobase_phys)
223 #define IIOPOFF(pa)	((u_int)(pa) - intiobase_phys)
224 
225 /* XXX EIO space mapping should be modified like hp300 XXX */
226 #define	EIOSIZE		(extiotop_phys - extiobase_phys)
227 #define ISEIOVA(va) \
228 	((char *)(va) >= extiobase && (char *)(va) < (char *)EIOSIZE)
229 #define EIOV(pa)	(((u_int)(pa) - extiobase_phys) + (u_int)extiobase)
230 
231 #if defined(CACHE_HAVE_PAC) || defined(CACHE_HAVE_VAC)
232 #define M68K_CACHEOPS_MACHDEP
233 #endif
234 
235 #ifdef CACHE_HAVE_PAC
236 #define M68K_CACHEOPS_MACHDEP_PCIA
237 #endif
238 
239 #ifdef CACHE_HAVE_VAC
240 #define M68K_CACHEOPS_MACHDEP_DCIA
241 #define M68K_CACHEOPS_MACHDEP_DCIS
242 #define M68K_CACHEOPS_MACHDEP_DCIU
243 #endif
244 
245 #endif /* !_NEWS68K_CPU_H_ */
246