Crate frame_allocator
source ·Expand description
Provides an allocator for physical memory frames. The minimum unit of allocation is a single frame.
This is currently a modified and more complex version of the page_allocator
crate.
TODO: extract the common code and create a generic allocator that can be specialized to allocate pages or frames.
This also supports early allocation of frames before heap allocation is available, and does so behind the scenes using the same single interface. Early pre-heap allocations are limited to tracking a small number of available chunks (currently 32).
Once heap allocation is available, it uses a dynamically-allocated list of frame chunks to track allocations.
The core allocation function is allocate_frames_deferred()
,
but there are several convenience functions that offer simpler interfaces for general usage.
Notes and Missing Features
This allocator currently does not merge freed chunks (de-fragmentation). We don’t need to do so until we actually run out of address space or until a requested address is in a chunk that needs to be merged.
Structs
AllocatedFrames
.Frame
]s; derefs to [FrameRange
].AllocatedFrame
in a range of AllocatedFrames
.Enums
Functions
PhysicalAddress
.PhysicalAddress
with a size given in number of bytes. allocated_frames_deferred()
,
but accepts a size value for the allocated frames in number of bytes instead of number of frames. PhysicalAddress
.