added some helper functions to for the recursive mapping structures
This commit is contained in:
parent
4b485f5733
commit
14938ef7e1
1 changed files with 32 additions and 0 deletions
|
@ -69,6 +69,38 @@ int create_page_map(task_t* task, int copy)
|
||||||
task->page_map = get_boot_page_map();
|
task->page_map = get_boot_page_map();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
static inline size_t canonicalize(size_t addr)
|
||||||
|
{
|
||||||
|
if (addr & (1UL<<47))
|
||||||
|
return addr;
|
||||||
|
else
|
||||||
|
return addr & ((1UL<<48) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int map_to_level(size_t addr)
|
||||||
|
{
|
||||||
|
if (addr >= PAGE_PML4)
|
||||||
|
return 4;
|
||||||
|
else if (addr >= PAGE_PDPT)
|
||||||
|
return 3;
|
||||||
|
else if (addr >= PAGE_PGD)
|
||||||
|
return 2;
|
||||||
|
else if (addr >= PAGE_PGT)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline const char * map_to_lvlname(size_t addr)
|
||||||
|
{
|
||||||
|
const char* names[] = {"(none)", "PGT", "PGD", "PDPT", "PML4"};
|
||||||
|
return names[map_to_level(addr)];
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline size_t map_to_virt(size_t addr)
|
||||||
|
{
|
||||||
|
return canonicalize(addr << (map_to_level(addr) * PAGE_MAP_SHIFT));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int drop_page_map(void)
|
int drop_page_map(void)
|
||||||
|
|
Loading…
Add table
Reference in a new issue