BitmapFrameAlloc

Struct BitmapFrameAlloc 

Source
pub struct BitmapFrameAlloc {
    bitmap: [u64; 256],
    base: u64,
}
Expand description

Minimal bitmap-based PMM for 4K frames in a fixed region.

This type manages a fixed region of physical memory, tracking free/used 4K frames using a bitmap. It supports allocation and freeing, but does not require a heap.

§Example

use kernel_alloc::frame_alloc::BitmapFrameAlloc;
use kernel_vmem::FrameAlloc;
let mut pmm = BitmapFrameAlloc::new();
let frame = pmm.alloc_4k();
if let Some(pa) = frame {
    // Use the physical address...
    pmm.free_4k(pa);
}

§Safety

  • Only physical addresses within the managed region are tracked.
  • The user must ensure that reserved/used frames (e.g., kernel, bootloader) are marked as used before allocation.
  • No synchronization is provided; not thread-safe.

Fields§

§bitmap: [u64; 256]§base: u64

Implementations§

Source§

impl BitmapFrameAlloc

Source

pub const fn new() -> Self

Source

pub const fn mark_used(&mut self, frame_idx: usize)

Mark a frame as used (allocated).

Source

pub const fn mark_free(&mut self, frame_idx: usize)

Mark a frame as free.

Source

pub const fn is_used(&self, frame_idx: usize) -> bool

Returns true if the frame is allocated.

Trait Implementations§

Source§

impl Default for BitmapFrameAlloc

Source§

fn default() -> Self

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

impl FrameAlloc for BitmapFrameAlloc

Source§

fn alloc_4k(&mut self) -> Option<PhysicalPage<Size4K>>

Allocate a zeroed 4 KiB page suitable for a page-table.
Source§

fn free_4k(&mut self, pa: PhysicalPage<Size4K>)

Deallocate a zeroed 4 KiB page suitable for a page-table.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.