#pragma once // mm_phys.h - physical memory manager (PMM) // Stack allocator over 4 KB frames, seeded from MEMORY_MAP. #include #include #include #include #define PAGE_SIZE 4096ULL #define PAGE_MASK (~(PAGE_SIZE - 1)) typedef uint64_t PHYSICAL_ADDRESS; // Called once by KernelMain with the MEMORY_MAP from BOOT_INFO. bool MmInitializePhysical(const MEMORY_MAP* map, uint64_t physicalWindowBase); // Allocate / free a single 4 KB frame. // MmAllocateFrame returns 0 on failure. PHYSICAL_ADDRESS MmAllocateFrame(void); void MmFreeFrame(PHYSICAL_ADDRESS frame); // Allocate 'count' physically contiguous 4 KB frames. // Returns 0 on failure. Use sparingly (DMA, page tables). __declspec(dllexport) PHYSICAL_ADDRESS MmAllocateContiguous(size_t count); size_t MmFreeFrameCount(void); size_t MmTotalFrameCount(void);