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