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