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 57af88ac7SKuriakose Kuruvilla * Common Development and Distribution License (the "License"). 67af88ac7SKuriakose Kuruvilla * 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 /* 22*c5a5e6f4SGordon Ross * Copyright 2015 Nexenta Systems, Inc. All rights reserved. 23*c5a5e6f4SGordon Ross * 247af88ac7SKuriakose Kuruvilla * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 297c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifndef _SYS_REGSET_H 327c478bd9Sstevel@tonic-gate #define _SYS_REGSET_H 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #if !defined(_ASM) 377c478bd9Sstevel@tonic-gate #include <sys/types.h> 387c478bd9Sstevel@tonic-gate #endif 39*c5a5e6f4SGordon Ross #include <sys/mcontext.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 427c478bd9Sstevel@tonic-gate extern "C" { 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * The names and offsets defined here should be specified by the 477c478bd9Sstevel@tonic-gate * AMD64 ABI suppl. 487c478bd9Sstevel@tonic-gate * 497c478bd9Sstevel@tonic-gate * We make fsbase and gsbase part of the lwp context (since they're 507c478bd9Sstevel@tonic-gate * the only way to access the full 64-bit address range via the segment 517c478bd9Sstevel@tonic-gate * registers) and thus belong here too. However we treat them as 527c478bd9Sstevel@tonic-gate * read-only; if %fs or %gs are updated, the results of the descriptor 537c478bd9Sstevel@tonic-gate * table lookup that those updates implicitly cause will be reflected 547c478bd9Sstevel@tonic-gate * in the corresponding fsbase and/or gsbase values the next time the 557c478bd9Sstevel@tonic-gate * context can be inspected. However it is NOT possible to override 567c478bd9Sstevel@tonic-gate * the fsbase/gsbase settings via this interface. 577c478bd9Sstevel@tonic-gate * 587c478bd9Sstevel@tonic-gate * Direct modification of the base registers (thus overriding the 597c478bd9Sstevel@tonic-gate * descriptor table base address) can be achieved with _lwp_setprivate. 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate #define REG_GSBASE 27 637c478bd9Sstevel@tonic-gate #define REG_FSBASE 26 647c478bd9Sstevel@tonic-gate #define REG_DS 25 657c478bd9Sstevel@tonic-gate #define REG_ES 24 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate #define REG_GS 23 687c478bd9Sstevel@tonic-gate #define REG_FS 22 697c478bd9Sstevel@tonic-gate #define REG_SS 21 707c478bd9Sstevel@tonic-gate #define REG_RSP 20 717c478bd9Sstevel@tonic-gate #define REG_RFL 19 727c478bd9Sstevel@tonic-gate #define REG_CS 18 737c478bd9Sstevel@tonic-gate #define REG_RIP 17 747c478bd9Sstevel@tonic-gate #define REG_ERR 16 757c478bd9Sstevel@tonic-gate #define REG_TRAPNO 15 767c478bd9Sstevel@tonic-gate #define REG_RAX 14 777c478bd9Sstevel@tonic-gate #define REG_RCX 13 787c478bd9Sstevel@tonic-gate #define REG_RDX 12 797c478bd9Sstevel@tonic-gate #define REG_RBX 11 807c478bd9Sstevel@tonic-gate #define REG_RBP 10 817c478bd9Sstevel@tonic-gate #define REG_RSI 9 827c478bd9Sstevel@tonic-gate #define REG_RDI 8 837c478bd9Sstevel@tonic-gate #define REG_R8 7 847c478bd9Sstevel@tonic-gate #define REG_R9 6 857c478bd9Sstevel@tonic-gate #define REG_R10 5 867c478bd9Sstevel@tonic-gate #define REG_R11 4 877c478bd9Sstevel@tonic-gate #define REG_R12 3 887c478bd9Sstevel@tonic-gate #define REG_R13 2 897c478bd9Sstevel@tonic-gate #define REG_R14 1 907c478bd9Sstevel@tonic-gate #define REG_R15 0 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * The names and offsets defined here are specified by i386 ABI suppl. 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define SS 18 /* only stored on a privilege transition */ 977c478bd9Sstevel@tonic-gate #define UESP 17 /* only stored on a privilege transition */ 987c478bd9Sstevel@tonic-gate #define EFL 16 997c478bd9Sstevel@tonic-gate #define CS 15 1007c478bd9Sstevel@tonic-gate #define EIP 14 1017c478bd9Sstevel@tonic-gate #define ERR 13 1027c478bd9Sstevel@tonic-gate #define TRAPNO 12 1037c478bd9Sstevel@tonic-gate #define EAX 11 1047c478bd9Sstevel@tonic-gate #define ECX 10 1057c478bd9Sstevel@tonic-gate #define EDX 9 1067c478bd9Sstevel@tonic-gate #define EBX 8 1077c478bd9Sstevel@tonic-gate #define ESP 7 1087c478bd9Sstevel@tonic-gate #define EBP 6 1097c478bd9Sstevel@tonic-gate #define ESI 5 1107c478bd9Sstevel@tonic-gate #define EDI 4 1117c478bd9Sstevel@tonic-gate #define DS 3 1127c478bd9Sstevel@tonic-gate #define ES 2 1137c478bd9Sstevel@tonic-gate #define FS 1 1147c478bd9Sstevel@tonic-gate #define GS 0 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* aliases for portability */ 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate #if defined(__amd64) 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate #define REG_PC REG_RIP 1217c478bd9Sstevel@tonic-gate #define REG_FP REG_RBP 1227c478bd9Sstevel@tonic-gate #define REG_SP REG_RSP 1237c478bd9Sstevel@tonic-gate #define REG_PS REG_RFL 1247c478bd9Sstevel@tonic-gate #define REG_R0 REG_RAX 1257c478bd9Sstevel@tonic-gate #define REG_R1 REG_RDX 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate #else /* __i386 */ 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate #define REG_PC EIP 1307c478bd9Sstevel@tonic-gate #define REG_FP EBP 1317c478bd9Sstevel@tonic-gate #define REG_SP UESP 1327c478bd9Sstevel@tonic-gate #define REG_PS EFL 1337c478bd9Sstevel@tonic-gate #define REG_R0 EAX 1347c478bd9Sstevel@tonic-gate #define REG_R1 EDX 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate #endif /* __i386 */ 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate #define NGREG _NGREG 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate #if !defined(_ASM) 1417c478bd9Sstevel@tonic-gate 142*c5a5e6f4SGordon Ross #ifdef __i386 1437c478bd9Sstevel@tonic-gate /* 1447c478bd9Sstevel@tonic-gate * (This structure definition is specified in the i386 ABI supplement) 145*c5a5e6f4SGordon Ross * It's likely we can just get rid of the struct __old_fpu or maybe 146*c5a5e6f4SGordon Ross * move it to $SRC/uts/intel/ia32/os/fpu.c which appears to be the 147*c5a5e6f4SGordon Ross * only place that uses it. See: www.illumos.org/issues/6284 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate typedef struct __old_fpu { 1507c478bd9Sstevel@tonic-gate union { 1517c478bd9Sstevel@tonic-gate struct __old_fpchip_state /* fp extension state */ 1527c478bd9Sstevel@tonic-gate { 1537c478bd9Sstevel@tonic-gate int state[27]; /* 287/387 saved state */ 1547c478bd9Sstevel@tonic-gate int status; /* status word saved at */ 1557c478bd9Sstevel@tonic-gate /* exception */ 1567c478bd9Sstevel@tonic-gate } fpchip_state; 1577c478bd9Sstevel@tonic-gate struct __old_fp_emul_space /* for emulator(s) */ 1587c478bd9Sstevel@tonic-gate { 1597c478bd9Sstevel@tonic-gate char fp_emul[246]; 1607c478bd9Sstevel@tonic-gate char fp_epad[2]; 1617c478bd9Sstevel@tonic-gate } fp_emul_space; 1627c478bd9Sstevel@tonic-gate int f_fpregs[62]; /* union of the above */ 1637c478bd9Sstevel@tonic-gate } fp_reg_set; 1647c478bd9Sstevel@tonic-gate long f_wregs[33]; /* saved weitek state */ 1657c478bd9Sstevel@tonic-gate } __old_fpregset_t; 1667c478bd9Sstevel@tonic-gate #endif /* __i386 */ 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #if defined(__amd64) 169*c5a5e6f4SGordon Ross #define _NDEBUGREG 16 1707c478bd9Sstevel@tonic-gate #else 171*c5a5e6f4SGordon Ross #define _NDEBUGREG 8 1727c478bd9Sstevel@tonic-gate #endif 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate typedef struct dbregset { 175*c5a5e6f4SGordon Ross unsigned long debugreg[_NDEBUGREG]; 1767c478bd9Sstevel@tonic-gate } dbregset_t; 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate #endif /* _ASM */ 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate /* 1817c478bd9Sstevel@tonic-gate * The version of privregs.h that is used on implementations that run on 1827c478bd9Sstevel@tonic-gate * processors that support the AMD64 instruction set is deliberately not 1837c478bd9Sstevel@tonic-gate * imported here. 1847c478bd9Sstevel@tonic-gate * 1857c478bd9Sstevel@tonic-gate * The amd64 'struct regs' definition may -not- compatible with either 1867c478bd9Sstevel@tonic-gate * 32-bit or 64-bit core file contents, nor with the ucontext. As a result, 1877c478bd9Sstevel@tonic-gate * the 'regs' structure cannot be used portably by applications, and should 1887c478bd9Sstevel@tonic-gate * only be used by the kernel implementation. 1897c478bd9Sstevel@tonic-gate * 1907c478bd9Sstevel@tonic-gate * The inclusion of the i386 version of privregs.h allows for some limited 1917c478bd9Sstevel@tonic-gate * source compatibility with 32-bit applications who expect to use 1927c478bd9Sstevel@tonic-gate * 'struct regs' to match the context of a 32-bit core file, or a ucontext_t. 1937c478bd9Sstevel@tonic-gate * 1947c478bd9Sstevel@tonic-gate * Note that the ucontext_t actually describes the general register in terms 1957c478bd9Sstevel@tonic-gate * of the gregset_t data type, as described in this file. Note also 1967c478bd9Sstevel@tonic-gate * that the core file content is defined by core(4) in terms of data types 1977c478bd9Sstevel@tonic-gate * defined by procfs -- see proc(4). 1987c478bd9Sstevel@tonic-gate */ 1997c478bd9Sstevel@tonic-gate #if defined(__i386) && \ 2007c478bd9Sstevel@tonic-gate (!defined(_KERNEL) && !defined(_XPG4_2) || defined(__EXTENSIONS__)) 2017c478bd9Sstevel@tonic-gate #include <sys/privregs.h> 2027c478bd9Sstevel@tonic-gate #endif /* __i386 (!_KERNEL && !_XPG4_2 || __EXTENSIONS__) */ 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2057c478bd9Sstevel@tonic-gate } 2067c478bd9Sstevel@tonic-gate #endif 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate #endif /* _SYS_REGSET_H */ 209