xref: /titanic_44/usr/src/uts/sparc/sys/ucontext.h (revision bb5c894bdad0d78b8fec5d050bda354c84f7c054)
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 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 #ifndef _SYS_UCONTEXT_H
31 #define	_SYS_UCONTEXT_H
32 
33 #include <sys/feature_tests.h>
34 
35 #include <sys/types.h>
36 #include <sys/regset.h>
37 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
38 #include <sys/signal.h>
39 #endif
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 /*
46  * Inclusion of <sys/signal.h> for sigset_t and stack_t definitions
47  * breaks XPG4v2 namespace.  Therefore we must duplicate the defines
48  * for these types here when _XPG4_2 is defined.
49  */
50 
51 #if defined(_XPG4_2) && !defined(__EXTENSIONS__)
52 #ifndef	_SIGSET_T
53 #define	_SIGSET_T
54 typedef	struct {	/* signal set type */
55 	unsigned int	__sigbits[4];
56 } sigset_t;
57 #endif /* _SIGSET_T */
58 
59 #ifndef	_STACK_T
60 #define	_STACK_T
61 typedef	struct {
62 	void	*ss_sp;
63 	size_t	ss_size;
64 	int	ss_flags;
65 } stack_t;
66 
67 #endif /* _STACK_T */
68 #endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */
69 
70 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
71 typedef	struct ucontext ucontext_t;
72 #else
73 typedef	struct __ucontext ucontext_t;
74 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
75 
76 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
77 struct	ucontext {
78 #else
79 struct	__ucontext {
80 #endif
81 	uint_t		uc_flags;
82 	ucontext_t	*uc_link;
83 	sigset_t   	uc_sigmask;
84 	stack_t 	uc_stack;
85 	mcontext_t	uc_mcontext;
86 #ifdef	__sparcv9
87 	long		uc_filler[4];
88 #else	/* __sparcv9 */
89 	long		uc_filler[23];
90 #endif	/* __sparcv9 */
91 };
92 
93 #ifdef _SYSCALL32
94 
95 /* Kernel view of user ILP32 ucontext structure */
96 
97 typedef struct ucontext32 {
98 	uint32_t	uc_flags;
99 	caddr32_t	uc_link;
100 	sigset_t	uc_sigmask;
101 	stack32_t	uc_stack;
102 	mcontext32_t	uc_mcontext;
103 	int32_t		uc_filler[23];
104 } ucontext32_t;
105 
106 #ifdef _KERNEL
107 extern void ucontext_32ton(const ucontext32_t *, ucontext_t *,
108     const struct fq32 *, struct fq *);
109 extern void fpuregset_nto32(const fpregset_t *, fpregset32_t *, struct fq32 *);
110 #endif
111 
112 #endif	/* _SYSCALL32 */
113 
114 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
115 #define	GETCONTEXT	0
116 #define	SETCONTEXT	1
117 #define	GETUSTACK	2
118 #define	SETUSTACK	3
119 
120 /*
121  * values for uc_flags
122  * these are implementation dependent flags, that should be hidden
123  * from the user interface, defining which elements of ucontext
124  * are valid, and should be restored on call to setcontext
125  */
126 
127 #define	UC_SIGMASK	0x01
128 #define	UC_STACK	0x02
129 #define	UC_CPU		0x04
130 #define	UC_MAU		0x08
131 #define	UC_FPU		UC_MAU
132 #define	UC_INTR		0x10
133 #define	UC_ASR		0x20
134 
135 #define	UC_MCONTEXT	(UC_CPU|UC_FPU|UC_ASR)
136 
137 /*
138  * UC_ALL specifies the default context
139  */
140 
141 #define	UC_ALL		(UC_SIGMASK|UC_STACK|UC_MCONTEXT)
142 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
143 
144 #ifdef _KERNEL
145 extern void savecontext(ucontext_t *, const k_sigset_t *);
146 extern void restorecontext(ucontext_t *);
147 
148 #ifdef _SYSCALL32
149 extern void savecontext32(ucontext32_t *, const k_sigset_t *, struct fq32 *);
150 #endif
151 #endif
152 
153 #ifdef	__cplusplus
154 }
155 #endif
156 
157 #endif /* _SYS_UCONTEXT_H */
158