1 /* $OpenBSD: uvm_pmap.h,v 1.34 2024/04/03 18:43:32 miod Exp $ */ 2 /* $NetBSD: uvm_pmap.h,v 1.1 2000/06/27 09:00:14 mrg Exp $ */ 3 4 /* 5 * Copyright (c) 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * The Mach Operating System project at Carnegie-Mellon University. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)pmap.h 8.1 (Berkeley) 6/11/93 36 * 37 * 38 * Copyright (c) 1987, 1990 Carnegie-Mellon University. 39 * All rights reserved. 40 * 41 * Author: Avadis Tevanian, Jr. 42 * 43 * Permission to use, copy, modify and distribute this software and 44 * its documentation is hereby granted, provided that both the copyright 45 * notice and this permission notice appear in all copies of the 46 * software, derivative works or modified versions, and any portions 47 * thereof, and that both notices appear in supporting documentation. 48 * 49 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 50 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 51 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 52 * 53 * Carnegie Mellon requests users of this software to return to 54 * 55 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 56 * School of Computer Science 57 * Carnegie Mellon University 58 * Pittsburgh PA 15213-3890 59 * 60 * any improvements or extensions that they make and grant Carnegie the 61 * rights to redistribute these changes. 62 */ 63 64 /* 65 * Machine address mapping definitions -- machine-independent 66 * section. [For machine-dependent section, see "machine/pmap.h".] 67 */ 68 69 #ifndef _PMAP_VM_ 70 #define _PMAP_VM_ 71 72 struct proc; /* for pmap_activate()/pmap_deactivate() proto */ 73 74 /* 75 * Each machine dependent implementation is expected to 76 * keep certain statistics. They may do this anyway they 77 * so choose, but are expected to return the statistics 78 * in the following structure. 79 */ 80 struct pmap_statistics { 81 long resident_count; /* # of pages mapped (total)*/ 82 long wired_count; /* # of pages wired */ 83 }; 84 typedef struct pmap_statistics *pmap_statistics_t; 85 86 #include <machine/pmap.h> 87 88 /* 89 * Flags passed to pmap_enter(). Note the bottom 3 bits are PROT_* 90 * bits, used to indicate the access type that was made (to seed modified 91 * and referenced information). 92 */ 93 #define PMAP_WIRED 0x00000010 /* wired mapping */ 94 #define PMAP_CANFAIL 0x00000020 /* can fail if resource shortage */ 95 #define PMAP_MD0 0x00000040 /* Machine dependant */ 96 #define PMAP_MD1 0x00000080 /* Machine dependant */ 97 #define PMAP_MD2 0x00000100 /* Machine dependant */ 98 #define PMAP_MD3 0x00000200 /* Machine dependant */ 99 100 #ifndef PMAP_WC 101 #define PMAP_WC 0 102 #endif 103 104 #ifndef PMAP_PREFER 105 #define PMAP_PREFER_ALIGN() 0 106 #define PMAP_PREFER_OFFSET(off) 0 107 #endif 108 109 #ifdef _KERNEL 110 __BEGIN_DECLS 111 #ifndef pmap_activate 112 void pmap_activate(struct proc *); 113 #endif 114 #ifndef pmap_deactivate 115 void pmap_deactivate(struct proc *); 116 #endif 117 #ifndef pmap_unwire 118 void pmap_unwire(pmap_t, vaddr_t); 119 #endif 120 121 #if !defined(pmap_clear_modify) 122 boolean_t pmap_clear_modify(struct vm_page *); 123 #endif 124 #if !defined(pmap_clear_reference) 125 boolean_t pmap_clear_reference(struct vm_page *); 126 #endif 127 128 #if !defined(pmap_collect) && defined(__HAVE_PMAP_COLLECT) 129 void pmap_collect(pmap_t); 130 #endif 131 #if !defined(pmap_copy_page) 132 void pmap_copy_page(struct vm_page *, struct vm_page *); 133 #endif 134 struct pmap *pmap_create(void); 135 void pmap_destroy(pmap_t); 136 int pmap_enter(pmap_t, 137 vaddr_t, paddr_t, vm_prot_t, int); 138 boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *); 139 #if defined(PMAP_GROWKERNEL) 140 vaddr_t pmap_growkernel(vaddr_t); 141 #endif 142 143 void pmap_init(void); 144 145 void pmap_kenter_pa(vaddr_t, paddr_t, vm_prot_t); 146 void pmap_kremove(vaddr_t, vsize_t); 147 #if !defined(pmap_is_modified) 148 boolean_t pmap_is_modified(struct vm_page *); 149 #endif 150 #if !defined(pmap_is_referenced) 151 boolean_t pmap_is_referenced(struct vm_page *); 152 #endif 153 154 void pmap_page_protect(struct vm_page *, vm_prot_t); 155 156 #if !defined(pmap_proc_iflush) 157 void pmap_proc_iflush(struct process *, vaddr_t, vsize_t); 158 #endif 159 void pmap_protect(pmap_t, vaddr_t, vaddr_t, vm_prot_t); 160 #if !defined(pmap_reference) 161 void pmap_reference(pmap_t); 162 #endif 163 #if !defined(pmap_remove) 164 void pmap_remove(pmap_t, vaddr_t, vaddr_t); 165 #endif 166 #if !defined(pmap_remove_holes) 167 void pmap_remove_holes(struct vmspace *); 168 #endif 169 #if !defined(pmap_update) 170 void pmap_update(pmap_t); 171 #endif 172 #if !defined(pmap_zero_page) 173 void pmap_zero_page(struct vm_page *); 174 #endif 175 176 #if defined(PMAP_STEAL_MEMORY) 177 vaddr_t pmap_steal_memory(vsize_t, vaddr_t *, vaddr_t *); 178 #else 179 void pmap_virtual_space(vaddr_t *, vaddr_t *); 180 #endif 181 182 /* nested pmaps are used in i386/amd64 vmm */ 183 #ifndef pmap_nested 184 #define pmap_nested(pm) 0 185 #endif 186 187 __END_DECLS 188 #endif /* kernel*/ 189 190 #endif /* _PMAP_VM_ */ 191