xref: /titanic_41/usr/src/uts/intel/ia32/sys/psw.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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 2004 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_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 /*
97  * kernel flags settings
98  */
99 #define	F_OFF		0x2		/* interrupts off */
100 #define	F_ON		0x202		/* interrupts on */
101 
102 #ifndef _ASM
103 typedef int	psw_t;
104 #endif
105 
106 #include <sys/tss.h>
107 #include <sys/segments.h>			/* selector definitions */
108 
109 #define	USERMODE(cs)	((uint_t)((cs)&CPL_MASK) != 0)
110 
111 #include <sys/spl.h>
112 
113 #ifdef	__cplusplus
114 }
115 #endif
116 
117 #endif	/* _IA32_SYS_PSW_H */
118