1 /* $NetBSD: mcontext.h,v 1.8 2008/04/28 20:23:28 martin 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 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _MIPS_MCONTEXT_H_ 33 #define _MIPS_MCONTEXT_H_ 34 35 /* 36 * General register state 37 */ 38 #define _NGREG 37 /* R0-R31, MDLO, MDHI, CAUSE, PC, SR */ 39 40 #define _REG_R0 0 41 #define _REG_AT 1 42 #define _REG_V0 2 43 #define _REG_V1 3 44 #define _REG_A0 4 45 #define _REG_A1 5 46 #define _REG_A2 6 47 #define _REG_A3 7 48 #define _REG_T0 8 49 #define _REG_T1 9 50 #define _REG_T2 10 51 #define _REG_T3 11 52 #define _REG_T4 12 53 #define _REG_T5 13 54 #define _REG_T6 14 55 #define _REG_T7 15 56 #define _REG_S0 16 57 #define _REG_S1 17 58 #define _REG_S2 18 59 #define _REG_S3 19 60 #define _REG_S4 20 61 #define _REG_S5 21 62 #define _REG_S6 22 63 #define _REG_S7 23 64 #define _REG_T8 24 65 #define _REG_T9 25 66 #define _REG_K0 26 67 #define _REG_K1 27 68 #define _REG_GP 28 69 #define _REG_SP 29 70 #define _REG_S8 30 71 #define _REG_RA 31 72 73 /* XXX: The following conflict with <mips/regnum.h> */ 74 #define _REG_MDLO 32 75 #define _REG_MDHI 33 76 #define _REG_CAUSE 34 77 #define _REG_EPC 35 78 #define _REG_SR 36 79 80 #ifndef __ASSEMBLER__ 81 82 /* Make sure this is signed; we need pointers to be sign-extended. */ 83 #if defined(__mips_n32) 84 typedef long long __greg_t; 85 #else 86 typedef long __greg_t; 87 #endif /* __mips_n32 */ 88 89 typedef __greg_t __gregset_t[_NGREG]; 90 91 /* 92 * For the O32 ABI, there are 16 doubles, one at each even FP reg 93 * number. The FP registers themselves are 32-bits. 94 * 95 * For 64-bit ABIs (include N32), each FP register is a 64-bit double. 96 */ 97 typedef __greg_t __freg_t; 98 99 /* 100 * Floating point register state 101 */ 102 #if defined(__mips_n32) || defined(_LP64) 103 typedef struct { 104 union { 105 double __fp64_dregs[32]; 106 __freg_t __fp_regs[32]; 107 } __fp_r; 108 unsigned int __fp_csr; 109 unsigned int __fp_pad; 110 } __fpregset_t; 111 #else /* !(__mips_n32 || _LP64) */ 112 typedef struct { 113 union { 114 double __fp_dregs[16]; 115 float __fp_fregs[32]; 116 __freg_t __fp_regs[32]; 117 } __fp_r; 118 unsigned int __fp_csr; 119 unsigned int __fp_pad; 120 } __fpregset_t; 121 #endif /* !(__mips_n32 || _LP64) */ 122 123 typedef struct { 124 __gregset_t __gregs; 125 __fpregset_t __fpregs; 126 } mcontext_t; 127 128 #endif /* !__ASSEMBLER__ */ 129 130 #define _UC_MACHINE_PAD 16 /* Padding appended to ucontext_t */ 131 132 /* 133 * Offsets relative to ucontext_t; intended to be used by assembly stubs. 134 */ 135 #if !defined(_MIPS_BSD_API) || _MIPS_BSD_API == _MIPS_BSD_API_LP32 136 #define _OFFSETOF_UC_GREGS 40 137 #else 138 #define _OFFSETOF_UC_GREGS 56 139 #endif 140 141 #define _UC_SETSTACK 0x00010000 142 #define _UC_CLRSTACK 0x00020000 143 144 #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) 145 #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EPC]) 146 #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0]) 147 148 #define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc) 149 150 #endif /* _MIPS_MCONTEXT_H_ */ 151