Home | History | Annotate | Line # | Download | only in include
frame.h revision 1.27
      1 /*	$NetBSD: frame.h,v 1.27 2007/03/12 02:51:03 thorpej 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 #include <m68k/cpuframe.h>
     83 
     84 /* common frame size */
     85 #define	CFSIZE		(sizeof(struct frame) - sizeof(union F_u))
     86 #define	NFMTSIZE	9
     87 
     88 #define	FMT0		0x0
     89 #define	FMT1		0x1
     90 #define	FMT2		0x2
     91 #define	FMT3		0x3
     92 #define	FMT4		0x4
     93 #define	FMT7		0x7
     94 #define	FMT8		0x8
     95 #define	FMT9		0x9
     96 #define	FMTA		0xA
     97 #define	FMTB		0xB
     98 
     99 /* frame specific info sizes */
    100 #define	FMT0SIZE	0
    101 #define	FMT1SIZE	0
    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)
    110 
    111 #define	V_BUSERR	0x008
    112 #define	V_ADDRERR	0x00C
    113 #define	V_TRAP1		0x084
    114 
    115 /* 68010 SSW bits */
    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
    124 
    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
    132 
    133 /* 68040 SSW bits */
    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
    157 
    158 /* 060 Fault Status Long Word (FPSP) */
    159 
    160 #define FSLW_MA		0x08000000
    161 #define FSLW_LK		0x02000000
    162 #define FSLW_RW		0x01800000
    163 
    164 #define FSLW_RW_R	0x01000000
    165 #define FSLW_RW_W	0x00800000
    166 
    167 #define FSLW_SIZE	0x00600000
    168 /*
    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
    171  * document.
    172  */
    173 #define FSLW_SIZE_LONG	0x00000000
    174 #define FSLW_SIZE_BYTE	0x00200000
    175 #define FSLW_SIZE_WORD	0x00400000
    176 #define FSLW_SIZE_MV16	0x00600000
    177 
    178 #define FLSW_TT		0x00180000
    179 #define FSLW_TM		0x00070000
    180 #define FSLW_TM_SV	0x00040000
    181 
    182 
    183 
    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
    199 
    200 /* struct fpframe060 */
    201 #define FPF6_FMT_NULL	0x00
    202 #define FPF6_FMT_IDLE	0x60
    203 #define FPF6_FMT_EXCP	0xe0
    204 
    205 #define	FPF6_V_BSUN	0
    206 #define	FPF6_V_INEX12	1
    207 #define	FPF6_V_DZ	2
    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
    213 
    214 #if defined(_KERNEL)
    215 
    216 #include <m68k/signal.h>
    217 
    218 #if defined(COMPAT_16)
    219 /*
    220  * Stack frame layout when delivering a signal.
    221  */
    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 */
    229 };
    230 #endif
    231 
    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 */
    239 };
    240 
    241 /*
    242  * Utility function to relocate the initial frame, make room to restore an
    243  * exception frame and reenter the syscall.
    244  */
    245 void	reenter_syscall(struct frame *, int) __attribute__((__noreturn__));
    246 
    247 /*
    248  * Create an FPU "idle" frame for use by cpu_setmcontext()
    249  */
    250 extern void m68k_make_fpu_idle_frame(void);
    251 extern struct fpframe m68k_cached_fpu_idle_frame;
    252 
    253 void	*getframe(struct lwp *, int, int *);
    254 void	buildcontext(struct lwp *, void *, void *);
    255 #ifdef COMPAT_16
    256 void	sendsig_sigcontext(const ksiginfo_t *, const sigset_t *);
    257 #endif
    258 
    259 #if defined(__mc68010__)
    260 /*
    261  * Restartable atomic sequence-cased compare-and-swap for locking
    262  * primitives.  We defined this here because it manipulates a
    263  * "clockframe" as prepared by interrupt handlers.
    264  */
    265 extern char	_lock_cas_ras_start;
    266 extern char	_lock_cas_ras_end;
    267 
    268 #define LOCK_CAS_CHECK(cfp)						\
    269 do {									\
    270 	if ((cfp)->cf_pc < (u_long)&_lock_cas_ras_end &&		\
    271 	    (cfp)->cf_pc > (u_long)&_lock_cas_ras_start) {		\
    272 	    	(cfp)->cf_pc = (u_long)&_lock_cas_ras_start;		\
    273 	}								\
    274 } while (/*CONSTCOND*/0)
    275 #else
    276 #define	LOCK_CAS_CHECK(cfp)	/* nothing */
    277 #endif /* __mc68010__ */
    278 
    279 #endif	/* _KERNEL */
    280 
    281 #endif	/* _M68K_FRAME_H_ */
    282