xref: /titanic_52/usr/src/uts/intel/ia32/sys/psw.h (revision ae115bc77f6fcde83175c75b4206dc2e50747966)
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*ae115bc7Smrj  * Common Development and Distribution License (the "License").
6*ae115bc7Smrj  * 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  */
217c478bd9Sstevel@tonic-gate /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T   */
237c478bd9Sstevel@tonic-gate /*	  All Rights Reserved   */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate /*
26*ae115bc7Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
277c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef _IA32_SYS_PSW_H
317c478bd9Sstevel@tonic-gate #define	_IA32_SYS_PSW_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifndef _ASM
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /* Flags Register */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate typedef struct flags {
447c478bd9Sstevel@tonic-gate 	uint_t	fl_cf	:  1,		/* carry/borrow */
457c478bd9Sstevel@tonic-gate 			:  1,		/* reserved */
467c478bd9Sstevel@tonic-gate 		fl_pf	:  1,		/* parity */
477c478bd9Sstevel@tonic-gate 			:  1,		/* reserved */
487c478bd9Sstevel@tonic-gate 		fl_af	:  1,		/* carry/borrow */
497c478bd9Sstevel@tonic-gate 			:  1,		/* reserved */
507c478bd9Sstevel@tonic-gate 		fl_zf	:  1,		/* zero */
517c478bd9Sstevel@tonic-gate 		fl_sf	:  1,		/* sign */
527c478bd9Sstevel@tonic-gate 		fl_tf	:  1,		/* trace */
537c478bd9Sstevel@tonic-gate 		fl_if	:  1,		/* interrupt enable */
547c478bd9Sstevel@tonic-gate 		fl_df	:  1,		/* direction */
557c478bd9Sstevel@tonic-gate 		fl_of	:  1,		/* overflow */
567c478bd9Sstevel@tonic-gate 		fl_iopl :  2,		/* I/O privilege level */
577c478bd9Sstevel@tonic-gate 		fl_nt	:  1,		/* nested task */
587c478bd9Sstevel@tonic-gate 			:  1,		/* reserved */
597c478bd9Sstevel@tonic-gate 		fl_rf	:  1,		/* reset */
607c478bd9Sstevel@tonic-gate 		fl_vm	:  1,		/* virtual 86 mode */
617c478bd9Sstevel@tonic-gate 		fl_res	: 14;		/* reserved */
627c478bd9Sstevel@tonic-gate } flags_t;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #endif		/* !_ASM */
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate #define	PS_C		0x0001		/* carry bit			*/
67130a12b8Sfvdl #define	PS_MB1		0x0002		/* unused; must be 1.		*/
687c478bd9Sstevel@tonic-gate #define	PS_P		0x0004		/* parity bit			*/
697c478bd9Sstevel@tonic-gate #define	PS_AC		0x0010		/* auxiliary carry bit		*/
707c478bd9Sstevel@tonic-gate #define	PS_Z		0x0040		/* zero bit			*/
717c478bd9Sstevel@tonic-gate #define	PS_N		0x0080		/* negative bit			*/
727c478bd9Sstevel@tonic-gate #define	PS_T		0x0100		/* trace enable bit		*/
737c478bd9Sstevel@tonic-gate #define	PS_IE		0x0200		/* interrupt enable bit		*/
747c478bd9Sstevel@tonic-gate #define	PS_D		0x0400		/* direction bit		*/
757c478bd9Sstevel@tonic-gate #define	PS_V		0x0800		/* overflow bit			*/
767c478bd9Sstevel@tonic-gate #define	PS_IOPL		0x3000		/* I/O privilege level		*/
777c478bd9Sstevel@tonic-gate #define	PS_NT		0x4000		/* nested task flag		*/
787c478bd9Sstevel@tonic-gate #define	PS_RF		0x10000		/* restore flag			*/
797c478bd9Sstevel@tonic-gate #define	PS_VM		0x20000		/* virtual 86 mode flag		*/
807c478bd9Sstevel@tonic-gate #define	PS_ACHK		0x40000		/* alignment check enable (486) */
817c478bd9Sstevel@tonic-gate #define	PS_VINT		0x80000		/* virtual interrupt flag	*/
827c478bd9Sstevel@tonic-gate #define	PS_VINTP	0x100000	/* virtual interrupt pending	*/
837c478bd9Sstevel@tonic-gate #define	PS_ID		0x200000	/* ID flag			*/
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #define	PS_ICC		(PS_C|PS_AC|PS_Z|PS_N)	   /* integer condition codes */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #define	FMT_FLAGS_REG				\
887c478bd9Sstevel@tonic-gate 	"\20\26id\25vip\24vif\23ac\22vm\21rf"	\
897c478bd9Sstevel@tonic-gate 	"\17nt\14of\13df\12if\11tf\10sf\7zf\5af\3pf\1cf"
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #define	PSL_USER	0x202		/* initial user FLAGS */
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /* user variable PS bits */
947c478bd9Sstevel@tonic-gate #define	PSL_USERMASK	(PS_ICC|PS_D|PS_T|PS_V|PS_P|PS_ACHK|PS_NT)
957c478bd9Sstevel@tonic-gate 
96130a12b8Sfvdl /* PS bits changeable by the sahf instruction */
97130a12b8Sfvdl #define	PSL_LSAHFMASK	(PS_ICC|PS_P)
98130a12b8Sfvdl 
997c478bd9Sstevel@tonic-gate /*
1007c478bd9Sstevel@tonic-gate  * kernel flags settings
1017c478bd9Sstevel@tonic-gate  */
1027c478bd9Sstevel@tonic-gate #define	F_OFF		0x2		/* interrupts off */
1037c478bd9Sstevel@tonic-gate #define	F_ON		0x202		/* interrupts on */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate #ifndef _ASM
1067c478bd9Sstevel@tonic-gate typedef int	psw_t;
1077c478bd9Sstevel@tonic-gate #endif
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate #include <sys/tss.h>
1107c478bd9Sstevel@tonic-gate #include <sys/segments.h>			/* selector definitions */
1117c478bd9Sstevel@tonic-gate 
112*ae115bc7Smrj #define	USERMODE(cs)	((uint16_t)(cs) != KCS_SEL)
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #include <sys/spl.h>
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1177c478bd9Sstevel@tonic-gate }
1187c478bd9Sstevel@tonic-gate #endif
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #endif	/* _IA32_SYS_PSW_H */
121