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