xref: /titanic_50/usr/src/lib/libbc/libc/sys/common/ucontext.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * This file contains all the type definitions necessary to
31  * define the equivalent of SVR4 struct ucontext.
32  */
33 
34 /* Definition for alternate stack */
35 typedef struct sigaltstack {
36 	char *ss_sp;
37 	int  ss_size;
38 	int  ss_flags;
39 } stack_t;
40 
41 /* Register window */
42 struct  rwindow {
43         int  rw_local[8];            /* locals */
44         int  rw_in[8];               /* ins */
45 };
46 
47 #define   SPARC_MAXREGWINDOW      31 /* max windows in SPARC arch. */
48 
49 struct gwindows {
50         int             wbcnt;
51         int             *spbuf[SPARC_MAXREGWINDOW];
52         struct rwindow  wbuf[SPARC_MAXREGWINDOW];
53 };
54 
55 typedef struct gwindows gwindows_t;
56 
57 /* Floating point registers */
58 struct fpq {
59         unsigned long *fpq_addr;        /* address */
60         unsigned long fpq_instr;        /* instruction */
61 };
62 
63 struct fq {
64         union {                         /* FPU inst/addr queue */
65                 double whole;
66                 struct fpq fpq;
67         } FQu;
68 };
69 
70 struct fpu {
71         union {                            /* FPU floating point regs */
72                 unsigned   fpu_regs[32];   /* 32 singles */
73                 double     fpu_dregs[16];  /* 16 doubles */
74         } fpu_fr;
75         struct fq       *fpu_q;             /* ptr to array of FQ entries */
76         unsigned    fpu_fsr;                /* FPU status register */
77         unsigned char   fpu_qcnt;           /* # of entries in saved FQ */
78         unsigned char   fpu_q_entrysize;    /* # of bytes per FQ entry */
79         unsigned char   fpu_en;             /* flag signifying fpu in use */
80 };
81 
82 typedef struct fpu      fpregset_t;
83 
84 /* Register set */
85 #define NGREG   19
86 
87 typedef int  gregset_t[NGREG];
88 
89 typedef struct mcontext{
90         gregset_t       gregs;  /* general register set */
91         gwindows_t      *gwins; /* POSSIBLE pointer to register windows */
92         fpregset_t      fpregs; /* floating point register set */
93         long            filler[21];
94 } mcontext_t;
95 
96 
97 typedef struct ucontext{
98         unsigned long   uc_flags;
99         struct ucontext *uc_link;
100         unsigned long   uc_sigmask[4];
101         stack_t         uc_stack;
102         mcontext_t      uc_mcontext;
103         long            uc_filler[23];
104 } ucontext_t;
105 
106 
107 
108 /* The following is needed by the setjmp/longjmp routines */
109 
110 #define _ABI_JBLEN	12	/* _JBLEN from base */
111 
112 /*
113  * The following structure MUST match the ABI size specifier _SIGJBLEN.
114  * This is 19 (words). The ABI value for _JBLEN is 12 (words).
115  * A sigset_t is 16 bytes and a stack_t is 12 bytes.  The layout must
116  * match sigjmp_struct_t, defined in usr/src/lib/libc/inc/sigjmp_struct.h
117  */
118 typedef struct setjmp_struct_t {
119 	int		sjs_flags;	/* JBUF[ 0]	*/
120 	int		sjs_sp;		/* JBUF[ 1]	*/
121 	int		sjs_pc;		/* JBUF[ 2]	*/
122 	int		sjs_fp;		/* JBUF[ 3]	*/
123 	int		sjs_i7;		/* JBUF[ 4]	*/
124 	void		*sjs_uclink;
125 	unsigned long	sjs_pad[_ABI_JBLEN - 6];
126 	unsigned long	sjs_sigmask[4];
127 	stack_t		sjs_stack;
128 } setjmp_struct_t;
129 
130 typedef struct o_setjmp_struct_t {
131 	int		sjs_flags;	/* JBUF[ 0]	*/
132 	int		sjs_sp;		/* JBUF[ 1]	*/
133 	int		sjs_pc;		/* JBUF[ 2]	*/
134 	unsigned long	sjs_sigmask[3];
135 	stack_t		sjs_stack;
136 } o_setjmp_struct_t;
137 
138 #define JB_SAVEMASK	0x1
139 #define UC_SIGMASK	001
140 #define UC_STACK	002
141 
142