Loading...
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 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | /* * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 1.1 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ */ /* * Mach Operating System * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University * All Rights Reserved. * * 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 Mellon * the rights to redistribute these changes. */ /* */ /* * File: vm/pmap.h * Author: Avadis Tevanian, Jr. * Date: 1985 * * Machine address mapping definitions -- machine-independent * section. [For machine-dependent section, see "machine/pmap.h".] */ #ifndef _VM_PMAP_H_ #define _VM_PMAP_H_ #include <sys/appleapiopts.h> #ifdef __APPLE_API_PRIVATE #include <mach/kern_return.h> #include <mach/vm_param.h> #include <mach/vm_types.h> #include <mach/vm_attributes.h> #include <mach/boolean.h> #include <mach/vm_prot.h> /* * The following is a description of the interface to the * machine-dependent "physical map" data structure. The module * must provide a "pmap_t" data type that represents the * set of valid virtual-to-physical addresses for one user * address space. [The kernel address space is represented * by a distinguished "pmap_t".] The routines described manage * this type, install and update virtual-to-physical mappings, * and perform operations on physical addresses common to * many address spaces. */ /* Copy between a physical page and a virtual address */ extern kern_return_t copypv( addr64_t source, addr64_t sink, unsigned int size, int which); #define cppvPsnk 1 #define cppvPsrc 2 #define cppvFsnk 4 #define cppvFsrc 8 #define cppvNoModSnk 16 #define cppvNoRefSrc 32 #define cppvKmap 64 /* User the kernel's vm_map */ #if !defined(MACH_KERNEL_PRIVATE) typedef void *pmap_t; #else /* MACH_KERNEL_PRIVATE */ typedef struct pmap *pmap_t; #include <machine/pmap.h> /* * Routines used for initialization. * There is traditionally also a pmap_bootstrap, * used very early by machine-dependent code, * but it is not part of the interface. */ extern vm_offset_t pmap_steal_memory(vm_size_t size); /* During VM initialization, * steal a chunk of memory. */ extern unsigned int pmap_free_pages(void); /* During VM initialization, * report remaining unused * physical pages. */ extern void pmap_startup( vm_offset_t *startp, vm_offset_t *endp); /* During VM initialization, * use remaining physical pages * to allocate page frames. */ extern void pmap_init(void); /* Initialization, * after kernel runs * in virtual memory. */ #ifndef MACHINE_PAGES /* * If machine/pmap.h defines MACHINE_PAGES, it must implement * the above functions. The pmap module has complete control. * Otherwise, it must implement * pmap_free_pages * pmap_virtual_space * pmap_next_page * pmap_init * and vm/vm_resident.c implements pmap_steal_memory and pmap_startup * using pmap_free_pages, pmap_next_page, pmap_virtual_space, * and pmap_enter. pmap_free_pages may over-estimate the number * of unused physical pages, and pmap_next_page may return FALSE * to indicate that there are no more unused pages to return. * However, for best performance pmap_free_pages should be accurate. */ extern boolean_t pmap_next_page(ppnum_t *pnum); /* During VM initialization, * return the next unused * physical page. */ extern void pmap_virtual_space( vm_offset_t *virtual_start, vm_offset_t *virtual_end); /* During VM initialization, * report virtual space * available for the kernel. */ #endif /* MACHINE_PAGES */ /* * Routines to manage the physical map data structure. */ extern pmap_t pmap_create(vm_size_t size); /* Create a pmap_t. */ extern pmap_t (pmap_kernel)(void); /* Return the kernel's pmap */ extern void pmap_reference(pmap_t pmap); /* Gain a reference. */ extern void pmap_destroy(pmap_t pmap); /* Release a reference. */ extern void pmap_switch(pmap_t); extern void pmap_enter( /* Enter a mapping */ pmap_t pmap, vm_offset_t v, ppnum_t pn, vm_prot_t prot, unsigned int flags, boolean_t wired); extern void pmap_remove_some_phys( pmap_t pmap, ppnum_t pn); /* * Routines that operate on physical addresses. */ extern void pmap_page_protect( /* Restrict access to page. */ ppnum_t phys, vm_prot_t prot); extern void (pmap_zero_page)( ppnum_t pn); extern void (pmap_zero_part_page)( ppnum_t pn, vm_offset_t offset, vm_size_t len); extern void (pmap_copy_page)( ppnum_t src, ppnum_t dest); extern void (pmap_copy_part_page)( ppnum_t src, vm_offset_t src_offset, ppnum_t dst, vm_offset_t dst_offset, vm_size_t len); extern void (pmap_copy_part_lpage)( vm_offset_t src, ppnum_t dst, vm_offset_t dst_offset, vm_size_t len); extern void (pmap_copy_part_rpage)( ppnum_t src, vm_offset_t src_offset, vm_offset_t dst, vm_size_t len); /* * debug/assertions. pmap_verify_free returns true iff * the given physical page is mapped into no pmap. */ extern boolean_t pmap_verify_free(ppnum_t pn); /* * Statistics routines */ extern int (pmap_resident_count)(pmap_t pmap); /* * Sundry required (internal) routines */ extern void pmap_collect(pmap_t pmap);/* Perform garbage * collection, if any */ extern vm_offset_t (pmap_phys_address)( /* Transform address returned * by device driver mapping * function to physical address * known to this module. */ int frame); extern int (pmap_phys_to_frame)( /* Inverse of pmap_phys_addess, * for use by device driver * mapping function in * machine-independent * pseudo-devices. */ vm_offset_t phys); /* * Optional routines */ extern void (pmap_copy)( /* Copy range of mappings, * if desired. */ pmap_t dest, pmap_t source, vm_offset_t dest_va, vm_size_t size, vm_offset_t source_va); extern kern_return_t (pmap_attribute)( /* Get/Set special memory * attributes */ pmap_t pmap, vm_offset_t va, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t* value); extern kern_return_t (pmap_attribute_cache_sync)( /* Flush appropriate * cache based on * page number sent */ ppnum_t pn, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t* value); /* * Routines defined as macros. */ #ifndef PMAP_ACTIVATE_USER #define PMAP_ACTIVATE_USER(act, cpu) { \ pmap_t pmap; \ \ pmap = (act)->map->pmap; \ if (pmap != pmap_kernel()) \ PMAP_ACTIVATE(pmap, (act), (cpu)); \ } #endif /* PMAP_ACTIVATE_USER */ #ifndef PMAP_DEACTIVATE_USER #define PMAP_DEACTIVATE_USER(act, cpu) { \ pmap_t pmap; \ \ pmap = (act)->map->pmap; \ if ((pmap) != pmap_kernel()) \ PMAP_DEACTIVATE(pmap, (act), (cpu)); \ } #endif /* PMAP_DEACTIVATE_USER */ #ifndef PMAP_ACTIVATE_KERNEL #define PMAP_ACTIVATE_KERNEL(cpu) \ PMAP_ACTIVATE(pmap_kernel(), THR_ACT_NULL, cpu) #endif /* PMAP_ACTIVATE_KERNEL */ #ifndef PMAP_DEACTIVATE_KERNEL #define PMAP_DEACTIVATE_KERNEL(cpu) \ PMAP_DEACTIVATE(pmap_kernel(), THR_ACT_NULL, cpu) #endif /* PMAP_DEACTIVATE_KERNEL */ #ifndef PMAP_ENTER /* * Macro to be used in place of pmap_enter() */ #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \ MACRO_BEGIN \ pmap_enter( \ (pmap), \ (virtual_address), \ (page)->phys_page, \ (protection) & ~(page)->page_lock, \ flags, \ (wired) \ ); \ MACRO_END #endif /* !PMAP_ENTER */ /* * Routines to manage reference/modify bits based on * physical addresses, simulating them if not provided * by the hardware. */ /* Clear reference bit */ extern void pmap_clear_reference(ppnum_t pn); /* Return reference bit */ extern boolean_t (pmap_is_referenced)(ppnum_t pn); /* Set modify bit */ extern void pmap_set_modify(ppnum_t pn); /* Clear modify bit */ extern void pmap_clear_modify(ppnum_t pn); /* Return modify bit */ extern boolean_t pmap_is_modified(ppnum_t pn); /* * Routines that operate on ranges of virtual addresses. */ extern void pmap_protect( /* Change protections. */ pmap_t map, vm_offset_t s, vm_offset_t e, vm_prot_t prot); extern void (pmap_pageable)( pmap_t pmap, vm_offset_t start, vm_offset_t end, boolean_t pageable); #endif /* MACH_KERNEL_PRIVATE */ /* * JMM - This portion is exported to other kernel components right now, * but will be pulled back in the future when the needed functionality * is provided in a cleaner manner. */ #define PMAP_NULL ((pmap_t) 0) extern pmap_t kernel_pmap; /* The kernel's map */ #define pmap_kernel() (kernel_pmap) /* machine independent WIMG bits */ #define VM_MEM_GUARDED 0x1 #define VM_MEM_COHERENT 0x2 #define VM_MEM_NOT_CACHEABLE 0x4 #define VM_MEM_WRITE_THROUGH 0x8 #define VM_WIMG_MASK 0xFF #define VM_WIMG_USE_DEFAULT 0x80000000 extern void pmap_modify_pages( /* Set modify bit for pages */ pmap_t map, vm_offset_t s, vm_offset_t e); extern vm_offset_t pmap_extract(pmap_t pmap, vm_offset_t va); extern void pmap_change_wiring( /* Specify pageability */ pmap_t pmap, vm_offset_t va, boolean_t wired); extern void pmap_remove( /* Remove mappings. */ pmap_t map, addr64_t s, addr64_t e); #endif /* __APPLE_API_PRIVATE */ #endif /* _VM_PMAP_H_ */ |