xref: /illumos-gate/usr/src/uts/intel/sys/ucontext.h (revision 7c478bd95313f5f23a4c958a745db2134aa0324)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_UCONTEXT_H
32*7c478bd9Sstevel@tonic-gate #define	_SYS_UCONTEXT_H
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/regset.h>
40*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
41*7c478bd9Sstevel@tonic-gate #include <sys/signal.h>
42*7c478bd9Sstevel@tonic-gate #endif
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
45*7c478bd9Sstevel@tonic-gate extern "C" {
46*7c478bd9Sstevel@tonic-gate #endif
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /*
49*7c478bd9Sstevel@tonic-gate  * Inclusion of <sys/signal.h> for sigset_t and stack_t definitions
50*7c478bd9Sstevel@tonic-gate  * breaks XPG4v2 namespace.  Therefore we must duplicate the defines
51*7c478bd9Sstevel@tonic-gate  * for these types here when _XPG4_2 is defined.
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) && !defined(__EXTENSIONS__)
55*7c478bd9Sstevel@tonic-gate #ifndef	_SIGSET_T
56*7c478bd9Sstevel@tonic-gate #define	_SIGSET_T
57*7c478bd9Sstevel@tonic-gate typedef	struct {	/* signal set type */
58*7c478bd9Sstevel@tonic-gate 	unsigned long	__sigbits[4];
59*7c478bd9Sstevel@tonic-gate } sigset_t;
60*7c478bd9Sstevel@tonic-gate #endif /* _SIGSET_T */
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate #ifndef	_STACK_T
63*7c478bd9Sstevel@tonic-gate #define	_STACK_T
64*7c478bd9Sstevel@tonic-gate typedef	struct {
65*7c478bd9Sstevel@tonic-gate 	void	*ss_sp;
66*7c478bd9Sstevel@tonic-gate 	size_t	ss_size;
67*7c478bd9Sstevel@tonic-gate 	int	ss_flags;
68*7c478bd9Sstevel@tonic-gate } stack_t;
69*7c478bd9Sstevel@tonic-gate #endif /* _STACK_T */
70*7c478bd9Sstevel@tonic-gate #endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
73*7c478bd9Sstevel@tonic-gate typedef	struct ucontext ucontext_t;
74*7c478bd9Sstevel@tonic-gate #else
75*7c478bd9Sstevel@tonic-gate typedef	struct __ucontext ucontext_t;
76*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
79*7c478bd9Sstevel@tonic-gate struct	ucontext {
80*7c478bd9Sstevel@tonic-gate #else
81*7c478bd9Sstevel@tonic-gate struct	__ucontext {
82*7c478bd9Sstevel@tonic-gate #endif
83*7c478bd9Sstevel@tonic-gate 	unsigned long	uc_flags;
84*7c478bd9Sstevel@tonic-gate 	ucontext_t	*uc_link;
85*7c478bd9Sstevel@tonic-gate 	sigset_t   	uc_sigmask;
86*7c478bd9Sstevel@tonic-gate 	stack_t 	uc_stack;
87*7c478bd9Sstevel@tonic-gate 	mcontext_t 	uc_mcontext;
88*7c478bd9Sstevel@tonic-gate 	long		uc_filler[5];	/* see ABI spec for Intel386 */
89*7c478bd9Sstevel@tonic-gate };
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /* Kernel view of user ILP32 ucontext structure */
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate typedef struct ucontext32 {
96*7c478bd9Sstevel@tonic-gate 	uint32_t	uc_flags;
97*7c478bd9Sstevel@tonic-gate 	caddr32_t	uc_link;
98*7c478bd9Sstevel@tonic-gate 	sigset32_t	uc_sigmask;
99*7c478bd9Sstevel@tonic-gate 	stack32_t	uc_stack;
100*7c478bd9Sstevel@tonic-gate 	mcontext32_t	uc_mcontext;
101*7c478bd9Sstevel@tonic-gate 	int32_t		uc_filler[5];
102*7c478bd9Sstevel@tonic-gate } ucontext32_t;
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
105*7c478bd9Sstevel@tonic-gate extern void ucontext_nto32(const ucontext_t *src, ucontext32_t *dest);
106*7c478bd9Sstevel@tonic-gate extern void ucontext_32ton(const ucontext32_t *src, ucontext_t *dest);
107*7c478bd9Sstevel@tonic-gate #endif
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
112*7c478bd9Sstevel@tonic-gate #define	GETCONTEXT	0
113*7c478bd9Sstevel@tonic-gate #define	SETCONTEXT	1
114*7c478bd9Sstevel@tonic-gate #define	GETUSTACK	2
115*7c478bd9Sstevel@tonic-gate #define	SETUSTACK	3
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate /*
118*7c478bd9Sstevel@tonic-gate  * values for uc_flags
119*7c478bd9Sstevel@tonic-gate  * these are implementation dependent flags, that should be hidden
120*7c478bd9Sstevel@tonic-gate  * from the user interface, defining which elements of ucontext
121*7c478bd9Sstevel@tonic-gate  * are valid, and should be restored on call to setcontext
122*7c478bd9Sstevel@tonic-gate  */
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate #define	UC_SIGMASK	0x01
125*7c478bd9Sstevel@tonic-gate #define	UC_STACK	0x02
126*7c478bd9Sstevel@tonic-gate #define	UC_CPU		0x04
127*7c478bd9Sstevel@tonic-gate #define	UC_MAU		0x08
128*7c478bd9Sstevel@tonic-gate #define	UC_FPU		UC_MAU
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate #define	UC_MCONTEXT	(UC_CPU|UC_FPU)
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /*
133*7c478bd9Sstevel@tonic-gate  * UC_ALL specifies the default context
134*7c478bd9Sstevel@tonic-gate  */
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate #define	UC_ALL		(UC_SIGMASK|UC_STACK|UC_MCONTEXT)
137*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
140*7c478bd9Sstevel@tonic-gate void savecontext(ucontext_t *, k_sigset_t);
141*7c478bd9Sstevel@tonic-gate void restorecontext(ucontext_t *);
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
144*7c478bd9Sstevel@tonic-gate extern void savecontext32(ucontext32_t *ucp, k_sigset_t mask);
145*7c478bd9Sstevel@tonic-gate #endif
146*7c478bd9Sstevel@tonic-gate #endif
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
149*7c478bd9Sstevel@tonic-gate }
150*7c478bd9Sstevel@tonic-gate #endif
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate #endif /* _SYS_UCONTEXT_H */
153