FreeBSD/sys/i386/i386/pmap.c
/*
 *	Routine:	pmap_extract_and_hold
 *	Function:
 *		Atomically extract and hold the physical page
 *		with the given pmap and virtual address pair
 *		if that mapping permits the given protection.
 */
pmap_extract_and_hold
Function:
Atomically extract and hold the physical page
with the given pmap and virtual address pair
if that mapping permits the given protection.
pmap_extract_and_hold Function : Atomically extract and hold the physical page with the given pmap and virtual address pair if that mapping permits the given protection .
vm_page_t
pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
{
	pd_entry_t pde;
	pt_entry_t pte, *ptep;
	vm_page_t m;
	vm_paddr_t pa;
	pa = 0;
	m = NULL;
	PMAP_LOCK(pmap);
retry:
	pde = *pmap_pde(pmap, va);
	if (pde != 0) {
		if (pde & PG_PS) {
			if ((pde & PG_RW) || (prot & VM_PROT_WRITE) == 0) {
				if (vm_page_pa_tryrelock(pmap, (pde &
				    PG_PS_FRAME) | (va & PDRMASK), &pa))
					goto retry;
				m = PHYS_TO_VM_PAGE((pde & PG_PS_FRAME) |
				    (va & PDRMASK));
				vm_page_hold(m);
			}
		} else {
			ptep = pmap_pte(pmap, va);
			pte = *ptep;
			pmap_pte_release(ptep);
			if (pte != 0 &&
			    ((pte & PG_RW) || (prot & VM_PROT_WRITE) == 0)) {
				if (vm_page_pa_tryrelock(pmap, pte & PG_FRAME,
				    &pa))
					goto retry;
				m = PHYS_TO_VM_PAGE(pte & PG_FRAME);
				vm_page_hold(m);
			}
		}
	}
	PA_UNLOCK_COND(pa);
	PMAP_UNLOCK(pmap);
	return (m);
}
vm_page_t pmap_extract_and_hold ( pmap_t pmap , vm_offset_t va , vm_prot_t prot ) { pd_entry_t pde ; pt_entry_t pte , * ptep ; vm_page_t m ; vm_paddr_t pa ; pa = 0 ; m = NULL ; PMAP_LOCK ( pmap ) ; retry : pde = * pmap_pde ( pmap , va ) ; if ( pde != 0 ) { if ( pde & PG_PS ) { if ( ( pde & PG_RW ) || ( prot & VM_PROT_WRITE ) == 0 ) { if ( vm_page_pa_tryrelock ( pmap , ( pde & PG_PS_FRAME ) | ( va & PDRMASK ) , & pa ) ) goto retry ; m = PHYS_TO_VM_PAGE ( ( pde & PG_PS_FRAME ) | ( va & PDRMASK ) ) ; vm_page_hold ( m ) ; } } else { ptep = pmap_pte ( pmap , va ) ; pte = * ptep ; pmap_pte_release ( ptep ) ; if ( pte != 0 && ( ( pte & PG_RW ) || ( prot & VM_PROT_WRITE ) == 0 ) ) { if ( vm_page_pa_tryrelock ( pmap , pte & PG_FRAME , & pa ) ) goto retry ; m = PHYS_TO_VM_PAGE ( pte & PG_FRAME ) ; vm_page_hold ( m ) ; } } } PA_UNLOCK_COND ( pa ) ; PMAP_UNLOCK ( pmap ) ; return ( m ) ; }
Routine:        pmap_extract_and_hold
      Function:
              Atomically extract and hold the physical page
              with the given pmap and virtual address pair
              if that mapping permits the given protection.
Routine : pmap_extract_and_hold Function : Atomically extract and hold the physical page with the given pmap and virtual address pair if that mapping permits the given protection .