1 /* $OpenBSD: uvm_pmap.h,v 1.18 2005/04/04 23:40:05 miod Exp $ */
2 /* $NetBSD: uvm_pmap.h,v 1.1 2000/06/27 09:00:14 mrg Exp $ */
3
4 /*
5 * Copyright (c) 1991, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * The Mach Operating System project at Carnegie-Mellon University.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)pmap.h 8.1 (Berkeley) 6/11/93
36 *
37 *
38 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
39 * All rights reserved.
40 *
41 * Author: Avadis Tevanian, Jr.
42 *
43 * Permission to use, copy, modify and distribute this software and
44 * its documentation is hereby granted, provided that both the copyright
45 * notice and this permission notice appear in all copies of the
46 * software, derivative works or modified versions, and any portions
47 * thereof, and that both notices appear in supporting documentation.
48 *
49 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
50 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
51 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
52 *
53 * Carnegie Mellon requests users of this software to return to
54 *
55 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
56 * School of Computer Science
57 * Carnegie Mellon University
58 * Pittsburgh PA 15213-3890
59 *
60 * any improvements or extensions that they make and grant Carnegie the
61 * rights to redistribute these changes.
62 */
63
64 /*
65 * Machine address mapping definitions -- machine-independent
66 * section. [For machine-dependent section, see "machine/pmap.h".]
67 */
68
69 #ifndef _PMAP_VM_
70 #define _PMAP_VM_
71
72 struct proc; /* for pmap_activate()/pmap_deactivate() proto */
73
74 /*
75 * Each machine dependent implementation is expected to
76 * keep certain statistics. They may do this anyway they
77 * so choose, but are expected to return the statistics
78 * in the following structure.
79 */
80 struct pmap_statistics {
81 long resident_count; /* # of pages mapped (total)*/
82 long wired_count; /* # of pages wired */
83 };
84 typedef struct pmap_statistics *pmap_statistics_t;
85
86 #include <machine/pmap.h>
87
88 /*
89 * Flags passed to pmap_enter(). Note the bottom 3 bits are VM_PROT_*
90 * bits, used to indicate the access type that was made (to seed modified
91 * and referenced information).
92 */
93 #define PMAP_WIRED 0x00000010 /* wired mapping */
94 #define PMAP_CANFAIL 0x00000020 /* can fail if resource shortage */
95
96 #ifndef PMAP_EXCLUDE_DECLS /* Used in Sparc port to virtualize pmap mod */
97 #ifdef _KERNEL
98 __BEGIN_DECLS
99 #ifndef pmap_activate
100 void pmap_activate(struct proc *);
101 #endif
102 #ifndef pmap_deactivate
103 void pmap_deactivate(struct proc *);
104 #endif
105 #ifndef pmap_unwire
106 void pmap_unwire(pmap_t, vaddr_t);
107 #endif
108
109 #if !defined(pmap_clear_modify)
110 boolean_t pmap_clear_modify(struct vm_page *);
111 #endif
112 #if !defined(pmap_clear_reference)
113 boolean_t pmap_clear_reference(struct vm_page *);
114 #endif
115
116 #if !defined(pmap_collect)
117 void pmap_collect(pmap_t);
118 #endif
119 #if !defined(pmap_copy)
120 void pmap_copy(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t);
121 #endif
122 #if !defined(pmap_copy_page)
123 void pmap_copy_page(struct vm_page *, struct vm_page *);
124 #endif
125 struct pmap *pmap_create(void);
126 void pmap_destroy(pmap_t);
127 int pmap_enter(pmap_t,
128 vaddr_t, paddr_t, vm_prot_t, int);
129 boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
130 #if defined(PMAP_GROWKERNEL)
131 vaddr_t pmap_growkernel(vaddr_t);
132 #endif
133
134 void pmap_init(void);
135
136 void pmap_kenter_pa(vaddr_t, paddr_t, vm_prot_t);
137 void pmap_kremove(vaddr_t, vsize_t);
138 #if !defined(pmap_is_modified)
139 boolean_t pmap_is_modified(struct vm_page *);
140 #endif
141 #if !defined(pmap_is_referenced)
142 boolean_t pmap_is_referenced(struct vm_page *);
143 #endif
144
145 void pmap_page_protect(struct vm_page *, vm_prot_t);
146
147 #if !defined(pmap_phys_address)
148 paddr_t pmap_phys_address(int);
149 #endif
150 void pmap_protect(pmap_t,
151 vaddr_t, vaddr_t, vm_prot_t);
152 #if !defined(pmap_reference)
153 void pmap_reference(pmap_t);
154 #endif
155 #if !defined(pmap_remove)
156 void pmap_remove(pmap_t, vaddr_t, vaddr_t);
157 #endif
158 #if !defined(pmap_update)
159 void pmap_update(pmap_t);
160 #endif
161 #if !defined(pmap_zero_page)
162 void pmap_zero_page(struct vm_page *);
163 #endif
164
165 void pmap_virtual_space(vaddr_t *, vaddr_t *);
166 #if defined(PMAP_STEAL_MEMORY)
167 vaddr_t pmap_steal_memory(vsize_t, vaddr_t *, vaddr_t *);
168 #endif
169
170 #if defined(PMAP_FORK)
171 void pmap_fork(pmap_t, pmap_t);
172 #endif
173 __END_DECLS
174 #endif /* kernel*/
175 #endif /* PMAP_EXCLUDE_DECLS */
176
177 #endif /* _PMAP_VM_ */