FreeBSD/sys/arm/arm/pmap-v4.c
/*
 * remove a page from the kernel pagetables
 */
remove a page from the kernel pagetables
remove a page from the kernel pagetables
void
pmap_kremove(vm_offset_t va)
{
	struct l2_bucket *l2b;
	pt_entry_t *pte, opte;
	struct pv_entry *pve;
	vm_page_t m;
	vm_offset_t pa;
	l2b = pmap_get_l2_bucket(kernel_pmap, va);
	if (!l2b)
		return;
	KASSERT(l2b != NULL, ("No L2 Bucket"));
	pte = &l2b->l2b_kva[l2pte_index(va)];
	opte = *pte;
	if (l2pte_valid(opte)) {
		if ((opte & L2_TYPE_MASK) == L2_TYPE_L)
			pa = (opte & L2_L_FRAME) | (va & L2_L_OFFSET);
		else
			pa = (opte & L2_S_FRAME) | (va & L2_S_OFFSET);
		rw_wlock(&pvh_global_lock);
		PMAP_LOCK(kernel_pmap);
		if (pvzone != NULL && (m = vm_phys_paddr_to_vm_page(pa)) &&
		    (pve = pmap_remove_pv(m, kernel_pmap, va)))
			pmap_free_pv_entry(pve);
		PMAP_UNLOCK(kernel_pmap);
		rw_wunlock(&pvh_global_lock);
		va = va & ~PAGE_MASK;
		cpu_dcache_wbinv_range(va, PAGE_SIZE);
		cpu_l2cache_wbinv_range(va, PAGE_SIZE);
		cpu_tlb_flushD_SE(va);
		cpu_cpwait();
		*pte = 0;
	}
}
void pmap_kremove ( vm_offset_t va ) { struct l2_bucket * l2b ; pt_entry_t * pte , opte ; struct pv_entry * pve ; vm_page_t m ; vm_offset_t pa ; l2b = pmap_get_l2_bucket ( kernel_pmap , va ) ; if ( ! l2b ) return ; KASSERT ( l2b != NULL , ( " " ) ) ; pte = & l2b -> l2b_kva [ l2pte_index ( va ) ] ; opte = * pte ; if ( l2pte_valid ( opte ) ) { if ( ( opte & L2_TYPE_MASK ) == L2_TYPE_L ) pa = ( opte & L2_L_FRAME ) | ( va & L2_L_OFFSET ) ; else pa = ( opte & L2_S_FRAME ) | ( va & L2_S_OFFSET ) ; rw_wlock ( & pvh_global_lock ) ; PMAP_LOCK ( kernel_pmap ) ; if ( pvzone != NULL && ( m = vm_phys_paddr_to_vm_page ( pa ) ) && ( pve = pmap_remove_pv ( m , kernel_pmap , va ) ) ) pmap_free_pv_entry ( pve ) ; PMAP_UNLOCK ( kernel_pmap ) ; rw_wunlock ( & pvh_global_lock ) ; va = va & ~ PAGE_MASK ; cpu_dcache_wbinv_range ( va , PAGE_SIZE ) ; cpu_l2cache_wbinv_range ( va , PAGE_SIZE ) ; cpu_tlb_flushD_SE ( va ) ; cpu_cpwait ( ) ; * pte = 0 ; } }
remove a page from the kernel pagetables
remove a page from the kernel pagetables
/* pa = vtophs(va) taken from pmap_extract() */ /* note: should never have to remove an allocation
		 * before the pvzone is initialized.
		 */