xref: /netbsd-src/sys/arch/news68k/include/cpu.h (revision ba65fde2d7fefa7d39838fa5fa855e62bd606b5e)
1 /*	$NetBSD: cpu.h,v 1.41 2012/02/02 16:59:43 tsutsui 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.  One the hp300, 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)	\
108 	do { ci->ci_want_resched = 1; aston(); } while (/* CONSTCOND */0)
109 
110 /*
111  * Give a profiling tick to the current process when the user profiling
112  * buffer pages are invalid.  On the hp300, request an ast to send us
113  * through trap, marking the proc as needing a profiling tick.
114  */
115 #define cpu_need_proftick(l)	\
116 	do { (l)->l_pflag |= LP_OWEUPC; aston(); } while (/* CONSTCOND */0)
117 
118 /*
119  * Notify the current process (p) that it has a signal pending,
120  * process as soon as possible.
121  */
122 #define cpu_signotify(l)	aston()
123 
124 extern int astpending;		/* need to trap before returning to user mode */
125 extern volatile u_char *ctrl_ast;
126 #define aston()		\
127 	do { astpending++; *ctrl_ast = 0xff; } while (/* CONSTCOND */0)
128 
129 #endif /* _KERNEL */
130 
131 /*
132  * CTL_MACHDEP definitions.
133  */
134 #define CPU_CONSDEV		1	/* dev_t: console terminal device */
135 #define CPU_MAXID		2	/* number of valid machdep ids */
136 
137 #ifdef _KERNEL
138 
139 #if defined(news1700) || defined(news1200)
140 #ifndef M68030
141 #define M68030
142 #endif
143 #define M68K_MMU_MOTOROLA
144 #endif
145 
146 #if defined(news1700)
147 #define CACHE_HAVE_PAC
148 #endif
149 
150 #endif
151 
152 #ifdef _KERNEL
153 extern int systype;
154 #define NEWS1700	0
155 #define NEWS1200	1
156 
157 extern int cpuspeed;
158 extern char *intiobase, *intiolimit, *extiobase;
159 extern u_int intiobase_phys, intiotop_phys;
160 extern u_int extiobase_phys, extiotop_phys;
161 extern u_int intrcnt[];
162 
163 extern void (*vectab[])(void);
164 extern void *romcallvec;
165 
166 struct frame;
167 
168 /* locore.s functions */
169 int suline(void *, void *);
170 void loadustp(int);
171 void badtrap(void);
172 void intrhand_vectored(void);
173 int getsr(void);
174 
175 
176 void doboot(int)
177 	__attribute__((__noreturn__));
178 void nmihand(struct frame *);
179 void ecacheon(void);
180 void ecacheoff(void);
181 
182 /* machdep.c functions */
183 int badaddr(void *, int);
184 int badbaddr(void *);
185 
186 #endif
187 
188 /* physical memory sections */
189 #define ROMBASE		0xe0000000
190 
191 #define INTIOBASE1700	0xe0c00000
192 #define INTIOTOP1700	0xe1d00000 /* XXX */
193 #define EXTIOBASE1700	0xf0f00000
194 #define EXTIOTOP1700	0xf1000000 /* XXX */
195 #define CTRL_POWER1700	0xe1380000
196 #define CTRL_LED1700	0xe0dc0000
197 
198 #define INTIOBASE1200	0xe1000000
199 #define INTIOTOP1200	0xe1d00000 /* XXX */
200 #define EXTIOBASE1200	0xe4000000
201 #define EXTIOTOP1200	0xe4020000 /* XXX */
202 #define CTRL_POWER1200	0xe1000000
203 #define CTRL_LED1200	0xe1500001
204 
205 #define MAXADDR		0xfffff000
206 
207 /*
208  * Internal IO space:
209  *
210  * Internal IO space is mapped in the kernel from ``intiobase'' to
211  * ``intiolimit'' (defined in locore.s).  Since it is always mapped,
212  * conversion between physical and kernel virtual addresses is easy.
213  */
214 #define ISIIOVA(va) \
215 	((char *)(va) >= intiobase && (char *)(va) < intiolimit)
216 #define IIOV(pa)	(((u_int)(pa) - intiobase_phys) + (u_int)intiobase)
217 #define ISIIOPA(pa) \
218 	((u_int)(pa) >= intiobase_phys && (u_int)(pa) < intiotop_phys)
219 #define IIOP(va)	(((u_int)(va) - (u_int)intiobase) + intiobase_phys)
220 #define IIOPOFF(pa)	((u_int)(pa) - intiobase_phys)
221 
222 /* XXX EIO space mapping should be modified like hp300 XXX */
223 #define	EIOSIZE		(extiotop_phys - extiobase_phys)
224 #define ISEIOVA(va) \
225 	((char *)(va) >= extiobase && (char *)(va) < (char *)EIOSIZE)
226 #define EIOV(pa)	(((u_int)(pa) - extiobase_phys) + (u_int)extiobase)
227 
228 #if defined(CACHE_HAVE_PAC) || defined(CACHE_HAVE_VAC)
229 #define M68K_CACHEOPS_MACHDEP
230 #endif
231 
232 #ifdef CACHE_HAVE_PAC
233 #define M68K_CACHEOPS_MACHDEP_PCIA
234 #endif
235 
236 #ifdef CACHE_HAVE_VAC
237 #define M68K_CACHEOPS_MACHDEP_DCIA
238 #define M68K_CACHEOPS_MACHDEP_DCIS
239 #define M68K_CACHEOPS_MACHDEP_DCIU
240 #endif
241 
242 #endif /* !_NEWS68K_CPU_H_ */
243