FreeBSD/sys/i386/i386/pmap.c
/*
 * perform the pmap work for mincore
 */
perform the pmap work for mincore
perform the pmap work for mincore
int
pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *locked_pa)
{
	pd_entry_t *pdep;
	pt_entry_t *ptep, pte;
	vm_paddr_t pa;
	int val;
	PMAP_LOCK(pmap);
retry:
	pdep = pmap_pde(pmap, addr);
	if (*pdep != 0) {
		if (*pdep & PG_PS) {
			pte = *pdep;
			pa = ((*pdep & PG_PS_FRAME) | (addr & PDRMASK)) &
			    PG_FRAME;
			val = MINCORE_SUPER;
		} else {
			ptep = pmap_pte(pmap, addr);
			pte = *ptep;
			pmap_pte_release(ptep);
			pa = pte & PG_FRAME;
			val = 0;
		}
	} else {
		pte = 0;
		pa = 0;
		val = 0;
	}
	if ((pte & PG_V) != 0) {
		val |= MINCORE_INCORE;
		if ((pte & (PG_M | PG_RW)) == (PG_M | PG_RW))
			val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER;
		if ((pte & PG_A) != 0)
			val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER;
	}
	if ((val & (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER)) !=
	    (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER) &&
	    (pte & (PG_MANAGED | PG_V)) == (PG_MANAGED | PG_V)) {
		if (vm_page_pa_tryrelock(pmap, pa, locked_pa))
			goto retry;
	} else
		PA_UNLOCK_COND(*locked_pa);
	PMAP_UNLOCK(pmap);
	return (val);
}
int pmap_mincore ( pmap_t pmap , vm_offset_t addr , vm_paddr_t * locked_pa ) { pd_entry_t * pdep ; pt_entry_t * ptep , pte ; vm_paddr_t pa ; int val ; PMAP_LOCK ( pmap ) ; retry : pdep = pmap_pde ( pmap , addr ) ; if ( * pdep != 0 ) { if ( * pdep & PG_PS ) { pte = * pdep ; pa = ( ( * pdep & PG_PS_FRAME ) | ( addr & PDRMASK ) ) & PG_FRAME ; val = MINCORE_SUPER ; } else { ptep = pmap_pte ( pmap , addr ) ; pte = * ptep ; pmap_pte_release ( ptep ) ; pa = pte & PG_FRAME ; val = 0 ; } } else { pte = 0 ; pa = 0 ; val = 0 ; } if ( ( pte & PG_V ) != 0 ) { val |= MINCORE_INCORE ; if ( ( pte & ( PG_M | PG_RW ) ) == ( PG_M | PG_RW ) ) val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER ; if ( ( pte & PG_A ) != 0 ) val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER ; } if ( ( val & ( MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER ) ) != ( MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER ) && ( pte & ( PG_MANAGED | PG_V ) ) == ( PG_MANAGED | PG_V ) ) { if ( vm_page_pa_tryrelock ( pmap , pa , locked_pa ) ) goto retry ; } else PA_UNLOCK_COND ( * locked_pa ) ; PMAP_UNLOCK ( pmap ) ; return ( val ) ; }
perform the pmap work for mincore
perform the pmap work for mincore
/* Compute the physical address of the 4KB page. */ /* Ensure that "PHYS_TO_VM_PAGE(pa)->object" doesn't change. */