mcontext.h revision 1.6 1 /* $NetBSD: mcontext.h,v 1.6 2004/07/03 05:06:37 simonb 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 * For the O32 ABI, there are 16 doubles, one at each even FP reg
100 * number. The FP registers themselves are 32-bits.
101 *
102 * For 64-bit ABIs (include N32), each FP register is a 64-bit double.
103 */
104 typedef __greg_t __freg_t;
105
106 /*
107 * Floating point register state
108 */
109 #if defined(__mips_n32) || defined(_LP64)
110 typedef struct {
111 union {
112 double __fp64_dregs[32];
113 __freg_t __fp_regs[32];
114 } __fp_r;
115 unsigned int __fp_csr;
116 unsigned int __fp_pad;
117 } __fpregset_t;
118 #else /* !(__mips_n32 || _LP64) */
119 typedef struct {
120 union {
121 double __fp_dregs[16];
122 float __fp_fregs[32];
123 __freg_t __fp_regs[32];
124 } __fp_r;
125 unsigned int __fp_csr;
126 unsigned int __fp_pad;
127 } __fpregset_t;
128 #endif /* !(__mips_n32 || _LP64) */
129
130 typedef struct {
131 __gregset_t __gregs;
132 __fpregset_t __fpregs;
133 } mcontext_t;
134
135 #endif /* !__ASSEMBLER__ */
136
137 #define _UC_MACHINE_PAD 16 /* Padding appended to ucontext_t */
138
139 /*
140 * Offsets relative to ucontext_t; intended to be used by assembly stubs.
141 */
142 #if !defined(_MIPS_BSD_API) || _MIPS_BSD_API == _MIPS_BSD_API_LP32
143 #define _OFFSETOF_UC_GREGS 40
144 #else
145 #define _OFFSETOF_UC_GREGS 56
146 #endif
147
148 #define _UC_SETSTACK 0x00010000
149 #define _UC_CLRSTACK 0x00020000
150
151 #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
152 #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EPC])
153 #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0])
154
155 #define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
156
157 #endif /* _MIPS_MCONTEXT_H_ */
158