1 /* $NetBSD: frame.h,v 1.28 2007/03/13 17:17:28 thorpej Exp $ */
4 * Copyright (c) 1982, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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
35 * from: Utah $Hdr: frame.h 1.8 92/12/20$
37 * @(#)frame.h 8.1 (Berkeley) 6/10/93
40 * Copyright (c) 1988 University of Utah.
42 * This code is derived from software contributed to Berkeley by
43 * the Systems Programming Group of the University of Utah Computer
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
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.
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
74 * from: Utah $Hdr: frame.h 1.8 92/12/20$
76 * @(#)frame.h 8.1 (Berkeley) 6/10/93
79 #ifndef _M68K_FRAME_H_
80 #define _M68K_FRAME_H_
82 #include <m68k/cpuframe.h>
84 /* common frame size */
85 #define CFSIZE (sizeof(struct frame) - sizeof(union F_u))
99 /* frame specific info sizes */
102 #define FMT2SIZE sizeof(struct fmt2)
103 #define FMT3SIZE sizeof(struct fmt3)
104 #define FMT4SIZE sizeof(struct fmt4)
105 #define FMT7SIZE sizeof(struct fmt7)
106 #define FMT8SIZE sizeof(struct fmt8)
107 #define FMT9SIZE sizeof(struct fmt9)
108 #define FMTASIZE sizeof(struct fmtA)
109 #define FMTBSIZE sizeof(struct fmtB)
111 #define V_BUSERR 0x008
112 #define V_ADDRERR 0x00C
113 #define V_TRAP1 0x084
116 #define SSW1_RR 0x8000
117 #define SSW1_IF 0x2000
118 #define SSW1_DF 0x1000
119 #define SSW1_RM 0x0800
120 #define SSW1_HI 0x0400
121 #define SSW1_BX 0x0200
122 #define SSW1_RW 0x0100
123 #define SSW1_FCMASK 0x000F
125 /* 68020/68030 SSW bits */
126 #define SSW_RC 0x2000
127 #define SSW_RB 0x1000
128 #define SSW_DF 0x0100
129 #define SSW_RM 0x0080
130 #define SSW_RW 0x0040
131 #define SSW_FCMASK 0x0007
134 #define SSW4_CP 0x8000
135 #define SSW4_CU 0x4000
136 #define SSW4_CT 0x2000
137 #define SSW4_CM 0x1000
138 #define SSW4_MA 0x0800
139 #define SSW4_ATC 0x0400
140 #define SSW4_LK 0x0200
141 #define SSW4_RW 0x0100
142 #define SSW4_WBSV 0x0080 /* really in WB status, not SSW */
143 #define SSW4_SZMASK 0x0060
144 #define SSW4_SZLW 0x0000
145 #define SSW4_SZB 0x0020
146 #define SSW4_SZW 0x0040
147 #define SSW4_SZLN 0x0060
148 #define SSW4_TTMASK 0x0018
149 #define SSW4_TTNOR 0x0000
150 #define SSW4_TTM16 0x0008
151 #define SSW4_TMMASK 0x0007
152 #define SSW4_TMDCP 0x0000
153 #define SSW4_TMUD 0x0001
154 #define SSW4_TMUC 0x0002
155 #define SSW4_TMKD 0x0005
156 #define SSW4_TMKC 0x0006
158 /* 060 Fault Status Long Word (FPSP) */
160 #define FSLW_MA 0x08000000
161 #define FSLW_LK 0x02000000
162 #define FSLW_RW 0x01800000
164 #define FSLW_RW_R 0x01000000
165 #define FSLW_RW_W 0x00800000
167 #define FSLW_SIZE 0x00600000
169 * We better define the FSLW_SIZE values here, as the table given in the
170 * MC68060UM/AD rev. 0/1 p. 8-23 is wrong, and was corrected in the errata
173 #define FSLW_SIZE_LONG 0x00000000
174 #define FSLW_SIZE_BYTE 0x00200000
175 #define FSLW_SIZE_WORD 0x00400000
176 #define FSLW_SIZE_MV16 0x00600000
178 #define FLSW_TT 0x00180000
179 #define FSLW_TM 0x00070000
180 #define FSLW_TM_SV 0x00040000
184 #define FSLW_IO 0x00008000
185 #define FSLW_PBE 0x00004000
186 #define FSLW_SBE 0x00002000
187 #define FSLW_PTA 0x00001000
188 #define FSLW_PTB 0x00000800
189 #define FSLW_IL 0x00000400
190 #define FSLW_PF 0x00000200
191 #define FSLW_SP 0x00000100
192 #define FSLW_WP 0x00000080
193 #define FSLW_TWE 0x00000040
194 #define FSLW_RE 0x00000020
195 #define FSLW_WE 0x00000010
196 #define FSLW_TTR 0x00000008
197 #define FSLW_BPE 0x00000004
198 #define FSLW_SEE 0x00000001
200 /* struct fpframe060 */
201 #define FPF6_FMT_NULL 0x00
202 #define FPF6_FMT_IDLE 0x60
203 #define FPF6_FMT_EXCP 0xe0
205 #define FPF6_V_BSUN 0
206 #define FPF6_V_INEX12 1
208 #define FPF6_V_UNFL 3
209 #define FPF6_V_OPERR 4
210 #define FPF6_V_OVFL 5
211 #define FPF6_V_SNAN 6
212 #define FPF6_V_UNSUP 7
216 #include <m68k/signal.h>
218 #if defined(COMPAT_16)
220 * Stack frame layout when delivering a signal.
222 struct sigframe_sigcontext
{
223 int sf_ra
; /* handler return address */
224 int sf_signum
; /* signal number for handler */
225 int sf_code
; /* additional info for handler */
226 struct sigcontext
*sf_scp
; /* context pointer for handler */
227 struct sigcontext sf_sc
; /* actual context */
228 struct sigstate sf_state
; /* state of the hardware */
232 struct sigframe_siginfo
{
233 int sf_ra
; /* return address for handler */
234 int sf_signum
; /* "signum" argument for handler */
235 siginfo_t
*sf_sip
; /* "sip" argument for handler */
236 ucontext_t
*sf_ucp
; /* "ucp" argument for handler */
237 siginfo_t sf_si
; /* actual saved siginfo */
238 ucontext_t sf_uc
; /* actual saved ucontext */
242 * Utility function to relocate the initial frame, make room to restore an
243 * exception frame and reenter the syscall.
245 void reenter_syscall(struct frame
*, int) __attribute__((__noreturn__
));
248 * Create an FPU "idle" frame for use by cpu_setmcontext()
250 extern void m68k_make_fpu_idle_frame(void);
251 extern struct fpframe m68k_cached_fpu_idle_frame
;
253 void *getframe(struct lwp
*, int, int *);
254 void buildcontext(struct lwp
*, void *, void *);
256 void sendsig_sigcontext(const ksiginfo_t
*, const sigset_t
*);
259 #if defined(__mc68010__)
261 * Restartable atomic sequence-cased compare-and-swap for atomic_cas ops
262 * and locking primitives. We defined this here because it manipulates a
263 * "clockframe" as prepared by interrupt handlers.
265 extern char _atomic_cas_ras_start
;
266 extern char _atomic_cas_ras_end
;
268 #define ATOMIC_CAS_CHECK(cfp) \
270 if (! CLKF_USERMODE(cfp) && \
271 (CLKF_PC(cfp) < (u_long)&_atomic_cas_ras_end && \
272 CLKF_PC(cfp) > (u_long)&_atomic_cas_ras_start)) { \
273 (cfp)->cf_pc = (u_long)&_atomic_cas_ras_start; \
275 } while (/*CONSTCOND*/0)
277 #define ATOMIC_CAS_CHECK(cfp) /* nothing */
278 #endif /* __mc68010__ */
282 #endif /* _M68K_FRAME_H_ */