|
|
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: /* Initialization, after kernel runs in virtual memory. */
71: extern void pmap_init(void);
1.1 root 72:
73: #ifndef MACHINE_PAGES
74: /*
75: * If machine/pmap.h defines MACHINE_PAGES, it must implement
76: * the above functions. The pmap module has complete control.
77: * Otherwise, it must implement
78: * pmap_free_pages
79: * pmap_virtual_space
80: * pmap_init
1.1.1.5 ! root 81: * and vm/vm_resident.c implements pmap_steal_memory using
! 82: * pmap_free_pages, pmap_virtual_space, and pmap_enter.
! 83: *
! 84: * pmap_free_pages may over-estimate the number of unused physical pages.
1.1 root 85: * However, for best performance pmap_free_pages should be accurate.
86: */
87:
1.1.1.3 root 88: /* During VM initialization, report virtual space available for the kernel. */
89: extern void pmap_virtual_space(vm_offset_t *, vm_offset_t *);
1.1.1.2 root 90: #endif /* MACHINE_PAGES */
1.1 root 91:
92: /*
93: * Routines to manage the physical map data structure.
94: */
95:
96: /* Create a pmap_t. */
97: pmap_t pmap_create(vm_size_t size);
98:
99: /* Return the kernel's pmap_t. */
100: #ifndef pmap_kernel
101: extern pmap_t pmap_kernel(void);
1.1.1.2 root 102: #endif /* pmap_kernel */
1.1 root 103:
104: /* Gain and release a reference. */
1.1.1.2 root 105: extern void pmap_reference(pmap_t pmap);
1.1 root 106: extern void pmap_destroy(pmap_t pmap);
107:
108: /* Enter a mapping */
109: extern void pmap_enter(pmap_t pmap, vm_offset_t va, vm_offset_t pa,
110: vm_prot_t prot, boolean_t wired);
111:
112:
113: /*
114: * Routines that operate on ranges of virtual addresses.
115: */
116:
117: /* Remove mappings. */
118: void pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva);
119:
120: /* Change protections. */
121: void pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot);
122:
123: /*
124: * Routines to set up hardware state for physical maps to be used.
125: */
1.1.1.3 root 126: /* Prepare pmap_t to run on a given processor. */
127: extern void pmap_activate(pmap_t, thread_t, int);
128: /* Release pmap_t from use on processor. */
129: extern void pmap_deactivate(pmap_t, thread_t, int);
1.1 root 130:
131:
132: /*
133: * Routines that operate on physical addresses.
134: */
135:
136: /* Restrict access to page. */
137: void pmap_page_protect(vm_offset_t pa, vm_prot_t prot);
138:
139: /*
140: * Routines to manage reference/modify bits based on
141: * physical addresses, simulating them if not provided
142: * by the hardware.
143: */
144:
145: /* Clear reference bit */
146: void pmap_clear_reference(vm_offset_t pa);
147:
148: /* Return reference bit */
149: #ifndef pmap_is_referenced
150: boolean_t pmap_is_referenced(vm_offset_t pa);
1.1.1.2 root 151: #endif /* pmap_is_referenced */
1.1 root 152:
153: /* Clear modify bit */
154: void pmap_clear_modify(vm_offset_t pa);
155:
156: /* Return modify bit */
157: boolean_t pmap_is_modified(vm_offset_t pa);
158:
159: /*
160: * Sundry required routines
161: */
1.1.1.3 root 162: /* Return a virtual-to-physical mapping, if possible. */
163: extern vm_offset_t pmap_extract(pmap_t, vm_offset_t);
164: /* Perform garbage collection, if any. */
165: extern void pmap_collect(pmap_t);
166: /* Specify pageability. */
167: extern void pmap_change_wiring(pmap_t, vm_offset_t, boolean_t);
1.1 root 168:
169: /*
170: * Optional routines
171: */
172: #ifndef pmap_copy
1.1.1.3 root 173: /* Copy range of mappings, if desired. */
174: extern void pmap_copy(pmap_t, pmap_t, vm_offset_t, vm_size_t,
175: vm_offset_t);
1.1.1.2 root 176: #endif /* pmap_copy */
1.1 root 177: #ifndef pmap_attribute
1.1.1.3 root 178: /* Get/Set special memory attributes. */
1.1.1.4 root 179: extern kern_return_t pmap_attribute(void);
1.1.1.2 root 180: #endif /* pmap_attribute */
1.1 root 181:
182: /*
1.1.1.3 root 183: * Grab a physical page:
184: * the standard memory allocation mechanism
185: * during system initialization.
186: */
187: extern vm_offset_t pmap_grab_page (void);
188:
189: extern boolean_t pmap_valid_page(vm_offset_t x);
190:
191: /*
192: * Make the specified pages (by pmap, offset)
193: * pageable (or not) as requested.
194: */
195: extern void pmap_pageable(
196: pmap_t pmap,
197: vm_offset_t start,
198: vm_offset_t end,
199: boolean_t pageable);
200:
201: /*
202: * Back-door routine for mapping kernel VM at initialization.
203: * Useful for mapping memory outside the range
204: * [phys_first_addr, phys_last_addr) (i.e., devices).
205: * Otherwise like pmap_map.
206: */
207: extern vm_offset_t pmap_map_bd(
208: vm_offset_t virt,
209: vm_offset_t start,
210: vm_offset_t end,
211: vm_prot_t prot);
212:
213: /*
1.1 root 214: * Routines defined as macros.
215: */
216: #ifndef PMAP_ACTIVATE_USER
217: #define PMAP_ACTIVATE_USER(pmap, thread, cpu) { \
218: if ((pmap) != kernel_pmap) \
219: PMAP_ACTIVATE(pmap, thread, cpu); \
220: }
1.1.1.2 root 221: #endif /* PMAP_ACTIVATE_USER */
1.1 root 222:
223: #ifndef PMAP_DEACTIVATE_USER
224: #define PMAP_DEACTIVATE_USER(pmap, thread, cpu) { \
225: if ((pmap) != kernel_pmap) \
226: PMAP_DEACTIVATE(pmap, thread, cpu); \
227: }
1.1.1.2 root 228: #endif /* PMAP_DEACTIVATE_USER */
1.1 root 229:
230: #ifndef PMAP_ACTIVATE_KERNEL
231: #define PMAP_ACTIVATE_KERNEL(cpu) \
232: PMAP_ACTIVATE(kernel_pmap, THREAD_NULL, cpu)
1.1.1.2 root 233: #endif /* PMAP_ACTIVATE_KERNEL */
1.1 root 234:
235: #ifndef PMAP_DEACTIVATE_KERNEL
236: #define PMAP_DEACTIVATE_KERNEL(cpu) \
237: PMAP_DEACTIVATE(kernel_pmap, THREAD_NULL, cpu)
1.1.1.2 root 238: #endif /* PMAP_DEACTIVATE_KERNEL */
1.1 root 239:
240: /*
241: * Exported data structures
242: */
243:
244: extern pmap_t kernel_pmap; /* The kernel's map */
245:
1.1.1.2 root 246: #endif /* _VM_PMAP_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.