Created
September 30, 2016 06:47
-
-
Save yasyf/7f90575556e46c9326f6982207192f8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pte_t * | |
pgdir_walk(pde_t *pgdir, const void *va, int create) | |
{ | |
pde_t page_dir_entry = pgdir[PDX(va)]; | |
if (!page_dir_entry && create) { | |
struct PageInfo *page = page_alloc(ALLOC_ZERO); | |
if (page != NULL) { | |
page->pp_ref += 1; | |
page_dir_entry = PTE_ADDR(page2pa(page)) | PTE_SYSCALL; | |
pgdir[PDX(va)] = page_dir_entry; | |
} | |
} | |
if (!page_dir_entry) { | |
return NULL; | |
} | |
pte_t *page_table = KADDR(PTE_ADDR(page_dir_entry)); | |
return page_table + PTX(va); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment