#pragma once #include #include #include #include #include namespace Kernel { class GeneralAllocator { BAN_NON_COPYABLE(GeneralAllocator); BAN_NON_MOVABLE(GeneralAllocator); public: static BAN::ErrorOr> create(PageTable&, vaddr_t first_vaddr); ~GeneralAllocator(); BAN::ErrorOr> clone(PageTable&); BAN::Optional paddr_of(vaddr_t); vaddr_t allocate(size_t); bool deallocate(vaddr_t); private: GeneralAllocator(PageTable&, vaddr_t first_vaddr); private: struct Allocation { vaddr_t address { 0 }; BAN::Vector pages; bool contains(vaddr_t); }; private: PageTable& m_page_table; BAN::LinkedList m_allocations; const vaddr_t m_first_vaddr; }; }