VMM - touch_page adds P3

This commit is contained in:
Thomas Lovén 2017-12-27 23:08:41 +01:00
parent 28c8afe3c5
commit 1d4b689215
2 changed files with 26 additions and 0 deletions

View File

@ -49,3 +49,13 @@ int vmm_set_page(void *P4, uintptr_t addr, uintptr_t page, uint16_t flags)
P1e(P4, addr).value = page | flags; P1e(P4, addr).value = page | flags;
return 0; return 0;
} }
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();
return 0;
}

View File

@ -114,3 +114,19 @@ TEST(set_page_fails_if_PT_missing)
ASSERT_NEQ_INT(retval, 0); ASSERT_NEQ_INT(retval, 0);
} }
uintptr_t pmm_alloc()
{
uintptr_t *pages[] = {p3, p2, p1};
static int counter=0;
return (uintptr_t)pages[counter++];
}
TEST(touch_page_adds_P3)
{
p4[0] = 0;
touch_page(p4, 0, 0);
ASSERT_NEQ_PTR(p4[0], 0);
}