sys/vm/pmap.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | /* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * The Mach Operating System project at Carnegie-Mellon University. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: @(#)pmap.h 8.1 (Berkeley) 6/11/93 * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. * * Author: Avadis Tevanian, Jr. * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/pmap.h,v 1.33.2.4 2002/03/06 22:44:24 silby Exp $ */ /* * Machine address mapping definitions -- machine-independent * section. [For machine-dependent section, see "machine/pmap.h".] */ #ifndef _VM_PMAP_H_ #define _VM_PMAP_H_ #ifndef _SYS_TYPES_H_ #include <sys/types.h> #endif #ifndef _SYS_SPINLOCK_H_ #include <sys/spinlock.h> #endif #ifndef _MACHINE_PMAP_H_ #include <machine/pmap.h> #endif #ifdef _KERNEL #ifndef _VM_VM_H_ #include <vm/vm.h> #endif struct lwp; struct proc; struct thread; struct vm_page; struct vmspace; struct vmspace_entry; struct vm_map_entry; struct pmap_pgscan_info { struct pmap *pmap; vm_offset_t beg_addr; vm_offset_t end_addr; vm_offset_t offset; vm_pindex_t limit; vm_pindex_t busycount; vm_pindex_t cleancount; vm_pindex_t actioncount; int (*callback)(struct pmap_pgscan_info *, vm_offset_t va, struct vm_page *); }; typedef struct vm_phystable { vm_paddr_t phys_beg; vm_paddr_t phys_end; uint32_t flags; uint32_t affinity; } vm_phystable_t; /* * Most of these variables represent parameters set up by low level MD kernel * boot code to be used by higher level MI initialization code to identify * the portions of kernel and physical memory which are free for allocation. * * KvaStart/KvaEnd/ - Reserved Kernel Virtual Memory address space. * KvaSize This range represents the entire KVA space but * might omit certain special mapping areas. It is * used to determine what kernel memory userland has * access to. * * DMapMaxAddress - Maximum virtual address for DMap (not physical addr). * We do not allocate the entire space from * DMAP_MIN_ADDRESS to DMAP_MAX_ADDRESS. * * virtual_{start,end} - KVA space available for allocation, not including * KVA space reserved during MD startup. Used by * the KMEM subsystem, used to initialize kernel_map. * * phys_avail[] - Array of {start,end} physical addresses, not * including physical memory allocated by MD startup * code. Used to initialize the VM subsystem. */ extern vm_offset_t KvaStart; extern vm_offset_t KvaEnd; extern vm_offset_t KvaSize; extern vm_offset_t DMapMaxAddress; extern vm_offset_t virtual_start; extern vm_offset_t virtual_end; extern vm_offset_t virtual2_start; extern vm_offset_t virtual2_end; extern vm_phystable_t phys_avail[]; extern vm_phystable_t dump_avail[]; /* * High-level pmap scan */ void pmap_pgscan(struct pmap_pgscan_info *info); /* * Return true if the passed address is in the kernel address space. * This is mainly a check that the address is NOT in the user address space. * * For a vkernels all addresses are in the kernel address space. */ static inline int kva_p(const void *addr) { #ifdef _KERNEL_VIRTUAL return (addr != NULL); #else return ((unsigned long)KvaStart <= (unsigned long)addr) && ((unsigned long)addr < (unsigned long)KvaEnd); #endif } vm_page_t pmap_unwire (pmap_t, vm_offset_t *); void pmap_clear_modify (struct vm_page *m); void pmap_clear_reference (struct vm_page *m); void pmap_collect (void); void pmap_copy (pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t); void pmap_copy_page (vm_paddr_t, vm_paddr_t); void pmap_copy_page_frag (vm_paddr_t, vm_paddr_t, size_t bytes); void pmap_enter (pmap_t, vm_offset_t, struct vm_page *, vm_prot_t, boolean_t, struct vm_map_entry *); void pmap_maybethreaded(pmap_t); int pmap_mapped_sync(vm_page_t m); vm_page_t pmap_fault_page_quick(pmap_t, vm_offset_t, vm_prot_t, int *); vm_paddr_t pmap_extract (pmap_t pmap, vm_offset_t va, void **handlep); void pmap_extract_done (void *handle); void pmap_growkernel (vm_offset_t, vm_offset_t); void pmap_init (void); boolean_t pmap_is_modified (struct vm_page *m); int pmap_ts_referenced (struct vm_page *m); vm_offset_t pmap_map (vm_offset_t *, vm_paddr_t, vm_paddr_t, int); void pmap_object_init_pt (pmap_t pmap, struct vm_map_entry *entry, vm_offset_t addr, vm_offset_t size, int pagelimit); void pmap_page_protect (struct vm_page *m, vm_prot_t prot); void pmap_page_init (struct vm_page *m); vm_paddr_t uservtophys(vm_offset_t va); vm_paddr_t pmap_phys_address (vm_pindex_t); void pmap_pinit (pmap_t); void pmap_puninit (pmap_t); void pmap_pinit0 (pmap_t); void pmap_pinit2 (pmap_t); void pmap_ept_transform (pmap_t, int); void pmap_npt_transform (pmap_t, int); void pmap_protect (pmap_t, vm_offset_t, vm_offset_t, vm_prot_t); void pmap_remove_specific (pmap_t, vm_page_t); void pmap_qenter (vm_offset_t, struct vm_page **, int); void pmap_qenter_noinval (vm_offset_t, struct vm_page **, int); void pmap_qremove (vm_offset_t, int); void pmap_qremove_quick (vm_offset_t, int); void pmap_qremove_noinval (vm_offset_t, int); void pmap_kenter (vm_offset_t, vm_paddr_t); int pmap_kenter_quick (vm_offset_t, vm_paddr_t); int pmap_kenter_noinval (vm_offset_t, vm_paddr_t); void pmap_kmodify_rw(vm_offset_t va); void pmap_kmodify_nc(vm_offset_t va); void pmap_kremove (vm_offset_t); void pmap_kremove_quick (vm_offset_t); void pmap_kremove_noinval (vm_offset_t); void pmap_reference (pmap_t); void pmap_remove (pmap_t, vm_offset_t, vm_offset_t); void pmap_remove_pages (pmap_t, vm_offset_t, vm_offset_t); void pmap_zero_page (vm_paddr_t); void pmap_zero_page_area (vm_paddr_t, int off, int size); int pmap_prefault_ok (pmap_t, vm_offset_t); void pmap_change_attr(vm_offset_t va, vm_size_t count, int mode); int pmap_mincore (pmap_t pmap, vm_offset_t addr); void pmap_init_proc (struct proc *); void pmap_init_thread (struct thread *td); void pmap_replacevm (struct proc *, struct vmspace *, int); void pmap_setlwpvm (struct lwp *, struct vmspace *); vm_paddr_t pmap_kextract(vm_offset_t); void pmap_invalidate_range(pmap_t, vm_offset_t, vm_offset_t); void pmap_add_cpu(struct vmspace *vm, int cpuid); void pmap_del_cpu(struct vmspace *vm, int cpuid); void pmap_del_all_cpus(struct vmspace *vm); vm_offset_t pmap_addr_hint (vm_object_t obj, vm_offset_t addr, vm_size_t size); void *pmap_kenter_temporary (vm_paddr_t pa, long i); void pmap_init2 (void); struct vm_page *pmap_kvtom(vm_offset_t va); void pmap_object_init(vm_object_t object); void pmap_object_free(vm_object_t object); void smap_smep_disable(void); void smap_smep_enable(void); #define vtophys(va) pmap_kextract(((vm_offset_t)(va))) #define vtophys_pte(va) ((pt_entry_t)pmap_kextract(((vm_offset_t)(va)))) #endif /* _KERNEL */ #endif /* _VM_PMAP_H_ */ |