⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

FrameAllocator

Struct FrameAllocator 

Source
pub struct FrameAllocator { /* private fields */ }
Expand description

NUMA-aware hybrid frame allocator

Implementations§

Source§

impl FrameAllocator

Source

pub const fn new() -> Self

Create a new frame allocator

Source

pub fn add_reserved_region(&self, region: ReservedRegion) -> Result<()>

Add a reserved memory region

Source

pub fn is_reserved(&self, start: FrameNumber, count: usize) -> bool

Check if a frame range is reserved

Source

pub fn mark_standard_reserved_regions(&self)

Mark standard reserved regions (e.g., BIOS, kernel, boot data)

Source

pub fn init_numa_node( &mut self, node: usize, start_frame: FrameNumber, frame_count: usize, ) -> Result<()>

Initialize a NUMA node with memory range

Source

pub fn allocate_frames( &self, count: usize, numa_node: Option<usize>, ) -> Result<FrameNumber>

Allocate frames from a specific NUMA node

Source

pub fn allocate_frames_in_zone( &self, count: usize, numa_node: Option<usize>, zone: Option<MemoryZone>, ) -> Result<FrameNumber>

Allocate frames from a specific NUMA node and memory zone

Source

pub fn mark_frame_used(&self, frame: FrameNumber) -> Result<()>

Mark a specific physical frame as used (reserved) so it won’t be allocated. Used to protect boot page table frames from being overwritten by the frame allocator.

Source

pub fn free_frames(&self, frame: FrameNumber, count: usize) -> Result<()>

Free frames back to the allocator

Source

pub fn get_stats(&self) -> FrameAllocatorStats

Get allocator statistics

Source

pub fn allocate_frame_raii(&'static self) -> Result<FrameGuard>

Allocate a single frame with RAII guard

Source

pub fn allocate_frames_raii(&'static self, count: usize) -> Result<FramesGuard>

Allocate multiple frames with RAII guard

Source

pub fn allocate_frame_raii_numa( &'static self, numa_node: usize, ) -> Result<FrameGuard>

Allocate frame from specific NUMA node with RAII guard

Source

pub unsafe fn free_frame(&self, frame: PhysicalFrame)

Free a frame (used by RAII guards)

§Safety

The caller must ensure that:

  • The frame was previously allocated by this allocator
  • The frame is not currently in use
  • The frame will not be used after this call
Source

pub fn deallocate_frame(&self, frame: PhysicalAddress)

Deallocate a single frame (wrapper for free_frames)

Trait Implementations§

Source§

impl Default for FrameAllocator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for FrameAllocator

§

impl !RefUnwindSafe for FrameAllocator

§

impl Send for FrameAllocator

§

impl Sync for FrameAllocator

§

impl Unpin for FrameAllocator

§

impl UnwindSafe for FrameAllocator

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.