frame.h revision 1.20 1 /* $NetBSD: frame.h,v 1.20 2003/08/07 16:28:13 agc Exp $ */
2
3 /*
4 * Copyright (c) 1982, 1990, 1993
5 * The Regents of the University of California. 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: frame.h 1.8 92/12/20$
36 *
37 * @(#)frame.h 8.1 (Berkeley) 6/10/93
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: frame.h 1.8 92/12/20$
75 *
76 * @(#)frame.h 8.1 (Berkeley) 6/10/93
77 */
78
79 #ifndef _M68K_FRAME_H_
80 #define _M68K_FRAME_H_
81
82 struct frame {
83 struct trapframe {
84 int tf_regs[16];
85 short tf_pad;
86 short tf_stackadj;
87 u_short tf_sr;
88 u_int tf_pc;
89 u_short tf_format:4,
90 tf_vector:12;
91 } __attribute__((packed)) F_t;
92 union F_u {
93 struct fmt2 {
94 u_int f_iaddr;
95 } F_fmt2;
96
97 struct fmt3 {
98 u_int f_ea;
99 } F_fmt3;
100
101 struct fmt4 {
102 u_int f_fa;
103 u_int f_fslw;
104 /* for 060FP type 4 FP disabled frames: */
105 #define f_fea f_fa
106 #define f_pcfi f_fslw
107 } F_fmt4;
108
109 struct fmt7 {
110 u_int f_ea;
111 u_short f_ssw;
112 u_short f_wb3s, f_wb2s, f_wb1s;
113 u_int f_fa;
114 u_int f_wb3a, f_wb3d;
115 u_int f_wb2a, f_wb2d;
116 u_int f_wb1a, f_wb1d;
117 #define f_pd0 f_wb1d
118 u_int f_pd1, f_pd2, f_pd3;
119 } F_fmt7;
120
121 struct fmt8 {
122 u_short f_ssw;
123 u_int f_accaddr;
124 u_short f_ir0;
125 u_short f_dob;
126 u_short f_ir1;
127 u_short f_dib;
128 u_short f_ir2;
129 u_short f_irc;
130 u_short f_maskpc;
131 u_short f_iregs[15];
132 } __attribute__((packed)) F_fmt8;
133
134 struct fmt9 {
135 u_int f_iaddr;
136 u_short f_iregs[4];
137 } F_fmt9;
138
139 struct fmtA {
140 u_short f_ir0;
141 u_short f_ssw;
142 u_short f_ipsc;
143 u_short f_ipsb;
144 u_int f_dcfa;
145 u_short f_ir1, f_ir2;
146 u_int f_dob;
147 u_short f_ir3, f_ir4;
148 } F_fmtA;
149
150 struct fmtB {
151 u_short f_ir0;
152 u_short f_ssw;
153 u_short f_ipsc;
154 u_short f_ipsb;
155 u_int f_dcfa;
156 u_short f_ir1, f_ir2;
157 u_int f_dob;
158 u_short f_ir3, f_ir4;
159 u_short f_ir5, f_ir6;
160 u_int f_sba;
161 u_short f_ir7, f_ir8;
162 u_int f_dib;
163 u_short f_iregs[22];
164 } F_fmtB;
165 } F_u;
166 };
167
168 #define f_regs F_t.tf_regs
169 #define f_pad F_t.tf_pad
170 #define f_stackadj F_t.tf_stackadj
171 #define f_sr F_t.tf_sr
172 #define f_pc F_t.tf_pc
173 #define f_format F_t.tf_format
174 #define f_vector F_t.tf_vector
175 #define f_fmt2 F_u.F_fmt2
176 #define f_fmt3 F_u.F_fmt3
177 #define f_fmt4 F_u.F_fmt4
178 #define f_fmt7 F_u.F_fmt7
179 #define f_fmt8 F_u.F_fmt8
180 #define f_fmt9 F_u.F_fmt9
181 #define f_fmtA F_u.F_fmtA
182 #define f_fmtB F_u.F_fmtB
183
184 struct switchframe {
185 u_int sf_pc;
186 };
187
188 /* common frame size */
189 #define CFSIZE (sizeof(struct frame) - sizeof(union F_u))
190 #define NFMTSIZE 9
191
192 #define FMT0 0x0
193 #define FMT1 0x1
194 #define FMT2 0x2
195 #define FMT3 0x3
196 #define FMT4 0x4
197 #define FMT7 0x7
198 #define FMT8 0x8
199 #define FMT9 0x9
200 #define FMTA 0xA
201 #define FMTB 0xB
202
203 /* frame specific info sizes */
204 #define FMT0SIZE 0
205 #define FMT1SIZE 0
206 #define FMT2SIZE sizeof(struct fmt2)
207 #define FMT3SIZE sizeof(struct fmt3)
208 #define FMT4SIZE sizeof(struct fmt4)
209 #define FMT7SIZE sizeof(struct fmt7)
210 #define FMT8SIZE sizeof(struct fmt8)
211 #define FMT9SIZE sizeof(struct fmt9)
212 #define FMTASIZE sizeof(struct fmtA)
213 #define FMTBSIZE sizeof(struct fmtB)
214
215 #define V_BUSERR 0x008
216 #define V_ADDRERR 0x00C
217 #define V_TRAP1 0x084
218
219 /* 68010 SSW bits */
220 #define SSW1_RR 0x8000
221 #define SSW1_IF 0x2000
222 #define SSW1_DF 0x1000
223 #define SSW1_RM 0x0800
224 #define SSW1_HI 0x0400
225 #define SSW1_BX 0x0200
226 #define SSW1_RW 0x0100
227 #define SSW1_FCMASK 0x000F
228
229 /* 68020/68030 SSW bits */
230 #define SSW_RC 0x2000
231 #define SSW_RB 0x1000
232 #define SSW_DF 0x0100
233 #define SSW_RM 0x0080
234 #define SSW_RW 0x0040
235 #define SSW_FCMASK 0x0007
236
237 /* 68040 SSW bits */
238 #define SSW4_CP 0x8000
239 #define SSW4_CU 0x4000
240 #define SSW4_CT 0x2000
241 #define SSW4_CM 0x1000
242 #define SSW4_MA 0x0800
243 #define SSW4_ATC 0x0400
244 #define SSW4_LK 0x0200
245 #define SSW4_RW 0x0100
246 #define SSW4_WBSV 0x0080 /* really in WB status, not SSW */
247 #define SSW4_SZMASK 0x0060
248 #define SSW4_SZLW 0x0000
249 #define SSW4_SZB 0x0020
250 #define SSW4_SZW 0x0040
251 #define SSW4_SZLN 0x0060
252 #define SSW4_TTMASK 0x0018
253 #define SSW4_TTNOR 0x0000
254 #define SSW4_TTM16 0x0008
255 #define SSW4_TMMASK 0x0007
256 #define SSW4_TMDCP 0x0000
257 #define SSW4_TMUD 0x0001
258 #define SSW4_TMUC 0x0002
259 #define SSW4_TMKD 0x0005
260 #define SSW4_TMKC 0x0006
261
262 /* 060 Fault Status Long Word (FPSP) */
263
264 #define FSLW_MA 0x08000000
265 #define FSLW_LK 0x02000000
266 #define FSLW_RW 0x01800000
267
268 #define FSLW_RW_R 0x01000000
269 #define FSLW_RW_W 0x00800000
270
271 #define FSLW_SIZE 0x00600000
272 /*
273 * We better define the FSLW_SIZE values here, as the table given in the
274 * MC68060UM/AD rev. 0/1 p. 8-23 is wrong, and was corrected in the errata
275 * document.
276 */
277 #define FSLW_SIZE_LONG 0x00000000
278 #define FSLW_SIZE_BYTE 0x00200000
279 #define FSLW_SIZE_WORD 0x00400000
280 #define FSLW_SIZE_MV16 0x00600000
281
282 #define FLSW_TT 0x00180000
283 #define FSLW_TM 0x00070000
284 #define FSLW_TM_SV 0x00040000
285
286
287
288 #define FSLW_IO 0x00008000
289 #define FSLW_PBE 0x00004000
290 #define FSLW_SBE 0x00002000
291 #define FSLW_PTA 0x00001000
292 #define FSLW_PTB 0x00000800
293 #define FSLW_IL 0x00000400
294 #define FSLW_PF 0x00000200
295 #define FSLW_SP 0x00000100
296 #define FSLW_WP 0x00000080
297 #define FSLW_TWE 0x00000040
298 #define FSLW_RE 0x00000020
299 #define FSLW_WE 0x00000010
300 #define FSLW_TTR 0x00000008
301 #define FSLW_BPE 0x00000004
302 #define FSLW_SEE 0x00000001
303
304 struct fpframe {
305 union FPF_u1 {
306 u_int FPF_null;
307 struct {
308 u_char FPF_version;
309 u_char FPF_fsize;
310 u_short FPF_res1;
311 } FPF_nonnull;
312 } FPF_u1;
313 union FPF_u2 {
314 struct fpidle {
315 u_short fpf_ccr;
316 u_short fpf_res2;
317 u_int fpf_iregs1[8];
318 u_int fpf_xops[3];
319 u_int fpf_opreg;
320 u_int fpf_biu;
321 } FPF_idle;
322
323 struct fpbusy {
324 u_int fpf_iregs[53];
325 } FPF_busy;
326
327 struct fpunimp {
328 u_int fpf_state[10];
329 } FPF_unimp;
330 } FPF_u2;
331 u_int fpf_regs[8*3];
332 u_int fpf_fpcr;
333 u_int fpf_fpsr;
334 u_int fpf_fpiar;
335 };
336
337 #define fpf_null FPF_u1.FPF_null
338 #define fpf_version FPF_u1.FPF_nonnull.FPF_version
339 #define fpf_fsize FPF_u1.FPF_nonnull.FPF_fsize
340 #define fpf_res1 FPF_u1.FPF_nonnull.FPF_res1
341 #define fpf_idle FPF_u2.FPF_idle
342 #define fpf_busy FPF_u2.FPF_busy
343 #define fpf_unimp FPF_u2.FPF_unimp
344
345 /*
346 * This is incompatible with the earlier one; expecially, an earlier frame
347 * must not be FRESTOREd on a 060 or vv, because a frame error exception is
348 * not guaranteed.
349 */
350
351
352 struct fpframe060 {
353 u_short fpf6_excp_exp;
354 u_char fpf6_frmfmt;
355 #define FPF6_FMT_NULL 0x00
356 #define FPF6_FMT_IDLE 0x60
357 #define FPF6_FMT_EXCP 0xe0
358
359 u_char fpf6_v;
360 #define FPF6_V_BSUN 0
361 #define FPF6_V_INEX12 1
362 #define FPF6_V_DZ 2
363 #define FPF6_V_UNFL 3
364 #define FPF6_V_OPERR 4
365 #define FPF6_V_OVFL 5
366 #define FPF6_V_SNAN 6
367 #define FPF6_V_UNSUP 7
368
369 u_long fpf6_upper, fpf6_lower;
370 };
371
372 #if defined(_KERNEL)
373 /*
374 * Utility function to relocate the initial frame, make room to restore an
375 * exception frame and reenter the syscall.
376 */
377 void reenter_syscall __P((struct frame *, int)) __attribute__((__noreturn__));
378
379 /*
380 * Create an FPU "idle" frame for use by cpu_setmcontext()
381 */
382 extern void m68k_make_fpu_idle_frame(void);
383 extern struct fpframe m68k_cached_fpu_idle_frame;
384 #endif /* _KERNEL */
385
386 #endif /* _M68K_FRAME_H_ */
387