uvm.h revision 1.70
1/* $OpenBSD: uvm.h,v 1.70 2022/09/29 04:10:27 deraadt Exp $ */ 2/* $NetBSD: uvm.h,v 1.24 2000/11/27 08:40:02 chs Exp $ */ 3 4/* 5 * Copyright (c) 1997 Charles D. Cranor and Washington University. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * from: Id: uvm.h,v 1.1.2.14 1998/02/02 20:07:19 chuck Exp 29 */ 30 31#ifndef _UVM_UVM_H_ 32#define _UVM_UVM_H_ 33 34#include <uvm/uvm_extern.h> 35#include <uvm/uvm_amap.h> 36#include <uvm/uvm_aobj.h> 37#include <uvm/uvm_fault.h> 38#include <uvm/uvm_glue.h> 39#include <uvm/uvm_km.h> 40#include <uvm/uvm_swap.h> 41 42#include <uvm/uvm_pmemrange.h> 43 44/* 45 * uvm structure (vm global state: collected in one structure for ease 46 * of reference...) 47 * 48 * Locks used to protect struct members in this file: 49 * Q uvm.pageqlock 50 */ 51struct uvm { 52 /* vm_page related parameters */ 53 54 /* vm_page queues */ 55 struct pglist page_active; /* [Q] allocated pages, in use */ 56 struct pglist page_inactive; /* [Q] pages inactive (reclaim/free) */ 57 /* Lock order: pageqlock, then fpageqlock. */ 58 struct mutex pageqlock; /* [] lock for active/inactive page q */ 59 struct mutex fpageqlock; /* [] lock for free page q + pdaemon */ 60 boolean_t page_init_done; /* TRUE if uvm_page_init() finished */ 61 struct uvm_pmr_control pmr_control; /* pmemrange data */ 62 63 /* page daemon trigger */ 64 int pagedaemon; /* daemon sleeps on this */ 65 struct proc *pagedaemon_proc; /* daemon's pid */ 66 67 /* aiodone daemon trigger */ 68 int aiodoned; /* daemon sleeps on this */ 69 struct proc *aiodoned_proc; /* daemon's pid */ 70 struct mutex aiodoned_lock; 71 72 /* static kernel map entry pool */ 73 SLIST_HEAD(, vm_map_entry) kentry_free; /* free page pool */ 74 75 /* aio_done is locked by uvm.aiodoned_lock. */ 76 TAILQ_HEAD(, buf) aio_done; /* done async i/o reqs */ 77 78 /* kernel object: to support anonymous pageable kernel memory */ 79 struct uvm_object *kernel_object; 80}; 81 82/* 83 * vm_map_entry etype bits: 84 */ 85#define UVM_ET_OBJ 0x0001 /* it is a uvm_object */ 86#define UVM_ET_SUBMAP 0x0002 /* it is a vm_map submap */ 87#define UVM_ET_COPYONWRITE 0x0004 /* copy_on_write */ 88#define UVM_ET_NEEDSCOPY 0x0008 /* needs_copy */ 89#define UVM_ET_HOLE 0x0010 /* no backend */ 90#define UVM_ET_NOFAULT 0x0020 /* don't fault */ 91#define UVM_ET_STACK 0x0040 /* this is a stack */ 92#define UVM_ET_WC 0x0080 /* write combining */ 93#define UVM_ET_CONCEAL 0x0100 /* omit from dumps */ 94#define UVM_ET_SYSCALL 0x0200 /* syscall text segment */ 95#define UVM_ET_FREEMAPPED 0x8000 /* map entry is on free list (DEBUG) */ 96 97#define UVM_ET_ISOBJ(E) (((E)->etype & UVM_ET_OBJ) != 0) 98#define UVM_ET_ISSUBMAP(E) (((E)->etype & UVM_ET_SUBMAP) != 0) 99#define UVM_ET_ISCOPYONWRITE(E) (((E)->etype & UVM_ET_COPYONWRITE) != 0) 100#define UVM_ET_ISNEEDSCOPY(E) (((E)->etype & UVM_ET_NEEDSCOPY) != 0) 101#define UVM_ET_ISHOLE(E) (((E)->etype & UVM_ET_HOLE) != 0) 102#define UVM_ET_ISNOFAULT(E) (((E)->etype & UVM_ET_NOFAULT) != 0) 103#define UVM_ET_ISSTACK(E) (((E)->etype & UVM_ET_STACK) != 0) 104#define UVM_ET_ISWC(E) (((E)->etype & UVM_ET_WC) != 0) 105#define UVM_ET_ISCONCEAL(E) (((E)->etype & UVM_ET_CONCEAL) != 0) 106 107#ifdef _KERNEL 108 109/* 110 * holds all the internal UVM data 111 */ 112extern struct uvm uvm; 113 114/* 115 * UVM_PAGE_OWN: track page ownership (only if UVM_PAGE_TRKOWN) 116 */ 117 118#if defined(UVM_PAGE_TRKOWN) 119#define UVM_PAGE_OWN(PG, TAG) uvm_page_own(PG, TAG) 120#else 121#define UVM_PAGE_OWN(PG, TAG) /* nothing */ 122#endif /* UVM_PAGE_TRKOWN */ 123 124/* 125 * uvm_map internal functions. 126 * Used by uvm_map address selectors. 127 */ 128struct vm_map_entry *uvm_map_entrybyaddr(struct uvm_map_addr *, vaddr_t); 129int uvm_map_isavail(struct vm_map *, 130 struct uvm_addr_state *, 131 struct vm_map_entry **, struct vm_map_entry**, 132 vaddr_t, vsize_t); 133struct uvm_addr_state *uvm_map_uaddr(struct vm_map *, vaddr_t); 134struct uvm_addr_state *uvm_map_uaddr_e(struct vm_map *, struct vm_map_entry *); 135 136#define VMMAP_FREE_START(_entry) ((_entry)->end + (_entry)->guard) 137#define VMMAP_FREE_END(_entry) ((_entry)->end + (_entry)->guard + \ 138 (_entry)->fspace) 139 140#endif /* _KERNEL */ 141 142#endif /* _UVM_UVM_H_ */ 143