xref: /titanic_51/usr/src/uts/intel/sys/mcontext.h (revision bc0e91320069f0bcaee43e80a7ea686d9efa2d08)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
23  *
24  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25  */
26 /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
27 
28 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T		*/
29 /*	All Rights Reserved	*/
30 
31 /*
32  * Essential struct definitions for mcontext_t needed by ucontext.h
33  * These were formerly in regset.h, which now includes this file.
34  */
35 
36 #ifndef	_SYS_MCONTEXT_H
37 #define	_SYS_MCONTEXT_H
38 
39 #include <sys/feature_tests.h>
40 
41 #if !defined(_ASM)
42 #include <sys/types.h>
43 #endif
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * A gregset_t is defined as an array type for compatibility with the reference
51  * source. This is important due to differences in the way the C language
52  * treats arrays and structures as parameters.
53  */
54 #if defined(__amd64)
55 #define	_NGREG	28
56 #else
57 #define	_NGREG	19
58 #endif
59 
60 #if !defined(_ASM)
61 
62 #if defined(_LP64) || defined(_I32LPx)
63 typedef long	greg_t;
64 #else
65 typedef int	greg_t;
66 #endif
67 
68 #if defined(_SYSCALL32)
69 
70 typedef int32_t greg32_t;
71 typedef int64_t	greg64_t;
72 
73 #endif	/* _SYSCALL32 */
74 
75 typedef greg_t	gregset_t[_NGREG];
76 
77 #if defined(_SYSCALL32)
78 
79 #define	_NGREG32	19
80 #define	_NGREG64	28
81 
82 typedef greg32_t gregset32_t[_NGREG32];
83 typedef	greg64_t gregset64_t[_NGREG64];
84 
85 #endif	/* _SYSCALL32 */
86 
87 /*
88  * Floating point definitions.
89  */
90 
91 #if defined(__amd64)
92 
93 typedef struct _fpu {
94 	union {
95 		struct _fpchip_state {
96 			uint16_t cw;
97 			uint16_t sw;
98 			uint8_t  fctw;
99 			uint8_t  __fx_rsvd;
100 			uint16_t fop;
101 			uint64_t rip;
102 			uint64_t rdp;
103 			uint32_t mxcsr;
104 			uint32_t mxcsr_mask;
105 			union {
106 				uint16_t fpr_16[5];
107 				upad128_t __fpr_pad;
108 			} st[8];
109 			upad128_t xmm[16];
110 			upad128_t __fx_ign2[6];
111 			uint32_t status;	/* sw at exception */
112 			uint32_t xstatus;	/* mxcsr at exception */
113 		} fpchip_state;
114 		uint32_t	f_fpregs[130];
115 	} fp_reg_set;
116 } fpregset_t;
117 
118 #else	/* __i386 */
119 
120 /*
121  * This definition of the floating point structure is binary
122  * compatible with the Intel386 psABI definition, and source
123  * compatible with that specification for x87-style floating point.
124  * It also allows SSE/SSE2 state to be accessed on machines that
125  * possess such hardware capabilities.
126  */
127 typedef struct _fpu {
128 	union {
129 		struct _fpchip_state {
130 			uint32_t state[27];	/* 287/387 saved state */
131 			uint32_t status;	/* saved at exception */
132 			uint32_t mxcsr;		/* SSE control and status */
133 			uint32_t xstatus;	/* SSE mxcsr at exception */
134 			uint32_t __pad[2];	/* align to 128-bits */
135 			upad128_t xmm[8];	/* %xmm0-%xmm7 */
136 		} fpchip_state;
137 		struct _fp_emul_space {		/* for emulator(s) */
138 			uint8_t	fp_emul[246];
139 			uint8_t	fp_epad[2];
140 		} fp_emul_space;
141 		uint32_t	f_fpregs[95];	/* union of the above */
142 	} fp_reg_set;
143 } fpregset_t;
144 
145 #endif	/* __i386 */
146 
147 #if defined(_SYSCALL32)
148 
149 /* Kernel view of user i386 fpu structure */
150 
151 typedef struct fpu32 {
152 	union {
153 		struct fpchip32_state {
154 			uint32_t state[27];	/* 287/387 saved state */
155 			uint32_t status;	/* saved at exception */
156 			uint32_t mxcsr;		/* SSE control and status */
157 			uint32_t xstatus;	/* SSE mxcsr at exception */
158 			uint32_t __pad[2];	/* align to 128-bits */
159 			uint32_t xmm[8][4];	/* %xmm0-%xmm7 */
160 		} fpchip_state;
161 		uint32_t	f_fpregs[95];	/* union of the above */
162 	} fp_reg_set;
163 } fpregset32_t;
164 
165 #endif	/* _SYSCALL32 */
166 
167 /*
168  * Structure mcontext defines the complete hardware machine state.
169  * (This structure is specified in the i386 ABI suppl.)
170  */
171 typedef struct {
172 	gregset_t	gregs;		/* general register set */
173 	fpregset_t	fpregs;		/* floating point register set */
174 } mcontext_t;
175 
176 #if defined(_SYSCALL32)
177 
178 typedef struct {
179 	gregset32_t	gregs;		/* general register set */
180 	fpregset32_t	fpregs;		/* floating point register set */
181 } mcontext32_t;
182 
183 #endif	/* _SYSCALL32 */
184 
185 #endif	/* _ASM */
186 
187 #ifdef	__cplusplus
188 }
189 #endif
190 
191 #endif	/* _SYS_MCONTEXT_H */
192