Home | History | Annotate | Line # | Download | only in include
mcontext.h revision 1.9
      1  1.9      matt /*	$NetBSD: mcontext.h,v 1.9 2009/11/26 00:19:19 matt Exp $	*/
      2  1.2   thorpej 
      3  1.2   thorpej /*-
      4  1.2   thorpej  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
      5  1.2   thorpej  * All rights reserved.
      6  1.2   thorpej  *
      7  1.2   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2   thorpej  * by Klaus Klein, and by Jason R. Thorpe of Wasabi Systems, Inc.
      9  1.2   thorpej  *
     10  1.2   thorpej  * Redistribution and use in source and binary forms, with or without
     11  1.2   thorpej  * modification, are permitted provided that the following conditions
     12  1.2   thorpej  * are met:
     13  1.2   thorpej  * 1. Redistributions of source code must retain the above copyright
     14  1.2   thorpej  *    notice, this list of conditions and the following disclaimer.
     15  1.2   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.2   thorpej  *    notice, this list of conditions and the following disclaimer in the
     17  1.2   thorpej  *    documentation and/or other materials provided with the distribution.
     18  1.2   thorpej  *
     19  1.2   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.2   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.2   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.2   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.2   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.2   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.2   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.2   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.2   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.2   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.2   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     30  1.2   thorpej  */
     31  1.2   thorpej 
     32  1.2   thorpej #ifndef _MIPS_MCONTEXT_H_
     33  1.2   thorpej #define _MIPS_MCONTEXT_H_
     34  1.2   thorpej 
     35  1.2   thorpej /*
     36  1.2   thorpej  * General register state
     37  1.2   thorpej  */
     38  1.2   thorpej #define _NGREG		37	/* R0-R31, MDLO, MDHI, CAUSE, PC, SR */
     39  1.2   thorpej 
     40  1.2   thorpej #define _REG_R0		0
     41  1.2   thorpej #define _REG_AT		1
     42  1.2   thorpej #define _REG_V0		2
     43  1.2   thorpej #define _REG_V1		3
     44  1.2   thorpej #define _REG_A0		4
     45  1.2   thorpej #define _REG_A1		5
     46  1.2   thorpej #define _REG_A2		6
     47  1.2   thorpej #define _REG_A3		7
     48  1.2   thorpej #define _REG_T0		8
     49  1.2   thorpej #define _REG_T1		9
     50  1.2   thorpej #define _REG_T2		10
     51  1.2   thorpej #define _REG_T3		11
     52  1.2   thorpej #define _REG_T4		12
     53  1.2   thorpej #define _REG_T5		13
     54  1.2   thorpej #define _REG_T6		14
     55  1.2   thorpej #define _REG_T7		15
     56  1.2   thorpej #define _REG_S0		16
     57  1.2   thorpej #define _REG_S1		17
     58  1.2   thorpej #define _REG_S2		18
     59  1.2   thorpej #define _REG_S3		19
     60  1.2   thorpej #define _REG_S4		20
     61  1.2   thorpej #define _REG_S5		21
     62  1.2   thorpej #define _REG_S6		22
     63  1.2   thorpej #define _REG_S7		23
     64  1.2   thorpej #define _REG_T8		24
     65  1.2   thorpej #define _REG_T9		25
     66  1.2   thorpej #define _REG_K0		26
     67  1.2   thorpej #define _REG_K1		27
     68  1.2   thorpej #define _REG_GP		28
     69  1.2   thorpej #define _REG_SP		29
     70  1.2   thorpej #define _REG_S8		30
     71  1.2   thorpej #define _REG_RA		31
     72  1.2   thorpej 
     73  1.2   thorpej /* XXX: The following conflict with <mips/regnum.h> */
     74  1.2   thorpej #define _REG_MDLO	32
     75  1.2   thorpej #define _REG_MDHI	33
     76  1.2   thorpej #define _REG_CAUSE	34
     77  1.2   thorpej #define _REG_EPC	35
     78  1.2   thorpej #define _REG_SR		36
     79  1.2   thorpej 
     80  1.2   thorpej #ifndef __ASSEMBLER__
     81  1.2   thorpej 
     82  1.2   thorpej /* Make sure this is signed; we need pointers to be sign-extended. */
     83  1.2   thorpej #if defined(__mips_n32)
     84  1.9      matt typedef	long long	__greg_t;
     85  1.2   thorpej #else
     86  1.9      matt typedef	long		__greg_t;
     87  1.2   thorpej #endif /* __mips_n32 */
     88  1.2   thorpej 
     89  1.2   thorpej typedef	__greg_t	__gregset_t[_NGREG];
     90  1.2   thorpej 
     91  1.2   thorpej /*
     92  1.9      matt  * For the O32/O64 ABI, there are 16 doubles, one at each even FP reg
     93  1.6    simonb  * number.  The FP registers themselves are 32-bits.
     94  1.6    simonb  *
     95  1.6    simonb  * For 64-bit ABIs (include N32), each FP register is a 64-bit double.
     96  1.6    simonb  */
     97  1.6    simonb typedef	__greg_t	__freg_t;
     98  1.6    simonb 
     99  1.6    simonb /*
    100  1.2   thorpej  * Floating point register state
    101  1.2   thorpej  */
    102  1.9      matt struct __fpregset_nabi {
    103  1.6    simonb 	union {
    104  1.6    simonb 		double	__fp64_dregs[32];
    105  1.6    simonb 		__freg_t __fp_regs[32];
    106  1.6    simonb 	} __fp_r;
    107  1.6    simonb 	unsigned int	__fp_csr;
    108  1.6    simonb 	unsigned int	__fp_pad;
    109  1.9      matt };
    110  1.9      matt struct __fpregset_oabi {
    111  1.2   thorpej 	union {
    112  1.6    simonb 		double	__fp_dregs[16];
    113  1.6    simonb 		float	__fp_fregs[32];
    114  1.9      matt 		int32_t __fp_regs[32];
    115  1.2   thorpej 	} __fp_r;
    116  1.2   thorpej 	unsigned int	__fp_csr;
    117  1.2   thorpej 	unsigned int	__fp_pad;
    118  1.9      matt };
    119  1.9      matt 
    120  1.9      matt #if __mips_n32 || __mips_n64
    121  1.9      matt typedef struct __fpregset_nabi __fpregset_t;
    122  1.9      matt #else
    123  1.9      matt typedef struct __fpregset_oabi __fpregset_t;
    124  1.9      matt #else
    125  1.2   thorpej 
    126  1.2   thorpej typedef struct {
    127  1.2   thorpej 	__gregset_t	__gregs;
    128  1.2   thorpej 	__fpregset_t	__fpregs;
    129  1.2   thorpej } mcontext_t;
    130  1.2   thorpej 
    131  1.9      matt #ifdef COMPAT_NETBSD32
    132  1.9      matt typedef	int32_t		__greg32_t;
    133  1.9      matt typedef __greg32_t	__gregset32_t[_NGREG];
    134  1.9      matt 
    135  1.9      matt typedef struct {
    136  1.9      matt 	__gregset32_t		__gregs;
    137  1.9      matt 	__fpregset_oabi_t	__fpregs;
    138  1.9      matt } mcontext32_t;
    139  1.9      matt 
    140  1.9      matt #endif
    141  1.9      matt 
    142  1.2   thorpej #endif /* !__ASSEMBLER__ */
    143  1.2   thorpej 
    144  1.2   thorpej #define _UC_MACHINE_PAD	16	/* Padding appended to ucontext_t */
    145  1.2   thorpej 
    146  1.5  christos #define	_UC_SETSTACK	0x00010000
    147  1.5  christos #define	_UC_CLRSTACK	0x00020000
    148  1.2   thorpej 
    149  1.2   thorpej #define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.__gregs[_REG_SP])
    150  1.4   thorpej #define _UC_MACHINE_PC(uc)	((uc)->uc_mcontext.__gregs[_REG_EPC])
    151  1.4   thorpej #define _UC_MACHINE_INTRV(uc)	((uc)->uc_mcontext.__gregs[_REG_V0])
    152  1.4   thorpej 
    153  1.4   thorpej #define	_UC_MACHINE_SET_PC(uc, pc)	_UC_MACHINE_PC(uc) = (pc)
    154  1.2   thorpej 
    155  1.2   thorpej #endif	/* _MIPS_MCONTEXT_H_ */
    156