|
|
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>
1.1.1.3 ! root 45: #include <kern/thread.h>
1.1 root 46:
47: /*
48: * The following is a description of the interface to the
49: * machine-dependent "physical map" data structure. The module
50: * must provide a "pmap_t" data type that represents the
51: * set of valid virtual-to-physical addresses for one user
52: * address space. [The kernel address space is represented
53: * by a distinguished "pmap_t".] The routines described manage
54: * this type, install and update virtual-to-physical mappings,
55: * and perform operations on physical addresses common to
56: * many address spaces.
57: */
58:
59: /*
60: * Routines used for initialization.
61: * There is traditionally also a pmap_bootstrap,
62: * used very early by machine-dependent code,
63: * but it is not part of the interface.
64: */
65:
1.1.1.3 ! root 66: /* During VM initialization, steal a chunk of memory. */
! 67: extern vm_offset_t pmap_steal_memory(vm_size_t);
! 68: /* During VM initialization, report remaining unused physical pages. */
! 69: extern unsigned int pmap_free_pages(void);
! 70: /* During VM initialization, use remaining physical pages to allocate page
! 71: * frames. */
! 72: extern void pmap_startup(vm_offset_t *, vm_offset_t *);
! 73: /* Initialization, after kernel runs in virtual memory. */
! 74: extern void pmap_init(void);
1.1 root 75:
76: #ifndef MACHINE_PAGES
77: /*
78: * If machine/pmap.h defines MACHINE_PAGES, it must implement
79: * the above functions. The pmap module has complete control.
80: * Otherwise, it must implement
81: * pmap_free_pages
82: * pmap_virtual_space
83: * pmap_next_page
84: * pmap_init
85: * and vm/vm_resident.c implements pmap_steal_memory and pmap_startup
86: * using pmap_free_pages, pmap_next_page, pmap_virtual_space,
87: * and pmap_enter. pmap_free_pages may over-estimate the number
88: * of unused physical pages, and pmap_next_page may return FALSE
89: * to indicate that there are no more unused pages to return.
90: * However, for best performance pmap_free_pages should be accurate.
91: */
92:
1.1.1.3 ! root 93: /* During VM initialization, return the next unused physical page. */
! 94: extern boolean_t pmap_next_page(vm_offset_t *);
! 95: /* During VM initialization, report virtual space available for the kernel. */
! 96: extern void pmap_virtual_space(vm_offset_t *, vm_offset_t *);
1.1.1.2 root 97: #endif /* MACHINE_PAGES */
1.1 root 98:
99: /*
100: * Routines to manage the physical map data structure.
101: */
102:
103: /* Create a pmap_t. */
104: pmap_t pmap_create(vm_size_t size);
105:
106: /* Return the kernel's pmap_t. */
107: #ifndef pmap_kernel
108: extern pmap_t pmap_kernel(void);
1.1.1.2 root 109: #endif /* pmap_kernel */
1.1 root 110:
111: /* Gain and release a reference. */
1.1.1.2 root 112: extern void pmap_reference(pmap_t pmap);
1.1 root 113: extern void pmap_destroy(pmap_t pmap);
114:
115: /* Enter a mapping */
116: extern void pmap_enter(pmap_t pmap, vm_offset_t va, vm_offset_t pa,
117: vm_prot_t prot, boolean_t wired);
118:
119:
120: /*
121: * Routines that operate on ranges of virtual addresses.
122: */
123:
124: /* Remove mappings. */
125: void pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva);
126:
127: /* Change protections. */
128: void pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot);
129:
130: /*
131: * Routines to set up hardware state for physical maps to be used.
132: */
1.1.1.3 ! root 133: /* Prepare pmap_t to run on a given processor. */
! 134: extern void pmap_activate(pmap_t, thread_t, int);
! 135: /* Release pmap_t from use on processor. */
! 136: extern void pmap_deactivate(pmap_t, thread_t, int);
1.1 root 137:
138:
139: /*
140: * Routines that operate on physical addresses.
141: */
142:
143: /* Restrict access to page. */
144: void pmap_page_protect(vm_offset_t pa, vm_prot_t prot);
145:
146: /*
147: * Routines to manage reference/modify bits based on
148: * physical addresses, simulating them if not provided
149: * by the hardware.
150: */
151:
152: /* Clear reference bit */
153: void pmap_clear_reference(vm_offset_t pa);
154:
155: /* Return reference bit */
156: #ifndef pmap_is_referenced
157: boolean_t pmap_is_referenced(vm_offset_t pa);
1.1.1.2 root 158: #endif /* pmap_is_referenced */
1.1 root 159:
160: /* Clear modify bit */
161: void pmap_clear_modify(vm_offset_t pa);
162:
163: /* Return modify bit */
164: boolean_t pmap_is_modified(vm_offset_t pa);
165:
166:
167: /*
168: * Statistics routines
169: */
170:
171: #ifndef pmap_resident_count
172: extern int pmap_resident_count();
1.1.1.2 root 173: #endif /* pmap_resident_count */
1.1 root 174:
175: /*
176: * Sundry required routines
177: */
1.1.1.3 ! root 178: /* Return a virtual-to-physical mapping, if possible. */
! 179: extern vm_offset_t pmap_extract(pmap_t, vm_offset_t);
! 180: /* Is virtual address valid? */
! 181: extern boolean_t pmap_access();
! 182: /* Perform garbage collection, if any. */
! 183: extern void pmap_collect(pmap_t);
! 184: /* Specify pageability. */
! 185: extern void pmap_change_wiring(pmap_t, vm_offset_t, boolean_t);
1.1 root 186:
187: #ifndef pmap_phys_address
1.1.1.3 ! root 188: /* Transform address returned by device driver mapping function to physical
! 189: * address known to this module. */
! 190: extern vm_offset_t pmap_phys_address();
1.1.1.2 root 191: #endif /* pmap_phys_address */
1.1 root 192: #ifndef pmap_phys_to_frame
1.1.1.3 ! root 193: /* Inverse of pmap_phys_address, for use by device driver mapping function in
! 194: * machine-independent pseudo-devices. */
! 195: extern int pmap_phys_to_frame();
1.1.1.2 root 196: #endif /* pmap_phys_to_frame */
1.1 root 197:
198: /*
199: * Optional routines
200: */
201: #ifndef pmap_copy
1.1.1.3 ! root 202: /* Copy range of mappings, if desired. */
! 203: extern void pmap_copy(pmap_t, pmap_t, vm_offset_t, vm_size_t,
! 204: vm_offset_t);
1.1.1.2 root 205: #endif /* pmap_copy */
1.1 root 206: #ifndef pmap_attribute
1.1.1.3 ! root 207: /* Get/Set special memory attributes. */
! 208: extern kern_return_t pmap_attribute();
1.1.1.2 root 209: #endif /* pmap_attribute */
1.1 root 210:
211: /*
1.1.1.3 ! root 212: * Grab a physical page:
! 213: * the standard memory allocation mechanism
! 214: * during system initialization.
! 215: */
! 216: extern vm_offset_t pmap_grab_page (void);
! 217:
! 218: extern boolean_t pmap_valid_page(vm_offset_t x);
! 219:
! 220: /*
! 221: * Make the specified pages (by pmap, offset)
! 222: * pageable (or not) as requested.
! 223: */
! 224: extern void pmap_pageable(
! 225: pmap_t pmap,
! 226: vm_offset_t start,
! 227: vm_offset_t end,
! 228: boolean_t pageable);
! 229:
! 230: /*
! 231: * Back-door routine for mapping kernel VM at initialization.
! 232: * Useful for mapping memory outside the range
! 233: * [phys_first_addr, phys_last_addr) (i.e., devices).
! 234: * Otherwise like pmap_map.
! 235: */
! 236: extern vm_offset_t pmap_map_bd(
! 237: vm_offset_t virt,
! 238: vm_offset_t start,
! 239: vm_offset_t end,
! 240: vm_prot_t prot);
! 241:
! 242: /*
1.1 root 243: * Routines defined as macros.
244: */
245: #ifndef PMAP_ACTIVATE_USER
246: #define PMAP_ACTIVATE_USER(pmap, thread, cpu) { \
247: if ((pmap) != kernel_pmap) \
248: PMAP_ACTIVATE(pmap, thread, cpu); \
249: }
1.1.1.2 root 250: #endif /* PMAP_ACTIVATE_USER */
1.1 root 251:
252: #ifndef PMAP_DEACTIVATE_USER
253: #define PMAP_DEACTIVATE_USER(pmap, thread, cpu) { \
254: if ((pmap) != kernel_pmap) \
255: PMAP_DEACTIVATE(pmap, thread, cpu); \
256: }
1.1.1.2 root 257: #endif /* PMAP_DEACTIVATE_USER */
1.1 root 258:
259: #ifndef PMAP_ACTIVATE_KERNEL
260: #define PMAP_ACTIVATE_KERNEL(cpu) \
261: PMAP_ACTIVATE(kernel_pmap, THREAD_NULL, cpu)
1.1.1.2 root 262: #endif /* PMAP_ACTIVATE_KERNEL */
1.1 root 263:
264: #ifndef PMAP_DEACTIVATE_KERNEL
265: #define PMAP_DEACTIVATE_KERNEL(cpu) \
266: PMAP_DEACTIVATE(kernel_pmap, THREAD_NULL, cpu)
1.1.1.2 root 267: #endif /* PMAP_DEACTIVATE_KERNEL */
1.1 root 268:
269: /*
270: * Exported data structures
271: */
272:
273: extern pmap_t kernel_pmap; /* The kernel's map */
274:
1.1.1.2 root 275: #endif /* _VM_PMAP_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.