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 567256803Srh * Common Development and Distribution License (the "License"). 667256803Srh * 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 /* 2267256803Srh * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 249d12795fSRobert Mustacchi * Copyright (c) 2015, Joyent, Inc. All rights reserved. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*b4203d75SMarcel Telka /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 327c478bd9Sstevel@tonic-gate * The Regents of the University of California 337c478bd9Sstevel@tonic-gate * All Rights Reserved 347c478bd9Sstevel@tonic-gate * 357c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 367c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 377c478bd9Sstevel@tonic-gate * contributors. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifndef _VM_VPAGE_H 417c478bd9Sstevel@tonic-gate #define _VM_VPAGE_H 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef __cplusplus 447c478bd9Sstevel@tonic-gate extern "C" { 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * VM - Information per virtual page. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate struct vpage { 517c478bd9Sstevel@tonic-gate uchar_t nvp_prot; /* see <sys/mman.h> prot flags */ 527c478bd9Sstevel@tonic-gate uchar_t nvp_advice; /* pplock & <sys/mman.h> madvise flags */ 537c478bd9Sstevel@tonic-gate }; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * This was changed from a bitfield to flags/macros in order 577c478bd9Sstevel@tonic-gate * to conserve space (uchar_t bitfields are not ANSI). This could 587c478bd9Sstevel@tonic-gate * have been condensed to a uchar_t, but at the expense of complexity. 599d12795fSRobert Mustacchi * We've stolen three bits from the top of nvp_advice: the first to store 609d12795fSRobert Mustacchi * pplock, the second to identify pages for which we have reserved 619d12795fSRobert Mustacchi * swap space, but have not necessarily allocated anon slots, and the third to 629d12795fSRobert Mustacchi * indicate that the page should be zeroed on fork. 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 */ 7067256803Srh #define VP_SWAPRES_MASK (0x40) /* Swap space has been reserved, but we */ 7167256803Srh /* might not have allocated an anon slot */ 729d12795fSRobert Mustacchi #define VP_INHZERO_MASK (0x20) /* zero page on fork() */ 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate #define VPP_PROT(vpp) ((vpp)->nvp_prot) 757c478bd9Sstevel@tonic-gate #define VPP_ADVICE(vpp) ((vpp)->nvp_advice & VP_ADVICE_MASK) 767c478bd9Sstevel@tonic-gate #define VPP_ISPPLOCK(vpp) \ 777c478bd9Sstevel@tonic-gate ((uchar_t)((vpp)->nvp_advice & VP_PPLOCK_MASK)) 7867256803Srh #define VPP_ISSWAPRES(vpp) \ 7967256803Srh ((uchar_t)((vpp)->nvp_advice & VP_SWAPRES_MASK)) 809d12795fSRobert Mustacchi #define VPP_ISINHZERO(vpp) \ 819d12795fSRobert Mustacchi ((uchar_t)((vpp)->nvp_advice & VP_INHZERO_MASK)) 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate #define VPP_SETPROT(vpp, x) ((vpp)->nvp_prot = (x)) 847c478bd9Sstevel@tonic-gate #define VPP_SETADVICE(vpp, x) \ 857c478bd9Sstevel@tonic-gate ((vpp)->nvp_advice = ((vpp)->nvp_advice & ~VP_ADVICE_MASK) | \ 867c478bd9Sstevel@tonic-gate ((x) & VP_ADVICE_MASK)) 877c478bd9Sstevel@tonic-gate #define VPP_SETPPLOCK(vpp) ((vpp)->nvp_advice |= VP_PPLOCK_MASK) 887c478bd9Sstevel@tonic-gate #define VPP_CLRPPLOCK(vpp) ((vpp)->nvp_advice &= ~VP_PPLOCK_MASK) 8967256803Srh #define VPP_SETSWAPRES(vpp) ((vpp)->nvp_advice |= VP_SWAPRES_MASK) 9067256803Srh #define VPP_CLRSWAPRES(vpp) ((vpp)->nvp_advice &= ~VP_SWAPRES_MASK) 919d12795fSRobert Mustacchi #define VPP_SETINHZERO(vpp) ((vpp)->nvp_advice |= VP_INHZERO_MASK) 929d12795fSRobert Mustacchi #define VPP_CLRINHZERO(vpp) ((vpp)->nvp_advice &= ~VP_INHZERO_MASK) 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #ifdef __cplusplus 957c478bd9Sstevel@tonic-gate } 967c478bd9Sstevel@tonic-gate #endif 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #endif /* _VM_VPAGE_H */ 99