#pragma once #include "memory/pointer.h" #include "util/optional.h" #include "init/multiboot2.h" constexpr const size_t page_size = 4096; struct PhysicalAllocator { struct allocation_t { paddr_t ptr; size_t page_count; }; static void init(const multiboot::tag_mmap* multiboot_info); static PhysicalAllocator& getInstance(); optional allocPages(size_t page_count, size_t alignment_pages = 1); void free(allocation_t ptr); bool force(allocation_t ptr, bool free); private: struct page_t { page_t* next; page_t* prev; uint64_t count[510]; }; static_assert(sizeof(page_t) == page_size); page_t* storage; friend struct PhysicalAllocatorImpl; };