28 lines
938 B
C
28 lines
938 B
C
#pragma once
|
|
// mm_phys.h - physical memory manager (PMM)
|
|
// Stack allocator over 4 KB frames, seeded from MEMORY_MAP.
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <memory_map.h>
|
|
|
|
#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.
|
|
void 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).
|
|
PHYSICAL_ADDRESS MmAllocateContiguous(size_t count);
|
|
|
|
size_t MmFreeFrameCount(void);
|
|
size_t MmTotalFrameCount(void);
|