|
|
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: * Sundry required routines
168: */
1.1.1.3 root 169: /* Return a virtual-to-physical mapping, if possible. */
170: extern vm_offset_t pmap_extract(pmap_t, vm_offset_t);
171: /* Perform garbage collection, if any. */
172: extern void pmap_collect(pmap_t);
173: /* Specify pageability. */
174: extern void pmap_change_wiring(pmap_t, vm_offset_t, boolean_t);
1.1 root 175:
176: /*
177: * Optional routines
178: */
179: #ifndef pmap_copy
1.1.1.3 root 180: /* Copy range of mappings, if desired. */
181: extern void pmap_copy(pmap_t, pmap_t, vm_offset_t, vm_size_t,
182: vm_offset_t);
1.1.1.2 root 183: #endif /* pmap_copy */
1.1 root 184: #ifndef pmap_attribute
1.1.1.3 root 185: /* Get/Set special memory attributes. */
1.1.1.4 ! root 186: extern kern_return_t pmap_attribute(void);
1.1.1.2 root 187: #endif /* pmap_attribute */
1.1 root 188:
189: /*
1.1.1.3 root 190: * Grab a physical page:
191: * the standard memory allocation mechanism
192: * during system initialization.
193: */
194: extern vm_offset_t pmap_grab_page (void);
195:
196: extern boolean_t pmap_valid_page(vm_offset_t x);
197:
198: /*
199: * Make the specified pages (by pmap, offset)
200: * pageable (or not) as requested.
201: */
202: extern void pmap_pageable(
203: pmap_t pmap,
204: vm_offset_t start,
205: vm_offset_t end,
206: boolean_t pageable);
207:
208: /*
209: * Back-door routine for mapping kernel VM at initialization.
210: * Useful for mapping memory outside the range
211: * [phys_first_addr, phys_last_addr) (i.e., devices).
212: * Otherwise like pmap_map.
213: */
214: extern vm_offset_t pmap_map_bd(
215: vm_offset_t virt,
216: vm_offset_t start,
217: vm_offset_t end,
218: vm_prot_t prot);
219:
220: /*
1.1 root 221: * Routines defined as macros.
222: */
223: #ifndef PMAP_ACTIVATE_USER
224: #define PMAP_ACTIVATE_USER(pmap, thread, cpu) { \
225: if ((pmap) != kernel_pmap) \
226: PMAP_ACTIVATE(pmap, thread, cpu); \
227: }
1.1.1.2 root 228: #endif /* PMAP_ACTIVATE_USER */
1.1 root 229:
230: #ifndef PMAP_DEACTIVATE_USER
231: #define PMAP_DEACTIVATE_USER(pmap, thread, cpu) { \
232: if ((pmap) != kernel_pmap) \
233: PMAP_DEACTIVATE(pmap, thread, cpu); \
234: }
1.1.1.2 root 235: #endif /* PMAP_DEACTIVATE_USER */
1.1 root 236:
237: #ifndef PMAP_ACTIVATE_KERNEL
238: #define PMAP_ACTIVATE_KERNEL(cpu) \
239: PMAP_ACTIVATE(kernel_pmap, THREAD_NULL, cpu)
1.1.1.2 root 240: #endif /* PMAP_ACTIVATE_KERNEL */
1.1 root 241:
242: #ifndef PMAP_DEACTIVATE_KERNEL
243: #define PMAP_DEACTIVATE_KERNEL(cpu) \
244: PMAP_DEACTIVATE(kernel_pmap, THREAD_NULL, cpu)
1.1.1.2 root 245: #endif /* PMAP_DEACTIVATE_KERNEL */
1.1 root 246:
247: /*
248: * Exported data structures
249: */
250:
251: extern pmap_t kernel_pmap; /* The kernel's map */
252:
1.1.1.2 root 253: #endif /* _VM_PMAP_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.