Home | History | Annotate | Line # | Download | only in include
mcontext.h revision 1.10
      1   1.9      matt /*	$NetBSD: mcontext.h,v 1.10 2009/11/26 01:21:50 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.10      matt typedef	long long       __greg_t;
     85   1.2   thorpej #else
     86  1.10      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.10      matt  * For the O32 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.10      matt #if defined(__mips_n32) || defined(_LP64)
    103  1.10      matt typedef struct {
    104   1.6    simonb 	union {
    105   1.6    simonb 		double	__fp64_dregs[32];
    106   1.6    simonb 		__freg_t __fp_regs[32];
    107   1.6    simonb 	} __fp_r;
    108   1.6    simonb 	unsigned int	__fp_csr;
    109   1.6    simonb 	unsigned int	__fp_pad;
    110  1.10      matt } __fpregset_t;
    111  1.10      matt #else /* !(__mips_n32 || _LP64) */
    112  1.10      matt typedef struct {
    113   1.2   thorpej 	union {
    114   1.6    simonb 		double	__fp_dregs[16];
    115   1.6    simonb 		float	__fp_fregs[32];
    116  1.10      matt 		__freg_t __fp_regs[32];
    117   1.2   thorpej 	} __fp_r;
    118   1.2   thorpej 	unsigned int	__fp_csr;
    119   1.2   thorpej 	unsigned int	__fp_pad;
    120  1.10      matt } __fpregset_t;
    121  1.10      matt #endif /* !(__mips_n32 || _LP64) */
    122   1.2   thorpej 
    123   1.2   thorpej typedef struct {
    124   1.2   thorpej 	__gregset_t	__gregs;
    125   1.2   thorpej 	__fpregset_t	__fpregs;
    126   1.2   thorpej } mcontext_t;
    127   1.2   thorpej 
    128  1.10      matt #endif /* !__ASSEMBLER__ */
    129   1.9      matt 
    130  1.10      matt #define _UC_MACHINE_PAD	16	/* Padding appended to ucontext_t */
    131   1.9      matt 
    132  1.10      matt /*
    133  1.10      matt  * Offsets relative to ucontext_t; intended to be used by assembly stubs.
    134  1.10      matt  */
    135  1.10      matt #if !defined(_MIPS_BSD_API) || _MIPS_BSD_API == _MIPS_BSD_API_LP32
    136  1.10      matt #define _OFFSETOF_UC_GREGS	40
    137  1.10      matt #else
    138  1.10      matt #define _OFFSETOF_UC_GREGS	56
    139   1.9      matt #endif
    140   1.9      matt 
    141   1.5  christos #define	_UC_SETSTACK	0x00010000
    142   1.5  christos #define	_UC_CLRSTACK	0x00020000
    143   1.2   thorpej 
    144   1.2   thorpej #define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.__gregs[_REG_SP])
    145   1.4   thorpej #define _UC_MACHINE_PC(uc)	((uc)->uc_mcontext.__gregs[_REG_EPC])
    146   1.4   thorpej #define _UC_MACHINE_INTRV(uc)	((uc)->uc_mcontext.__gregs[_REG_V0])
    147   1.4   thorpej 
    148   1.4   thorpej #define	_UC_MACHINE_SET_PC(uc, pc)	_UC_MACHINE_PC(uc) = (pc)
    149   1.2   thorpej 
    150   1.2   thorpej #endif	/* _MIPS_MCONTEXT_H_ */
    151