VMM - touch_page adds P2 and P1

This commit is contained in:
Thomas Lovén 2017-12-27 23:18:01 +01:00
parent 1d4b689215
commit 86d8aea9ea
2 changed files with 19 additions and 5 deletions

View File

@ -55,7 +55,11 @@ int touch_page(void *P4, uintptr_t addr, uint16_t flags)
(void)flags;
if(!P4) return -1;
if(!P4e(P4, addr).present)
P4e(P4, addr).value = pmm_alloc();
P4e(P4, addr).value = pmm_alloc() | flags | PAGE_PRESENT;
if(!P3e(P4, addr).present)
P3e(P4, addr).value = pmm_alloc() | flags | PAGE_PRESENT;
if(!P2e(P4, addr).present)
P2e(P4, addr).value = pmm_alloc() | flags | PAGE_PRESENT;
return 0;
}

View File

@ -124,9 +124,19 @@ uintptr_t pmm_alloc()
TEST(touch_page_adds_P3)
{
p4[0] = 0;
touch_page(p4, (1UL<<39)+(2UL<<30)+(3UL<<21)+(4UL<<12), 0);
touch_page(p4, 0, 0);
ASSERT_NEQ_PTR(p4[0], 0);
ASSERT_EQ_PTR(p4[1], (uintptr_t)p3 | PAGE_PRESENT);
}
TEST(touch_page_adds_P2)
{
touch_page(p4, (1UL<<39)+(2UL<<30)+(3UL<<21)+(4UL<<12), 0);
ASSERT_EQ_PTR(p3[2], (uintptr_t)p2 | PAGE_PRESENT);
}
TEST(touch_page_adds_P1)
{
touch_page(p4, (1UL<<39)+(2UL<<30)+(3UL<<21)+(4UL<<12), 0);
ASSERT_EQ_PTR(p2[3], (uintptr_t)p1 | PAGE_PRESENT);
}