device_pager.c (89c9c53da05197f657dfe8e0bdda6941a2e9a0d4) device_pager.c (92bab635d359616180771d2d2630d00493bc4cc6)
1/*
2 * Copyright (c) 1990 University of Utah.
3 * Copyright (c) 1991, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.

--- 60 unchanged lines hidden (view full) ---

69/* protect list manipulation */
70static struct mtx dev_pager_mtx;
71
72
73static uma_zone_t fakepg_zone;
74
75static vm_page_t dev_pager_getfake(vm_paddr_t);
76static void dev_pager_putfake(vm_page_t);
1/*
2 * Copyright (c) 1990 University of Utah.
3 * Copyright (c) 1991, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.

--- 60 unchanged lines hidden (view full) ---

69/* protect list manipulation */
70static struct mtx dev_pager_mtx;
71
72
73static uma_zone_t fakepg_zone;
74
75static vm_page_t dev_pager_getfake(vm_paddr_t);
76static void dev_pager_putfake(vm_page_t);
77static void dev_pager_updatefake(vm_page_t, vm_paddr_t);
77
78struct pagerops devicepagerops = {
79 .pgo_init = dev_pager_init,
80 .pgo_alloc = dev_pager_alloc,
81 .pgo_dealloc = dev_pager_dealloc,
82 .pgo_getpages = dev_pager_getpages,
83 .pgo_putpages = dev_pager_putpages,
84 .pgo_haspage = dev_pager_haspage,

--- 134 unchanged lines hidden (view full) ---

219
220 if (mapfunc == NULL || mapfunc == (d_mmap_t *)nullop)
221 panic("dev_pager_getpage: no map function");
222
223 ret = (*mapfunc)(dev, (vm_offset_t)offset << PAGE_SHIFT, &paddr, prot);
224 KASSERT(ret == 0, ("dev_pager_getpage: map function returns error"));
225 mtx_unlock(&Giant);
226
78
79struct pagerops devicepagerops = {
80 .pgo_init = dev_pager_init,
81 .pgo_alloc = dev_pager_alloc,
82 .pgo_dealloc = dev_pager_dealloc,
83 .pgo_getpages = dev_pager_getpages,
84 .pgo_putpages = dev_pager_putpages,
85 .pgo_haspage = dev_pager_haspage,

--- 134 unchanged lines hidden (view full) ---

220
221 if (mapfunc == NULL || mapfunc == (d_mmap_t *)nullop)
222 panic("dev_pager_getpage: no map function");
223
224 ret = (*mapfunc)(dev, (vm_offset_t)offset << PAGE_SHIFT, &paddr, prot);
225 KASSERT(ret == 0, ("dev_pager_getpage: map function returns error"));
226 mtx_unlock(&Giant);
227
227 /*
228 * Replace the passed in reqpage page with our own fake page and
229 * free up the all of the original pages.
230 */
231 page = dev_pager_getfake(paddr);
232 VM_OBJECT_LOCK(object);
233 TAILQ_INSERT_TAIL(&object->un_pager.devp.devp_pglist, page, pageq);
234 vm_page_lock_queues();
235 for (i = 0; i < count; i++)
236 vm_page_free(m[i]);
237 vm_page_unlock_queues();
238 vm_page_insert(page, object, offset);
239 m[reqpage] = page;
228 if ((m[reqpage]->flags & PG_FICTITIOUS) != 0) {
229 /*
230 * If the passed in reqpage page is a fake page, update it with
231 * the new physical address.
232 */
233 dev_pager_updatefake(m[reqpage], paddr);
234 VM_OBJECT_LOCK(object);
235 if (count > 1) {
236 vm_page_lock_queues();
237 for (i = 0; i < count; i++) {
238 if (i != reqpage)
239 vm_page_free(m[i]);
240 }
241 vm_page_unlock_queues();
242 }
243 } else {
244 /*
245 * Replace the passed in reqpage page with our own fake page and
246 * free up the all of the original pages.
247 */
248 page = dev_pager_getfake(paddr);
249 VM_OBJECT_LOCK(object);
250 TAILQ_INSERT_TAIL(&object->un_pager.devp.devp_pglist, page, pageq);
251 vm_page_lock_queues();
252 for (i = 0; i < count; i++)
253 vm_page_free(m[i]);
254 vm_page_unlock_queues();
255 vm_page_insert(page, object, offset);
256 m[reqpage] = page;
257 }
240
241 return (VM_PAGER_OK);
242}
243
244static void
245dev_pager_putpages(object, m, count, sync, rtvals)
246 vm_object_t object;
247 vm_page_t *m;

--- 43 unchanged lines hidden (view full) ---

291static void
292dev_pager_putfake(m)
293 vm_page_t m;
294{
295 if (!(m->flags & PG_FICTITIOUS))
296 panic("dev_pager_putfake: bad page");
297 uma_zfree(fakepg_zone, m);
298}
258
259 return (VM_PAGER_OK);
260}
261
262static void
263dev_pager_putpages(object, m, count, sync, rtvals)
264 vm_object_t object;
265 vm_page_t *m;

--- 43 unchanged lines hidden (view full) ---

309static void
310dev_pager_putfake(m)
311 vm_page_t m;
312{
313 if (!(m->flags & PG_FICTITIOUS))
314 panic("dev_pager_putfake: bad page");
315 uma_zfree(fakepg_zone, m);
316}
317
318static void
319dev_pager_updatefake(m, paddr)
320 vm_page_t m;
321 vm_paddr_t paddr;
322{
323 if (!(m->flags & PG_FICTITIOUS))
324 panic("dev_pager_updatefake: bad page");
325 m->phys_addr = paddr;
326}