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