xref: /titanic_53/usr/src/uts/sparc/sys/ucontext.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 2003 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"	/* from SVr4.0 1.10 */
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 int	__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 
70*7c478bd9Sstevel@tonic-gate #endif /* _STACK_T */
71*7c478bd9Sstevel@tonic-gate #endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
74*7c478bd9Sstevel@tonic-gate typedef	struct ucontext ucontext_t;
75*7c478bd9Sstevel@tonic-gate #else
76*7c478bd9Sstevel@tonic-gate typedef	struct __ucontext ucontext_t;
77*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
80*7c478bd9Sstevel@tonic-gate struct	ucontext {
81*7c478bd9Sstevel@tonic-gate #else
82*7c478bd9Sstevel@tonic-gate struct	__ucontext {
83*7c478bd9Sstevel@tonic-gate #endif
84*7c478bd9Sstevel@tonic-gate 	uint_t		uc_flags;
85*7c478bd9Sstevel@tonic-gate 	ucontext_t	*uc_link;
86*7c478bd9Sstevel@tonic-gate 	sigset_t   	uc_sigmask;
87*7c478bd9Sstevel@tonic-gate 	stack_t 	uc_stack;
88*7c478bd9Sstevel@tonic-gate 	mcontext_t	uc_mcontext;
89*7c478bd9Sstevel@tonic-gate #ifdef	__sparcv9
90*7c478bd9Sstevel@tonic-gate 	long		uc_filler[4];
91*7c478bd9Sstevel@tonic-gate #else	/* __sparcv9 */
92*7c478bd9Sstevel@tonic-gate 	long		uc_filler[23];
93*7c478bd9Sstevel@tonic-gate #endif	/* __sparcv9 */
94*7c478bd9Sstevel@tonic-gate };
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate /* Kernel view of user ILP32 ucontext structure */
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate typedef struct ucontext32 {
101*7c478bd9Sstevel@tonic-gate 	uint32_t	uc_flags;
102*7c478bd9Sstevel@tonic-gate 	caddr32_t	uc_link;
103*7c478bd9Sstevel@tonic-gate 	sigset32_t	uc_sigmask;
104*7c478bd9Sstevel@tonic-gate 	stack32_t	uc_stack;
105*7c478bd9Sstevel@tonic-gate 	mcontext32_t	uc_mcontext;
106*7c478bd9Sstevel@tonic-gate 	int32_t		uc_filler[23];
107*7c478bd9Sstevel@tonic-gate } ucontext32_t;
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
110*7c478bd9Sstevel@tonic-gate extern void ucontext_32ton(const ucontext32_t *, ucontext_t *,
111*7c478bd9Sstevel@tonic-gate     const struct fq32 *, struct fq *);
112*7c478bd9Sstevel@tonic-gate extern void fpuregset_nto32(const fpregset_t *, fpregset32_t *, struct fq32 *);
113*7c478bd9Sstevel@tonic-gate #endif
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
118*7c478bd9Sstevel@tonic-gate #define	GETCONTEXT	0
119*7c478bd9Sstevel@tonic-gate #define	SETCONTEXT	1
120*7c478bd9Sstevel@tonic-gate #define	GETUSTACK	2
121*7c478bd9Sstevel@tonic-gate #define	SETUSTACK	3
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate /*
124*7c478bd9Sstevel@tonic-gate  * values for uc_flags
125*7c478bd9Sstevel@tonic-gate  * these are implementation dependent flags, that should be hidden
126*7c478bd9Sstevel@tonic-gate  * from the user interface, defining which elements of ucontext
127*7c478bd9Sstevel@tonic-gate  * are valid, and should be restored on call to setcontext
128*7c478bd9Sstevel@tonic-gate  */
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate #define	UC_SIGMASK	0x01
131*7c478bd9Sstevel@tonic-gate #define	UC_STACK	0x02
132*7c478bd9Sstevel@tonic-gate #define	UC_CPU		0x04
133*7c478bd9Sstevel@tonic-gate #define	UC_MAU		0x08
134*7c478bd9Sstevel@tonic-gate #define	UC_FPU		UC_MAU
135*7c478bd9Sstevel@tonic-gate #define	UC_INTR		0x10
136*7c478bd9Sstevel@tonic-gate #define	UC_ASR		0x20
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate #define	UC_MCONTEXT	(UC_CPU|UC_FPU|UC_ASR)
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate /*
141*7c478bd9Sstevel@tonic-gate  * UC_ALL specifies the default context
142*7c478bd9Sstevel@tonic-gate  */
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate #define	UC_ALL		(UC_SIGMASK|UC_STACK|UC_MCONTEXT)
145*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
148*7c478bd9Sstevel@tonic-gate extern void savecontext(ucontext_t *, k_sigset_t);
149*7c478bd9Sstevel@tonic-gate extern void restorecontext(ucontext_t *);
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
152*7c478bd9Sstevel@tonic-gate extern void savecontext32(ucontext32_t *, k_sigset_t, struct fq32 *);
153*7c478bd9Sstevel@tonic-gate #endif
154*7c478bd9Sstevel@tonic-gate #endif
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
157*7c478bd9Sstevel@tonic-gate }
158*7c478bd9Sstevel@tonic-gate #endif
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate #endif /* _SYS_UCONTEXT_H */
161