xref: /netbsd-src/sys/arch/atari/include/cpu.h (revision 481fca6e59249d8ffcf24fef7cfbe7b131bfb080)
1 /*	$NetBSD: cpu.h,v 1.33 2000/05/26 21:19:34 thorpej Exp $	*/
2 
3 /*
4  * Copyright (c) 1988 University of Utah.
5  * Copyright (c) 1982, 1990 The Regents of the University of California.
6  * 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	7.7 (Berkeley) 6/27/91
43  */
44 
45 #ifndef _MACHINE_CPU_H_
46 #define _MACHINE_CPU_H_
47 
48 /*
49  * Exported definitions unique to atari/68k cpu support.
50  */
51 
52 #if defined(_KERNEL) && !defined(_LKM)
53 #include "opt_lockdebug.h"
54 #endif
55 
56 /*
57  * Get common m68k CPU definitions.
58  */
59 #include <m68k/cpu.h>
60 #define	M68K_MMU_MOTOROLA
61 
62 #include <sys/sched.h>
63 struct cpu_info {
64 	struct schedstate_percpu ci_schedstate; /* scheduler state */
65 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
66 	u_long ci_spin_locks;		/* # of spin locks held */
67 	u_long ci_simple_locks;		/* # of simple locks held */
68 #endif
69 };
70 
71 #ifdef _KERNEL
72 extern struct cpu_info cpu_info_store;
73 
74 #define	curcpu()	(&cpu_info_store)
75 
76 /*
77  * definitions of cpu-dependent requirements
78  * referenced in generic code
79  */
80 #define	cpu_swapin(p)			/* nothing */
81 #define	cpu_wait(p)			/* nothing */
82 #define cpu_swapout(p)			/* nothing */
83 #define	cpu_number()			0
84 
85 /*
86  * Arguments to hardclock and gatherstats encapsulate the previous
87  * machine state in an opaque clockframe.  On the hp300, we use
88  * what the hardware pushes on an interrupt (frame format 0).
89  */
90 struct clockframe {
91 	u_int	cf_regs[4];	/* d0,d1,a0,a1 (see locore.s)	*/
92 	u_short	cf_sr;		/* sr at time of interrupt	*/
93 	u_long	cf_pc;		/* pc at time of interrupt	*/
94 	u_short	cf_vo;		/* vector offset (4-word frame)	*/
95 };
96 
97 #define	CLKF_USERMODE(framep)	(((framep)->cf_sr & PSL_S) == 0)
98 #define	CLKF_BASEPRI(framep)	(((framep)->cf_sr & PSL_IPL) == 0)
99 #define	CLKF_PC(framep)		((framep)->cf_pc)
100 #if 0
101 /* We would like to do it this way... */
102 #define	CLKF_INTR(framep)	(((framep)->cf_sr & PSL_M) == 0)
103 #else
104 /* but until we start using PSL_M, we have to do this instead */
105 #define	CLKF_INTR(framep)	(0)	/* XXX */
106 #endif
107 
108 
109 /*
110  * Preempt the current process if in interrupt from user mode,
111  * or after the current trap/syscall if in system mode.
112  */
113 #define	need_resched()	{want_resched = 1; setsoftast();}
114 
115 /*
116  * Give a profiling tick to the current process from the softclock
117  * interrupt.  On hp300, request an ast to send us through trap(),
118  * marking the proc as needing a profiling tick.
119  */
120 #define	profile_tick(p, framep)	((p)->p_flag |= P_OWEUPC, setsoftast())
121 #define	need_proftick(p)	((p)->p_flag |= P_OWEUPC, setsoftast())
122 
123 /*
124  * Notify the current process (p) that it has a signal pending,
125  * process as soon as possible.
126  */
127 #define	signotify(p)	setsoftast()
128 
129 #define setsoftast()	(astpending = 1)
130 
131 extern int	astpending;	/* need trap before returning to user mode */
132 extern int	want_resched;	/* resched() was called */
133 
134 #endif /* _KERNEL */
135 
136 /* include support for software interrupts */
137 #include <machine/mtpr.h>
138 
139 /*
140  * The rest of this should probably be moved to ../atari/ataricpu.h,
141  * although some of it could probably be put into generic 68k headers.
142  */
143 #define	BASEPRI(sr)	((sr & PSL_IPL) == 0)
144 
145 /*
146  * Values for machineid.
147  */
148 #define	ATARI_68000	1		/* 68000 CPU			*/
149 #define	ATARI_68010	(1<<1)		/* 68010 CPU			*/
150 #define ATARI_68020	(1L<<2)		/* 68020 CPU			*/
151 #define ATARI_68030	(1L<<3)		/* 68030 CPU			*/
152 #define ATARI_68040	(1L<<4)		/* 68040 CPU			*/
153 #define ATARI_68060	(1L<<6)		/* 68060 CPU			*/
154 #define	ATARI_TT	(1L<<11)
155 #define	ATARI_FALCON	(1L<<12)
156 #define	ATARI_HADES	(1L<<13)
157 
158 #define	ATARI_CLKBROKEN	(1L<<16)
159 
160 #define	ATARI_ANYCPU	(ATARI_68000|ATARI_68010|ATARI_68020|ATARI_68030 \
161 			|ATARI_68040|ATARI_68060)
162 
163 #define	ATARI_ANYMACH	(ATARI_TT|ATARI_FALCON|ATARI_HADES)
164 
165 #ifdef _KERNEL
166 extern int machineid;
167 #endif
168 
169 /*
170  * CTL_MACHDEP definitions.
171  */
172 #define CPU_CONSDEV	1	/* dev_t: console terminal device */
173 #define CPU_MAXID	2	/* number of valid machdep ids */
174 
175 #define CTL_MACHDEP_NAMES { \
176 	{ 0, 0 }, \
177 	{ "console_device", CTLTYPE_STRUCT }, \
178 }
179 
180 #ifdef _KERNEL
181 /*
182  * Prototypes from atari_init.c
183  */
184 int	cpu_dump __P((int (*)(dev_t, daddr_t, caddr_t, size_t), daddr_t *));
185 int	cpu_dumpsize __P((void));
186 
187 /*
188  * Prototypes from autoconf.c
189  */
190 void	config_console __P((void));
191 
192 /*
193  * Prototypes from clock.c
194  */
195 long	clkread __P((void));
196 
197 /*
198  * Prototypes from disksubr.c
199  */
200 struct buf;
201 struct disklabel;
202 int	bounds_check_with_label __P((struct buf *, struct disklabel *, int));
203 
204 /*
205  * Prototypes from fpu.c
206  */
207 char	*fpu_describe __P((int));
208 int	fpu_probe __P((void));
209 
210 /*
211  * Prototypes from vm_machdep.c
212  */
213 int	badbaddr __P((caddr_t, int));
214 void	consinit __P((void));
215 void	dumpconf __P((void));
216 paddr_t	kvtop __P((caddr_t));
217 void	physaccess __P((caddr_t, caddr_t, int, int));
218 void	physunaccess __P((caddr_t, int));
219 void	setredzone __P((u_int *, caddr_t));
220 
221 /*
222  * Prototypes from locore.s
223  */
224 struct fpframe;
225 struct user;
226 struct pcb;
227 
228 void	clearseg __P((paddr_t));
229 void	doboot __P((void));
230 void	loadustp __P((int));
231 void	m68881_save __P((struct fpframe *));
232 void	m68881_restore __P((struct fpframe *));
233 void	physcopyseg __P((paddr_t, paddr_t));
234 u_int	probeva __P((u_int, u_int));
235 void	proc_trampoline __P((void));
236 void	savectx __P((struct pcb *));
237 int	suline __P((caddr_t, caddr_t));
238 void	switch_exit __P((struct proc *));
239 void	DCIAS __P((vaddr_t));
240 void	DCIA __P((void));
241 void	DCIS __P((void));
242 void	DCIU __P((void));
243 void	ICIA __P((void));
244 void	ICPA __P((void));
245 void	PCIA __P((void));
246 void	TBIA __P((void));
247 void	TBIS __P((vaddr_t));
248 void	TBIAS __P((void));
249 void	TBIAU __P((void));
250 
251 #if defined(M68040) || defined(M68060)
252 void	DCFA __P((void));
253 void	DCFP __P((paddr_t));
254 void	DCFL __P((paddr_t));
255 void	DCPL __P((paddr_t));
256 void	DCPP __P((paddr_t));
257 void	ICPL __P((paddr_t));
258 void	ICPP __P((paddr_t));
259 #endif
260 
261 /*
262  * Prototypes from machdep.c:
263  */
264 typedef void (*si_farg)(void *, void *);	/* XXX */
265 void	add_sicallback __P((si_farg, void *, void *));
266 void	rem_sicallback __P((si_farg));
267 void	cpu_startup __P((void));
268 void	dumpsys __P((void));
269 vaddr_t reserve_dumppages __P((vaddr_t));
270 void	softint __P((void));
271 
272 
273 /*
274  * Prototypes from nvram.c:
275  */
276 struct uio;
277 int	nvram_uio __P((struct uio *));
278 
279 /*
280  * Prototypes from sys_machdep.c:
281  */
282 int	cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
283 int	dma_cachectl __P((caddr_t, int));
284 
285 /*
286  * Prototypes from pci_machdep.c
287  */
288 void init_pci_bus __P((void));
289 
290 /*
291  * Prototypes from trap.c:
292  */
293 void  child_return __P((void *));
294 
295 #endif /* _KERNEL */
296 #endif /* !_MACHINE_CPU_H_ */
297