/*-1* SPDX-License-Identifier: (BSD-3-Clause AND MIT-CMU)2*3* Copyright (c) 1991, 19934* The Regents of the University of California. All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. Neither the name of the University nor the names of its contributors15* may be used to endorse or promote products derived from this software16* without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*30* Copyright (c) 1987, 1990 Carnegie-Mellon University.31* All rights reserved.32*33* Authors: Avadis Tevanian, Jr., Michael Wayne Young34*35* Permission to use, copy, modify and distribute this software and36* its documentation is hereby granted, provided that both the copyright37* notice and this permission notice appear in all copies of the38* software, derivative works or modified versions, and any portions39* thereof, and that both notices appear in supporting documentation.40*41* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"42* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND43* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.44*45* Carnegie Mellon requests users of this software to return to46*47* Software Distribution Coordinator or [email protected]48* School of Computer Science49* Carnegie Mellon University50* Pittsburgh PA 15213-389051*52* any improvements or extensions that they make and grant Carnegie the53* rights to redistribute these changes.54*/5556#ifndef VM_H57#define VM_H5859#include <machine/vm.h>6061typedef char vm_inherit_t; /* inheritance codes */6263#define VM_INHERIT_SHARE ((vm_inherit_t) 0)64#define VM_INHERIT_COPY ((vm_inherit_t) 1)65#define VM_INHERIT_NONE ((vm_inherit_t) 2)66#define VM_INHERIT_ZERO ((vm_inherit_t) 3)67#define VM_INHERIT_DEFAULT VM_INHERIT_COPY6869typedef u_char vm_prot_t; /* protection codes */7071#define VM_PROT_NONE ((vm_prot_t) 0x00)72#define VM_PROT_READ ((vm_prot_t) 0x01)73#define VM_PROT_WRITE ((vm_prot_t) 0x02)74#define VM_PROT_EXECUTE ((vm_prot_t) 0x04)75#define VM_PROT_COPY ((vm_prot_t) 0x08) /* copy-on-read */76#define VM_PROT_PRIV_FLAG ((vm_prot_t) 0x10)77#define VM_PROT_FAULT_LOOKUP VM_PROT_PRIV_FLAG78#define VM_PROT_NO_PROMOTE VM_PROT_PRIV_FLAG79#define VM_PROT_QUICK_NOFAULT VM_PROT_PRIV_FLAG /* same to save bits */8081#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)82#define VM_PROT_RW (VM_PROT_READ|VM_PROT_WRITE)83#define VM_PROT_DEFAULT VM_PROT_ALL8485enum obj_type {86OBJT_RESERVED = 0, /* was OBJT_DEFAULT */87OBJT_SWAP,88OBJT_DEFAULT = OBJT_SWAP,89OBJT_VNODE,90OBJT_DEVICE,91OBJT_PHYS,92OBJT_DEAD,93OBJT_SG,94OBJT_MGTDEVICE,95OBJT_FIRST_DYN,96};97typedef u_char objtype_t;9899union vm_map_object;100typedef union vm_map_object vm_map_object_t;101102struct vm_map_entry;103typedef struct vm_map_entry *vm_map_entry_t;104105struct vm_map;106typedef struct vm_map *vm_map_t;107108struct vm_object;109typedef struct vm_object *vm_object_t;110111#ifndef _KERNEL112/*113* This is defined in <sys/types.h> for the kernel so that non-vm kernel114* sources (mainly Mach-derived ones such as ddb) don't have to include115* vm stuff. Defining it there for applications might break things.116* Define it here for "applications" that include vm headers (e.g.,117* genassym).118*/119#ifndef HAVE_BOOLEAN120typedef int boolean_t;121#endif122123/*124* The exact set of memory attributes is machine dependent. However,125* every machine is required to define VM_MEMATTR_DEFAULT and126* VM_MEMATTR_UNCACHEABLE.127*/128typedef char vm_memattr_t; /* memory attribute codes */129130/*131* This is defined in <sys/types.h> for the kernel so that vnode_if.h132* doesn't have to include <vm/vm.h>.133*/134struct vm_page;135typedef struct vm_page *vm_page_t;136#endif /* _KERNEL */137138struct vm_reserv;139typedef struct vm_reserv *vm_reserv_t;140141/*142* Information passed from the machine-independent VM initialization code143* for use by machine-dependant code (mainly for MMU support)144*/145struct kva_md_info {146vm_offset_t buffer_sva;147vm_offset_t buffer_eva;148vm_offset_t clean_sva;149vm_offset_t clean_eva;150};151152/* bits from overcommit */153#define SWAP_RESERVE_FORCE_ON (1 << 0)154#define SWAP_RESERVE_RLIMIT_ON (1 << 1)155#define SWAP_RESERVE_ALLOW_NONWIRED (1 << 2)156157#ifdef NUMA158#define __numa_used159#else160#define __numa_used __unused161#endif162163#ifdef _KERNEL164struct ucred;165166void vm_ksubmap_init(struct kva_md_info *);167bool swap_reserve(vm_ooffset_t incr);168bool swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred);169void swap_reserve_force(vm_ooffset_t incr);170void swap_release(vm_ooffset_t decr);171void swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred);172173extern struct kva_md_info kmi;174#define VA_IS_CLEANMAP(va) \175((va) >= kmi.clean_sva && (va) < kmi.clean_eva)176177extern int old_mlock;178extern int vm_ndomains;179extern int vm_overcommit;180#endif /* _KERNEL */181182#endif /* VM_H */183184185