xref: /illumos-gate/usr/src/uts/intel/sys/psw.h (revision 0ccfe5834c3b867c1b6c273cae02ec8922bc0fd2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T   */
23 /*	  All Rights Reserved   */
24 
25 /*
26  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 #ifndef _SYS_PSW_H
31 #define	_SYS_PSW_H
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #ifndef _ASM
38 
39 /* Flags Register */
40 
41 typedef struct flags {
42 	uint_t	fl_cf	:  1,		/* carry/borrow */
43 			:  1,		/* reserved */
44 		fl_pf	:  1,		/* parity */
45 			:  1,		/* reserved */
46 		fl_af	:  1,		/* carry/borrow */
47 			:  1,		/* reserved */
48 		fl_zf	:  1,		/* zero */
49 		fl_sf	:  1,		/* sign */
50 		fl_tf	:  1,		/* trace */
51 		fl_if	:  1,		/* interrupt enable */
52 		fl_df	:  1,		/* direction */
53 		fl_of	:  1,		/* overflow */
54 		fl_iopl :  2,		/* I/O privilege level */
55 		fl_nt	:  1,		/* nested task */
56 			:  1,		/* reserved */
57 		fl_rf	:  1,		/* reset */
58 		fl_vm	:  1,		/* virtual 86 mode */
59 		fl_res	: 14;		/* reserved */
60 } flags_t;
61 
62 #endif		/* !_ASM */
63 
64 #define	PS_C		0x0001		/* carry bit			*/
65 #define	PS_MB1		0x0002		/* unused; must be 1.		*/
66 #define	PS_P		0x0004		/* parity bit			*/
67 #define	PS_AC		0x0010		/* auxiliary carry bit		*/
68 #define	PS_Z		0x0040		/* zero bit			*/
69 #define	PS_N		0x0080		/* negative bit			*/
70 #define	PS_T		0x0100		/* trace enable bit		*/
71 #define	PS_IE		0x0200		/* interrupt enable bit		*/
72 #define	PS_D		0x0400		/* direction bit		*/
73 #define	PS_V		0x0800		/* overflow bit			*/
74 #define	PS_IOPL		0x3000		/* I/O privilege level		*/
75 #define	PS_NT		0x4000		/* nested task flag		*/
76 #define	PS_RF		0x10000		/* restore flag			*/
77 #define	PS_VM		0x20000		/* virtual 86 mode flag		*/
78 #define	PS_ACHK		0x40000		/* alignment check enable (486) */
79 #define	PS_VINT		0x80000		/* virtual interrupt flag	*/
80 #define	PS_VINTP	0x100000	/* virtual interrupt pending	*/
81 #define	PS_ID		0x200000	/* ID flag			*/
82 
83 #define	PS_ICC		(PS_C|PS_AC|PS_Z|PS_N)	   /* integer condition codes */
84 
85 #define	FMT_FLAGS_REG				\
86 	"\20\26id\25vip\24vif\23ac\22vm\21rf"	\
87 	"\17nt\14of\13df\12if\11tf\10sf\7zf\5af\3pf\1cf"
88 
89 #define	PSL_USER	0x202		/* initial user FLAGS */
90 
91 /* user variable PS bits */
92 #define	PSL_USERMASK	(PS_ICC|PS_D|PS_T|PS_V|PS_P|PS_ACHK|PS_NT)
93 
94 /* PS bits changeable by the sahf instruction */
95 #define	PSL_LSAHFMASK	(PS_ICC|PS_P)
96 
97 /*
98  * kernel flags settings
99  *
100  * Note that the kernel's SMAP protection relies on PS_ACHK not being present in
101  * the following two definitions. See uts/intel/ml/copy.s for more
102  * information on SMAP.
103  */
104 #define	F_OFF		0x2		/* interrupts off */
105 #define	F_ON		0x202		/* interrupts on */
106 
107 #ifndef _ASM
108 typedef int	psw_t;
109 #endif
110 
111 #include <sys/tss.h>
112 #include <sys/segments.h>			/* selector definitions */
113 
114 #define	USERMODE(cs)	((uint16_t)(cs) != KCS_SEL)
115 
116 #include <sys/spl.h>
117 
118 #ifdef	__cplusplus
119 }
120 #endif
121 
122 #endif	/* _SYS_PSW_H */
123