kernel/vm.c
void
uvminit(pagetable_t pagetable, pagetable_t kpagetable, uchar *src, uint sz)
{
  char *mem;

  if(sz >= PGSIZE)
    panic("inituvm: more than a page");
  mem = kalloc();
  // printf("[uvminit]kalloc: %p\n", mem);
  memset(mem, 0, PGSIZE);
  mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
  mappages(kpagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X);
  memmove(mem, src, sz);
  // for (int i = 0; i < sz; i ++) {
  //   printf("[uvminit]mem: %p, %x\n", mem + i, mem[i]);
  // }
}
// Load the user initcode into address 0 of pagetable,
// for the very first process.
// sz must be less than a page.
Load the user initcode into address 0 of pagetable,
for the very first process.
sz must be less than a page.
Load the user initcode into address 0 of pagetable for the very first process . sz must be less than a page .
void
uvminit(pagetable_t pagetable, pagetable_t kpagetable, uchar *src, uint sz)
{
  char *mem;
  if(sz >= PGSIZE)
    panic("inituvm: more than a page");
  mem = kalloc();
  memset(mem, 0, PGSIZE);
  mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
  mappages(kpagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X);
  memmove(mem, src, sz);
}
void uvminit ( pagetable_t pagetable , pagetable_t kpagetable , uchar * src , uint sz ) { char * mem ; if ( sz >= PGSIZE ) panic ( " " ) ; mem = kalloc ( ) ; memset ( mem , 0 , PGSIZE ) ; mappages ( pagetable , 0 , PGSIZE , ( uint64 ) mem , PTE_W | PTE_R | PTE_X | PTE_U ) ; mappages ( kpagetable , 0 , PGSIZE , ( uint64 ) mem , PTE_W | PTE_R | PTE_X ) ; memmove ( mem , src , sz ) ; }
Load the user initcode into address 0 of pagetable,
for the very first process.
Load the user initcode into address 0 of pagetable for the very first process .
// printf("[uvminit]kalloc: %p\n", mem); // for (int i = 0; i < sz; i ++) { //   printf("[uvminit]mem: %p, %x\n", mem + i, mem[i]); // }