Fix the unsuitable use of pa2page in lab5_result
This commit is contained in:
parent
2cde1118f4
commit
89a9eb84d0
@ -418,7 +418,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) {
|
|||||||
*ptep_store = ptep;
|
*ptep_store = ptep;
|
||||||
}
|
}
|
||||||
if (ptep != NULL && *ptep & PTE_P) {
|
if (ptep != NULL && *ptep & PTE_P) {
|
||||||
return pa2page(*ptep);
|
return pte2page(*ptep);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -651,7 +651,7 @@ check_pgdir(void) {
|
|||||||
|
|
||||||
pte_t *ptep;
|
pte_t *ptep;
|
||||||
assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL);
|
assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL);
|
||||||
assert(pa2page(*ptep) == p1);
|
assert(pte2page(*ptep) == p1);
|
||||||
assert(page_ref(p1) == 1);
|
assert(page_ref(p1) == 1);
|
||||||
|
|
||||||
ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1];
|
ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1];
|
||||||
@ -669,7 +669,7 @@ check_pgdir(void) {
|
|||||||
assert(page_ref(p1) == 2);
|
assert(page_ref(p1) == 2);
|
||||||
assert(page_ref(p2) == 0);
|
assert(page_ref(p2) == 0);
|
||||||
assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL);
|
assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL);
|
||||||
assert(pa2page(*ptep) == p1);
|
assert(pte2page(*ptep) == p1);
|
||||||
assert((*ptep & PTE_U) == 0);
|
assert((*ptep & PTE_U) == 0);
|
||||||
|
|
||||||
page_remove(boot_pgdir, 0x0);
|
page_remove(boot_pgdir, 0x0);
|
||||||
@ -680,8 +680,8 @@ check_pgdir(void) {
|
|||||||
assert(page_ref(p1) == 0);
|
assert(page_ref(p1) == 0);
|
||||||
assert(page_ref(p2) == 0);
|
assert(page_ref(p2) == 0);
|
||||||
|
|
||||||
assert(page_ref(pa2page(boot_pgdir[0])) == 1);
|
assert(page_ref(pde2page(boot_pgdir[0])) == 1);
|
||||||
free_page(pa2page(boot_pgdir[0]));
|
free_page(pde2page(boot_pgdir[0]));
|
||||||
boot_pgdir[0] = 0;
|
boot_pgdir[0] = 0;
|
||||||
|
|
||||||
cprintf("check_pgdir() succeeded!\n");
|
cprintf("check_pgdir() succeeded!\n");
|
||||||
@ -715,7 +715,7 @@ check_boot_pgdir(void) {
|
|||||||
assert(strlen((const char *)0x100) == 0);
|
assert(strlen((const char *)0x100) == 0);
|
||||||
|
|
||||||
free_page(p);
|
free_page(p);
|
||||||
free_page(pa2page(PDE_ADDR(boot_pgdir[0])));
|
free_page(pde2page(boot_pgdir[0]));
|
||||||
boot_pgdir[0] = 0;
|
boot_pgdir[0] = 0;
|
||||||
|
|
||||||
cprintf("check_boot_pgdir() succeeded!\n");
|
cprintf("check_boot_pgdir() succeeded!\n");
|
||||||
|
@ -262,7 +262,7 @@ check_swap(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//free_page(pte2page(*temp_ptep));
|
//free_page(pte2page(*temp_ptep));
|
||||||
free_page(pa2page(pgdir[0]));
|
free_page(pde2page(pgdir[0]));
|
||||||
pgdir[0] = 0;
|
pgdir[0] = 0;
|
||||||
mm->pgdir = NULL;
|
mm->pgdir = NULL;
|
||||||
mm_destroy(mm);
|
mm_destroy(mm);
|
||||||
|
@ -357,7 +357,7 @@ check_pgfault(void) {
|
|||||||
assert(sum == 0);
|
assert(sum == 0);
|
||||||
|
|
||||||
page_remove(pgdir, ROUNDDOWN(addr, PGSIZE));
|
page_remove(pgdir, ROUNDDOWN(addr, PGSIZE));
|
||||||
free_page(pa2page(pgdir[0]));
|
free_page(pde2page(pgdir[0]));
|
||||||
pgdir[0] = 0;
|
pgdir[0] = 0;
|
||||||
|
|
||||||
mm->pgdir = NULL;
|
mm->pgdir = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user