pub struct BitmapPageAllocator<const PAGE_SIZE: usize> { /* private fields */ }
Expand description

A page-granularity memory allocator based on the bitmap_allocator.

It internally uses a bitmap, each bit indicates whether a page has been allocated.

The PAGE_SIZE must be a power of two.

Implementations§

source§

impl<const PAGE_SIZE: usize> BitmapPageAllocator<PAGE_SIZE>

source

pub const fn new() -> Self

Creates a new empty BitmapPageAllocator.

Trait Implementations§

source§

impl<const PAGE_SIZE: usize> BaseAllocator for BitmapPageAllocator<PAGE_SIZE>

source§

fn init(&mut self, start: usize, size: usize)

Initialize the allocator with a free memory region.
source§

fn add_memory(&mut self, _start: usize, _size: usize) -> AllocResult

Add a free memory region to the allocator.
source§

impl<const PAGE_SIZE: usize> PageAllocator for BitmapPageAllocator<PAGE_SIZE>

source§

const PAGE_SIZE: usize = PAGE_SIZE

The size of a memory page.
source§

fn alloc_pages( &mut self, num_pages: usize, align_pow2: usize ) -> AllocResult<usize>

Allocate contiguous memory pages with given count and alignment.
source§

fn dealloc_pages(&mut self, pos: usize, num_pages: usize)

Deallocate contiguous memory pages with given position and count.
source§

fn total_pages(&self) -> usize

Returns the total number of memory pages.
source§

fn used_pages(&self) -> usize

Returns the number of allocated memory pages.
source§

fn available_pages(&self) -> usize

Returns the number of available memory pages.

Auto Trait Implementations§

§

impl<const PAGE_SIZE: usize> RefUnwindSafe for BitmapPageAllocator<PAGE_SIZE>

§

impl<const PAGE_SIZE: usize> Send for BitmapPageAllocator<PAGE_SIZE>

§

impl<const PAGE_SIZE: usize> Sync for BitmapPageAllocator<PAGE_SIZE>

§

impl<const PAGE_SIZE: usize> Unpin for BitmapPageAllocator<PAGE_SIZE>

§

impl<const PAGE_SIZE: usize> UnwindSafe for BitmapPageAllocator<PAGE_SIZE>

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>,

§

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>,

§

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.