-
-
Save heatd/b4203342798b32606290cde8d58f49de 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
// Free a page table and all the physical memory pages | |
// in the user part. | |
void | |
freevm(pde_t *pgdir) | |
{ | |
uint i, j; | |
pte_t *pt; | |
if(pgdir == 0) | |
panic("freevm: no pgdir"); | |
deallocuvm(pgdir, KERNBASE, 0); | |
for(i = 0; i < NPDENTRIES; i++){ | |
if(pgdir[i] & PTE_P){ | |
pt = P2V(PTE_ADDR(pgdir[i])); | |
if ( /* is under KERNBASE */) { | |
for (j = 0; j < NPTENTRIES; j++) { | |
if (pt[j] & PTE_P) | |
kfree(P2V(PTE_ADDR(pt[j]))); | |
} | |
} | |
kfree(pt); | |
} | |
} | |
kfree((char*)pgdir); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment