|
@ -260,13 +260,32 @@ check_pgfault(void) { |
|
|
*(char *)(addr + i) = i; |
|
|
*(char *)(addr + i) = i; |
|
|
sum += i; |
|
|
sum += i; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i ++) { |
|
|
|
|
|
// 获取页目录项和页表项 |
|
|
|
|
|
pte_t *pte = get_pte(pgdir, addr + i, 0); |
|
|
|
|
|
if (pte != NULL && (*pte & PTE_P)) { |
|
|
|
|
|
// 检查访问位 |
|
|
|
|
|
if (*pte & PTE_A) { |
|
|
|
|
|
// A 位已置位 |
|
|
|
|
|
cprintf("Access bit is set.\n"); |
|
|
|
|
|
} else { |
|
|
|
|
|
// A 位未置位 |
|
|
|
|
|
cprintf("Access bit is not set.\n"); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 页表项不存在或未呈现 |
|
|
|
|
|
cprintf("PTE not present.\n"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i ++) { |
|
|
for (i = 0; i < 100; i ++) { |
|
|
sum -= *(char *)(addr + i); |
|
|
sum -= *(char *)(addr + i); |
|
|
} |
|
|
} |
|
|
assert(sum == 0); |
|
|
assert(sum == 0); |
|
|
|
|
|
|
|
|
page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); |
|
|
page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); |
|
|
free_page(pde2page(pgdir[0])); |
|
|
|
|
|
|
|
|
free_page(pa2page(pgdir[0])); |
|
|
pgdir[0] = 0; |
|
|
pgdir[0] = 0; |
|
|
|
|
|
|
|
|
mm->pgdir = NULL; |
|
|
mm->pgdir = NULL; |
|
|