1/* $OpenBSD: uvm_pmap.h,v 1.37 2025/06/02 18:49:04 claudio 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
72struct 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 */
80struct pmap_statistics {
81 long resident_count; /* # of pages mapped (total)*/
82 long wired_count; /* # of pages wired */
83};
84typedef 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 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#define PMAP_MD0 0x00000040 /* Machine dependant */
96#define PMAP_MD1 0x00000080 /* Machine dependant */
97#define PMAP_MD2 0x00000100 /* Machine dependant */
98#define PMAP_MD3 0x00000200 /* Machine dependant */
99
100#ifndef PMAP_WC
101#define PMAP_WC 0
102#endif
103
104#ifndef PMAP_PREFER
105#define PMAP_PREFER_ALIGN() 0
106#define PMAP_PREFER_OFFSET(off) 0
107#endif
108
109#ifdef _KERNEL
110__BEGIN_DECLS
111#ifndef pmap_activate
112void pmap_activate(struct proc *);
113#endif
114#ifndef pmap_deactivate
115void pmap_deactivate(struct proc *);
116#endif
117#ifndef pmap_unwire
118void pmap_unwire(pmap_t, vaddr_t);
119#endif
120
121#if !defined(pmap_clear_modify)
122boolean_t pmap_clear_modify(struct vm_page *);
123#endif
124#if !defined(pmap_clear_reference)
125boolean_t pmap_clear_reference(struct vm_page *);
126#endif
127
128#if !defined(pmap_copy_page)
129void pmap_copy_page(struct vm_page *, struct vm_page *);
130#endif
131struct pmap *pmap_create(void);
132void pmap_destroy(pmap_t);
133int pmap_enter(pmap_t,
134 vaddr_t, paddr_t, vm_prot_t, int);
135boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
136#if defined(PMAP_GROWKERNEL)
137vaddr_t pmap_growkernel(vaddr_t);
138#endif
139
140void pmap_init(void);
141
142void pmap_kenter_pa(vaddr_t, paddr_t, vm_prot_t);
143void pmap_kremove(vaddr_t, vsize_t);
144#if !defined(pmap_is_modified)
145boolean_t pmap_is_modified(struct vm_page *);
146#endif
147#if !defined(pmap_is_referenced)
148boolean_t pmap_is_referenced(struct vm_page *);
149#endif
150
151void pmap_page_protect(struct vm_page *, vm_prot_t);
152
153#if !defined(pmap_proc_iflush)
154void pmap_proc_iflush(struct process *, vaddr_t, vsize_t);
155#endif
156void pmap_protect(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
157#if !defined(pmap_reference)
158void pmap_reference(pmap_t);
159#endif
160#if !defined(pmap_remove)
161void pmap_remove(pmap_t, vaddr_t, vaddr_t);
162#endif
163#if !defined(pmap_remove_holes)
164void pmap_remove_holes(struct vmspace *);
165#endif
166#if !defined(pmap_update)
167void pmap_update(pmap_t);
168#endif
169#if !defined(pmap_zero_page)
170void pmap_zero_page(struct vm_page *);
171#endif
172
173#if defined(PMAP_STEAL_MEMORY)
174vaddr_t pmap_steal_memory(vsize_t, vaddr_t *, vaddr_t *);
175#else
176void pmap_virtual_space(vaddr_t *, vaddr_t *);
177#endif
178
179#if defined(__HAVE_PMAP_POPULATE)
180void pmap_populate(pmap_t, vaddr_t);
181#endif
182
183#if defined(__HAVE_PMAP_PURGE)
184void pmap_purge(struct proc *);
185#endif
186
187/* nested pmaps are used in i386/amd64 vmm */
188#ifndef pmap_nested
189#define pmap_nested(pm) 0
190#endif
191
192__END_DECLS
193#endif /* kernel*/
194
195#endif /* _PMAP_VM_ */