kernel/vm.c
int
mappages(pagetable_t pagetable, uint64 va, uint64 size, uint64 pa, int perm)
{
  uint64 a, last;
  pte_t *pte;

  a = PGROUNDDOWN(va);
  last = PGROUNDDOWN(va + size - 1);
  
  for(;;){
    if((pte = walk(pagetable, a, 1)) == NULL)
      return -1;
    if(*pte & PTE_V)
      panic("remap");
    *pte = PA2PTE(pa) | perm | PTE_V;
    if(a == last)
      break;
    a += PGSIZE;
    pa += PGSIZE;
  }
  return 0;
}
// Create PTEs for virtual addresses starting at va that refer to
// physical addresses starting at pa. va and size might not
// be page-aligned. Returns 0 on success, -1 if walk() couldn't
// allocate a needed page-table page.
Create PTEs for virtual addresses starting at va that refer to
physical addresses starting at pa. va and size might not
be page-aligned. Returns 0 on success, -1 if walk() couldn't
allocate a needed page-table page.
Create PTEs for virtual addresses starting at va that refer to physical addresses starting at pa . va and size might not be page - aligned . Returns 0 on success - 1 if walk () couldn ' t allocate a needed page - table page .
int
mappages(pagetable_t pagetable, uint64 va, uint64 size, uint64 pa, int perm)
{
  uint64 a, last;
  pte_t *pte;
  a = PGROUNDDOWN(va);
  last = PGROUNDDOWN(va + size - 1);
  for(;;){
    if((pte = walk(pagetable, a, 1)) == NULL)
      return -1;
    if(*pte & PTE_V)
      panic("remap");
    *pte = PA2PTE(pa) | perm | PTE_V;
    if(a == last)
      break;
    a += PGSIZE;
    pa += PGSIZE;
  }
  return 0;
}
int mappages ( pagetable_t pagetable , uint64 va , uint64 size , uint64 pa , int perm ) { uint64 a , last ; pte_t * pte ; a = PGROUNDDOWN ( va ) ; last = PGROUNDDOWN ( va + size - 1 ) ; for ( ; ; ) { if ( ( pte = walk ( pagetable , a , 1 ) ) == NULL ) return -1 ; if ( * pte & PTE_V ) panic ( " " ) ; * pte = PA2PTE ( pa ) | perm | PTE_V ; if ( a == last ) break ; a += PGSIZE ; pa += PGSIZE ; } return 0 ; }
Create PTEs for virtual addresses starting at va that refer to
physical addresses starting at pa. va and size might not
be page-aligned.
Create PTEs for virtual addresses starting at va that refer to physical addresses starting at pa . va and size might not be page - aligned .