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*67256803Srh87107 * Common Development and Distribution License (the "License"). 6*67256803Srh87107 * 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 /* 22*67256803Srh87107 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 317c478bd9Sstevel@tonic-gate * The Regents of the University of California 327c478bd9Sstevel@tonic-gate * All Rights Reserved 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 357c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 367c478bd9Sstevel@tonic-gate * contributors. 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifndef _VM_VPAGE_H 407c478bd9Sstevel@tonic-gate #define _VM_VPAGE_H 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #ifdef __cplusplus 457c478bd9Sstevel@tonic-gate extern "C" { 467c478bd9Sstevel@tonic-gate #endif 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * VM - Information per virtual page. 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate struct vpage { 527c478bd9Sstevel@tonic-gate uchar_t nvp_prot; /* see <sys/mman.h> prot flags */ 537c478bd9Sstevel@tonic-gate uchar_t nvp_advice; /* pplock & <sys/mman.h> madvise flags */ 547c478bd9Sstevel@tonic-gate }; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * This was changed from a bitfield to flags/macros in order 587c478bd9Sstevel@tonic-gate * to conserve space (uchar_t bitfields are not ANSI). This could 597c478bd9Sstevel@tonic-gate * have been condensed to a uchar_t, but at the expense of complexity. 60*67256803Srh87107 * We've stolen two bits from the top of nvp_advice: the first to store 61*67256803Srh87107 * pplock, and the second to identify pages for which we have reserved 62*67256803Srh87107 * swap space, but have not necessarily allocated anon slots. 637c478bd9Sstevel@tonic-gate * 647c478bd9Sstevel@tonic-gate * WARNING: VPP_SETADVICE(vpp, x) evaluates vpp twice, and VPP_PLOCK(vpp) 657c478bd9Sstevel@tonic-gate * returns a positive integer when the lock is held, not necessarily (1). 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate #define VP_ADVICE_MASK (0x07) 687c478bd9Sstevel@tonic-gate #define VP_PPLOCK_MASK (0x80) /* physical page locked by me */ 697c478bd9Sstevel@tonic-gate #define VP_PPLOCK_SHIFT (0x07) /* offset of lock hiding inside nvp_advice */ 70*67256803Srh87107 #define VP_SWAPRES_MASK (0x40) /* Swap space has been reserved, but we */ 71*67256803Srh87107 /* might not have allocated an anon slot */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #define VPP_PROT(vpp) ((vpp)->nvp_prot) 747c478bd9Sstevel@tonic-gate #define VPP_ADVICE(vpp) ((vpp)->nvp_advice & VP_ADVICE_MASK) 757c478bd9Sstevel@tonic-gate #define VPP_ISPPLOCK(vpp) \ 767c478bd9Sstevel@tonic-gate ((uchar_t)((vpp)->nvp_advice & VP_PPLOCK_MASK)) 77*67256803Srh87107 #define VPP_ISSWAPRES(vpp) \ 78*67256803Srh87107 ((uchar_t)((vpp)->nvp_advice & VP_SWAPRES_MASK)) 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #define VPP_SETPROT(vpp, x) ((vpp)->nvp_prot = (x)) 817c478bd9Sstevel@tonic-gate #define VPP_SETADVICE(vpp, x) \ 827c478bd9Sstevel@tonic-gate ((vpp)->nvp_advice = ((vpp)->nvp_advice & ~VP_ADVICE_MASK) | \ 837c478bd9Sstevel@tonic-gate ((x) & VP_ADVICE_MASK)) 847c478bd9Sstevel@tonic-gate #define VPP_SETPPLOCK(vpp) ((vpp)->nvp_advice |= VP_PPLOCK_MASK) 857c478bd9Sstevel@tonic-gate #define VPP_CLRPPLOCK(vpp) ((vpp)->nvp_advice &= ~VP_PPLOCK_MASK) 86*67256803Srh87107 #define VPP_SETSWAPRES(vpp) ((vpp)->nvp_advice |= VP_SWAPRES_MASK) 87*67256803Srh87107 #define VPP_CLRSWAPRES(vpp) ((vpp)->nvp_advice &= ~VP_SWAPRES_MASK) 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #ifdef __cplusplus 907c478bd9Sstevel@tonic-gate } 917c478bd9Sstevel@tonic-gate #endif 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate #endif /* _VM_VPAGE_H */ 94