Kernel/Utilities: add a new get_top_of_stack convenience function

This commit is contained in:
apio 2022-10-12 13:17:58 +02:00
parent cf3f61e373
commit 66add380cf
2 changed files with 10 additions and 0 deletions

View File

@ -7,4 +7,5 @@ namespace Utilities
uint64_t size); // Returns how many blocks of size blocksize does size occupy.
uint64_t get_rflags();
uint64_t get_top_of_stack(uint64_t bottom, uint64_t stack_pages);
}

View File

@ -1,5 +1,9 @@
#include "misc/utils.h"
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
uint64_t Utilities::get_blocks_from_size(uint64_t blocksize, uint64_t size)
{
return (size + (blocksize - 1)) / blocksize;
@ -9,4 +13,9 @@ extern "C" uint64_t asm_get_rflags();
uint64_t Utilities::get_rflags()
{
return asm_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);
}