|
|
1.1 ! root 1: /* ! 2: * Mach Operating System ! 3: * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University. ! 4: * Copyright (c) 1993,1994 The University of Utah and ! 5: * the Computer Systems Laboratory (CSL). ! 6: * All rights reserved. ! 7: * ! 8: * Permission to use, copy, modify and distribute this software and its ! 9: * documentation is hereby granted, provided that both the copyright ! 10: * notice and this permission notice appear in all copies of the ! 11: * software, derivative works or modified versions, and any portions ! 12: * thereof, and that both notices appear in supporting documentation. ! 13: * ! 14: * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF ! 15: * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY ! 16: * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF ! 17: * THIS SOFTWARE. ! 18: * ! 19: * Carnegie Mellon requests users of this software to return to ! 20: * ! 21: * Software Distribution Coordinator or [email protected] ! 22: * School of Computer Science ! 23: * Carnegie Mellon University ! 24: * Pittsburgh PA 15213-3890 ! 25: * ! 26: * any improvements or extensions that they make and grant Carnegie Mellon ! 27: * the rights to redistribute these changes. ! 28: */ ! 29: /* ! 30: * File: vm/pmap.h ! 31: * Author: Avadis Tevanian, Jr. ! 32: * Date: 1985 ! 33: * ! 34: * Machine address mapping definitions -- machine-independent ! 35: * section. [For machine-dependent section, see "machine/pmap.h".] ! 36: */ ! 37: ! 38: #ifndef _VM_PMAP_H_ ! 39: #define _VM_PMAP_H_ ! 40: ! 41: #include <machine/pmap.h> ! 42: #include <mach/machine/vm_types.h> ! 43: #include <mach/vm_prot.h> ! 44: #include <mach/boolean.h> ! 45: ! 46: /* ! 47: * The following is a description of the interface to the ! 48: * machine-dependent "physical map" data structure. The module ! 49: * must provide a "pmap_t" data type that represents the ! 50: * set of valid virtual-to-physical addresses for one user ! 51: * address space. [The kernel address space is represented ! 52: * by a distinguished "pmap_t".] The routines described manage ! 53: * this type, install and update virtual-to-physical mappings, ! 54: * and perform operations on physical addresses common to ! 55: * many address spaces. ! 56: */ ! 57: ! 58: /* ! 59: * Routines used for initialization. ! 60: * There is traditionally also a pmap_bootstrap, ! 61: * used very early by machine-dependent code, ! 62: * but it is not part of the interface. ! 63: */ ! 64: ! 65: extern vm_offset_t pmap_steal_memory(); /* During VM initialization, ! 66: * steal a chunk of memory. ! 67: */ ! 68: extern unsigned int pmap_free_pages(); /* During VM initialization, ! 69: * report remaining unused ! 70: * physical pages. ! 71: */ ! 72: extern void pmap_startup(); /* During VM initialization, ! 73: * use remaining physical pages ! 74: * to allocate page frames. ! 75: */ ! 76: extern void pmap_init(); /* Initialization, ! 77: * after kernel runs ! 78: * in virtual memory. ! 79: */ ! 80: ! 81: #ifndef MACHINE_PAGES ! 82: /* ! 83: * If machine/pmap.h defines MACHINE_PAGES, it must implement ! 84: * the above functions. The pmap module has complete control. ! 85: * Otherwise, it must implement ! 86: * pmap_free_pages ! 87: * pmap_virtual_space ! 88: * pmap_next_page ! 89: * pmap_init ! 90: * and vm/vm_resident.c implements pmap_steal_memory and pmap_startup ! 91: * using pmap_free_pages, pmap_next_page, pmap_virtual_space, ! 92: * and pmap_enter. pmap_free_pages may over-estimate the number ! 93: * of unused physical pages, and pmap_next_page may return FALSE ! 94: * to indicate that there are no more unused pages to return. ! 95: * However, for best performance pmap_free_pages should be accurate. ! 96: */ ! 97: ! 98: extern boolean_t pmap_next_page(); /* During VM initialization, ! 99: * return the next unused ! 100: * physical page. ! 101: */ ! 102: extern void pmap_virtual_space(); /* During VM initialization, ! 103: * report virtual space ! 104: * available for the kernel. ! 105: */ ! 106: #endif /* MACHINE_PAGES */ ! 107: ! 108: /* ! 109: * Routines to manage the physical map data structure. ! 110: */ ! 111: ! 112: /* Create a pmap_t. */ ! 113: pmap_t pmap_create(vm_size_t size); ! 114: ! 115: /* Return the kernel's pmap_t. */ ! 116: #ifndef pmap_kernel ! 117: extern pmap_t pmap_kernel(void); ! 118: #endif /* pmap_kernel */ ! 119: ! 120: /* Gain and release a reference. */ ! 121: extern void pmap_reference(pmap_t pmap); ! 122: extern void pmap_destroy(pmap_t pmap); ! 123: ! 124: /* Enter a mapping */ ! 125: extern void pmap_enter(pmap_t pmap, vm_offset_t va, vm_offset_t pa, ! 126: vm_prot_t prot, boolean_t wired); ! 127: ! 128: ! 129: /* ! 130: * Routines that operate on ranges of virtual addresses. ! 131: */ ! 132: ! 133: /* Remove mappings. */ ! 134: void pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva); ! 135: ! 136: /* Change protections. */ ! 137: void pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot); ! 138: ! 139: /* ! 140: * Routines to set up hardware state for physical maps to be used. ! 141: */ ! 142: extern void pmap_activate(); /* Prepare pmap_t to run ! 143: * on a given processor. ! 144: */ ! 145: extern void pmap_deactivate(); /* Release pmap_t from ! 146: * use on processor. ! 147: */ ! 148: ! 149: ! 150: /* ! 151: * Routines that operate on physical addresses. ! 152: */ ! 153: ! 154: /* Restrict access to page. */ ! 155: void pmap_page_protect(vm_offset_t pa, vm_prot_t prot); ! 156: ! 157: /* ! 158: * Routines to manage reference/modify bits based on ! 159: * physical addresses, simulating them if not provided ! 160: * by the hardware. ! 161: */ ! 162: ! 163: /* Clear reference bit */ ! 164: void pmap_clear_reference(vm_offset_t pa); ! 165: ! 166: /* Return reference bit */ ! 167: #ifndef pmap_is_referenced ! 168: boolean_t pmap_is_referenced(vm_offset_t pa); ! 169: #endif /* pmap_is_referenced */ ! 170: ! 171: /* Clear modify bit */ ! 172: void pmap_clear_modify(vm_offset_t pa); ! 173: ! 174: /* Return modify bit */ ! 175: boolean_t pmap_is_modified(vm_offset_t pa); ! 176: ! 177: ! 178: /* ! 179: * Statistics routines ! 180: */ ! 181: extern void pmap_statistics(); /* Return statistics */ ! 182: ! 183: #ifndef pmap_resident_count ! 184: extern int pmap_resident_count(); ! 185: #endif /* pmap_resident_count */ ! 186: ! 187: /* ! 188: * Sundry required routines ! 189: */ ! 190: extern vm_offset_t pmap_extract(); /* Return a virtual-to-physical ! 191: * mapping, if possible. ! 192: */ ! 193: ! 194: extern boolean_t pmap_access(); /* Is virtual address valid? */ ! 195: ! 196: extern void pmap_collect(); /* Perform garbage ! 197: * collection, if any ! 198: */ ! 199: ! 200: extern void pmap_change_wiring(); /* Specify pageability */ ! 201: ! 202: #ifndef pmap_phys_address ! 203: extern vm_offset_t pmap_phys_address(); /* Transform address ! 204: * returned by device ! 205: * driver mapping function ! 206: * to physical address ! 207: * known to this module. ! 208: */ ! 209: #endif /* pmap_phys_address */ ! 210: #ifndef pmap_phys_to_frame ! 211: extern int pmap_phys_to_frame(); /* Inverse of ! 212: * pmap_phys_address, ! 213: * for use by device driver ! 214: * mapping function in ! 215: * machine-independent ! 216: * pseudo-devices. ! 217: */ ! 218: #endif /* pmap_phys_to_frame */ ! 219: ! 220: /* ! 221: * Optional routines ! 222: */ ! 223: #ifndef pmap_copy ! 224: extern void pmap_copy(); /* Copy range of ! 225: * mappings, if desired. ! 226: */ ! 227: #endif /* pmap_copy */ ! 228: #ifndef pmap_attribute ! 229: extern kern_return_t pmap_attribute(); /* Get/Set special ! 230: * memory attributes ! 231: */ ! 232: #endif /* pmap_attribute */ ! 233: ! 234: /* ! 235: * Routines defined as macros. ! 236: */ ! 237: #ifndef PMAP_ACTIVATE_USER ! 238: #define PMAP_ACTIVATE_USER(pmap, thread, cpu) { \ ! 239: if ((pmap) != kernel_pmap) \ ! 240: PMAP_ACTIVATE(pmap, thread, cpu); \ ! 241: } ! 242: #endif /* PMAP_ACTIVATE_USER */ ! 243: ! 244: #ifndef PMAP_DEACTIVATE_USER ! 245: #define PMAP_DEACTIVATE_USER(pmap, thread, cpu) { \ ! 246: if ((pmap) != kernel_pmap) \ ! 247: PMAP_DEACTIVATE(pmap, thread, cpu); \ ! 248: } ! 249: #endif /* PMAP_DEACTIVATE_USER */ ! 250: ! 251: #ifndef PMAP_ACTIVATE_KERNEL ! 252: #define PMAP_ACTIVATE_KERNEL(cpu) \ ! 253: PMAP_ACTIVATE(kernel_pmap, THREAD_NULL, cpu) ! 254: #endif /* PMAP_ACTIVATE_KERNEL */ ! 255: ! 256: #ifndef PMAP_DEACTIVATE_KERNEL ! 257: #define PMAP_DEACTIVATE_KERNEL(cpu) \ ! 258: PMAP_DEACTIVATE(kernel_pmap, THREAD_NULL, cpu) ! 259: #endif /* PMAP_DEACTIVATE_KERNEL */ ! 260: ! 261: /* ! 262: * Exported data structures ! 263: */ ! 264: ! 265: extern pmap_t kernel_pmap; /* The kernel's map */ ! 266: ! 267: #endif /* _VM_PMAP_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.