x86: mmu: implement arch_page_phys_get()
This implements arch_page_phys_get() to translate mapped virtual addresses back to physical addresses. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
085d3768e1
commit
18aad13d76
1 changed files with 23 additions and 0 deletions
|
@ -1844,6 +1844,29 @@ void arch_reserved_pages_update(void)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_ARCH_HAS_RESERVED_PAGE_FRAMES */
|
#endif /* CONFIG_ARCH_HAS_RESERVED_PAGE_FRAMES */
|
||||||
|
|
||||||
|
int arch_page_phys_get(void *virt, uintptr_t *phys)
|
||||||
|
{
|
||||||
|
pentry_t pte = 0;
|
||||||
|
int level, ret;
|
||||||
|
|
||||||
|
__ASSERT(POINTER_TO_UINT(virt) % CONFIG_MMU_PAGE_SIZE == 0U,
|
||||||
|
"unaligned address %p to %s", virt, __func__);
|
||||||
|
|
||||||
|
pentry_get(&level, &pte, z_x86_page_tables_get(), virt);
|
||||||
|
|
||||||
|
if ((pte & MMU_P) != 0) {
|
||||||
|
if (phys != NULL) {
|
||||||
|
*phys = (uintptr_t)get_entry_phys(pte, PTE_LEVEL);
|
||||||
|
}
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
|
/* Not mapped */
|
||||||
|
ret = -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEMAND_PAGING
|
#ifdef CONFIG_DEMAND_PAGING
|
||||||
#define PTE_MASK (paging_levels[PTE_LEVEL].mask)
|
#define PTE_MASK (paging_levels[PTE_LEVEL].mask)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue