Skip to content

Commit

Permalink
finish lab3 exercise1
Browse files Browse the repository at this point in the history
  • Loading branch information
evan69 committed Mar 24, 2017
1 parent 8294b63 commit 84081bc
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions labcodes/lab3/kern/mm/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,36 @@ do_pgfault(struct mm_struct *mm, uint32_t error_code, uintptr_t addr) {
}
}
#endif
ptep = get_pte(mm->pgdir,addr,1);
if(ptep == NULL)
{
cprintf("create pte failed");
goto failed;
}

if(*ptep == 0)
{
struct Page * alloc_result = pgdir_alloc_page(mm->pgdir,addr,perm);
if(alloc_result == NULL)
{
goto failed;
}
}
else
{
if(swap_init_ok)
{
struct Page* page = NULL;
swap_in(mm,addr,&page);
//if(page_insert(mm->pgdir,))
}
else
{
cprintf("no swap_init_ok but ptep is %x, failed\n",*ptep);
goto failed;
}
}

ret = 0;
failed:
return ret;
Expand Down

0 comments on commit 84081bc

Please sign in to comment.