1 /* $NetBSD: mcontext.h,v 1.10 2009/11/26 01:21:50 matt Exp $ */
4 * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
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.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
32 #ifndef _MIPS_MCONTEXT_H_
33 #define _MIPS_MCONTEXT_H_
36 * General register state
38 #define _NGREG 37 /* R0-R31, MDLO, MDHI, CAUSE, PC, SR */
73 /* XXX: The following conflict with <mips/regnum.h> */
82 /* Make sure this is signed; we need pointers to be sign-extended. */
83 #if defined(__mips_n32)
84 typedef long long __greg_t
;
86 typedef long __greg_t
;
87 #endif /* __mips_n32 */
89 typedef __greg_t __gregset_t
[_NGREG
];
92 * For the O32/O64 ABI, there are 16 doubles, one at each even FP reg
93 * number. The FP registers themselves are 32-bits.
95 * For 64-bit ABIs (include N32), each FP register is a 64-bit double.
97 typedef __greg_t __freg_t
;
100 * Floating point register state
102 struct __fpregset_nabi
{
104 double __fp64_dregs
[32];
105 __freg_t __fp_regs
[32];
109 struct __fpregset_oabi
{
111 double __fp_dregs
[16];
112 float __fp_fregs
[32];
113 __int32_t __fp_regs
[32];
115 unsigned int __fp_csr
;
116 unsigned int __fp_pad
;
119 #if __mips_n32 || __mips_n64
120 typedef struct __fpregset_nabi __fpregset_t
;
122 typedef struct __fpregset_oabi __fpregset_t
;
127 __fpregset_t __fpregs
;
130 #if defined(_KERNEL) && defined(_LP64)
131 typedef __int32_t __greg32_t
;
132 typedef __greg32_t __gregset32_t
[_NGREG
];
135 __gregset32_t __gregs
;
136 struct __fpregset_oabi __fpregs
;
141 struct __fpregset_nabi __fpregs
;
144 #endif /* _KERNEL && _LP64 */
146 #endif /* !__ASSEMBLER__ */
148 #define _UC_MACHINE_PAD 16 /* Padding appended to ucontext_t */
150 #define _UC_SETSTACK 0x00010000
151 #define _UC_CLRSTACK 0x00020000
153 #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
154 #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EPC])
155 #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0])
157 #define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
159 #define _UC_MACHINE32_SP(uc) _UC_MACHINE_SP(uc)
160 #define _UC_MACHINE32_PC(uc) _UC_MACHINE_PC(uc)
161 #define _UC_MACHINE32_INTRV(uc) _UC_MACHINE_INTRV(uc)
163 #define _UC_MACHINE32_SET_PC(uc, pc) _UC_MACHINE_PC((uc), (pc))
165 #endif /* _MIPS_MCONTEXT_H_ */