kernel/vm.c
int
copyin(pagetable_t pagetable, char *dst, uint64 srcva, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    va0 = PGROUNDDOWN(srcva);
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == NULL)
      return -1;
    n = PGSIZE - (srcva - va0);
    if(n > len)
      n = len;
    memmove(dst, (void *)(pa0 + (srcva - va0)), n);

    len -= n;
    dst += n;
    srcva = va0 + PGSIZE;
  }
  return 0;
}
// Copy from user to kernel.
// Copy len bytes to dst from virtual address srcva in a given page table.
// Return 0 on success, -1 on error.
Copy from user to kernel.
Copy len bytes to dst from virtual address srcva in a given page table.
Return 0 on success, -1 on error.
Copy from user to kernel . Copy len bytes to dst from virtual address srcva in a given page table . Return 0 on success - 1 on error .
int
copyin(pagetable_t pagetable, char *dst, uint64 srcva, uint64 len)
{
  uint64 n, va0, pa0;
  while(len > 0){
    va0 = PGROUNDDOWN(srcva);
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == NULL)
      return -1;
    n = PGSIZE - (srcva - va0);
    if(n > len)
      n = len;
    memmove(dst, (void *)(pa0 + (srcva - va0)), n);
    len -= n;
    dst += n;
    srcva = va0 + PGSIZE;
  }
  return 0;
}
int copyin ( pagetable_t pagetable , char * dst , uint64 srcva , uint64 len ) { uint64 n , va0 , pa0 ; while ( len > 0 ) { va0 = PGROUNDDOWN ( srcva ) ; pa0 = walkaddr ( pagetable , va0 ) ; if ( pa0 == NULL ) return -1 ; n = PGSIZE - ( srcva - va0 ) ; if ( n > len ) n = len ; memmove ( dst , ( void * ) ( pa0 + ( srcva - va0 ) ) , n ) ; len -= n ; dst += n ; srcva = va0 + PGSIZE ; } return 0 ; }
Copy from user to kernel.
Copy from user to kernel .