pmap.h revision 1.2 1 1.1 cherry /*-
2 1.1 cherry * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
3 1.1 cherry * All rights reserved.
4 1.1 cherry *
5 1.1 cherry * This code is derived from software contributed to The NetBSD Foundation
6 1.1 cherry * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
7 1.1 cherry * NASA Ames Research Center and by Chris G. Demetriou.
8 1.1 cherry *
9 1.1 cherry * Redistribution and use in source and binary forms, with or without
10 1.1 cherry * modification, are permitted provided that the following conditions
11 1.1 cherry * are met:
12 1.1 cherry * 1. Redistributions of source code must retain the above copyright
13 1.1 cherry * notice, this list of conditions and the following disclaimer.
14 1.1 cherry * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 cherry * notice, this list of conditions and the following disclaimer in the
16 1.1 cherry * documentation and/or other materials provided with the distribution.
17 1.1 cherry * 3. All advertising materials mentioning features or use of this software
18 1.1 cherry * must display the following acknowledgement:
19 1.1 cherry * This product includes software developed by the NetBSD
20 1.1 cherry * Foundation, Inc. and its contributors.
21 1.1 cherry * 4. Neither the name of The NetBSD Foundation nor the names of its
22 1.1 cherry * contributors may be used to endorse or promote products derived
23 1.1 cherry * from this software without specific prior written permission.
24 1.1 cherry *
25 1.1 cherry * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 1.1 cherry * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1 cherry * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1 cherry * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 1.1 cherry * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1 cherry * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 cherry * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 cherry * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1 cherry * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 cherry * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1 cherry * POSSIBILITY OF SUCH DAMAGE.
36 1.1 cherry */
37 1.1 cherry
38 1.1 cherry /*-
39 1.1 cherry * Copyright (c) 1991 Regents of the University of California.
40 1.1 cherry * All rights reserved.
41 1.1 cherry *
42 1.1 cherry * This code is derived from software contributed to Berkeley by
43 1.1 cherry * the Systems Programming Group of the University of Utah Computer
44 1.1 cherry * Science Department and William Jolitz of UUNET Technologies Inc.
45 1.1 cherry *
46 1.1 cherry * Redistribution and use in source and binary forms, with or without
47 1.1 cherry * modification, are permitted provided that the following conditions
48 1.1 cherry * are met:
49 1.1 cherry * 1. Redistributions of source code must retain the above copyright
50 1.1 cherry * notice, this list of conditions and the following disclaimer.
51 1.1 cherry * 2. Redistributions in binary form must reproduce the above copyright
52 1.1 cherry * notice, this list of conditions and the following disclaimer in the
53 1.1 cherry * documentation and/or other materials provided with the distribution.
54 1.1 cherry * 4. Neither the name of the University nor the names of its contributors
55 1.1 cherry * may be used to endorse or promote products derived from this software
56 1.1 cherry * without specific prior written permission.
57 1.1 cherry *
58 1.1 cherry * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 1.1 cherry * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 1.1 cherry * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 1.1 cherry * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 1.1 cherry * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 1.1 cherry * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 1.1 cherry * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 1.1 cherry * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 1.1 cherry * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 1.1 cherry * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 1.1 cherry * SUCH DAMAGE.
69 1.1 cherry *
70 1.1 cherry * Derived from hp300 version by Mike Hibler, this version by William
71 1.1 cherry * Jolitz uses a recursive map [a pde points to the page directory] to
72 1.1 cherry * map the page tables using the pagetables themselves. This is done to
73 1.1 cherry * reduce the impact on kernel virtual memory for lots of sparse address
74 1.1 cherry * space, and to reduce the cost of memory to each process.
75 1.1 cherry *
76 1.1 cherry * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
77 1.1 cherry * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
78 1.1 cherry * from: i386 pmap.h,v 1.54 1997/11/20 19:30:35 bde Exp
79 1.1 cherry * $FreeBSD: src/sys/ia64/include/pmap.h,v 1.25 2005/09/03 23:53:50 marcel Exp $
80 1.1 cherry */
81 1.1 cherry
82 1.1 cherry #ifndef _PMAP_MACHINE_
83 1.1 cherry #define _PMAP_MACHINE_
84 1.1 cherry
85 1.2 cherry #include <sys/lock.h>
86 1.2 cherry
87 1.1 cherry paddr_t vtophys(vaddr_t);
88 1.1 cherry
89 1.1 cherry struct pv_entry; /* Forward declaration. */
90 1.1 cherry
91 1.1 cherry struct pmap {
92 1.1 cherry TAILQ_ENTRY(pmap) pm_list; /* list of all pmaps */
93 1.1 cherry TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */
94 1.1 cherry int pm_count; /* pmap reference count */
95 1.1 cherry struct simplelock pm_slock; /* lock on pmap */
96 1.1 cherry u_int32_t pm_rid[5]; /* base RID for pmap */
97 1.1 cherry int pm_active; /* active flag */
98 1.1 cherry struct pmap_statistics pm_stats; /* pmap statistics */
99 1.1 cherry unsigned long pm_cpus; /* mask of CPUs using pmap */
100 1.1 cherry
101 1.1 cherry };
102 1.1 cherry
103 1.1 cherry typedef struct pmap *pmap_t;
104 1.1 cherry
105 1.1 cherry /*
106 1.1 cherry * For each vm_page_t, there is a list of all currently valid virtual
107 1.1 cherry * mappings of that page. An entry is a pv_entry_t, the list is pv_pvlist.
108 1.1 cherry */
109 1.1 cherry typedef struct pv_entry {
110 1.1 cherry pmap_t pv_pmap; /* pmap where mapping lies */
111 1.1 cherry vaddr_t pv_va; /* virtual address for mapping */
112 1.1 cherry TAILQ_ENTRY(pv_entry) pv_list;
113 1.1 cherry TAILQ_ENTRY(pv_entry) pv_plist;
114 1.1 cherry } *pv_entry_t;
115 1.1 cherry
116 1.1 cherry /* pvh_attrs */
117 1.1 cherry #define PGA_MODIFIED 0x01 /* modified */
118 1.1 cherry #define PGA_REFERENCED 0x02 /* referenced */
119 1.1 cherry
120 1.1 cherry
121 1.1 cherry extern struct pmap kernel_pmap_store;
122 1.1 cherry
123 1.1 cherry #define pmap_kernel() (&kernel_pmap_store)
124 1.1 cherry
125 1.1 cherry #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
126 1.1 cherry #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
127 1.1 cherry
128 1.1 cherry #define pmap_copy(dp, sp, da, l, sa) /* nothing */
129 1.1 cherry #define pmap_update(pmap) /* nothing (yet) */
130 1.1 cherry
131 1.1 cherry void pmap_bootstrap(void);
132 1.1 cherry
133 1.1 cherry #define pmap_is_referenced(pg) \
134 1.1 cherry (((pg)->mdpage.pvh_attrs & PGA_REFERENCED) != 0)
135 1.1 cherry #define pmap_is_modified(pg) \
136 1.1 cherry (((pg)->mdpage.pvh_attrs & PGA_MODIFIED) != 0)
137 1.1 cherry
138 1.1 cherry
139 1.1 cherry #define PMAP_STEAL_MEMORY /* enable pmap_steal_memory() */
140 1.1 cherry
141 1.1 cherry /*
142 1.1 cherry * Alternate mapping hooks for pool pages. Avoids thrashing the TLB.
143 1.1 cherry */
144 1.1 cherry #define PMAP_MAP_POOLPAGE(pa) IA64_PHYS_TO_RR7((pa))
145 1.1 cherry #define PMAP_UNMAP_POOLPAGE(va) IA64_RR_MASK((va))
146 1.1 cherry
147 1.1 cherry /*
148 1.1 cherry * Macros for locking pmap structures.
149 1.1 cherry *
150 1.1 cherry * Note that we if we access the kernel pmap in interrupt context, it
151 1.1 cherry * is only to update statistics. Since stats are updated using atomic
152 1.1 cherry * operations, locking the kernel pmap is not necessary. Therefore,
153 1.1 cherry * it is not necessary to block interrupts when locking pmap strucutres.
154 1.1 cherry */
155 1.1 cherry #define PMAP_LOCK(pmap) simple_lock(&(pmap)->pm_slock)
156 1.1 cherry #define PMAP_UNLOCK(pmap) simple_unlock(&(pmap)->pm_slock)
157 1.1 cherry
158 1.1 cherry
159 1.1 cherry #define PMAP_VHPT_LOG2SIZE 16
160 1.1 cherry
161 1.1 cherry
162 1.1 cherry #endif /* _PMAP_MACHINE_ */
163