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