This source file includes following definitions.
- amap_lookup
- amap_lookups
- amap_add
- amap_unadd
- amap_ref
- amap_unref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 #ifndef _UVM_UVM_AMAP_I_H_
39 #define _UVM_UVM_AMAP_I_H_
40
41
42
43
44
45
46
47
48
49
50 #if defined(UVM_AMAP_INLINE) || defined(UVM_AMAP_C)
51
52
53
54
55
56
57 AMAP_INLINE struct vm_anon *
58 amap_lookup(aref, offset)
59 struct vm_aref *aref;
60 vaddr_t offset;
61 {
62 int slot;
63 struct vm_amap *amap = aref->ar_amap;
64 UVMHIST_FUNC("amap_lookup"); UVMHIST_CALLED(maphist);
65
66 AMAP_B2SLOT(slot, offset);
67 slot += aref->ar_pageoff;
68
69 if (slot >= amap->am_nslot)
70 panic("amap_lookup: offset out of range");
71
72 UVMHIST_LOG(maphist, "<- done (amap=%p, offset=0x%lx, result=%p)",
73 amap, offset, amap->am_anon[slot], 0);
74 return(amap->am_anon[slot]);
75 }
76
77
78
79
80
81
82
83 AMAP_INLINE void
84 amap_lookups(aref, offset, anons, npages)
85 struct vm_aref *aref;
86 vaddr_t offset;
87 struct vm_anon **anons;
88 int npages;
89 {
90 int slot;
91 struct vm_amap *amap = aref->ar_amap;
92 UVMHIST_FUNC("amap_lookups"); UVMHIST_CALLED(maphist);
93
94 AMAP_B2SLOT(slot, offset);
95 slot += aref->ar_pageoff;
96
97 UVMHIST_LOG(maphist, " slot=%ld, npages=%ld, nslot=%ld", slot, npages,
98 amap->am_nslot, 0);
99
100 if ((slot + (npages - 1)) >= amap->am_nslot)
101 panic("amap_lookups: offset out of range");
102
103 memcpy(anons, &amap->am_anon[slot], npages * sizeof(struct vm_anon *));
104
105 UVMHIST_LOG(maphist, "<- done", 0, 0, 0, 0);
106 return;
107 }
108
109
110
111
112
113
114
115
116
117 AMAP_INLINE void
118 amap_add(aref, offset, anon, replace)
119 struct vm_aref *aref;
120 vaddr_t offset;
121 struct vm_anon *anon;
122 boolean_t replace;
123 {
124 int slot;
125 struct vm_amap *amap = aref->ar_amap;
126 UVMHIST_FUNC("amap_add"); UVMHIST_CALLED(maphist);
127
128 AMAP_B2SLOT(slot, offset);
129 slot += aref->ar_pageoff;
130
131 if (slot >= amap->am_nslot)
132 panic("amap_add: offset out of range");
133
134 if (replace) {
135
136 if (amap->am_anon[slot] == NULL)
137 panic("amap_add: replacing null anon");
138 if (amap->am_anon[slot]->an_page != NULL &&
139 (amap->am_flags & AMAP_SHARED) != 0) {
140 pmap_page_protect(amap->am_anon[slot]->an_page,
141 VM_PROT_NONE);
142
143
144
145 }
146 } else {
147 if (amap->am_anon[slot] != NULL)
148 panic("amap_add: slot in use");
149
150 amap->am_bckptr[slot] = amap->am_nused;
151 amap->am_slots[amap->am_nused] = slot;
152 amap->am_nused++;
153 }
154 amap->am_anon[slot] = anon;
155 UVMHIST_LOG(maphist,
156 "<- done (amap=%p, offset=0x%lx, anon=%p, rep=%ld)",
157 amap, offset, anon, replace);
158 }
159
160
161
162
163
164
165 AMAP_INLINE void
166 amap_unadd(aref, offset)
167 struct vm_aref *aref;
168 vaddr_t offset;
169 {
170 int ptr, slot;
171 struct vm_amap *amap = aref->ar_amap;
172 UVMHIST_FUNC("amap_unadd"); UVMHIST_CALLED(maphist);
173
174 AMAP_B2SLOT(slot, offset);
175 slot += aref->ar_pageoff;
176
177 if (slot >= amap->am_nslot)
178 panic("amap_unadd: offset out of range");
179
180 if (amap->am_anon[slot] == NULL)
181 panic("amap_unadd: nothing there");
182
183 amap->am_anon[slot] = NULL;
184 ptr = amap->am_bckptr[slot];
185
186 if (ptr != (amap->am_nused - 1)) {
187 amap->am_slots[ptr] = amap->am_slots[amap->am_nused - 1];
188 amap->am_bckptr[amap->am_slots[ptr]] = ptr;
189 }
190 amap->am_nused--;
191 UVMHIST_LOG(maphist, "<- done (amap=%p, slot=%ld)", amap, slot,0, 0);
192 }
193
194
195
196
197
198
199
200
201 AMAP_INLINE void
202 amap_ref(amap, offset, len, flags)
203 struct vm_amap *amap;
204 vaddr_t offset;
205 vsize_t len;
206 int flags;
207 {
208 UVMHIST_FUNC("amap_ref"); UVMHIST_CALLED(maphist);
209
210 amap->am_ref++;
211 if (flags & AMAP_SHARED)
212 amap->am_flags |= AMAP_SHARED;
213 #ifdef UVM_AMAP_PPREF
214 if (amap->am_ppref == NULL && (flags & AMAP_REFALL) == 0 &&
215 len != amap->am_nslot)
216 amap_pp_establish(amap);
217 if (amap->am_ppref && amap->am_ppref != PPREF_NONE) {
218 if (flags & AMAP_REFALL)
219 amap_pp_adjref(amap, 0, amap->am_nslot, 1);
220 else
221 amap_pp_adjref(amap, offset, len, 1);
222 }
223 #endif
224 UVMHIST_LOG(maphist,"<- done! amap=%p", amap, 0, 0, 0);
225 }
226
227
228
229
230
231
232
233
234
235
236 AMAP_INLINE void
237 amap_unref(amap, offset, len, all)
238 struct vm_amap *amap;
239 vaddr_t offset;
240 vsize_t len;
241 boolean_t all;
242 {
243 UVMHIST_FUNC("amap_unref"); UVMHIST_CALLED(maphist);
244
245 UVMHIST_LOG(maphist," amap=%p refs=%ld, nused=%ld",
246 amap, amap->am_ref, amap->am_nused, 0);
247
248
249
250
251
252 if (amap->am_ref-- == 1) {
253 amap_wipeout(amap);
254 UVMHIST_LOG(maphist,"<- done (was last ref)!", 0, 0, 0, 0);
255 return;
256 }
257
258
259
260
261 if (amap->am_ref == 1 && (amap->am_flags & AMAP_SHARED) != 0)
262 amap->am_flags &= ~AMAP_SHARED;
263 #ifdef UVM_AMAP_PPREF
264 if (amap->am_ppref == NULL && all == 0 && len != amap->am_nslot)
265 amap_pp_establish(amap);
266 if (amap->am_ppref && amap->am_ppref != PPREF_NONE) {
267 if (all)
268 amap_pp_adjref(amap, 0, amap->am_nslot, -1);
269 else
270 amap_pp_adjref(amap, offset, len, -1);
271 }
272 #endif
273
274 UVMHIST_LOG(maphist,"<- done!", 0, 0, 0, 0);
275 }
276
277 #endif
278
279 #endif