kernel/vm.c
void
vmunmap(pagetable_t pagetable, uint64 va, uint64 npages, int do_free)
{
  uint64 a;
  pte_t *pte;

  if((va % PGSIZE) != 0)
    panic("vmunmap: not aligned");

  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    if((pte = walk(pagetable, a, 0)) == 0)
      panic("vmunmap: walk");
    if((*pte & PTE_V) == 0)
      panic("vmunmap: not mapped");
    if(PTE_FLAGS(*pte) == PTE_V)
      panic("vmunmap: not a leaf");
    if(do_free){
      uint64 pa = PTE2PA(*pte);
      kfree((void*)pa);
    }
    *pte = 0;
  }
}
// Remove npages of mappings starting from va. va must be
// page-aligned. The mappings must exist.
// Optionally free the physical memory.
Remove npages of mappings starting from va. va must be
page-aligned. The mappings must exist.
Optionally free the physical memory.
Remove npages of mappings starting from va . va must be page - aligned . The mappings must exist . Optionally free the physical memory .
void
vmunmap(pagetable_t pagetable, uint64 va, uint64 npages, int do_free)
{
  uint64 a;
  pte_t *pte;
  if((va % PGSIZE) != 0)
    panic("vmunmap: not aligned");
  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    if((pte = walk(pagetable, a, 0)) == 0)
      panic("vmunmap: walk");
    if((*pte & PTE_V) == 0)
      panic("vmunmap: not mapped");
    if(PTE_FLAGS(*pte) == PTE_V)
      panic("vmunmap: not a leaf");
    if(do_free){
      uint64 pa = PTE2PA(*pte);
      kfree((void*)pa);
    }
    *pte = 0;
  }
}
void vmunmap ( pagetable_t pagetable , uint64 va , uint64 npages , int do_free ) { uint64 a ; pte_t * pte ; if ( ( va % PGSIZE ) != 0 ) panic ( " " ) ; for ( a = va ; a < va + npages * PGSIZE ; a += PGSIZE ) { if ( ( pte = walk ( pagetable , a , 0 ) ) == 0 ) panic ( " " ) ; if ( ( * pte & PTE_V ) == 0 ) panic ( " " ) ; if ( PTE_FLAGS ( * pte ) == PTE_V ) panic ( " " ) ; if ( do_free ) { uint64 pa = PTE2PA ( * pte ) ; kfree ( ( void * ) pa ) ; } * pte = 0 ; } }
Remove npages of mappings starting from va. va must be
page-aligned.
Remove npages of mappings starting from va . va must be page - aligned .