xref: /titanic_50/usr/src/uts/sparc/sys/procfs_isa.h (revision bc0e91320069f0bcaee43e80a7ea686d9efa2d08)
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 (c) 1996-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_PROCFS_ISA_H
28 #define	_SYS_PROCFS_ISA_H
29 
30 /*
31  * Instruction Set Architecture specific component of <sys/procfs.h>
32  * sparc v8/v9 version
33  */
34 
35 #include <sys/regset.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Possible values of pr_dmodel.
43  * This isn't isa-specific, but it needs to be defined here for other reasons.
44  */
45 #define	PR_MODEL_UNKNOWN 0
46 #define	PR_MODEL_ILP32	1	/* process data model is ILP32 */
47 #define	PR_MODEL_LP64	2	/* process data model is LP64 */
48 
49 /*
50  * To determine whether application is running native.
51  */
52 #if defined(_LP64)
53 #define	PR_MODEL_NATIVE	PR_MODEL_LP64
54 #elif defined(_ILP32)
55 #define	PR_MODEL_NATIVE	PR_MODEL_ILP32
56 #else
57 #error "No DATAMODEL_NATIVE specified"
58 #endif	/* _LP64 || _ILP32 */
59 
60 /*
61  * Holds one sparc instruction, for both ILP32 and LP64.
62  */
63 typedef	uint32_t	instr_t;
64 
65 /*
66  * General register access (sparc).
67  * Don't confuse definitions here with definitions in <sys/regset.h>.
68  * Registers are 32 bits for ILP32, 64 bits for LP64.
69  */
70 #define	NPRGREG	38
71 #if defined(_LP64) || defined(_I32LPx)
72 typedef	long		prgreg_t;
73 #else
74 typedef	int		prgreg_t;
75 #endif
76 typedef	prgreg_t	prgregset_t[NPRGREG];
77 
78 #define	R_G0	0
79 #define	R_G1	1
80 #define	R_G2	2
81 #define	R_G3	3
82 #define	R_G4	4
83 #define	R_G5	5
84 #define	R_G6	6
85 #define	R_G7	7
86 #define	R_O0	8
87 #define	R_O1	9
88 #define	R_O2	10
89 #define	R_O3	11
90 #define	R_O4	12
91 #define	R_O5	13
92 #define	R_O6	14
93 #define	R_O7	15
94 #define	R_L0	16
95 #define	R_L1	17
96 #define	R_L2	18
97 #define	R_L3	19
98 #define	R_L4	20
99 #define	R_L5	21
100 #define	R_L6	22
101 #define	R_L7	23
102 #define	R_I0	24
103 #define	R_I1	25
104 #define	R_I2	26
105 #define	R_I3	27
106 #define	R_I4	28
107 #define	R_I5	29
108 #define	R_I6	30
109 #define	R_I7	31
110 
111 #ifdef	__sparcv9
112 #define	R_CCR	32	/* v9 condition code register */
113 #else
114 #define	R_PSR	32	/* v7/v8 processor status register */
115 #endif
116 
117 #define	R_PC	33
118 #define	R_nPC	34
119 #define	R_Y	35
120 
121 #ifdef	__sparcv9
122 #define	R_ASI	36
123 #define	R_FPRS	37
124 #else
125 #define	R_WIM	36
126 #define	R_TBR	37
127 #endif
128 
129 /*
130  * The following defines are for portability.
131  */
132 #ifdef	__sparcv9
133 #define	R_PS	R_CCR
134 #else
135 #define	R_PS	R_PSR
136 #endif
137 #define	R_SP	R_O6
138 #define	R_FP	R_I6
139 #define	R_R0	R_O0
140 #define	R_R1	R_O1
141 
142 #if defined(_SYSCALL32)
143 /*
144  * kernel view of the _ILP32 register set
145  */
146 typedef	int32_t		prgreg32_t;
147 typedef	prgreg32_t	prgregset32_t[NPRGREG];
148 #define	R_PSR	32
149 #define	R_WIM	36
150 #define	R_TBR	37
151 #endif
152 
153 /*
154  * Floating-point register access (sparc FPU).
155  * See <sys/regset.h> for details of interpretation.
156  */
157 #ifdef	__sparcv9
158 typedef struct prfpregset {
159 	union {				/* FPU floating point regs */
160 		uint32_t pr_regs[32];		/* 32 singles */
161 		double	pr_dregs[32];		/* 32 doubles */
162 		long double pr_qregs[16];	/* 16 quads */
163 	} pr_fr;
164 	uint64_t pr_filler;
165 	uint64_t pr_fsr;		/* FPU status register */
166 	uint8_t	pr_qcnt;		/* # of entries in saved FQ */
167 	uint8_t	pr_q_entrysize;		/* # of bytes per FQ entry */
168 	uint8_t	pr_en;			/* flag signifying fpu in use */
169 	char	pr_pad[13];		/* ensure sizeof(prfpregset)%16 == 0 */
170 	struct _fq pr_q[16];		/* contains the FQ array */
171 } prfpregset_t;
172 #else
173 typedef struct prfpregset {
174 	union {				/* FPU floating point regs */
175 		uint32_t pr_regs[32];		/* 32 singles */
176 		double	pr_dregs[16];		/* 16 doubles */
177 	} pr_fr;
178 	uint32_t pr_filler;
179 	uint32_t pr_fsr;		/* FPU status register */
180 	uint8_t	pr_qcnt;		/* # of entries in saved FQ */
181 	uint8_t	pr_q_entrysize;		/* # of bytes per FQ entry */
182 	uint8_t	pr_en;			/* flag signifying fpu in use */
183 	struct _fq pr_q[32];		/* contains the FQ array */
184 } prfpregset_t;
185 #endif	/* __sparcv9 */
186 
187 #if defined(_SYSCALL32)
188 /*
189  * kernel view of the _ILP32 floating point register set
190  */
191 typedef struct prfpregset32 {
192 	union {				/* FPU floating point regs */
193 		uint32_t pr_regs[32];		/* 32 singles */
194 		double	pr_dregs[16];		/* 16 doubles */
195 	} pr_fr;
196 	uint32_t pr_filler;
197 	uint32_t pr_fsr;		/* FPU status register */
198 	uint8_t	pr_qcnt;		/* # of entries in saved FQ */
199 	uint8_t	pr_q_entrysize;		/* # of bytes per FQ entry */
200 	uint8_t	pr_en;			/* flag signifying fpu in use */
201 	struct fq32 pr_q[32];		/* contains the FQ array */
202 } prfpregset32_t;
203 #endif	/* _SYSCALL32 */
204 
205 /*
206  * Extra register access
207  */
208 
209 #define	XR_G0		0
210 #define	XR_G1		1
211 #define	XR_G2		2
212 #define	XR_G3		3
213 #define	XR_G4		4
214 #define	XR_G5		5
215 #define	XR_G6		6
216 #define	XR_G7		7
217 #define	NPRXGREG	8
218 
219 #define	XR_O0		0
220 #define	XR_O1		1
221 #define	XR_O2		2
222 #define	XR_O3		3
223 #define	XR_O4		4
224 #define	XR_O5		5
225 #define	XR_O6		6
226 #define	XR_O7		7
227 #define	NPRXOREG	8
228 
229 #define	NPRXFILLER	8
230 
231 #define	XR_TYPE_V8P	1		/* interpret union as pr_v8p */
232 
233 typedef struct prxregset {
234 	uint32_t	pr_type;		/* how to interpret union */
235 	uint32_t	pr_align;		/* alignment for the union */
236 	union {
237 	    struct pr_v8p {
238 		union {				/* extra FP registers */
239 			uint32_t	pr_regs[32];
240 			double		pr_dregs[16];
241 #ifndef __sparcv9		/* 32-bit alignment problem */
242 			long double	pr_qregs[8];
243 #endif
244 		} pr_xfr;
245 		uint32_t	pr_xfsr;	/* upper 32bits, FP state reg */
246 		uint32_t	pr_fprs;	/* FP registers state */
247 		uint32_t	pr_xg[NPRXGREG]; /* upper 32bits, G registers */
248 		uint32_t	pr_xo[NPRXOREG]; /* upper 32bits, O registers */
249 		uint64_t	pr_tstate;	/* TSTATE register */
250 		uint32_t	pr_filler[NPRXFILLER];
251 	    } pr_v8p;
252 	} pr_un;
253 } prxregset_t;
254 
255 /*
256  * Given a pointer to a prxregset structure, this macro yields the value
257  * of the %gsr embedded in the structure.  It is an lvalue, so it can
258  * be used to assign the value of the %gsr into the structure.
259  * (Please don't ask why this is done this way.)
260  */
261 #define	PRXREG_GSR(xrp)	(*(uint64_t *)((xrp)->pr_un.pr_v8p.pr_filler))
262 
263 #ifdef	__cplusplus
264 }
265 #endif
266 
267 #endif	/* _SYS_PROCFS_ISA_H */
268