xref: /illumos-gate/usr/src/uts/intel/sys/trap.h (revision f0089e39)
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
5*f0089e39SRichard Lowe  * Common Development and Distribution License (the "License").
6*f0089e39SRichard Lowe  * 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  */
21*f0089e39SRichard Lowe /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
22*f0089e39SRichard Lowe /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
23*f0089e39SRichard Lowe /*	  All Rights Reserved	*/
24*f0089e39SRichard Lowe 
257c478bd9Sstevel@tonic-gate /*
26*f0089e39SRichard Lowe  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
277c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
28*f0089e39SRichard Lowe  *
29*f0089e39SRichard Lowe  * Copyright 2018 Joyent, Inc.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifndef _SYS_TRAP_H
337c478bd9Sstevel@tonic-gate #define	_SYS_TRAP_H
347c478bd9Sstevel@tonic-gate 
35*f0089e39SRichard Lowe #ifdef	__cplusplus
36*f0089e39SRichard Lowe extern "C" {
37*f0089e39SRichard Lowe #endif
38*f0089e39SRichard Lowe 
39*f0089e39SRichard Lowe /*
40*f0089e39SRichard Lowe  * Trap type values
41*f0089e39SRichard Lowe  */
42*f0089e39SRichard Lowe 
43*f0089e39SRichard Lowe #define	T_ZERODIV	0x0	/* #de	divide by 0 error		*/
44*f0089e39SRichard Lowe #define	T_SGLSTP	0x1	/* #db	single step			*/
45*f0089e39SRichard Lowe #define	T_NMIFLT	0x2	/*	NMI				*/
46*f0089e39SRichard Lowe #define	T_BPTFLT	0x3	/* #bp	breakpoint fault, INT3 insn	*/
47*f0089e39SRichard Lowe #define	T_OVFLW		0x4	/* #of	INTO overflow fault		*/
48*f0089e39SRichard Lowe #define	T_BOUNDFLT	0x5	/* #br	BOUND insn fault		*/
49*f0089e39SRichard Lowe #define	T_ILLINST	0x6	/* #ud	invalid opcode fault		*/
50*f0089e39SRichard Lowe #define	T_NOEXTFLT	0x7	/* #nm	device not available: x87	*/
51*f0089e39SRichard Lowe #define	T_DBLFLT	0x8	/* #df	double fault			*/
52*f0089e39SRichard Lowe #define	T_EXTOVRFLT	0x9	/*	[not generated: 386 only]	*/
53*f0089e39SRichard Lowe #define	T_TSSFLT	0xa	/* #ts	invalid TSS fault		*/
54*f0089e39SRichard Lowe #define	T_SEGFLT	0xb	/* #np	segment not present fault	*/
55*f0089e39SRichard Lowe #define	T_STKFLT	0xc	/* #ss	stack fault			*/
56*f0089e39SRichard Lowe #define	T_GPFLT		0xd	/* #gp	general protection fault	*/
57*f0089e39SRichard Lowe #define	T_PGFLT		0xe	/* #pf	page fault			*/
58*f0089e39SRichard Lowe #define	T_RESVTRAP	0xf	/*	reserved			*/
59*f0089e39SRichard Lowe #define	T_EXTERRFLT	0x10	/* #mf	x87 FPU error fault		*/
60*f0089e39SRichard Lowe #define	T_ALIGNMENT	0x11	/* #ac	alignment check error		*/
61*f0089e39SRichard Lowe #define	T_MCE		0x12	/* #mc	machine check exception		*/
62*f0089e39SRichard Lowe #define	T_SIMDFPE	0x13	/* #xm	SSE/SSE exception		*/
63*f0089e39SRichard Lowe #define	T_DBGENTR	0x14	/*	debugger entry			*/
64*f0089e39SRichard Lowe #define	T_INVALTRAP	0x1e	/*	invalid				*/
65*f0089e39SRichard Lowe #define	T_ENDPERR	0x21	/*	emulated extension error flt	*/
66*f0089e39SRichard Lowe #define	T_ENOEXTFLT	0x20	/*	emulated ext not present	*/
67*f0089e39SRichard Lowe #define	T_FASTTRAP	0xd2	/*	fast system call		*/
68*f0089e39SRichard Lowe #define	T_SYSCALLINT	0x91	/*	general system call		*/
69*f0089e39SRichard Lowe #define	T_DTRACE_RET	0x92	/*	DTrace pid return		*/
70*f0089e39SRichard Lowe #define	T_INT80		0x80	/*	int80 handler for linux emulation */
71*f0089e39SRichard Lowe #define	T_SOFTINT	0x50fd	/*	pseudo softint trap type	*/
72*f0089e39SRichard Lowe 
73*f0089e39SRichard Lowe /*
74*f0089e39SRichard Lowe  * Pseudo traps.
75*f0089e39SRichard Lowe  */
76*f0089e39SRichard Lowe #define	T_INTERRUPT		0x100
77*f0089e39SRichard Lowe #define	T_FAULT			0x200
78*f0089e39SRichard Lowe #define	T_AST			0x400
79*f0089e39SRichard Lowe #define	T_SYSCALL		0x180
80*f0089e39SRichard Lowe 
817c478bd9Sstevel@tonic-gate 
82*f0089e39SRichard Lowe /*
83*f0089e39SRichard Lowe  *  Values of error code on stack in case of page fault
84*f0089e39SRichard Lowe  */
85*f0089e39SRichard Lowe 
86*f0089e39SRichard Lowe #define	PF_ERR_MASK	0x01	/* Mask for error bit */
87*f0089e39SRichard Lowe #define	PF_ERR_PAGE	0x00	/* page not present */
88*f0089e39SRichard Lowe #define	PF_ERR_PROT	0x01	/* protection error */
89*f0089e39SRichard Lowe #define	PF_ERR_WRITE	0x02	/* fault caused by write (else read) */
90*f0089e39SRichard Lowe #define	PF_ERR_USER	0x04	/* processor was in user mode */
91*f0089e39SRichard Lowe 				/*	(else supervisor) */
92*f0089e39SRichard Lowe #define	PF_ERR_EXEC	0x10	/* attempt to execute a No eXec page (AMD) */
93*f0089e39SRichard Lowe 				/* or kernel tried to execute a user page  */
94*f0089e39SRichard Lowe 				/* (Intel SMEP) */
95*f0089e39SRichard Lowe 
96*f0089e39SRichard Lowe /*
97*f0089e39SRichard Lowe  *  Definitions for fast system call subfunctions
98*f0089e39SRichard Lowe  */
99*f0089e39SRichard Lowe #define	T_FNULL		0	/* Null trap for testing		*/
100*f0089e39SRichard Lowe #define	T_FGETFP	1	/* Get emulated FP context		*/
101*f0089e39SRichard Lowe #define	T_FSETFP	2	/* Set emulated FP context		*/
102*f0089e39SRichard Lowe #define	T_GETHRTIME	3	/* Get high resolution time		*/
103*f0089e39SRichard Lowe #define	T_GETHRVTIME	4	/* Get high resolution virtual time	*/
104*f0089e39SRichard Lowe #define	T_GETHRESTIME	5	/* Get high resolution time		*/
105*f0089e39SRichard Lowe #define	T_GETLGRP	6	/* Get home lgrpid			*/
106*f0089e39SRichard Lowe 
107*f0089e39SRichard Lowe #define	T_LASTFAST	6	/* Last valid subfunction		*/
108*f0089e39SRichard Lowe 
109*f0089e39SRichard Lowe /*
110*f0089e39SRichard Lowe  * Offsets for an interrupt/trap frame.
111*f0089e39SRichard Lowe  */
112*f0089e39SRichard Lowe #define	T_FRAME_ERR	0
113*f0089e39SRichard Lowe #define	T_FRAME_RIP	8
114*f0089e39SRichard Lowe #define	T_FRAME_CS	16
115*f0089e39SRichard Lowe #define	T_FRAME_RFLAGS	24
116*f0089e39SRichard Lowe #define	T_FRAME_RSP	32
117*f0089e39SRichard Lowe #define	T_FRAME_SS	40
1187c478bd9Sstevel@tonic-gate 
119*f0089e39SRichard Lowe #define	T_FRAMERET_RIP		0
120*f0089e39SRichard Lowe #define	T_FRAMERET_CS		8
121*f0089e39SRichard Lowe #define	T_FRAMERET_RFLAGS	16
122*f0089e39SRichard Lowe #define	T_FRAMERET_RSP		24
123*f0089e39SRichard Lowe #define	T_FRAMERET_SS		32
1247c478bd9Sstevel@tonic-gate 
125*f0089e39SRichard Lowe #ifdef	__cplusplus
126*f0089e39SRichard Lowe }
1277c478bd9Sstevel@tonic-gate #endif
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #endif	/* _SYS_TRAP_H */
130