std :: kernel::frame
Struct std::FrameAllocator
struct FrameAllocator {
unsigned int bitmap[FRAME_BITMAP_SIZE];
unsigned long total_frames;
unsigned long used_frames;
unsigned long base;
}Fields
total number of physical frames
currently allocated frames
physical address of frame 0
Methods
Initialize for total_frames frames starting at physical 0 (clears bitmap).
Initialize for total_frames frames starting at physical base_phys
(4 KiB aligned) — e.g. the RAM base on boards where RAM isn't at 0.
Physical address of frame number frame: base + frame * 4096.
Allocate a single frame. Returns frame number, or -1 if OOM.
Free a frame by frame number.
Check if a frame is allocated. Returns 1 if allocated.
Mark a range of frames as used (e.g., for kernel image).
Return the number of free frames.