frame.h revision 1.27 1 1.27 thorpej /* $NetBSD: frame.h,v 1.27 2007/03/12 02:51:03 thorpej Exp $ */
2 1.8 cgd
3 1.1 cgd /*
4 1.6 mycroft * Copyright (c) 1982, 1990, 1993
5 1.6 mycroft * The Regents of the University of California. All rights reserved.
6 1.20 agc *
7 1.20 agc * This code is derived from software contributed to Berkeley by
8 1.20 agc * the Systems Programming Group of the University of Utah Computer
9 1.20 agc * Science Department.
10 1.20 agc *
11 1.20 agc * Redistribution and use in source and binary forms, with or without
12 1.20 agc * modification, are permitted provided that the following conditions
13 1.20 agc * are met:
14 1.20 agc * 1. Redistributions of source code must retain the above copyright
15 1.20 agc * notice, this list of conditions and the following disclaimer.
16 1.20 agc * 2. Redistributions in binary form must reproduce the above copyright
17 1.20 agc * notice, this list of conditions and the following disclaimer in the
18 1.20 agc * documentation and/or other materials provided with the distribution.
19 1.20 agc * 3. Neither the name of the University nor the names of its contributors
20 1.20 agc * may be used to endorse or promote products derived from this software
21 1.20 agc * without specific prior written permission.
22 1.20 agc *
23 1.20 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.20 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.20 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.20 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.20 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.20 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.20 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.20 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.20 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.20 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.20 agc * SUCH DAMAGE.
34 1.20 agc *
35 1.20 agc * from: Utah $Hdr: frame.h 1.8 92/12/20$
36 1.20 agc *
37 1.20 agc * @(#)frame.h 8.1 (Berkeley) 6/10/93
38 1.20 agc */
39 1.20 agc /*
40 1.20 agc * Copyright (c) 1988 University of Utah.
41 1.1 cgd *
42 1.1 cgd * This code is derived from software contributed to Berkeley by
43 1.1 cgd * the Systems Programming Group of the University of Utah Computer
44 1.1 cgd * Science Department.
45 1.1 cgd *
46 1.1 cgd * Redistribution and use in source and binary forms, with or without
47 1.1 cgd * modification, are permitted provided that the following conditions
48 1.1 cgd * are met:
49 1.1 cgd * 1. Redistributions of source code must retain the above copyright
50 1.1 cgd * notice, this list of conditions and the following disclaimer.
51 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
52 1.1 cgd * notice, this list of conditions and the following disclaimer in the
53 1.1 cgd * documentation and/or other materials provided with the distribution.
54 1.1 cgd * 3. All advertising materials mentioning features or use of this software
55 1.1 cgd * must display the following acknowledgement:
56 1.1 cgd * This product includes software developed by the University of
57 1.1 cgd * California, Berkeley and its contributors.
58 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
59 1.1 cgd * may be used to endorse or promote products derived from this software
60 1.1 cgd * without specific prior written permission.
61 1.1 cgd *
62 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 1.1 cgd * SUCH DAMAGE.
73 1.1 cgd *
74 1.6 mycroft * from: Utah $Hdr: frame.h 1.8 92/12/20$
75 1.6 mycroft *
76 1.8 cgd * @(#)frame.h 8.1 (Berkeley) 6/10/93
77 1.1 cgd */
78 1.9 chopps
79 1.13 gwr #ifndef _M68K_FRAME_H_
80 1.13 gwr #define _M68K_FRAME_H_
81 1.13 gwr
82 1.21 cl #include <m68k/cpuframe.h>
83 1.22 cl
84 1.22 cl /* common frame size */
85 1.22 cl #define CFSIZE (sizeof(struct frame) - sizeof(union F_u))
86 1.22 cl #define NFMTSIZE 9
87 1.22 cl
88 1.22 cl #define FMT0 0x0
89 1.22 cl #define FMT1 0x1
90 1.22 cl #define FMT2 0x2
91 1.22 cl #define FMT3 0x3
92 1.22 cl #define FMT4 0x4
93 1.22 cl #define FMT7 0x7
94 1.22 cl #define FMT8 0x8
95 1.22 cl #define FMT9 0x9
96 1.22 cl #define FMTA 0xA
97 1.22 cl #define FMTB 0xB
98 1.22 cl
99 1.22 cl /* frame specific info sizes */
100 1.22 cl #define FMT0SIZE 0
101 1.22 cl #define FMT1SIZE 0
102 1.22 cl #define FMT2SIZE sizeof(struct fmt2)
103 1.22 cl #define FMT3SIZE sizeof(struct fmt3)
104 1.22 cl #define FMT4SIZE sizeof(struct fmt4)
105 1.22 cl #define FMT7SIZE sizeof(struct fmt7)
106 1.22 cl #define FMT8SIZE sizeof(struct fmt8)
107 1.22 cl #define FMT9SIZE sizeof(struct fmt9)
108 1.22 cl #define FMTASIZE sizeof(struct fmtA)
109 1.22 cl #define FMTBSIZE sizeof(struct fmtB)
110 1.22 cl
111 1.22 cl #define V_BUSERR 0x008
112 1.22 cl #define V_ADDRERR 0x00C
113 1.22 cl #define V_TRAP1 0x084
114 1.22 cl
115 1.22 cl /* 68010 SSW bits */
116 1.22 cl #define SSW1_RR 0x8000
117 1.22 cl #define SSW1_IF 0x2000
118 1.22 cl #define SSW1_DF 0x1000
119 1.22 cl #define SSW1_RM 0x0800
120 1.22 cl #define SSW1_HI 0x0400
121 1.22 cl #define SSW1_BX 0x0200
122 1.22 cl #define SSW1_RW 0x0100
123 1.22 cl #define SSW1_FCMASK 0x000F
124 1.22 cl
125 1.22 cl /* 68020/68030 SSW bits */
126 1.22 cl #define SSW_RC 0x2000
127 1.22 cl #define SSW_RB 0x1000
128 1.22 cl #define SSW_DF 0x0100
129 1.22 cl #define SSW_RM 0x0080
130 1.22 cl #define SSW_RW 0x0040
131 1.22 cl #define SSW_FCMASK 0x0007
132 1.22 cl
133 1.22 cl /* 68040 SSW bits */
134 1.22 cl #define SSW4_CP 0x8000
135 1.22 cl #define SSW4_CU 0x4000
136 1.22 cl #define SSW4_CT 0x2000
137 1.22 cl #define SSW4_CM 0x1000
138 1.22 cl #define SSW4_MA 0x0800
139 1.22 cl #define SSW4_ATC 0x0400
140 1.22 cl #define SSW4_LK 0x0200
141 1.22 cl #define SSW4_RW 0x0100
142 1.22 cl #define SSW4_WBSV 0x0080 /* really in WB status, not SSW */
143 1.22 cl #define SSW4_SZMASK 0x0060
144 1.22 cl #define SSW4_SZLW 0x0000
145 1.22 cl #define SSW4_SZB 0x0020
146 1.22 cl #define SSW4_SZW 0x0040
147 1.22 cl #define SSW4_SZLN 0x0060
148 1.22 cl #define SSW4_TTMASK 0x0018
149 1.22 cl #define SSW4_TTNOR 0x0000
150 1.22 cl #define SSW4_TTM16 0x0008
151 1.22 cl #define SSW4_TMMASK 0x0007
152 1.22 cl #define SSW4_TMDCP 0x0000
153 1.22 cl #define SSW4_TMUD 0x0001
154 1.22 cl #define SSW4_TMUC 0x0002
155 1.22 cl #define SSW4_TMKD 0x0005
156 1.22 cl #define SSW4_TMKC 0x0006
157 1.22 cl
158 1.22 cl /* 060 Fault Status Long Word (FPSP) */
159 1.22 cl
160 1.22 cl #define FSLW_MA 0x08000000
161 1.22 cl #define FSLW_LK 0x02000000
162 1.22 cl #define FSLW_RW 0x01800000
163 1.22 cl
164 1.22 cl #define FSLW_RW_R 0x01000000
165 1.22 cl #define FSLW_RW_W 0x00800000
166 1.22 cl
167 1.22 cl #define FSLW_SIZE 0x00600000
168 1.22 cl /*
169 1.22 cl * We better define the FSLW_SIZE values here, as the table given in the
170 1.22 cl * MC68060UM/AD rev. 0/1 p. 8-23 is wrong, and was corrected in the errata
171 1.22 cl * document.
172 1.22 cl */
173 1.22 cl #define FSLW_SIZE_LONG 0x00000000
174 1.22 cl #define FSLW_SIZE_BYTE 0x00200000
175 1.22 cl #define FSLW_SIZE_WORD 0x00400000
176 1.22 cl #define FSLW_SIZE_MV16 0x00600000
177 1.22 cl
178 1.22 cl #define FLSW_TT 0x00180000
179 1.22 cl #define FSLW_TM 0x00070000
180 1.22 cl #define FSLW_TM_SV 0x00040000
181 1.22 cl
182 1.22 cl
183 1.22 cl
184 1.22 cl #define FSLW_IO 0x00008000
185 1.22 cl #define FSLW_PBE 0x00004000
186 1.22 cl #define FSLW_SBE 0x00002000
187 1.22 cl #define FSLW_PTA 0x00001000
188 1.22 cl #define FSLW_PTB 0x00000800
189 1.22 cl #define FSLW_IL 0x00000400
190 1.22 cl #define FSLW_PF 0x00000200
191 1.22 cl #define FSLW_SP 0x00000100
192 1.22 cl #define FSLW_WP 0x00000080
193 1.22 cl #define FSLW_TWE 0x00000040
194 1.22 cl #define FSLW_RE 0x00000020
195 1.22 cl #define FSLW_WE 0x00000010
196 1.22 cl #define FSLW_TTR 0x00000008
197 1.22 cl #define FSLW_BPE 0x00000004
198 1.22 cl #define FSLW_SEE 0x00000001
199 1.22 cl
200 1.22 cl /* struct fpframe060 */
201 1.22 cl #define FPF6_FMT_NULL 0x00
202 1.22 cl #define FPF6_FMT_IDLE 0x60
203 1.22 cl #define FPF6_FMT_EXCP 0xe0
204 1.22 cl
205 1.22 cl #define FPF6_V_BSUN 0
206 1.22 cl #define FPF6_V_INEX12 1
207 1.22 cl #define FPF6_V_DZ 2
208 1.22 cl #define FPF6_V_UNFL 3
209 1.22 cl #define FPF6_V_OPERR 4
210 1.22 cl #define FPF6_V_OVFL 5
211 1.22 cl #define FPF6_V_SNAN 6
212 1.22 cl #define FPF6_V_UNSUP 7
213 1.22 cl
214 1.25 drochner #if defined(_KERNEL)
215 1.25 drochner
216 1.21 cl #include <m68k/signal.h>
217 1.1 cgd
218 1.25 drochner #if defined(COMPAT_16)
219 1.11 is /*
220 1.21 cl * Stack frame layout when delivering a signal.
221 1.11 is */
222 1.21 cl struct sigframe_sigcontext {
223 1.21 cl int sf_ra; /* handler return address */
224 1.21 cl int sf_signum; /* signal number for handler */
225 1.21 cl int sf_code; /* additional info for handler */
226 1.21 cl struct sigcontext *sf_scp; /* context pointer for handler */
227 1.21 cl struct sigcontext sf_sc; /* actual context */
228 1.21 cl struct sigstate sf_state; /* state of the hardware */
229 1.1 cgd };
230 1.21 cl #endif
231 1.1 cgd
232 1.21 cl struct sigframe_siginfo {
233 1.21 cl int sf_ra; /* return address for handler */
234 1.21 cl int sf_signum; /* "signum" argument for handler */
235 1.21 cl siginfo_t *sf_sip; /* "sip" argument for handler */
236 1.21 cl ucontext_t *sf_ucp; /* "ucp" argument for handler */
237 1.21 cl siginfo_t sf_si; /* actual saved siginfo */
238 1.21 cl ucontext_t sf_uc; /* actual saved ucontext */
239 1.11 is };
240 1.16 kleink
241 1.16 kleink /*
242 1.16 kleink * Utility function to relocate the initial frame, make room to restore an
243 1.16 kleink * exception frame and reenter the syscall.
244 1.16 kleink */
245 1.24 thorpej void reenter_syscall(struct frame *, int) __attribute__((__noreturn__));
246 1.19 thorpej
247 1.19 thorpej /*
248 1.19 thorpej * Create an FPU "idle" frame for use by cpu_setmcontext()
249 1.19 thorpej */
250 1.19 thorpej extern void m68k_make_fpu_idle_frame(void);
251 1.19 thorpej extern struct fpframe m68k_cached_fpu_idle_frame;
252 1.21 cl
253 1.24 thorpej void *getframe(struct lwp *, int, int *);
254 1.24 thorpej void buildcontext(struct lwp *, void *, void *);
255 1.21 cl #ifdef COMPAT_16
256 1.24 thorpej void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *);
257 1.21 cl #endif
258 1.21 cl
259 1.27 thorpej #if defined(__mc68010__)
260 1.27 thorpej /*
261 1.27 thorpej * Restartable atomic sequence-cased compare-and-swap for locking
262 1.27 thorpej * primitives. We defined this here because it manipulates a
263 1.27 thorpej * "clockframe" as prepared by interrupt handlers.
264 1.27 thorpej */
265 1.27 thorpej extern char _lock_cas_ras_start;
266 1.27 thorpej extern char _lock_cas_ras_end;
267 1.27 thorpej
268 1.27 thorpej #define LOCK_CAS_CHECK(cfp) \
269 1.27 thorpej do { \
270 1.27 thorpej if ((cfp)->cf_pc < (u_long)&_lock_cas_ras_end && \
271 1.27 thorpej (cfp)->cf_pc > (u_long)&_lock_cas_ras_start) { \
272 1.27 thorpej (cfp)->cf_pc = (u_long)&_lock_cas_ras_start; \
273 1.27 thorpej } \
274 1.27 thorpej } while (/*CONSTCOND*/0)
275 1.27 thorpej #else
276 1.27 thorpej #define LOCK_CAS_CHECK(cfp) /* nothing */
277 1.27 thorpej #endif /* __mc68010__ */
278 1.27 thorpej
279 1.19 thorpej #endif /* _KERNEL */
280 1.13 gwr
281 1.13 gwr #endif /* _M68K_FRAME_H_ */
282