FreeBSD/Linux Kernel Cross Reference
sys/vm/pmap.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: pmap.h,v $
29 * Revision 2.6 91/05/18 14:39:51 rpd
30 * Removed pmap_update.
31 * [91/04/12 rpd]
32 * Removed pmap_bootstrap, pmap_map, pmap_valid_page.
33 * Added pmap_startup, pmap_steal_memory, pmap_free_pages,
34 * pmap_virtual_space, pmap_next_page.
35 * [91/03/22 rpd]
36 *
37 * Revision 2.5 91/05/14 17:48:08 mrt
38 * Correcting copyright
39 *
40 * Revision 2.4 91/02/05 17:57:34 mrt
41 * Changed to new Mach copyright
42 * [91/02/01 16:31:04 mrt]
43 *
44 * Revision 2.3 90/01/22 23:09:05 af
45 * Added (optional) pmap_attributes. This should be implemented
46 * just as a macro that evaluates to KERN_INVALID_ARGUMENT for
47 * those architectures that do not support any special memory
48 * feature in hardware. NUMA machines and cache-incoherent
49 * machines (e.g. mips) should instead implement it as appropriate.
50 * [89/12/08 af]
51 *
52 * Revision 2.2 89/11/29 14:16:53 af
53 * Carried over the following mods from impure kernel.
54 * Added pmap_phys_to_frame as inverse of pmap_phys_address, for use by
55 * memory map function in machine-independent pseudo device drivers.
56 * The correct thing to do, of course, is to change the device driver map
57 * function spec to return a physical address instead of a frame, but
58 * this would require changing too many device drivers...
59 * [89/09/05 16:45:48 jsb]
60 *
61 * Removed unused and ugly pmap_redzone() from the list of required
62 * pmap functions. Made more routines implementable as macros.
63 * [89/08/05 af]
64 * Separate user and kernel cases of PMAP_ACTIVATE and
65 * PMAP_DEACTIVATE; supply default definitions.
66 * [89/04/28 dbg]
67 *
68 * Revision 2.1 89/08/03 16:44:35 rwd
69 * Created.
70 *
71 * Revision 2.8 89/04/18 21:24:43 mwyoung
72 * Recent history [mwyoung]:
73 * Remove pmap_remove_all(), pmap_copy_on_write(), as they're
74 * no longer required routines. The machine-independent code
75 * uses pmap_page_protect() instead.
76 * Documented interface. The precise interface specification
77 * should be reconstructed from the pmap implementations.
78 * History condensation:
79 * Added calls for page locking [mwyoung].
80 * Added reference bit handling [avie].
81 * Created [avie].
82 * [89/04/18 mwyoung]
83 *
84 */
85 /*
86 * File: vm/pmap.h
87 * Author: Avadis Tevanian, Jr.
88 * Date: 1985
89 *
90 * Machine address mapping definitions -- machine-independent
91 * section. [For machine-dependent section, see "machine/pmap.h".]
92 */
93
94 #ifndef _VM_PMAP_H_
95 #define _VM_PMAP_H_
96
97 #include <machine/pmap.h>
98 #include <mach/machine/vm_types.h>
99 #include <mach/boolean.h>
100
101 /*
102 * The following is a description of the interface to the
103 * machine-dependent "physical map" data structure. The module
104 * must provide a "pmap_t" data type that represents the
105 * set of valid virtual-to-physical addresses for one user
106 * address space. [The kernel address space is represented
107 * by a distinguished "pmap_t".] The routines described manage
108 * this type, install and update virtual-to-physical mappings,
109 * and perform operations on physical addresses common to
110 * many address spaces.
111 */
112
113 /*
114 * Routines used for initialization.
115 * There is traditionally also a pmap_bootstrap,
116 * used very early by machine-dependent code,
117 * but it is not part of the interface.
118 */
119
120 extern vm_offset_t pmap_steal_memory(); /* During VM initialization,
121 * steal a chunk of memory.
122 */
123 extern unsigned int pmap_free_pages(); /* During VM initialization,
124 * report remaining unused
125 * physical pages.
126 */
127 extern void pmap_startup(); /* During VM initialization,
128 * use remaining physical pages
129 * to allocate page frames.
130 */
131 extern void pmap_init(); /* Initialization,
132 * after kernel runs
133 * in virtual memory.
134 */
135
136 #ifndef MACHINE_PAGES
137 /*
138 * If machine/pmap.h defines MACHINE_PAGES, it must implement
139 * the above functions. The pmap module has complete control.
140 * Otherwise, it must implement
141 * pmap_free_pages
142 * pmap_virtual_space
143 * pmap_next_page
144 * pmap_init
145 * and vm/vm_resident.c implements pmap_steal_memory and pmap_startup
146 * using pmap_free_pages, pmap_next_page, pmap_virtual_space,
147 * and pmap_enter. pmap_free_pages may over-estimate the number
148 * of unused physical pages, and pmap_next_page may return FALSE
149 * to indicate that there are no more unused pages to return.
150 * However, for best performance pmap_free_pages should be accurate.
151 */
152
153 extern boolean_t pmap_next_page(); /* During VM initialization,
154 * return the next unused
155 * physical page.
156 */
157 extern void pmap_virtual_space(); /* During VM initialization,
158 * report virtual space
159 * available for the kernel.
160 */
161 #endif MACHINE_PAGES
162
163 /*
164 * Routines to manage the physical map data structure.
165 */
166 extern pmap_t pmap_create(); /* Create a pmap_t. */
167 #ifndef pmap_kernel
168 extern pmap_t pmap_kernel(); /* Return the kernel's pmap_t. */
169 #endif pmap_kernel
170 extern void pmap_reference(); /* Gain a reference. */
171 extern void pmap_destroy(); /* Release a reference. */
172
173 extern void pmap_enter(); /* Enter a mapping */
174
175 /*
176 * Routines that operate on ranges of virtual addresses.
177 */
178 extern void pmap_remove(); /* Remove mappings. */
179 extern void pmap_protect(); /* Change protections. */
180
181 /*
182 * Routines to set up hardware state for physical maps to be used.
183 */
184 extern void pmap_activate(); /* Prepare pmap_t to run
185 * on a given processor.
186 */
187 extern void pmap_deactivate(); /* Release pmap_t from
188 * use on processor.
189 */
190
191
192 /*
193 * Routines that operate on physical addresses.
194 */
195 extern void pmap_page_protect(); /* Restrict access to page. */
196
197 /*
198 * Routines to manage reference/modify bits based on
199 * physical addresses, simulating them if not provided
200 * by the hardware.
201 */
202 extern void pmap_clear_reference(); /* Clear reference bit */
203 #ifndef pmap_is_referenced
204 extern boolean_t pmap_is_referenced(); /* Return reference bit */
205 #endif pmap_is_referenced
206 extern void pmap_clear_modify(); /* Clear modify bit */
207 extern boolean_t pmap_is_modified(); /* Return modify bit */
208
209
210 /*
211 * Statistics routines
212 */
213 extern void pmap_statistics(); /* Return statistics */
214
215 #ifndef pmap_resident_count
216 extern int pmap_resident_count();
217 #endif pmap_resident_count
218
219 /*
220 * Sundry required routines
221 */
222 extern vm_offset_t pmap_extract(); /* Return a virtual-to-physical
223 * mapping, if possible.
224 */
225
226 extern boolean_t pmap_access(); /* Is virtual address valid? */
227
228 extern void pmap_collect(); /* Perform garbage
229 * collection, if any
230 */
231
232 extern void pmap_change_wiring(); /* Specify pageability */
233
234 #ifndef pmap_phys_address
235 extern vm_offset_t pmap_phys_address(); /* Transform address
236 * returned by device
237 * driver mapping function
238 * to physical address
239 * known to this module.
240 */
241 #endif pmap_phys_address
242 #ifndef pmap_phys_to_frame
243 extern int pmap_phys_to_frame(); /* Inverse of
244 * pmap_phys_address,
245 * for use by device driver
246 * mapping function in
247 * machine-independent
248 * pseudo-devices.
249 */
250 #endif pmap_phys_to_frame
251
252 /*
253 * Optional routines
254 */
255 #ifndef pmap_copy
256 extern void pmap_copy(); /* Copy range of
257 * mappings, if desired.
258 */
259 #endif pmap_copy
260 #ifndef pmap_attribute
261 extern kern_return_t pmap_attribute(); /* Get/Set special
262 * memory attributes
263 */
264 #endif pmap_attribute
265
266 /*
267 * Routines defined as macros.
268 */
269 #ifndef PMAP_ACTIVATE_USER
270 #define PMAP_ACTIVATE_USER(pmap, thread, cpu) { \
271 if ((pmap) != kernel_pmap) \
272 PMAP_ACTIVATE(pmap, thread, cpu); \
273 }
274 #endif PMAP_ACTIVATE_USER
275
276 #ifndef PMAP_DEACTIVATE_USER
277 #define PMAP_DEACTIVATE_USER(pmap, thread, cpu) { \
278 if ((pmap) != kernel_pmap) \
279 PMAP_DEACTIVATE(pmap, thread, cpu); \
280 }
281 #endif PMAP_DEACTIVATE_USER
282
283 #ifndef PMAP_ACTIVATE_KERNEL
284 #define PMAP_ACTIVATE_KERNEL(cpu) \
285 PMAP_ACTIVATE(kernel_pmap, THREAD_NULL, cpu)
286 #endif PMAP_ACTIVATE_KERNEL
287
288 #ifndef PMAP_DEACTIVATE_KERNEL
289 #define PMAP_DEACTIVATE_KERNEL(cpu) \
290 PMAP_DEACTIVATE(kernel_pmap, THREAD_NULL, cpu)
291 #endif PMAP_DEACTIVATE_KERNEL
292
293 /*
294 * Exported data structures
295 */
296
297 extern pmap_t kernel_pmap; /* The kernel's map */
298
299 #endif _VM_PMAP_H_
Cache object: 91d8d8e749038695d0e5a43363942436
|