#pragma once #include #ifndef PAGE_SIZE #define PAGE_SIZE 4096 #endif extern "C" uint64_t asm_get_rflags(); namespace Utilities { inline uint64_t get_blocks_from_size(uint64_t blocksize, uint64_t size) { return (size + (blocksize - 1)) / blocksize; } inline uint64_t get_rflags() { return asm_get_rflags(); } inline uint64_t get_top_of_stack(uint64_t bottom, uint64_t stack_pages) { return bottom + (stack_pages * PAGE_SIZE) - sizeof(uintptr_t); } inline uint64_t round_down_to_nearest_page(uint64_t addr) { return addr - (addr % PAGE_SIZE); } inline uint64_t round_up_to_nearest_page(uint64_t addr) { if (addr % PAGE_SIZE) return addr + (PAGE_SIZE - (addr % PAGE_SIZE)); return addr; } }