MCPcopy Create free account
hub / github.com/F-Stack/f-stack / old_dev_pager_fault

Function old_dev_pager_fault

freebsd/vm/device_pager.c:332–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332static int
333old_dev_pager_fault(vm_object_t object, vm_ooffset_t offset, int prot,
334 vm_page_t *mres)
335{
336 vm_paddr_t paddr;
337 vm_page_t m_paddr, page;
338 struct cdev *dev;
339 struct cdevsw *csw;
340 struct file *fpop;
341 struct thread *td;
342 vm_memattr_t memattr, memattr1;
343 int ref, ret;
344
345 memattr = object->memattr;
346
347 VM_OBJECT_WUNLOCK(object);
348
349 dev = object->handle;
350 csw = dev_refthread(dev, &ref);
351 if (csw == NULL) {
352 VM_OBJECT_WLOCK(object);
353 return (VM_PAGER_FAIL);
354 }
355 td = curthread;
356 fpop = td->td_fpop;
357 td->td_fpop = NULL;
358 ret = csw->d_mmap(dev, offset, &paddr, prot, &memattr);
359 td->td_fpop = fpop;
360 dev_relthread(dev, ref);
361 if (ret != 0) {
362 printf(
363 "WARNING: dev_pager_getpage: map function returns error %d", ret);
364 VM_OBJECT_WLOCK(object);
365 return (VM_PAGER_FAIL);
366 }
367
368 /* If "paddr" is a real page, perform a sanity check on "memattr". */
369 if ((m_paddr = vm_phys_paddr_to_vm_page(paddr)) != NULL &&
370 (memattr1 = pmap_page_get_memattr(m_paddr)) != memattr) {
371 /*
372 * For the /dev/mem d_mmap routine to return the
373 * correct memattr, pmap_page_get_memattr() needs to
374 * be called, which we do there.
375 */
376 if ((csw->d_flags & D_MEM) == 0) {
377 printf("WARNING: Device driver %s has set "
378 "\"memattr\" inconsistently (drv %u pmap %u).\n",
379 csw->d_name, memattr, memattr1);
380 }
381 memattr = memattr1;
382 }
383 if (((*mres)->flags & PG_FICTITIOUS) != 0) {
384 /*
385 * If the passed in result page is a fake page, update it with
386 * the new physical address.
387 */
388 page = *mres;
389 VM_OBJECT_WLOCK(object);

Callers

nothing calls this directly

Calls 8

dev_refthreadFunction · 0.85
dev_relthreadFunction · 0.85
vm_phys_paddr_to_vm_pageFunction · 0.85
vm_page_updatefakeFunction · 0.85
vm_page_getfakeFunction · 0.85
vm_page_replaceFunction · 0.85
vm_page_validFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected