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