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