xref: /onnv-gate/usr/src/uts/common/vm/vpage.h (revision 6517:dc84548e930e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*6517Srh87107  * Common Development and Distribution License (the "License").
6*6517Srh87107  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*6517Srh87107  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
310Sstevel@tonic-gate  * The Regents of the University of California
320Sstevel@tonic-gate  * All Rights Reserved
330Sstevel@tonic-gate  *
340Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
350Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
360Sstevel@tonic-gate  * contributors.
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifndef	_VM_VPAGE_H
400Sstevel@tonic-gate #define	_VM_VPAGE_H
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #ifdef	__cplusplus
450Sstevel@tonic-gate extern "C" {
460Sstevel@tonic-gate #endif
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * VM - Information per virtual page.
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate struct vpage {
520Sstevel@tonic-gate 	uchar_t nvp_prot;	/* see <sys/mman.h> prot flags */
530Sstevel@tonic-gate 	uchar_t nvp_advice;	/* pplock & <sys/mman.h> madvise flags */
540Sstevel@tonic-gate };
550Sstevel@tonic-gate 
560Sstevel@tonic-gate /*
570Sstevel@tonic-gate  * This was changed from a bitfield to flags/macros in order
580Sstevel@tonic-gate  * to conserve space (uchar_t bitfields are not ANSI).  This could
590Sstevel@tonic-gate  * have been condensed to a uchar_t, but at the expense of complexity.
60*6517Srh87107  * We've stolen two bits from the top of nvp_advice: the first to store
61*6517Srh87107  * pplock, and the second to identify pages for which we have reserved
62*6517Srh87107  * swap space, but have not necessarily allocated anon slots.
630Sstevel@tonic-gate  *
640Sstevel@tonic-gate  * WARNING: VPP_SETADVICE(vpp, x) evaluates vpp twice, and VPP_PLOCK(vpp)
650Sstevel@tonic-gate  * returns a positive integer when the lock is held, not necessarily (1).
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate #define	VP_ADVICE_MASK	(0x07)
680Sstevel@tonic-gate #define	VP_PPLOCK_MASK	(0x80)	/* physical page locked by me */
690Sstevel@tonic-gate #define	VP_PPLOCK_SHIFT	(0x07)	/* offset of lock hiding inside nvp_advice */
70*6517Srh87107 #define	VP_SWAPRES_MASK	(0x40)	/* Swap space has been reserved, but we */
71*6517Srh87107 				/* might not have allocated an anon slot */
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #define	VPP_PROT(vpp)	((vpp)->nvp_prot)
740Sstevel@tonic-gate #define	VPP_ADVICE(vpp)	((vpp)->nvp_advice & VP_ADVICE_MASK)
750Sstevel@tonic-gate #define	VPP_ISPPLOCK(vpp) \
760Sstevel@tonic-gate 	((uchar_t)((vpp)->nvp_advice & VP_PPLOCK_MASK))
77*6517Srh87107 #define	VPP_ISSWAPRES(vpp) \
78*6517Srh87107 	((uchar_t)((vpp)->nvp_advice & VP_SWAPRES_MASK))
790Sstevel@tonic-gate 
800Sstevel@tonic-gate #define	VPP_SETPROT(vpp, x)	((vpp)->nvp_prot = (x))
810Sstevel@tonic-gate #define	VPP_SETADVICE(vpp, x) \
820Sstevel@tonic-gate 	((vpp)->nvp_advice = ((vpp)->nvp_advice & ~VP_ADVICE_MASK) | \
830Sstevel@tonic-gate 		((x) & VP_ADVICE_MASK))
840Sstevel@tonic-gate #define	VPP_SETPPLOCK(vpp)	((vpp)->nvp_advice |= VP_PPLOCK_MASK)
850Sstevel@tonic-gate #define	VPP_CLRPPLOCK(vpp)	((vpp)->nvp_advice &= ~VP_PPLOCK_MASK)
86*6517Srh87107 #define	VPP_SETSWAPRES(vpp)	((vpp)->nvp_advice |= VP_SWAPRES_MASK)
87*6517Srh87107 #define	VPP_CLRSWAPRES(vpp)	((vpp)->nvp_advice &= ~VP_SWAPRES_MASK)
880Sstevel@tonic-gate 
890Sstevel@tonic-gate #ifdef	__cplusplus
900Sstevel@tonic-gate }
910Sstevel@tonic-gate #endif
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #endif	/* _VM_VPAGE_H */
94