Kernel/Utilities: Add new round_{up,down}_to_nearest_page functions
This commit is contained in:
parent
baa71b09cc
commit
0f5910add7
@ -8,4 +8,6 @@ namespace Utilities
|
||||
|
||||
uint64_t get_rflags();
|
||||
uint64_t get_top_of_stack(uint64_t bottom, uint64_t stack_pages);
|
||||
uint64_t round_down_to_nearest_page(uint64_t addr);
|
||||
uint64_t round_up_to_nearest_page(uint64_t addr);
|
||||
}
|
@ -18,4 +18,15 @@ uint64_t Utilities::get_rflags()
|
||||
uint64_t Utilities::get_top_of_stack(uint64_t bottom, uint64_t stack_pages)
|
||||
{
|
||||
return bottom + (stack_pages * PAGE_SIZE) - sizeof(uintptr_t);
|
||||
}
|
||||
|
||||
uint64_t Utilities::round_down_to_nearest_page(uint64_t addr)
|
||||
{
|
||||
return addr - (addr % PAGE_SIZE);
|
||||
}
|
||||
|
||||
uint64_t Utilities::round_up_to_nearest_page(uint64_t addr)
|
||||
{
|
||||
if (addr % PAGE_SIZE) return addr + (PAGE_SIZE - (addr % PAGE_SIZE));
|
||||
return addr;
|
||||
}
|
Loading…
Reference in New Issue
Block a user