std1.0.0-beta-7 SafeC docs

std :: kernel::frame

Struct std::FrameAllocator

#include <std/kernel/frame.h> source

struct FrameAllocator {
    unsigned int bitmap[FRAME_BITMAP_SIZE];
    unsigned long total_frames;
    unsigned long used_frames;
    unsigned long base;
}

Fields

§unsigned int bitmap[FRAME_BITMAP_SIZE]source
§unsigned long total_framessource

total number of physical frames

§unsigned long used_framessource

currently allocated frames

§unsigned long basesource

physical address of frame 0

Methods

§void init(unsigned long total_frames)source · definition

Initialize for total_frames frames starting at physical 0 (clears bitmap).

§void init_at(unsigned long base_phys, unsigned long total_frames)source · definition

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.

§unsigned long frame_addr(unsigned long frame) constsource · definition

Physical address of frame number frame: base + frame * 4096.

§long long alloc()source · definition

Allocate a single frame. Returns frame number, or -1 if OOM.

§void free(unsigned long frame)source · definition

Free a frame by frame number.

§int is_used(unsigned long frame) constsource · definition

Check if a frame is allocated. Returns 1 if allocated.

§void mark_range(unsigned long start, unsigned long count)source · definition

Mark a range of frames as used (e.g., for kernel image).

§unsigned long free_count() constsource · definition

Return the number of free frames.