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