Home | History | Annotate | Line # | Download | only in include
mcontext.h revision 1.13
      1  1.13      matt /*	$NetBSD: mcontext.h,v 1.13 2011/02/23 07:47:09 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.11      matt typedef	long long	__greg_t;
     85   1.2   thorpej #else
     86  1.11      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.11      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.11      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.11      matt 	__greg_t	__fp_csr;
    108  1.11      matt };
    109  1.11      matt struct __fpregset_oabi {
    110   1.2   thorpej 	union {
    111   1.6    simonb 		double	__fp_dregs[16];
    112   1.6    simonb 		float	__fp_fregs[32];
    113  1.11      matt 		__int32_t __fp_regs[32];
    114   1.2   thorpej 	} __fp_r;
    115   1.2   thorpej 	unsigned int	__fp_csr;
    116   1.2   thorpej 	unsigned int	__fp_pad;
    117  1.11      matt };
    118  1.11      matt 
    119  1.11      matt #if __mips_n32 || __mips_n64
    120  1.11      matt typedef struct __fpregset_nabi __fpregset_t;
    121  1.11      matt #else
    122  1.11      matt typedef struct __fpregset_oabi __fpregset_t;
    123  1.11      matt #endif
    124   1.2   thorpej 
    125   1.2   thorpej typedef struct {
    126   1.2   thorpej 	__gregset_t	__gregs;
    127   1.2   thorpej 	__fpregset_t	__fpregs;
    128   1.2   thorpej } mcontext_t;
    129   1.2   thorpej 
    130  1.12      matt #if defined(_KERNEL) && !defined(__mips_o32)
    131  1.11      matt typedef	__int32_t	__greg32_t;
    132  1.11      matt typedef __greg32_t	__gregset32_t[_NGREG];
    133  1.11      matt 
    134  1.11      matt typedef struct {
    135  1.11      matt 	__gregset32_t		__gregs;
    136  1.11      matt 	struct __fpregset_oabi	__fpregs;
    137  1.11      matt } mcontext_o32_t;
    138  1.11      matt 
    139  1.11      matt typedef struct {
    140  1.11      matt 	__gregset_t		__gregs;
    141  1.11      matt 	struct __fpregset_nabi	__fpregs;
    142  1.11      matt } mcontext32_t;
    143  1.11      matt 
    144  1.11      matt #endif /* _KERNEL && _LP64 */
    145  1.11      matt 
    146  1.10      matt #endif /* !__ASSEMBLER__ */
    147   1.9      matt 
    148  1.10      matt #define _UC_MACHINE_PAD	16	/* Padding appended to ucontext_t */
    149   1.9      matt 
    150   1.5  christos #define	_UC_SETSTACK	0x00010000
    151   1.5  christos #define	_UC_CLRSTACK	0x00020000
    152   1.2   thorpej 
    153   1.2   thorpej #define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.__gregs[_REG_SP])
    154   1.4   thorpej #define _UC_MACHINE_PC(uc)	((uc)->uc_mcontext.__gregs[_REG_EPC])
    155   1.4   thorpej #define _UC_MACHINE_INTRV(uc)	((uc)->uc_mcontext.__gregs[_REG_V0])
    156   1.4   thorpej 
    157   1.4   thorpej #define	_UC_MACHINE_SET_PC(uc, pc)	_UC_MACHINE_PC(uc) = (pc)
    158   1.2   thorpej 
    159  1.11      matt #define _UC_MACHINE32_SP(uc)	_UC_MACHINE_SP(uc)
    160  1.11      matt #define _UC_MACHINE32_PC(uc)	_UC_MACHINE_PC(uc)
    161  1.11      matt #define _UC_MACHINE32_INTRV(uc)	_UC_MACHINE_INTRV(uc)
    162  1.11      matt 
    163  1.11      matt #define	_UC_MACHINE32_SET_PC(uc, pc)	_UC_MACHINE_PC((uc), (pc))
    164  1.11      matt 
    165  1.13      matt #define	__UCONTEXT_SIZE_O32	(40 + 288 +  64)	/* 392 */
    166  1.13      matt #define	__UCONTEXT_SIZE_N32	(40 + 560 +  64)	/* 664 */
    167  1.13      matt #define	__UCONTEXT_SIZE_N64	(56 + 560 + 128)	/* 774 */
    168  1.13      matt 
    169  1.13      matt #ifdef __mips_o32
    170  1.13      matt #define	__UCONTEXT_SIZE		__UCONTEXT_SIZE_O32
    171  1.13      matt #elif __mips_n32
    172  1.13      matt #define	__UCONTEXT_SIZE		__UCONTEXT_SIZE_N32
    173  1.13      matt #elif __mips_n64
    174  1.13      matt #define	__UCONTEXT_SIZE		__UCONTEXT_SIZE_N64
    175  1.13      matt #define	__UCONTEXT32_SIZE	__UCONTEXT_SIZE_N32
    176  1.13      matt #elif
    177  1.13      matt #error O64 is not supported
    178  1.13      matt #endif
    179  1.13      matt 
    180   1.2   thorpej #endif	/* _MIPS_MCONTEXT_H_ */
    181