regset.h revision 7c478bd95313f5f23a4c958a745db2134aa0324
17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
227c478bdstevel@tonic-gate/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
237c478bdstevel@tonic-gate/*	All Rights Reserved	*/
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate/*
277c478bdstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
287c478bdstevel@tonic-gate * Use is subject to license terms.
297c478bdstevel@tonic-gate */
307c478bdstevel@tonic-gate
317c478bdstevel@tonic-gate#ifndef	_SYS_REGSET_H
327c478bdstevel@tonic-gate#define	_SYS_REGSET_H
337c478bdstevel@tonic-gate
347c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.1	*/
357c478bdstevel@tonic-gate
367c478bdstevel@tonic-gate#include <sys/feature_tests.h>
377c478bdstevel@tonic-gate
387c478bdstevel@tonic-gate#if !defined(_ASM)
397c478bdstevel@tonic-gate#include <sys/int_types.h>
407c478bdstevel@tonic-gate#endif
417c478bdstevel@tonic-gate
427c478bdstevel@tonic-gate#ifdef	__cplusplus
437c478bdstevel@tonic-gateextern "C" {
447c478bdstevel@tonic-gate#endif
457c478bdstevel@tonic-gate
467c478bdstevel@tonic-gate/*
477c478bdstevel@tonic-gate * Location of the users' stored registers relative to R0.
487c478bdstevel@tonic-gate * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
497c478bdstevel@tonic-gate */
507c478bdstevel@tonic-gate#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
517c478bdstevel@tonic-gate
527c478bdstevel@tonic-gate#if defined(__sparcv9)
537c478bdstevel@tonic-gate#define	REG_CCR (0)
547c478bdstevel@tonic-gate#if defined(_SYSCALL32)
557c478bdstevel@tonic-gate#define	REG_PSR (0)
567c478bdstevel@tonic-gate#endif /* _SYSCALL32 */
577c478bdstevel@tonic-gate#else
587c478bdstevel@tonic-gate#define	REG_PSR (0)
597c478bdstevel@tonic-gate#endif  /* __sparcv9 */
607c478bdstevel@tonic-gate
617c478bdstevel@tonic-gate#define	REG_PC	(1)
627c478bdstevel@tonic-gate#define	REG_nPC	(2)
637c478bdstevel@tonic-gate#define	REG_Y	(3)
647c478bdstevel@tonic-gate#define	REG_G1	(4)
657c478bdstevel@tonic-gate#define	REG_G2	(5)
667c478bdstevel@tonic-gate#define	REG_G3	(6)
677c478bdstevel@tonic-gate#define	REG_G4	(7)
687c478bdstevel@tonic-gate#define	REG_G5	(8)
697c478bdstevel@tonic-gate#define	REG_G6	(9)
707c478bdstevel@tonic-gate#define	REG_G7	(10)
717c478bdstevel@tonic-gate#define	REG_O0	(11)
727c478bdstevel@tonic-gate#define	REG_O1	(12)
737c478bdstevel@tonic-gate#define	REG_O2	(13)
747c478bdstevel@tonic-gate#define	REG_O3	(14)
757c478bdstevel@tonic-gate#define	REG_O4	(15)
767c478bdstevel@tonic-gate#define	REG_O5	(16)
777c478bdstevel@tonic-gate#define	REG_O6	(17)
787c478bdstevel@tonic-gate#define	REG_O7	(18)
797c478bdstevel@tonic-gate#if defined(__sparcv9)
807c478bdstevel@tonic-gate#define	REG_ASI	(19)
817c478bdstevel@tonic-gate#define	REG_FPRS (20)
827c478bdstevel@tonic-gate#endif	/* __sparcv9 */
837c478bdstevel@tonic-gate
847c478bdstevel@tonic-gate/* the following defines are for portability */
857c478bdstevel@tonic-gate#if !defined(__sparcv9)
867c478bdstevel@tonic-gate#define	REG_PS	REG_PSR
877c478bdstevel@tonic-gate#endif	/* __sparcv9 */
887c478bdstevel@tonic-gate#define	REG_SP	REG_O6
897c478bdstevel@tonic-gate#define	REG_R0	REG_O0
907c478bdstevel@tonic-gate#define	REG_R1	REG_O1
917c478bdstevel@tonic-gate#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
927c478bdstevel@tonic-gate
937c478bdstevel@tonic-gate/*
947c478bdstevel@tonic-gate * A gregset_t is defined as an array type for compatibility with the reference
957c478bdstevel@tonic-gate * source. This is important due to differences in the way the C language
967c478bdstevel@tonic-gate * treats arrays and structures as parameters.
977c478bdstevel@tonic-gate *
987c478bdstevel@tonic-gate * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
997c478bdstevel@tonic-gate * but that the SPARC V8 ABI defines it absolutely to be 19.
1007c478bdstevel@tonic-gate */
1017c478bdstevel@tonic-gate#if defined(__sparcv9)
1027c478bdstevel@tonic-gate#define	_NGREG	21
1037c478bdstevel@tonic-gate#else	/* __sparcv9 */
1047c478bdstevel@tonic-gate#define	_NGREG	19
1057c478bdstevel@tonic-gate#endif	/* __sparcv9 */
1067c478bdstevel@tonic-gate#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
1077c478bdstevel@tonic-gate#define	NGREG	_NGREG
1087c478bdstevel@tonic-gate#endif
1097c478bdstevel@tonic-gate
1107c478bdstevel@tonic-gate#ifndef	_ASM
1117c478bdstevel@tonic-gate
1127c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
1137c478bdstevel@tonic-gatetypedef long	greg_t;
1147c478bdstevel@tonic-gate#else
1157c478bdstevel@tonic-gatetypedef int	greg_t;
1167c478bdstevel@tonic-gate#endif
1177c478bdstevel@tonic-gate
1187c478bdstevel@tonic-gate#if defined(_SYSCALL32)
1197c478bdstevel@tonic-gate
1207c478bdstevel@tonic-gatetypedef int32_t greg32_t;
1217c478bdstevel@tonic-gatetypedef int64_t greg64_t;
1227c478bdstevel@tonic-gate
1237c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
1247c478bdstevel@tonic-gate
1257c478bdstevel@tonic-gatetypedef greg_t	gregset_t[_NGREG];
1267c478bdstevel@tonic-gate
1277c478bdstevel@tonic-gate#if defined(_SYSCALL32)
1287c478bdstevel@tonic-gate
1297c478bdstevel@tonic-gate#define	_NGREG32	19
1307c478bdstevel@tonic-gate#define	_NGREG64	21
1317c478bdstevel@tonic-gate
1327c478bdstevel@tonic-gatetypedef	greg32_t gregset32_t[_NGREG32];
1337c478bdstevel@tonic-gatetypedef greg64_t gregset64_t[_NGREG64];
1347c478bdstevel@tonic-gate
1357c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
1367c478bdstevel@tonic-gate
1377c478bdstevel@tonic-gate#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
1387c478bdstevel@tonic-gate/*
1397c478bdstevel@tonic-gate * The following structures define how a register window can appear on the
1407c478bdstevel@tonic-gate * stack. This structure is available (when required) through the `gwins'
1417c478bdstevel@tonic-gate * field of an mcontext (nested within ucontext). SPARC_MAXWINDOW is the
1427c478bdstevel@tonic-gate * maximum number of outstanding regiters window defined in the SPARC
1437c478bdstevel@tonic-gate * architecture (*not* implementation).
1447c478bdstevel@tonic-gate */
1457c478bdstevel@tonic-gate#define	SPARC_MAXREGWINDOW	31	/* max windows in SPARC arch. */
1467c478bdstevel@tonic-gate
1477c478bdstevel@tonic-gatestruct rwindow {
1487c478bdstevel@tonic-gate	greg_t	rw_local[8];		/* locals */
1497c478bdstevel@tonic-gate	greg_t	rw_in[8];		/* ins */
1507c478bdstevel@tonic-gate};
1517c478bdstevel@tonic-gate
1527c478bdstevel@tonic-gate#if defined(_SYSCALL32)
1537c478bdstevel@tonic-gate
1547c478bdstevel@tonic-gatestruct rwindow32 {
1557c478bdstevel@tonic-gate	greg32_t rw_local[8];		/* locals */
1567c478bdstevel@tonic-gate	greg32_t rw_in[8];		/* ins */
1577c478bdstevel@tonic-gate};
1587c478bdstevel@tonic-gate
1597c478bdstevel@tonic-gatestruct rwindow64 {
1607c478bdstevel@tonic-gate	greg64_t rw_local[8];		/* locals */
1617c478bdstevel@tonic-gate	greg64_t rw_in[8];		/* ins */
1627c478bdstevel@tonic-gate};
1637c478bdstevel@tonic-gate
1647c478bdstevel@tonic-gate#if defined(_KERNEL)
1657c478bdstevel@tonic-gateextern	void	rwindow_nto32(struct rwindow *, struct rwindow32 *);
1667c478bdstevel@tonic-gateextern	void	rwindow_32ton(struct rwindow32 *, struct rwindow *);
1677c478bdstevel@tonic-gate#endif
1687c478bdstevel@tonic-gate
1697c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
1707c478bdstevel@tonic-gate
1717c478bdstevel@tonic-gate#define	rw_fp	rw_in[6]		/* frame pointer */
1727c478bdstevel@tonic-gate#define	rw_rtn	rw_in[7]		/* return address */
1737c478bdstevel@tonic-gate
1747c478bdstevel@tonic-gatetypedef struct gwindows {
1757c478bdstevel@tonic-gate	int		wbcnt;
1767c478bdstevel@tonic-gate	greg_t		*spbuf[SPARC_MAXREGWINDOW];
1777c478bdstevel@tonic-gate	struct rwindow	wbuf[SPARC_MAXREGWINDOW];
1787c478bdstevel@tonic-gate} gwindows_t;
1797c478bdstevel@tonic-gate
1807c478bdstevel@tonic-gate#if defined(_SYSCALL32)
1817c478bdstevel@tonic-gate
1827c478bdstevel@tonic-gatetypedef struct gwindows32 {
1837c478bdstevel@tonic-gate	int32_t		wbcnt;
1847c478bdstevel@tonic-gate	caddr32_t	spbuf[SPARC_MAXREGWINDOW];
1857c478bdstevel@tonic-gate	struct rwindow32 wbuf[SPARC_MAXREGWINDOW];
1867c478bdstevel@tonic-gate} gwindows32_t;
1877c478bdstevel@tonic-gate
1887c478bdstevel@tonic-gatetypedef struct gwindows64 {
1897c478bdstevel@tonic-gate	int		wbcnt;
1907c478bdstevel@tonic-gate	greg64_t	*spbuf[SPARC_MAXREGWINDOW];
1917c478bdstevel@tonic-gate	struct rwindow64 wbuf[SPARC_MAXREGWINDOW];
1927c478bdstevel@tonic-gate} gwindows64_t;
1937c478bdstevel@tonic-gate
1947c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
1957c478bdstevel@tonic-gate
1967c478bdstevel@tonic-gate
1977c478bdstevel@tonic-gate/*
1987c478bdstevel@tonic-gate * Floating point definitions.
1997c478bdstevel@tonic-gate */
2007c478bdstevel@tonic-gate
2017c478bdstevel@tonic-gate#define	MAXFPQ	16	/* max # of fpu queue entries currently supported */
2027c478bdstevel@tonic-gate
2037c478bdstevel@tonic-gate/*
2047c478bdstevel@tonic-gate * struct fq defines the minimal format of a floating point instruction queue
2057c478bdstevel@tonic-gate * entry. The size of entries in the floating point queue are implementation
2067c478bdstevel@tonic-gate * dependent. The union FQu is guarenteed to be the first field in any ABI
2077c478bdstevel@tonic-gate * conformant system implementation. Any additional fields provided by an
2087c478bdstevel@tonic-gate * implementation should not be used applications designed to be ABI conformant.
2097c478bdstevel@tonic-gate */
2107c478bdstevel@tonic-gate
2117c478bdstevel@tonic-gatestruct fpq {
2127c478bdstevel@tonic-gate	unsigned int *fpq_addr;		/* address */
2137c478bdstevel@tonic-gate	unsigned int fpq_instr;		/* instruction */
2147c478bdstevel@tonic-gate};
2157c478bdstevel@tonic-gate
2167c478bdstevel@tonic-gatestruct fq {
2177c478bdstevel@tonic-gate	union {				/* FPU inst/addr queue */
2187c478bdstevel@tonic-gate		double whole;
2197c478bdstevel@tonic-gate		struct fpq fpq;
2207c478bdstevel@tonic-gate	} FQu;
2217c478bdstevel@tonic-gate};
2227c478bdstevel@tonic-gate
2237c478bdstevel@tonic-gate#if defined(_SYSCALL32)
2247c478bdstevel@tonic-gate
2257c478bdstevel@tonic-gatestruct fpq32 {
2267c478bdstevel@tonic-gate	caddr32_t	fpq_addr;	/* address */
2277c478bdstevel@tonic-gate	uint32_t	fpq_instr;	/* instruction */
2287c478bdstevel@tonic-gate};
2297c478bdstevel@tonic-gate
2307c478bdstevel@tonic-gatestruct fq32 {
2317c478bdstevel@tonic-gate	union {				/* FPU inst/addr queue */
2327c478bdstevel@tonic-gate		double whole;
2337c478bdstevel@tonic-gate		struct fpq32 fpq;
2347c478bdstevel@tonic-gate	} FQu;
2357c478bdstevel@tonic-gate};
2367c478bdstevel@tonic-gate
2377c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
2387c478bdstevel@tonic-gate
2397c478bdstevel@tonic-gate/*
2407c478bdstevel@tonic-gate * struct fpu is the floating point processor state. struct fpu is the sum
2417c478bdstevel@tonic-gate * total of all possible floating point state which includes the state of
2427c478bdstevel@tonic-gate * external floating point hardware, fpa registers, etc..., if it exists.
2437c478bdstevel@tonic-gate *
2447c478bdstevel@tonic-gate * A floating point instuction queue may or may not be associated with
2457c478bdstevel@tonic-gate * the floating point processor state. If a queue does exist, the field
2467c478bdstevel@tonic-gate * fpu_q will point to an array of fpu_qcnt entries where each entry is
2477c478bdstevel@tonic-gate * fpu_q_entrysize long. fpu_q_entry has a lower bound of sizeof (union FQu)
2487c478bdstevel@tonic-gate * and no upper bound. If no floating point queue entries are associated
2497c478bdstevel@tonic-gate * with the processor state, fpu_qcnt will be zeo and fpu_q will be NULL.
2507c478bdstevel@tonic-gate */
2517c478bdstevel@tonic-gate
2527c478bdstevel@tonic-gate/*
2537c478bdstevel@tonic-gate * The following #define's are obsolete and may be removed in a future release.
2547c478bdstevel@tonic-gate * The corresponding integer types should be used instead (i.e. uint64_t).
2557c478bdstevel@tonic-gate */
2567c478bdstevel@tonic-gate#define	FPU_REGS_TYPE		uint32_t
2577c478bdstevel@tonic-gate#define	FPU_DREGS_TYPE		uint64_t
2587c478bdstevel@tonic-gate#define	V7_FPU_FSR_TYPE		uint32_t
2597c478bdstevel@tonic-gate#define	V9_FPU_FSR_TYPE		uint64_t
2607c478bdstevel@tonic-gate#define	V9_FPU_FPRS_TYPE	uint32_t
2617c478bdstevel@tonic-gate
2627c478bdstevel@tonic-gate#if defined(__sparcv9)
2637c478bdstevel@tonic-gate
2647c478bdstevel@tonic-gatestruct fpu {
2657c478bdstevel@tonic-gate	union {					/* FPU floating point regs */
2667c478bdstevel@tonic-gate		uint32_t	fpu_regs[32];	/* 32 singles */
2677c478bdstevel@tonic-gate		double		fpu_dregs[32];	/* 32 doubles */
2687c478bdstevel@tonic-gate		long double	fpu_qregs[16];	/* 16 quads */
2697c478bdstevel@tonic-gate	} fpu_fr;
2707c478bdstevel@tonic-gate	struct fq	*fpu_q;			/* ptr to array of FQ entries */
2717c478bdstevel@tonic-gate	uint64_t	fpu_fsr;		/* FPU status register */
2727c478bdstevel@tonic-gate	uint8_t		fpu_qcnt;		/* # of entries in saved FQ */
2737c478bdstevel@tonic-gate	uint8_t		fpu_q_entrysize;	/* # of bytes per FQ entry */
2747c478bdstevel@tonic-gate	uint8_t		fpu_en;			/* flag specifying fpu in use */
2757c478bdstevel@tonic-gate};
2767c478bdstevel@tonic-gate
2777c478bdstevel@tonic-gate#else	/* __sparcv9 */
2787c478bdstevel@tonic-gate
2797c478bdstevel@tonic-gatestruct fpu {
2807c478bdstevel@tonic-gate	union {					/* FPU floating point regs */
2817c478bdstevel@tonic-gate		uint32_t	fpu_regs[32];	/* 32 singles */
2827c478bdstevel@tonic-gate		double		fpu_dregs[16];	/* 16 doubles */
2837c478bdstevel@tonic-gate	} fpu_fr;
2847c478bdstevel@tonic-gate	struct fq	*fpu_q;			/* ptr to array of FQ entries */
2857c478bdstevel@tonic-gate	uint32_t	fpu_fsr;		/* FPU status register */
2867c478bdstevel@tonic-gate	uint8_t		fpu_qcnt;		/* # of entries in saved FQ */
2877c478bdstevel@tonic-gate	uint8_t		fpu_q_entrysize;	/* # of bytes per FQ entry */
2887c478bdstevel@tonic-gate	uint8_t		fpu_en;			/* flag signifying fpu in use */
2897c478bdstevel@tonic-gate};
2907c478bdstevel@tonic-gate
2917c478bdstevel@tonic-gate#endif	/* __sparcv9 */
2927c478bdstevel@tonic-gate
2937c478bdstevel@tonic-gatetypedef struct fpu	fpregset_t;
2947c478bdstevel@tonic-gate
2957c478bdstevel@tonic-gate#if defined(_SYSCALL32)
2967c478bdstevel@tonic-gate
2977c478bdstevel@tonic-gate/* Kernel view of user sparcv7/v8 fpu structure */
2987c478bdstevel@tonic-gate
2997c478bdstevel@tonic-gatestruct fpu32 {
3007c478bdstevel@tonic-gate	union {					/* FPU floating point regs */
3017c478bdstevel@tonic-gate		uint32_t	fpu_regs[32];	/* 32 singles */
3027c478bdstevel@tonic-gate		double		fpu_dregs[16];	/* 16 doubles */
3037c478bdstevel@tonic-gate	} fpu_fr;
3047c478bdstevel@tonic-gate	caddr32_t	fpu_q;			/* ptr to array of FQ entries */
3057c478bdstevel@tonic-gate	uint32_t	fpu_fsr;		/* FPU status register */
3067c478bdstevel@tonic-gate	uint8_t		fpu_qcnt;		/* # of entries in saved FQ */
3077c478bdstevel@tonic-gate	uint8_t		fpu_q_entrysize;	/* # of bytes per FQ entry */
3087c478bdstevel@tonic-gate	uint8_t		fpu_en;			/* flag signifying fpu in use */
3097c478bdstevel@tonic-gate};
3107c478bdstevel@tonic-gate
3117c478bdstevel@tonic-gatetypedef struct fpu32	fpregset32_t;
3127c478bdstevel@tonic-gate
3137c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
3147c478bdstevel@tonic-gate
3157c478bdstevel@tonic-gate/*
3167c478bdstevel@tonic-gate * The ABI uses struct fpu, so we use this to describe the kernel's view of the
3177c478bdstevel@tonic-gate * fpu.
3187c478bdstevel@tonic-gate */
3197c478bdstevel@tonic-gatetypedef struct {
3207c478bdstevel@tonic-gate	union _fpu_fr {				/* V9 FPU floating point regs */
3217c478bdstevel@tonic-gate		uint32_t	fpu_regs[32];	/* 32 singles */
3227c478bdstevel@tonic-gate		uint64_t	fpu_dregs[32];	/* 32 doubles */
3237c478bdstevel@tonic-gate		long double	fpu_qregs[16];	/* 16 quads */
3247c478bdstevel@tonic-gate	} fpu_fr;
3257c478bdstevel@tonic-gate	uint64_t	fpu_fsr;		/* FPU status register */
3267c478bdstevel@tonic-gate	uint32_t	 fpu_fprs;		/* fprs register */
3277c478bdstevel@tonic-gate	struct fq	*fpu_q;
3287c478bdstevel@tonic-gate	uint8_t		fpu_qcnt;
3297c478bdstevel@tonic-gate	uint8_t		fpu_q_entrysize;
3307c478bdstevel@tonic-gate	uint8_t		fpu_en;			/* flag signifying fpu in use */
3317c478bdstevel@tonic-gate} kfpu_t;
3327c478bdstevel@tonic-gate
3337c478bdstevel@tonic-gate#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
3347c478bdstevel@tonic-gate
3357c478bdstevel@tonic-gate#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
3367c478bdstevel@tonic-gate/*
3377c478bdstevel@tonic-gate * The following structure is for associating extra register state with
3387c478bdstevel@tonic-gate * the ucontext structure and is kept within the uc_mcontext filler area.
3397c478bdstevel@tonic-gate *
3407c478bdstevel@tonic-gate * If (xrs_id == XRS_ID) then the xrs_ptr field is a valid pointer to
3417c478bdstevel@tonic-gate * extra register state. The exact format of the extra register state
3427c478bdstevel@tonic-gate * pointed to by xrs_ptr is platform-dependent.
3437c478bdstevel@tonic-gate *
3447c478bdstevel@tonic-gate * Note: a platform may or may not manage extra register state.
3457c478bdstevel@tonic-gate */
3467c478bdstevel@tonic-gatetypedef struct {
3477c478bdstevel@tonic-gate	unsigned int	xrs_id;		/* indicates xrs_ptr validity */
3487c478bdstevel@tonic-gate	caddr_t		xrs_ptr;	/* ptr to extra reg state */
3497c478bdstevel@tonic-gate} xrs_t;
3507c478bdstevel@tonic-gate
3517c478bdstevel@tonic-gate#define	XRS_ID			0x78727300	/* the string "xrs" */
3527c478bdstevel@tonic-gate
3537c478bdstevel@tonic-gate#if defined(_SYSCALL32)
3547c478bdstevel@tonic-gate
3557c478bdstevel@tonic-gatetypedef	struct {
3567c478bdstevel@tonic-gate	uint32_t	xrs_id;		/* indicates xrs_ptr validity */
3577c478bdstevel@tonic-gate	caddr32_t	xrs_ptr;	/* ptr to extra reg state */
3587c478bdstevel@tonic-gate} xrs32_t;
3597c478bdstevel@tonic-gate
3607c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
3617c478bdstevel@tonic-gate
3627c478bdstevel@tonic-gate#if defined(__sparcv9)
3637c478bdstevel@tonic-gate
3647c478bdstevel@tonic-gate/*
3657c478bdstevel@tonic-gate * Ancillary State Registers
3667c478bdstevel@tonic-gate *
3677c478bdstevel@tonic-gate * The SPARC V9 architecture defines 25 ASRs, numbered from 7 through 31.
3687c478bdstevel@tonic-gate * ASRs 16 through 31 are available to user programs, though the meaning
3697c478bdstevel@tonic-gate * and content of these registers is implementation dependent.
3707c478bdstevel@tonic-gate */
3717c478bdstevel@tonic-gatetypedef	int64_t	asrset_t[16];	/* %asr16 - > %asr31 */
3727c478bdstevel@tonic-gate
3737c478bdstevel@tonic-gate#endif	/* __sparcv9 */
3747c478bdstevel@tonic-gate
3757c478bdstevel@tonic-gate/*
3767c478bdstevel@tonic-gate * Structure mcontext defines the complete hardware machine state. If
3777c478bdstevel@tonic-gate * the field `gwins' is non NULL, it points to a save area for register
3787c478bdstevel@tonic-gate * window frames. If `gwins' is NULL, the register windows were saved
3797c478bdstevel@tonic-gate * on the user's stack.
3807c478bdstevel@tonic-gate *
3817c478bdstevel@tonic-gate * The filler of 21 longs is historical (now filler[19] plus the xrs_t
3827c478bdstevel@tonic-gate * field). The value was selected to provide binary compatibility with
3837c478bdstevel@tonic-gate * statically linked ICL binaries. It is in the ABI (do not change). It
3847c478bdstevel@tonic-gate * actually appears in the ABI as a single filler of 44 is in the field
3857c478bdstevel@tonic-gate * uc_filler of struct ucontext. It is split here so that ucontext.h can
3867c478bdstevel@tonic-gate * (hopefully) remain architecture independent.
3877c478bdstevel@tonic-gate *
3887c478bdstevel@tonic-gate * Note that 2 longs of the filler are used to hold extra register state info.
3897c478bdstevel@tonic-gate */
3907c478bdstevel@tonic-gatetypedef struct {
3917c478bdstevel@tonic-gate	gregset_t	gregs;	/* general register set */
3927c478bdstevel@tonic-gate	gwindows_t	*gwins;	/* POSSIBLE pointer to register windows */
3937c478bdstevel@tonic-gate	fpregset_t	fpregs;	/* floating point register set */
3947c478bdstevel@tonic-gate	xrs_t		xrs;	/* POSSIBLE extra register state association */
3957c478bdstevel@tonic-gate#if defined(__sparcv9)
3967c478bdstevel@tonic-gate	asrset_t	asrs;		/* ancillary registers */
3977c478bdstevel@tonic-gate	long		filler[4];	/* room for expansion */
3987c478bdstevel@tonic-gate#else	/* __sparcv9 */
3997c478bdstevel@tonic-gate	long		filler[19];
4007c478bdstevel@tonic-gate#endif	/* __sparcv9 */
4017c478bdstevel@tonic-gate} mcontext_t;
4027c478bdstevel@tonic-gate
4037c478bdstevel@tonic-gate#if defined(_SYSCALL32)
4047c478bdstevel@tonic-gate
4057c478bdstevel@tonic-gatetypedef struct {
4067c478bdstevel@tonic-gate	gregset32_t	gregs;	/* general register set */
4077c478bdstevel@tonic-gate	caddr32_t	gwins;	/* POSSIBLE pointer to register windows */
4087c478bdstevel@tonic-gate	fpregset32_t	fpregs;	/* floating point register set */
4097c478bdstevel@tonic-gate	xrs32_t		xrs;	/* POSSIBLE extra register state association */
4107c478bdstevel@tonic-gate	int32_t		filler[19];
4117c478bdstevel@tonic-gate} mcontext32_t;
4127c478bdstevel@tonic-gate
4137c478bdstevel@tonic-gate#endif /* _SYSCALL32 */
4147c478bdstevel@tonic-gate
4157c478bdstevel@tonic-gate#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
4167c478bdstevel@tonic-gate#endif	/* _ASM */
4177c478bdstevel@tonic-gate
4187c478bdstevel@tonic-gate/*
4197c478bdstevel@tonic-gate * The version of privregs.h that is used on implementations that run
4207c478bdstevel@tonic-gate * on processors that support the V9 instruction set is deliberately not
4217c478bdstevel@tonic-gate * imported here.
4227c478bdstevel@tonic-gate *
4237c478bdstevel@tonic-gate * The V9 'struct regs' definition is -not- compatible with either 32-bit
4247c478bdstevel@tonic-gate * or 64-bit core file contents, nor with the ucontext.  As a result, the
4257c478bdstevel@tonic-gate * 'regs' structure cannot be used portably by applications, and should
4267c478bdstevel@tonic-gate * only be used by the kernel implementation.
4277c478bdstevel@tonic-gate *
4287c478bdstevel@tonic-gate * The inclusion of the SPARC V7 version of privregs.h allows for some
4297c478bdstevel@tonic-gate * limited source compatibility with 32-bit applications who expect to use
4307c478bdstevel@tonic-gate * 'struct regs' to match the content of a 32-bit core file, or a ucontext_t.
4317c478bdstevel@tonic-gate *
4327c478bdstevel@tonic-gate * Note that the ucontext_t actually describes the general registers in
4337c478bdstevel@tonic-gate * terms of the gregset_t data type, as described in this file.  Note also
4347c478bdstevel@tonic-gate * that the core file content is defined by core(4) in terms of data types
4357c478bdstevel@tonic-gate * defined by procfs -- see proc(4).
4367c478bdstevel@tonic-gate */
4377c478bdstevel@tonic-gate#if !defined(__sparcv9)
4387c478bdstevel@tonic-gate#if !defined(_KERNEL) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
4397c478bdstevel@tonic-gate#include <v7/sys/privregs.h>
4407c478bdstevel@tonic-gate#endif	/* !_KERNEL && !_XPG4_2 || __EXTENSIONS__ */
4417c478bdstevel@tonic-gate#endif	/* __sparcv9 */
4427c478bdstevel@tonic-gate
4437c478bdstevel@tonic-gate/*
4447c478bdstevel@tonic-gate * The following is here for XPG4.2 standards compliance.
4457c478bdstevel@tonic-gate * regset.h is included in ucontext.h for the definition of
4467c478bdstevel@tonic-gate * mcontext_t, all of which breaks XPG4.2 namespace.
4477c478bdstevel@tonic-gate */
4487c478bdstevel@tonic-gate
4497c478bdstevel@tonic-gate#if defined(_XPG4_2) && !defined(__EXTENSIONS__)
4507c478bdstevel@tonic-gate/*
4517c478bdstevel@tonic-gate * The following is here for UNIX 95 compliance (XPG Issue 4, Version 2
4527c478bdstevel@tonic-gate * System Interfaces and Headers. The structures included here are identical
4537c478bdstevel@tonic-gate * to those visible elsewhere in this header except that the structure
4547c478bdstevel@tonic-gate * element names have been changed in accordance with the X/Open namespace
4557c478bdstevel@tonic-gate * rules.  Specifically, depending on the name and scope, the names have
4567c478bdstevel@tonic-gate * been prepended with a single or double underscore (_ or __).  See the
4577c478bdstevel@tonic-gate * structure definitions in the non-X/Open namespace for more detailed
4587c478bdstevel@tonic-gate * comments describing each of these structures.
4597c478bdstevel@tonic-gate */
4607c478bdstevel@tonic-gate
4617c478bdstevel@tonic-gate#ifndef	_ASM
4627c478bdstevel@tonic-gate
4637c478bdstevel@tonic-gate/*
4647c478bdstevel@tonic-gate * The following structures define how a register window can appear on the
4657c478bdstevel@tonic-gate * stack.
4667c478bdstevel@tonic-gate */
4677c478bdstevel@tonic-gate#define	_SPARC_MAXREGWINDOW	31		/* max windows in SPARC arch. */
4687c478bdstevel@tonic-gate
4697c478bdstevel@tonic-gatestruct	__rwindow {
4707c478bdstevel@tonic-gate	greg_t	__rw_local[8];		/* locals */
4717c478bdstevel@tonic-gate	greg_t	__rw_in[8];		/* ins */
4727c478bdstevel@tonic-gate};
4737c478bdstevel@tonic-gate
4747c478bdstevel@tonic-gate#define	__rw_fp		__rw_in[6]		/* frame pointer */
4757c478bdstevel@tonic-gate#define	__rw_rtn	__rw_in[7]		/* return address */
4767c478bdstevel@tonic-gate
4777c478bdstevel@tonic-gatestruct __gwindows {
4787c478bdstevel@tonic-gate	int		__wbcnt;
4797c478bdstevel@tonic-gate	greg_t		*__spbuf[_SPARC_MAXREGWINDOW];
4807c478bdstevel@tonic-gate	struct __rwindow	__wbuf[_SPARC_MAXREGWINDOW];
4817c478bdstevel@tonic-gate};
4827c478bdstevel@tonic-gate
4837c478bdstevel@tonic-gatetypedef struct __gwindows	gwindows_t;
4847c478bdstevel@tonic-gate
4857c478bdstevel@tonic-gate/*
4867c478bdstevel@tonic-gate * The fq structure defines the minimal format of a floating point
4877c478bdstevel@tonic-gate * instruction queue entry.
4887c478bdstevel@tonic-gate */
4897c478bdstevel@tonic-gate
4907c478bdstevel@tonic-gatestruct __fpq {
4917c478bdstevel@tonic-gate	unsigned int *__fpq_addr;	/* address */
4927c478bdstevel@tonic-gate	unsigned int __fpq_instr;	/* instruction */
4937c478bdstevel@tonic-gate};
4947c478bdstevel@tonic-gate
4957c478bdstevel@tonic-gatestruct __fq {
4967c478bdstevel@tonic-gate	union {				/* FPU inst/addr queue */
4977c478bdstevel@tonic-gate		double __whole;
4987c478bdstevel@tonic-gate		struct __fpq __fpq;
4997c478bdstevel@tonic-gate	} _FQu;
5007c478bdstevel@tonic-gate};
5017c478bdstevel@tonic-gate
5027c478bdstevel@tonic-gate/*
5037c478bdstevel@tonic-gate * The fpu structure is the floating point processor state.
5047c478bdstevel@tonic-gate */
5057c478bdstevel@tonic-gate
5067c478bdstevel@tonic-gate/*
5077c478bdstevel@tonic-gate * The following #define's are obsolete and may be removed in a future release.
5087c478bdstevel@tonic-gate * The corresponding integer types should be used instead (i.e. uint64_t).
5097c478bdstevel@tonic-gate */
5107c478bdstevel@tonic-gate#define	_FPU_REGS_TYPE		uint32_t
5117c478bdstevel@tonic-gate#define	_FPU_DREGS_TYPE		uint64_t
5127c478bdstevel@tonic-gate#define	_V7_FPU_FSR_TYPE	uint32_t
5137c478bdstevel@tonic-gate#define	_V9_FPU_FSR_TYPE	uint64_t
5147c478bdstevel@tonic-gate#define	_V9_FPU_FPRS_TYPE	uint32_t
5157c478bdstevel@tonic-gate
5167c478bdstevel@tonic-gate#if defined(__sparcv9)
5177c478bdstevel@tonic-gate
5187c478bdstevel@tonic-gate/*
5197c478bdstevel@tonic-gate * SPARC Version 9 floating point
5207c478bdstevel@tonic-gate */
5217c478bdstevel@tonic-gate
5227c478bdstevel@tonic-gatestruct __fpu {
5237c478bdstevel@tonic-gate	union {					/* FPU floating point regs */
5247c478bdstevel@tonic-gate		uint32_t	__fpu_regs[32];		/* 32 singles */
5257c478bdstevel@tonic-gate		double		__fpu_dregs[32];	/* 32 doubles */
5267c478bdstevel@tonic-gate		long double	__fpu_qregs[16];	/* 16 quads */
5277c478bdstevel@tonic-gate	} __fpu_fr;
5287c478bdstevel@tonic-gate	struct __fq	*__fpu_q;		/* ptr to array of FQ entries */
5297c478bdstevel@tonic-gate	uint64_t	__fpu_fsr;	/* FPU status register */
5307c478bdstevel@tonic-gate	uint8_t		__fpu_qcnt;		/* # of entries in saved FQ */
5317c478bdstevel@tonic-gate	uint8_t		__fpu_q_entrysize;	/* # of bytes per FQ entry */
5327c478bdstevel@tonic-gate	uint8_t		__fpu_en;		/* flag signifying fpu in use */
5337c478bdstevel@tonic-gate};
5347c478bdstevel@tonic-gate
5357c478bdstevel@tonic-gate#else	/* __sparcv9 */
5367c478bdstevel@tonic-gate
5377c478bdstevel@tonic-gate/*
5387c478bdstevel@tonic-gate * SPARC Version 7 and 8 floating point
5397c478bdstevel@tonic-gate */
5407c478bdstevel@tonic-gate
5417c478bdstevel@tonic-gatestruct __fpu {
5427c478bdstevel@tonic-gate	union {					/* FPU floating point regs */
5437c478bdstevel@tonic-gate		uint32_t	__fpu_regs[32];		/* 32 singles */
5447c478bdstevel@tonic-gate		double		__fpu_dregs[16];	/* 16 doubles */
5457c478bdstevel@tonic-gate	} __fpu_fr;
5467c478bdstevel@tonic-gate	struct __fq	*__fpu_q;		/* ptr to array of FQ entries */
5477c478bdstevel@tonic-gate	uint32_t	__fpu_fsr;	/* FPU status register */
5487c478bdstevel@tonic-gate	uint8_t		__fpu_qcnt;		/* # of entries in saved FQ */
5497c478bdstevel@tonic-gate	uint8_t		__fpu_q_entrysize;	/* # of bytes per FQ entry */
5507c478bdstevel@tonic-gate	uint8_t		__fpu_en;		/* flag signifying fpu in use */
5517c478bdstevel@tonic-gate};
5527c478bdstevel@tonic-gate
5537c478bdstevel@tonic-gate#endif	/* __sparcv9 */
5547c478bdstevel@tonic-gate
5557c478bdstevel@tonic-gatetypedef struct __fpu	fpregset_t;
5567c478bdstevel@tonic-gate
5577c478bdstevel@tonic-gate/*
5587c478bdstevel@tonic-gate * The xrs_t structure is for associating extra register state with
5597c478bdstevel@tonic-gate * the ucontext structure and is kept within the uc_mcontext filler area.
5607c478bdstevel@tonic-gate */
5617c478bdstevel@tonic-gatetypedef struct {
5627c478bdstevel@tonic-gate	unsigned int	__xrs_id;	/* indicates xrs_ptr validity */
5637c478bdstevel@tonic-gate	caddr_t		__xrs_ptr;	/* ptr to extra reg state */
5647c478bdstevel@tonic-gate} xrs_t;
5657c478bdstevel@tonic-gate
5667c478bdstevel@tonic-gate#define	_XRS_ID			0x78727300	/* the string "xrs" */
5677c478bdstevel@tonic-gate
5687c478bdstevel@tonic-gate#if defined(__sparcv9)
5697c478bdstevel@tonic-gate
5707c478bdstevel@tonic-gate/*
5717c478bdstevel@tonic-gate * Ancillary State Registers
5727c478bdstevel@tonic-gate *
5737c478bdstevel@tonic-gate * The SPARC V9 architecture defines 25 ASRs, numbered from 7 through 31.
5747c478bdstevel@tonic-gate * ASRs 16 through 31 are available to user programs, though the meaning
5757c478bdstevel@tonic-gate * and content of these registers is implementation dependent.
5767c478bdstevel@tonic-gate */
5777c478bdstevel@tonic-gatetypedef	int64_t	asrset_t[16];	/* %asr16 - > %asr31 */
5787c478bdstevel@tonic-gate
5797c478bdstevel@tonic-gate#endif	/* __sparcv9 */
5807c478bdstevel@tonic-gate
5817c478bdstevel@tonic-gate/*
5827c478bdstevel@tonic-gate * Structure mcontext defines the complete hardware machine state.
5837c478bdstevel@tonic-gate */
5847c478bdstevel@tonic-gatetypedef struct {
5857c478bdstevel@tonic-gate	gregset_t	__gregs; /* general register set */
5867c478bdstevel@tonic-gate	gwindows_t	*__gwins; /* POSSIBLE pointer to register windows */
5877c478bdstevel@tonic-gate	fpregset_t	__fpregs; /* floating point register set */
5887c478bdstevel@tonic-gate	xrs_t		__xrs;	/* POSSIBLE extra register state association */
5897c478bdstevel@tonic-gate#if defined(__sparcv9)
5907c478bdstevel@tonic-gate	asrset_t	__asrs;		/* ancillary registers */
5917c478bdstevel@tonic-gate	long		__filler[4];	/* room for expansion */
5927c478bdstevel@tonic-gate#else	/* __sparcv9 */
5937c478bdstevel@tonic-gate	long		__filler[19];
5947c478bdstevel@tonic-gate#endif	/* __sparcv9 */
5957c478bdstevel@tonic-gate} mcontext_t;
5967c478bdstevel@tonic-gate
5977c478bdstevel@tonic-gate#endif	/* _ASM */
5987c478bdstevel@tonic-gate#endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */
5997c478bdstevel@tonic-gate
6007c478bdstevel@tonic-gate
6017c478bdstevel@tonic-gate#ifdef	__cplusplus
6027c478bdstevel@tonic-gate}
6037c478bdstevel@tonic-gate#endif
6047c478bdstevel@tonic-gate
6057c478bdstevel@tonic-gate#endif	/* _SYS_REGSET_H */
606