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