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
57a676c8wroche * Common Development and Distribution License (the "License").
67a676c8wroche * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
227c478bdstevel@tonic-gate/*	All Rights Reserved	*/
237c478bdstevel@tonic-gate
247c478bdstevel@tonic-gate
257c478bdstevel@tonic-gate/*
26bc0e913Gordon Ross * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
27bc0e913Gordon Ross *
287a676c8wroche * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
297c478bdstevel@tonic-gate * Use is subject to license terms.
307c478bdstevel@tonic-gate */
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate#ifndef	_SYS_REGSET_H
337c478bdstevel@tonic-gate#define	_SYS_REGSET_H
347c478bdstevel@tonic-gate
357c478bdstevel@tonic-gate#include <sys/feature_tests.h>
367c478bdstevel@tonic-gate
377c478bdstevel@tonic-gate#if !defined(_ASM)
387c478bdstevel@tonic-gate#include <sys/int_types.h>
397c478bdstevel@tonic-gate#endif
40bc0e913Gordon Ross#include <sys/mcontext.h>
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(__sparcv9)
517c478bdstevel@tonic-gate#define	REG_CCR (0)
527c478bdstevel@tonic-gate#if defined(_SYSCALL32)
537c478bdstevel@tonic-gate#define	REG_PSR (0)
547c478bdstevel@tonic-gate#endif /* _SYSCALL32 */
557c478bdstevel@tonic-gate#else
567c478bdstevel@tonic-gate#define	REG_PSR (0)
577c478bdstevel@tonic-gate#endif  /* __sparcv9 */
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gate#define	REG_PC	(1)
607c478bdstevel@tonic-gate#define	REG_nPC	(2)
617c478bdstevel@tonic-gate#define	REG_Y	(3)
627c478bdstevel@tonic-gate#define	REG_G1	(4)
637c478bdstevel@tonic-gate#define	REG_G2	(5)
647c478bdstevel@tonic-gate#define	REG_G3	(6)
657c478bdstevel@tonic-gate#define	REG_G4	(7)
667c478bdstevel@tonic-gate#define	REG_G5	(8)
677c478bdstevel@tonic-gate#define	REG_G6	(9)
687c478bdstevel@tonic-gate#define	REG_G7	(10)
697c478bdstevel@tonic-gate#define	REG_O0	(11)
707c478bdstevel@tonic-gate#define	REG_O1	(12)
717c478bdstevel@tonic-gate#define	REG_O2	(13)
727c478bdstevel@tonic-gate#define	REG_O3	(14)
737c478bdstevel@tonic-gate#define	REG_O4	(15)
747c478bdstevel@tonic-gate#define	REG_O5	(16)
757c478bdstevel@tonic-gate#define	REG_O6	(17)
767c478bdstevel@tonic-gate#define	REG_O7	(18)
777c478bdstevel@tonic-gate#if defined(__sparcv9)
787c478bdstevel@tonic-gate#define	REG_ASI	(19)
797c478bdstevel@tonic-gate#define	REG_FPRS (20)
807c478bdstevel@tonic-gate#endif	/* __sparcv9 */
817c478bdstevel@tonic-gate
827c478bdstevel@tonic-gate/* the following defines are for portability */
837c478bdstevel@tonic-gate#if !defined(__sparcv9)
847c478bdstevel@tonic-gate#define	REG_PS	REG_PSR
857c478bdstevel@tonic-gate#endif	/* __sparcv9 */
867c478bdstevel@tonic-gate#define	REG_SP	REG_O6
877c478bdstevel@tonic-gate#define	REG_R0	REG_O0
887c478bdstevel@tonic-gate#define	REG_R1	REG_O1
897c478bdstevel@tonic-gate
907c478bdstevel@tonic-gate#ifndef	_ASM
917c478bdstevel@tonic-gate
92bc0e913Gordon Ross#define	NGREG	_NGREG
93bc0e913Gordon Ross#define	MAXFPQ	_MAXFPQ
9461679b0Gordon Ross
957c478bdstevel@tonic-gate/*
967c478bdstevel@tonic-gate * The following structures define how a register window can appear on the
977c478bdstevel@tonic-gate * stack. This structure is available (when required) through the `gwins'
987c478bdstevel@tonic-gate * field of an mcontext (nested within ucontext). SPARC_MAXWINDOW is the
997c478bdstevel@tonic-gate * maximum number of outstanding regiters window defined in the SPARC
1007c478bdstevel@tonic-gate * architecture (*not* implementation).
1017c478bdstevel@tonic-gate */
1027c478bdstevel@tonic-gate#define	SPARC_MAXREGWINDOW	31	/* max windows in SPARC arch. */
1037c478bdstevel@tonic-gate
104bc0e913Gordon Rossstruct	rwindow {
1057c478bdstevel@tonic-gate	greg_t	rw_local[8];		/* locals */
1067c478bdstevel@tonic-gate	greg_t	rw_in[8];		/* ins */
1077c478bdstevel@tonic-gate};
1087c478bdstevel@tonic-gate
1097c478bdstevel@tonic-gate#if defined(_SYSCALL32)
1107c478bdstevel@tonic-gate
1117c478bdstevel@tonic-gatestruct rwindow32 {
1127c478bdstevel@tonic-gate	greg32_t rw_local[8];		/* locals */
1137c478bdstevel@tonic-gate	greg32_t rw_in[8];		/* ins */
1147c478bdstevel@tonic-gate};
1157c478bdstevel@tonic-gate
1167c478bdstevel@tonic-gatestruct rwindow64 {
1177c478bdstevel@tonic-gate	greg64_t rw_local[8];		/* locals */
1187c478bdstevel@tonic-gate	greg64_t rw_in[8];		/* ins */
1197c478bdstevel@tonic-gate};
1207c478bdstevel@tonic-gate
1217c478bdstevel@tonic-gate#if defined(_KERNEL)
1227c478bdstevel@tonic-gateextern	void	rwindow_nto32(struct rwindow *, struct rwindow32 *);
1237c478bdstevel@tonic-gateextern	void	rwindow_32ton(struct rwindow32 *, struct rwindow *);
1247c478bdstevel@tonic-gate#endif
1257c478bdstevel@tonic-gate
1267c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
1277c478bdstevel@tonic-gate
1287c478bdstevel@tonic-gate#define	rw_fp	rw_in[6]		/* frame pointer */
1297c478bdstevel@tonic-gate#define	rw_rtn	rw_in[7]		/* return address */
1307c478bdstevel@tonic-gate
131bc0e913Gordon Rosstypedef struct _gwindows {
1327c478bdstevel@tonic-gate	int		wbcnt;
1337c478bdstevel@tonic-gate	greg_t		*spbuf[SPARC_MAXREGWINDOW];
1347c478bdstevel@tonic-gate	struct rwindow	wbuf[SPARC_MAXREGWINDOW];
1357c478bdstevel@tonic-gate} gwindows_t;
1367c478bdstevel@tonic-gate
1377c478bdstevel@tonic-gate#if defined(_SYSCALL32)
1387c478bdstevel@tonic-gate
1397c478bdstevel@tonic-gatetypedef struct gwindows32 {
1407c478bdstevel@tonic-gate	int32_t		wbcnt;
1417c478bdstevel@tonic-gate	caddr32_t	spbuf[SPARC_MAXREGWINDOW];
1427c478bdstevel@tonic-gate	struct rwindow32 wbuf[SPARC_MAXREGWINDOW];
1437c478bdstevel@tonic-gate} gwindows32_t;
1447c478bdstevel@tonic-gate
1457c478bdstevel@tonic-gatetypedef struct gwindows64 {
1467c478bdstevel@tonic-gate	int		wbcnt;
1477c478bdstevel@tonic-gate	greg64_t	*spbuf[SPARC_MAXREGWINDOW];
1487c478bdstevel@tonic-gate	struct rwindow64 wbuf[SPARC_MAXREGWINDOW];
1497c478bdstevel@tonic-gate} gwindows64_t;
1507c478bdstevel@tonic-gate
1517c478bdstevel@tonic-gate#endif	/* _SYSCALL32 */
1527c478bdstevel@tonic-gate
1537c478bdstevel@tonic-gate/*
1547c478bdstevel@tonic-gate * The following #define's are obsolete and may be removed in a future release.
1557c478bdstevel@tonic-gate * The corresponding integer types should be used instead (i.e. uint64_t).
1567c478bdstevel@tonic-gate */
1577c478bdstevel@tonic-gate#define	FPU_REGS_TYPE		uint32_t
1587c478bdstevel@tonic-gate#define	FPU_DREGS_TYPE		uint64_t
1597c478bdstevel@tonic-gate#define	V7_FPU_FSR_TYPE		uint32_t
1607c478bdstevel@tonic-gate#define	V9_FPU_FSR_TYPE		uint64_t
1617c478bdstevel@tonic-gate#define	V9_FPU_FPRS_TYPE	uint32_t
1627c478bdstevel@tonic-gate
163bc0e913Gordon Ross#define	XRS_ID			_XRS_ID
1647c478bdstevel@tonic-gate
165bc0e913Gordon Ross#endif	/* !_ASM */
1667c478bdstevel@tonic-gate
1677c478bdstevel@tonic-gate/*
1687c478bdstevel@tonic-gate * The version of privregs.h that is used on implementations that run
1697c478bdstevel@tonic-gate * on processors that support the V9 instruction set is deliberately not
1707c478bdstevel@tonic-gate * imported here.
1717c478bdstevel@tonic-gate *
1727c478bdstevel@tonic-gate * The V9 'struct regs' definition is -not- compatible with either 32-bit
1737c478bdstevel@tonic-gate * or 64-bit core file contents, nor with the ucontext.  As a result, the
1747c478bdstevel@tonic-gate * 'regs' structure cannot be used portably by applications, and should
1757c478bdstevel@tonic-gate * only be used by the kernel implementation.
1767c478bdstevel@tonic-gate *
1777c478bdstevel@tonic-gate * The inclusion of the SPARC V7 version of privregs.h allows for some
1787c478bdstevel@tonic-gate * limited source compatibility with 32-bit applications who expect to use
1797c478bdstevel@tonic-gate * 'struct regs' to match the content of a 32-bit core file, or a ucontext_t.
1807c478bdstevel@tonic-gate *
1817c478bdstevel@tonic-gate * Note that the ucontext_t actually describes the general registers in
182bc0e913Gordon Ross * terms of the gregset_t data type, as described in mcontex.h.  Note also
1837c478bdstevel@tonic-gate * that the core file content is defined by core(4) in terms of data types
1847c478bdstevel@tonic-gate * defined by procfs -- see proc(4).
1857c478bdstevel@tonic-gate */
1867c478bdstevel@tonic-gate#if !defined(__sparcv9)
1877c478bdstevel@tonic-gate#if !defined(_KERNEL) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
1887c478bdstevel@tonic-gate#include <v7/sys/privregs.h>
1897c478bdstevel@tonic-gate#endif	/* !_KERNEL && !_XPG4_2 || __EXTENSIONS__ */
1907c478bdstevel@tonic-gate#endif	/* __sparcv9 */
1917c478bdstevel@tonic-gate
1927c478bdstevel@tonic-gate#ifdef	__cplusplus
1937c478bdstevel@tonic-gate}
1947c478bdstevel@tonic-gate#endif
1957c478bdstevel@tonic-gate
1967c478bdstevel@tonic-gate#endif	/* _SYS_REGSET_H */
197