xref: /netbsd-src/sys/arch/news68k/include/cpu.h (revision d710132b4b8ce7f7cccaaf660cb16aa16b4077a0)
1 /*	$NetBSD: cpu.h,v 1.15 2003/01/21 21:59:49 jdolecek 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 #ifndef _NEWS68K_CPU_H_
46 #define _NEWS68K_CPU_H_
47 
48 /*
49  * Exported definitions unique to news68k cpu support.
50  */
51 
52 #if defined(_KERNEL_OPT)
53 #include "opt_lockdebug.h"
54 #endif
55 
56 /*
57  * Get common m68k CPU definitions.
58  */
59 #include <m68k/cpu.h>
60 
61 /*
62  * XXX news1700 L2 cache would be corrupted with DC_BE and IC_BE...
63  * XXX Should these be defined in machine/cpu.h?
64  */
65 #undef CACHE_ON
66 #undef CACHE_CLR
67 #undef IC_CLEAR
68 #undef DC_CLEAR
69 #define CACHE_ON	(DC_WA|DC_CLR|DC_ENABLE|IC_CLR|IC_ENABLE)
70 #define CACHE_CLR	CACHE_ON
71 #define IC_CLEAR	(DC_WA|DC_ENABLE|IC_CLR|IC_ENABLE)
72 #define DC_CLEAR	(DC_WA|DC_CLR|DC_ENABLE|IC_ENABLE)
73 
74 #define DCIC_CLR	(DC_CLR|IC_CLR)
75 #define CACHE_BE	(DC_BE|IC_BE)
76 
77 /*
78  * Get interrupt glue.
79  */
80 #include <machine/intr.h>
81 
82 #include <sys/sched.h>
83 struct cpu_info {
84 	struct schedstate_percpu ci_schedstate; /* scheduler state */
85 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
86 	u_long ci_spin_locks;		/* # of spin locks held */
87 	u_long ci_simple_locks;		/* # of simple locks held */
88 #endif
89 };
90 
91 #ifdef _KERNEL
92 extern struct cpu_info cpu_info_store;
93 
94 #define	curcpu()			(&cpu_info_store)
95 
96 /*
97  * definitions of cpu-dependent requirements
98  * referenced in generic code
99  */
100 #define cpu_swapin(p)			/* nothing */
101 #define cpu_wait(p)			/* nothing */
102 #define cpu_swapout(p)			/* nothing */
103 #define cpu_number()			0
104 
105 void	cpu_proc_fork(struct proc *, struct proc *);
106 
107 /*
108  * Arguments to hardclock and gatherstats encapsulate the previous
109  * machine state in an opaque clockframe.  One the hp300, we use
110  * what the hardware pushes on an interrupt (frame format 0).
111  */
112 struct clockframe {
113 	u_short	sr;		/* sr at time of interrupt */
114 	u_long	pc;		/* pc at time of interrupt */
115 	u_short	vo;		/* vector offset (4-word frame) */
116 };
117 
118 #define CLKF_USERMODE(framep)	(((framep)->sr & PSL_S) == 0)
119 #define CLKF_BASEPRI(framep)	(((framep)->sr & PSL_IPL) == 0)
120 #define CLKF_PC(framep)		((framep)->pc)
121 #if 0
122 /* We would like to do it this way... */
123 #define CLKF_INTR(framep)	(((framep)->sr & PSL_M) == 0)
124 #else
125 /* but until we start using PSL_M, we have to do this instead */
126 #define CLKF_INTR(framep)	(0)	/* XXX */
127 #endif
128 
129 
130 /*
131  * Preempt the current process if in interrupt from user mode,
132  * or after the current trap/syscall if in system mode.
133  */
134 extern int want_resched;	/* resched() was called */
135 #define need_resched(ci)	do { want_resched++; aston(); } while(0)
136 
137 /*
138  * Give a profiling tick to the current process when the user profiling
139  * buffer pages are invalid.  On the hp300, request an ast to send us
140  * through trap, marking the proc as needing a profiling tick.
141  */
142 #define need_proftick(p)	do { (p)->p_flag |= P_OWEUPC; aston(); } while(0)
143 
144 /*
145  * Notify the current process (p) that it has a signal pending,
146  * process as soon as possible.
147  */
148 #define signotify(p)	aston()
149 
150 extern int astpending;		/* need to trap before returning to user mode */
151 extern volatile u_char *ctrl_ast;
152 #define aston()		do { astpending++; *ctrl_ast = 0xff; } while(0)
153 
154 #endif /* _KERNEL */
155 
156 /*
157  * CTL_MACHDEP definitions.
158  */
159 #define CPU_CONSDEV		1	/* dev_t: console terminal device */
160 #define CPU_MAXID		2	/* number of valid machdep ids */
161 
162 #define CTL_MACHDEP_NAMES { \
163 	{ 0, 0 }, \
164 	{ "console_device", CTLTYPE_STRUCT }, \
165 }
166 
167 #ifdef _KERNEL
168 
169 #if defined(news1700) || defined(news1200)
170 #ifndef M68030
171 #define M68030
172 #endif
173 #define M68K_MMU_MOTOROLA
174 #endif
175 
176 #if defined(news1700)
177 #define CACHE_HAVE_PAC
178 #endif
179 
180 #endif
181 
182 #ifdef _KERNEL
183 extern int systype;
184 #define NEWS1700	0
185 #define NEWS1200	1
186 
187 extern int cpuspeed;
188 extern char *intiobase, *intiolimit, *extiobase;
189 extern u_int intiobase_phys, intiotop_phys;
190 extern u_int extiobase_phys, extiotop_phys;
191 extern u_int intrcnt[];
192 
193 extern void (*vectab[])(void);
194 
195 struct frame;
196 struct fpframe;
197 struct pcb;
198 
199 /* locore.s functions */
200 void m68881_save(struct fpframe *);
201 void m68881_restore(struct fpframe *);
202 
203 int suline(caddr_t, caddr_t);
204 void savectx(struct pcb *);
205 void switch_exit(struct lwp *);
206 void switch_lwp_exit(struct lwp *);
207 void proc_trampoline(void);
208 void loadustp(int);
209 void badtrap(void);
210 void intrhand_vectored(void);
211 int getsr(void);
212 
213 
214 void doboot(int)
215 	__attribute__((__noreturn__));
216 void nmihand(struct frame *);
217 void ecacheon(void);
218 void ecacheoff(void);
219 
220 /* machdep.c functions */
221 int badaddr(caddr_t, int);
222 int badbaddr(caddr_t);
223 
224 /* sys_machdep.c functions */
225 int cachectl1(unsigned long, vaddr_t, size_t, struct proc *);
226 
227 /* vm_machdep.c functions */
228 void physaccess(caddr_t, caddr_t, int, int);
229 void physunaccess(caddr_t, int);
230 int kvtop(caddr_t);
231 
232 #endif
233 
234 /* physical memory sections */
235 #define ROMBASE		(0xe0000000)
236 
237 #define INTIOBASE1700	(0xe0c00000)
238 #define INTIOTOP1700	(0xe1d00000) /* XXX */
239 #define EXTIOBASE1700	(0xf0f00000)
240 #define EXTIOTOP1700	(0xf1000000) /* XXX */
241 
242 #define INTIOBASE1200	(0xe1000000)
243 #define INTIOTOP1200	(0xe1d00000) /* XXX */
244 #define EXTIOBASE1200	(0xe4000000)
245 #define EXTIOTOP1200	(0xe4020000) /* XXX */
246 
247 #define MAXADDR		(0xfffff000)
248 
249 /*
250  * Internal IO space:
251  *
252  * Internal IO space is mapped in the kernel from ``intiobase'' to
253  * ``intiolimit'' (defined in locore.s).  Since it is always mapped,
254  * conversion between physical and kernel virtual addresses is easy.
255  */
256 #define ISIIOVA(va) \
257 	((char *)(va) >= intiobase && (char *)(va) < intiolimit)
258 #define IIOV(pa)	(((u_int)(pa) - intiobase_phys) + (u_int)intiobase)
259 #define ISIIOPA(pa) \
260 	((u_int)(pa) >= intiobase_phys && (u_int)(pa) < intiotop_phys)
261 #define IIOP(va)	(((u_int)(va) - (u_int)intiobase) + intiobase_phys)
262 #define IIOPOFF(pa)	((u_int)(pa) - intiobase_phys)
263 
264 /* XXX EIO space mapping should be modified like hp300 XXX */
265 #define	EIOSIZE		(extiotop_phys - extiobase_phys)
266 #define ISEIOVA(va) \
267 	((char *)(va) >= extiobase && (char *)(va) < (char *)EIOSIZE)
268 #define EIOV(pa)	(((u_int)(pa) - extiobase_phys) + (u_int)extiobase)
269 
270 #if defined(CACHE_HAVE_PAC) || defined(CACHE_HAVE_VAC)
271 #define M68K_CACHEOPS_MACHDEP
272 #endif
273 
274 #ifdef CACHE_HAVE_PAC
275 #define M68K_CACHEOPS_MACHDEP_PCIA
276 #endif
277 
278 #ifdef CACHE_HAVE_VAC
279 #define M68K_CACHEOPS_MACHDEP_DCIA
280 #define M68K_CACHEOPS_MACHDEP_DCIS
281 #define M68K_CACHEOPS_MACHDEP_DCIU
282 #endif
283 
284 #endif /* !_NEWS68K_CPU_H_ */
285