memblock: add functions to convert allocated pointers between virt/phys

This commit is contained in:
2023-02-06 20:39:33 +00:00
parent 6afb3bd10d
commit 998f05d337
2 changed files with 24 additions and 0 deletions

View File

@@ -404,3 +404,13 @@ void __next_memory_region(memblock_iter_t *it, memblock_type_t *type_a, memblock
/* ULLONG_MAX signals the end of the iteration */
it->__idx = ITER_END;
}
phys_addr_t memblock_virt_to_phys(void *p)
{
return (phys_addr_t)p - memblock.m_voffset;
}
void *memblock_phys_to_virt(phys_addr_t p)
{
return (void *)(p + memblock.m_voffset);
}