xref: /netbsd/sys/arch/amiga/include/cpu.h (revision 6550d01e)
1 /*	$NetBSD: cpu.h,v 1.77 2011/01/13 22:02:05 phx Exp $	*/
2 
3 /*
4  * Copyright (c) 1982, 1990 The Regents of the University of California.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * the Systems Programming Group of the University of Utah Computer
9  * Science Department.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
36  *
37  *	@(#)cpu.h	7.7 (Berkeley) 6/27/91
38  */
39 /*
40  * Copyright (c) 1988 University of Utah.
41  *
42  * This code is derived from software contributed to Berkeley by
43  * the Systems Programming Group of the University of Utah Computer
44  * Science Department.
45  *
46  * Redistribution and use in source and binary forms, with or without
47  * modification, are permitted provided that the following conditions
48  * are met:
49  * 1. Redistributions of source code must retain the above copyright
50  *    notice, this list of conditions and the following disclaimer.
51  * 2. Redistributions in binary form must reproduce the above copyright
52  *    notice, this list of conditions and the following disclaimer in the
53  *    documentation and/or other materials provided with the distribution.
54  * 3. All advertising materials mentioning features or use of this software
55  *    must display the following acknowledgement:
56  *	This product includes software developed by the University of
57  *	California, Berkeley and its contributors.
58  * 4. Neither the name of the University nor the names of its contributors
59  *    may be used to endorse or promote products derived from this software
60  *    without specific prior written permission.
61  *
62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72  * SUCH DAMAGE.
73  *
74  * from: Utah $Hdr: cpu.h 1.16 91/03/25$
75  *
76  *	@(#)cpu.h	7.7 (Berkeley) 6/27/91
77  */
78 #ifndef _MACHINE_CPU_H_
79 #define _MACHINE_CPU_H_
80 
81 #if defined(_KERNEL_OPT)
82 #include "opt_lockdebug.h"
83 #endif
84 
85 /*
86  * Get common m68k CPU definitions.
87  */
88 #include <m68k/cpu.h>
89 
90 #if defined(_KERNEL)
91 /*
92  * Exported definitions unique to amiga/68k cpu support.
93  */
94 #define	M68K_MMU_MOTOROLA
95 
96 extern volatile unsigned int interrupt_depth;
97 /*
98  * Arguments to hardclock and gatherstats encapsulate the previous
99  * machine state in an opaque clockframe.  One the hp300, we use
100  * what the hardware pushes on an interrupt (frame format 0).
101  */
102 struct clockframe {
103 	u_short	sr;		/* sr at time of interrupt */
104 	u_long	pc;		/* pc at time of interrupt */
105 	u_short	vo;		/* vector offset (4-word frame) */
106 };
107 
108 #define	CLKF_USERMODE(framep)	(((framep)->sr & PSL_S) == 0)
109 #define	CLKF_PC(framep)		((framep)->pc)
110 #define	CLKF_INTR(framep)	(interrupt_depth > 1)
111 
112 
113 /*
114  * Preempt the current process if in interrupt from user mode,
115  * or after the current trap/syscall if in system mode.
116  */
117 #define	cpu_need_resched(ci,flags)	{ci->ci_want_resched = 1; setsoftast();}
118 
119 /*
120  * Give a profiling tick to the current process from the softclock
121  * interrupt.  On hp300, request an ast to send us through trap(),
122  * marking the proc as needing a profiling tick.
123  */
124 #define	profile_tick(l, framep)	((l)->l_pflag |= LP_OWEUPC, setsoftast())
125 #define	cpu_need_proftick(l)	((l)->l_pflag |= LP_OWEUPC, setsoftast())
126 
127 /*
128  * Notify the current process (p) that it has a signal pending,
129  * process as soon as possible.
130  */
131 #define	cpu_signotify(l)	setsoftast()
132 
133 extern int astpending;		/* need trap before returning to user mode */
134 #define setsoftast()		(astpending = 1)
135 
136 /*
137  * The rest of this should probably be moved to ../amiga/amigacpu.h,
138  * although some of it could probably be put into generic 68k headers.
139  */
140 
141 /* values for machineid (happen to be AFF_* settings of AttnFlags) */
142 #define AMIGA_68020	(1L<<1)
143 #define AMIGA_68030	(1L<<2)
144 #define AMIGA_68040	(1L<<3)
145 #define AMIGA_68881	(1L<<4)
146 #define AMIGA_68882	(1L<<5)
147 #define	AMIGA_FPU40	(1L<<6)
148 #define AMIGA_68060	(1L<<7)
149 
150 extern int machineid;
151 
152 #endif /* _KERNEL */
153 
154 /*
155  * CTL_MACHDEP definitions.
156  */
157 #define CPU_CONSDEV	1	/* dev_t: console terminal device */
158 #define CPU_MAXID	2	/* number of valid machdep ids */
159 
160 #ifdef _KERNEL
161 /*
162  * Prototypes from amiga_init.c
163  */
164 void	*alloc_z2mem(long);
165 
166 /*
167  * Prototypes from autoconf.c
168  */
169 int	is_a600(void);
170 int	is_a1200(void);
171 int	is_a3000(void);
172 int	is_a4000(void);
173 #ifdef DRACO
174 #define	is_draco() ((machineid >> 24) == 0x7d ? (machineid >> 16) & 0xff : 0)
175 #endif
176 
177 #ifdef DRACO
178 /*
179  * Prototypes from kbd.c
180  */
181 void	drkbdintr(void);
182 
183 /*
184  * Prototypes from drsc.c
185  */
186 void	drsc_handler(void);
187 #endif
188 
189 /*
190  * Prototypes from locore.s
191  */
192 struct fpframe;
193 
194 void	clearseg(vm_offset_t);
195 void	doboot(void) __attribute__((__noreturn__));
196 void	loadustp(int);
197 #ifdef FPCOPROC
198 void	m68881_save(struct fpframe *);
199 void	m68881_restore(struct fpframe *);
200 #endif
201 void	physcopyseg(vm_offset_t, vm_offset_t);
202 u_int	probeva(u_int, u_int);
203 
204 /*
205  * Prototypes from machdep.c
206  */
207 int	badaddr(void *);
208 int	badbaddr(void *);
209 void	bootsync(void);
210 
211 /*
212  * Prototypes from pmap.c:
213  */
214 void	pmap_bootstrap(vm_offset_t, vm_offset_t);
215 
216 #endif /* _KERNEL */
217 
218 /*
219  * Reorder protection when accessing device registers.
220  */
221 #define amiga_membarrier()
222 
223 /*
224  * Finish all bus operations and flush pipelines.
225  */
226 #define amiga_cpu_sync() __asm volatile ("nop")
227 
228 #endif /* !_MACHINE_CPU_H_ */
229