FreeBSD/sys/i386/i386/pmap.c
/*
 * Release any resources held by the given physical map.
 * Called when a pmap initialized by pmap_pinit is being released.
 * Should only be called if the map contains no valid mappings.
 */
Release any resources held by the given physical map.
Called when a pmap initialized by pmap_pinit is being released.
Should only be called if the map contains no valid mappings.
Release any resources held by the given physical map . Called when a pmap initialized by pmap_pinit is being released . Should only be called if the map contains no valid mappings .
void
pmap_release(pmap_t pmap)
{
	vm_page_t m, ptdpg[NPGPTD];
	int i;
	KASSERT(pmap->pm_stats.resident_count == 0,
	    ("pmap_release: pmap resident count %ld != 0",
	    pmap->pm_stats.resident_count));
	KASSERT(vm_radix_is_empty(&pmap->pm_root),
	    ("pmap_release: pmap has reserved page table page(s)"));
	KASSERT(CPU_EMPTY(&pmap->pm_active),
	    ("releasing active pmap %p", pmap));
	mtx_lock_spin(&allpmaps_lock);
	LIST_REMOVE(pmap, pm_list);
	mtx_unlock_spin(&allpmaps_lock);
	for (i = 0; i < NPGPTD; i++)
		ptdpg[i] = PHYS_TO_VM_PAGE(pmap->pm_pdir[PTDPTDI + i] &
		    PG_FRAME);
	bzero(pmap->pm_pdir + PTDPTDI, (nkpt + NPGPTD) *
	    sizeof(*pmap->pm_pdir));
	pmap_qremove((vm_offset_t)pmap->pm_pdir, NPGPTD);
	for (i = 0; i < NPGPTD; i++) {
		m = ptdpg[i];
#if defined(PAE) || defined(PAE_TABLES)
		KASSERT(VM_PAGE_TO_PHYS(m) == (pmap->pm_pdpt[i] & PG_FRAME),
		    ("pmap_release: got wrong ptd page"));
#endif
		m->wire_count--;
		atomic_subtract_int(&vm_cnt.v_wire_count, 1);
		vm_page_free_zero(m);
	}
}
void pmap_release ( pmap_t pmap ) { vm_page_t m , ptdpg [ NPGPTD ] ; int i ; KASSERT ( pmap -> pm_stats . resident_count == 0 , ( " " , pmap -> pm_stats . resident_count ) ) ; KASSERT ( vm_radix_is_empty ( & pmap -> pm_root ) , ( " " ) ) ; KASSERT ( CPU_EMPTY ( & pmap -> pm_active ) , ( " " , pmap ) ) ; mtx_lock_spin ( & allpmaps_lock ) ; LIST_REMOVE ( pmap , pm_list ) ; mtx_unlock_spin ( & allpmaps_lock ) ; for ( i = 0 ; i < NPGPTD ; i ++ ) ptdpg [ i ] = PHYS_TO_VM_PAGE ( pmap -> pm_pdir [ PTDPTDI + i ] & PG_FRAME ) ; bzero ( pmap -> pm_pdir + PTDPTDI , ( nkpt + NPGPTD ) * sizeof ( * pmap -> pm_pdir ) ) ; pmap_qremove ( ( vm_offset_t ) pmap -> pm_pdir , NPGPTD ) ; for ( i = 0 ; i < NPGPTD ; i ++ ) { m = ptdpg [ i ] ; #if defined ( PAE ) || defined ( PAE_TABLES ) KASSERT ( VM_PAGE_TO_PHYS ( m ) == ( pmap -> pm_pdpt [ i ] & PG_FRAME ) , ( " " ) ) ; #endif m -> wire_count -- ; atomic_subtract_int ( & vm_cnt . v_wire_count , 1 ) ; vm_page_free_zero ( m ) ; } }
Release any resources held by the given physical map.
Release any resources held by the given physical map .