|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /*
23: * @OSF_COPYRIGHT@
24: */
25: /*
26: * Mach Operating System
27: * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28: * All Rights Reserved.
29: *
30: * Permission to use, copy, modify and distribute this software and its
31: * documentation is hereby granted, provided that both the copyright
32: * notice and this permission notice appear in all copies of the
33: * software, derivative works or modified versions, and any portions
34: * thereof, and that both notices appear in supporting documentation.
35: *
36: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39: *
40: * Carnegie Mellon requests users of this software to return to
41: *
42: * Software Distribution Coordinator or [email protected]
43: * School of Computer Science
44: * Carnegie Mellon University
45: * Pittsburgh PA 15213-3890
46: *
47: * any improvements or extensions that they make and grant Carnegie Mellon
48: * the rights to redistribute these changes.
49: */
50: /*
51: */
52: /*
53: * File: vm/pmap.h
54: * Author: Avadis Tevanian, Jr.
55: * Date: 1985
56: *
57: * Machine address mapping definitions -- machine-independent
58: * section. [For machine-dependent section, see "machine/pmap.h".]
59: */
60:
61: #ifndef _VM_PMAP_H_
62: #define _VM_PMAP_H_
63:
64: #include <mach/kern_return.h>
65: #include <mach/vm_param.h>
66: #include <mach/vm_types.h>
67: #include <mach/vm_attributes.h>
68: #include <mach/boolean.h>
69: #include <mach/vm_prot.h>
70:
71: /*
72: * The following is a description of the interface to the
73: * machine-dependent "physical map" data structure. The module
74: * must provide a "pmap_t" data type that represents the
75: * set of valid virtual-to-physical addresses for one user
76: * address space. [The kernel address space is represented
77: * by a distinguished "pmap_t".] The routines described manage
78: * this type, install and update virtual-to-physical mappings,
79: * and perform operations on physical addresses common to
80: * many address spaces.
81: */
82:
83: #ifndef MACH_KERNEL_PRIVATE
84:
85: typedef void *pmap_t;
86:
87: #else /* MACH_KERNEL_PRIVATE */
88:
89: typedef struct pmap *pmap_t;
90:
91: #include <machine/pmap.h>
92:
93: /*
94: * Routines used for initialization.
95: * There is traditionally also a pmap_bootstrap,
96: * used very early by machine-dependent code,
97: * but it is not part of the interface.
98: */
99:
100: extern vm_offset_t pmap_steal_memory(vm_size_t size);
101: /* During VM initialization,
102: * steal a chunk of memory.
103: */
104: extern unsigned int pmap_free_pages(void); /* During VM initialization,
105: * report remaining unused
106: * physical pages.
107: */
108: extern void pmap_startup(
109: vm_offset_t *startp,
110: vm_offset_t *endp);
111: /* During VM initialization,
112: * use remaining physical pages
113: * to allocate page frames.
114: */
115: extern void pmap_init(void); /* Initialization,
116: * after kernel runs
117: * in virtual memory.
118: */
119:
120: #ifndef MACHINE_PAGES
121: /*
122: * If machine/pmap.h defines MACHINE_PAGES, it must implement
123: * the above functions. The pmap module has complete control.
124: * Otherwise, it must implement
125: * pmap_free_pages
126: * pmap_virtual_space
127: * pmap_next_page
128: * pmap_init
129: * and vm/vm_resident.c implements pmap_steal_memory and pmap_startup
130: * using pmap_free_pages, pmap_next_page, pmap_virtual_space,
131: * and pmap_enter. pmap_free_pages may over-estimate the number
132: * of unused physical pages, and pmap_next_page may return FALSE
133: * to indicate that there are no more unused pages to return.
134: * However, for best performance pmap_free_pages should be accurate.
135: */
136:
137: extern boolean_t pmap_next_page(vm_offset_t *paddr);
138: /* During VM initialization,
139: * return the next unused
140: * physical page.
141: */
142: extern void pmap_virtual_space(
143: vm_offset_t *virtual_start,
144: vm_offset_t *virtual_end);
145: /* During VM initialization,
146: * report virtual space
147: * available for the kernel.
148: */
149: #endif /* MACHINE_PAGES */
150:
151: /*
152: * Routines to manage the physical map data structure.
153: */
154: extern pmap_t pmap_create(vm_size_t size); /* Create a pmap_t. */
155: extern pmap_t (pmap_kernel)(void); /* Return the kernel's pmap */
156: extern void pmap_reference(pmap_t pmap); /* Gain a reference. */
157: extern void pmap_destroy(pmap_t pmap); /* Release a reference. */
158: extern void pmap_switch(pmap_t);
159:
160:
161: extern void pmap_enter( /* Enter a mapping */
162: pmap_t pmap,
163: vm_offset_t v,
164: vm_offset_t pa,
165: vm_prot_t prot,
166: boolean_t wired);
167:
168:
169: /*
170: * Routines that operate on physical addresses.
171: */
172: extern void pmap_page_protect( /* Restrict access to page. */
173: vm_offset_t phys,
174: vm_prot_t prot);
175:
176: extern void (pmap_zero_page)(
177: vm_offset_t phys);
178:
179: extern void (pmap_zero_part_page)(
180: vm_offset_t p,
181: vm_offset_t offset,
182: vm_size_t len);
183:
184: extern void (pmap_copy_page)(
185: vm_offset_t src,
186: vm_offset_t dest);
187:
188: extern void (pmap_copy_part_page)(
189: vm_offset_t src,
190: vm_offset_t src_offset,
191: vm_offset_t dst,
192: vm_offset_t dst_offset,
193: vm_size_t len);
194:
195: extern void (pmap_copy_part_lpage)(
196: vm_offset_t src,
197: vm_offset_t dst,
198: vm_offset_t dst_offset,
199: vm_size_t len);
200:
201: extern void (pmap_copy_part_rpage)(
202: vm_offset_t src,
203: vm_offset_t src_offset,
204: vm_offset_t dst,
205: vm_size_t len);
206:
207: /*
208: * debug/assertions. pmap_verify_free returns true iff
209: * the given physical page is mapped into no pmap.
210: */
211: extern boolean_t pmap_verify_free(vm_offset_t paddr);
212:
213: /*
214: * Statistics routines
215: */
216: extern int (pmap_resident_count)(pmap_t pmap);
217:
218: /*
219: * Sundry required (internal) routines
220: */
221: extern void pmap_collect(pmap_t pmap);/* Perform garbage
222: * collection, if any */
223:
224:
225: extern vm_offset_t (pmap_phys_address)( /* Transform address returned
226: * by device driver mapping
227: * function to physical address
228: * known to this module. */
229: int frame);
230:
231: extern int (pmap_phys_to_frame)( /* Inverse of pmap_phys_addess,
232: * for use by device driver
233: * mapping function in
234: * machine-independent
235: * pseudo-devices. */
236: vm_offset_t phys);
237:
238: /*
239: * Optional routines
240: */
241: extern void (pmap_copy)( /* Copy range of mappings,
242: * if desired. */
243: pmap_t dest,
244: pmap_t source,
245: vm_offset_t dest_va,
246: vm_size_t size,
247: vm_offset_t source_va);
248:
249: extern kern_return_t (pmap_attribute)( /* Get/Set special memory
250: * attributes */
251: pmap_t pmap,
252: vm_offset_t va,
253: vm_size_t size,
254: vm_machine_attribute_t attribute,
255: vm_machine_attribute_val_t* value);
256:
257: /*
258: * Routines defined as macros.
259: */
260: #ifndef PMAP_ACTIVATE_USER
261: #define PMAP_ACTIVATE_USER(act, cpu) { \
262: pmap_t pmap; \
263: \
264: pmap = (act)->map->pmap; \
265: if (pmap != pmap_kernel()) \
266: PMAP_ACTIVATE(pmap, (act), (cpu)); \
267: }
268: #endif /* PMAP_ACTIVATE_USER */
269:
270: #ifndef PMAP_DEACTIVATE_USER
271: #define PMAP_DEACTIVATE_USER(act, cpu) { \
272: pmap_t pmap; \
273: \
274: pmap = (act)->map->pmap; \
275: if ((pmap) != pmap_kernel()) \
276: PMAP_DEACTIVATE(pmap, (act), (cpu)); \
277: }
278: #endif /* PMAP_DEACTIVATE_USER */
279:
280: #ifndef PMAP_ACTIVATE_KERNEL
281: #define PMAP_ACTIVATE_KERNEL(cpu) \
282: PMAP_ACTIVATE(pmap_kernel(), THR_ACT_NULL, cpu)
283: #endif /* PMAP_ACTIVATE_KERNEL */
284:
285: #ifndef PMAP_DEACTIVATE_KERNEL
286: #define PMAP_DEACTIVATE_KERNEL(cpu) \
287: PMAP_DEACTIVATE(pmap_kernel(), THR_ACT_NULL, cpu)
288: #endif /* PMAP_DEACTIVATE_KERNEL */
289:
290: #ifndef PMAP_ENTER
291: /*
292: * Macro to be used in place of pmap_enter()
293: */
294: #define PMAP_ENTER(pmap, virtual_address, page, protection, wired) \
295: MACRO_BEGIN \
296: pmap_enter( \
297: (pmap), \
298: (virtual_address), \
299: (page)->phys_addr, \
300: (protection) & ~(page)->page_lock, \
301: (wired) \
302: ); \
303: MACRO_END
304: #endif /* !PMAP_ENTER */
305:
306: #endif /* MACH_KERNEL_PRIVATE */
307:
308: /*
309: * JMM - This portion is exported to other kernel components right now,
310: * but will be pulled back in the future when the needed functionality
311: * is provided in a cleaner manner.
312: */
313:
314: #define PMAP_NULL ((pmap_t) 0)
315:
316: extern pmap_t kernel_pmap; /* The kernel's map */
317: #define pmap_kernel() (kernel_pmap)
318:
319: /*
320: * Routines to manage reference/modify bits based on
321: * physical addresses, simulating them if not provided
322: * by the hardware.
323: */
324: /* Clear reference bit */
325: extern void pmap_clear_reference(vm_offset_t paddr);
326: /* Return reference bit */
327: extern boolean_t (pmap_is_referenced)(vm_offset_t paddr);
328: /* Set modify bit */
329: extern void pmap_set_modify(vm_offset_t paddr);
330: /* Clear modify bit */
331: extern void pmap_clear_modify(vm_offset_t paddr);
332: /* Return modify bit */
333: extern boolean_t pmap_is_modified(vm_offset_t paddr);
334:
335: /*
336: * Routines that operate on ranges of virtual addresses.
337: */
338: extern void pmap_remove( /* Remove mappings. */
339: pmap_t map,
340: vm_offset_t s,
341: vm_offset_t e);
342:
343: extern void pmap_protect( /* Change protections. */
344: pmap_t map,
345: vm_offset_t s,
346: vm_offset_t e,
347: vm_prot_t prot);
348:
349: extern void (pmap_pageable)(
350: pmap_t pmap,
351: vm_offset_t start,
352: vm_offset_t end,
353: boolean_t pageable);
354:
355: extern void pmap_modify_pages( /* Set modify bit for pages */
356: pmap_t map,
357: vm_offset_t s,
358: vm_offset_t e);
359:
360: extern vm_offset_t pmap_extract(pmap_t pmap,
361: vm_offset_t va);
362:
363: extern void pmap_change_wiring( /* Specify pageability */
364: pmap_t pmap,
365: vm_offset_t va,
366: boolean_t wired);
367: #endif /* _VM_PMAP_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.