xref: /titanic_52/usr/src/uts/intel/ia32/sys/psw.h (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
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 _IA32_SYS_PSW_H
31 #define	_IA32_SYS_PSW_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #ifndef _ASM
40 
41 /* Flags Register */
42 
43 typedef struct flags {
44 	uint_t	fl_cf	:  1,		/* carry/borrow */
45 			:  1,		/* reserved */
46 		fl_pf	:  1,		/* parity */
47 			:  1,		/* reserved */
48 		fl_af	:  1,		/* carry/borrow */
49 			:  1,		/* reserved */
50 		fl_zf	:  1,		/* zero */
51 		fl_sf	:  1,		/* sign */
52 		fl_tf	:  1,		/* trace */
53 		fl_if	:  1,		/* interrupt enable */
54 		fl_df	:  1,		/* direction */
55 		fl_of	:  1,		/* overflow */
56 		fl_iopl :  2,		/* I/O privilege level */
57 		fl_nt	:  1,		/* nested task */
58 			:  1,		/* reserved */
59 		fl_rf	:  1,		/* reset */
60 		fl_vm	:  1,		/* virtual 86 mode */
61 		fl_res	: 14;		/* reserved */
62 } flags_t;
63 
64 #endif		/* !_ASM */
65 
66 #define	PS_C		0x0001		/* carry bit			*/
67 #define	PS_MB1		0x0002		/* unused; must be 1.		*/
68 #define	PS_P		0x0004		/* parity bit			*/
69 #define	PS_AC		0x0010		/* auxiliary carry bit		*/
70 #define	PS_Z		0x0040		/* zero bit			*/
71 #define	PS_N		0x0080		/* negative bit			*/
72 #define	PS_T		0x0100		/* trace enable bit		*/
73 #define	PS_IE		0x0200		/* interrupt enable bit		*/
74 #define	PS_D		0x0400		/* direction bit		*/
75 #define	PS_V		0x0800		/* overflow bit			*/
76 #define	PS_IOPL		0x3000		/* I/O privilege level		*/
77 #define	PS_NT		0x4000		/* nested task flag		*/
78 #define	PS_RF		0x10000		/* restore flag			*/
79 #define	PS_VM		0x20000		/* virtual 86 mode flag		*/
80 #define	PS_ACHK		0x40000		/* alignment check enable (486) */
81 #define	PS_VINT		0x80000		/* virtual interrupt flag	*/
82 #define	PS_VINTP	0x100000	/* virtual interrupt pending	*/
83 #define	PS_ID		0x200000	/* ID flag			*/
84 
85 #define	PS_ICC		(PS_C|PS_AC|PS_Z|PS_N)	   /* integer condition codes */
86 
87 #define	FMT_FLAGS_REG				\
88 	"\20\26id\25vip\24vif\23ac\22vm\21rf"	\
89 	"\17nt\14of\13df\12if\11tf\10sf\7zf\5af\3pf\1cf"
90 
91 #define	PSL_USER	0x202		/* initial user FLAGS */
92 
93 /* user variable PS bits */
94 #define	PSL_USERMASK	(PS_ICC|PS_D|PS_T|PS_V|PS_P|PS_ACHK|PS_NT)
95 
96 /* PS bits changeable by the sahf instruction */
97 #define	PSL_LSAHFMASK	(PS_ICC|PS_P)
98 
99 /*
100  * kernel flags settings
101  */
102 #define	F_OFF		0x2		/* interrupts off */
103 #define	F_ON		0x202		/* interrupts on */
104 
105 #ifndef _ASM
106 typedef int	psw_t;
107 #endif
108 
109 #include <sys/tss.h>
110 #include <sys/segments.h>			/* selector definitions */
111 
112 #define	USERMODE(cs)	((uint16_t)(cs) != KCS_SEL)
113 
114 #include <sys/spl.h>
115 
116 #ifdef	__cplusplus
117 }
118 #endif
119 
120 #endif	/* _IA32_SYS_PSW_H */
121