Skip to main content

Pmm

Trait Pmm 

Source
pub unsafe trait Pmm<const RAM_ONLY: bool>: Sync + Sized {
    // Required methods
    fn allocate_raw(
        &self,
        count: NonZero<usize>,
    ) -> Result<RawFrame, AllocError>;
    fn allocate_raw_at(
        &self,
        at: RawFrame,
        count: NonZero<usize>,
    ) -> Result<RawFrame, AllocError>;
    unsafe fn deallocate_raw(&self, base: RawFrame, count: NonZero<usize>);

    // Provided method
    fn allocate_one_raw(&self) -> Result<RawFrame, AllocError> { ... }
}
Available on crate feature full only.
Expand description

A physical memory allocator.

If the allocator only allocates from conventional RAM, then the RAM_ONLY flag is set, and any returned memory can be accessed via the page map.

§Safety

The implementation must return unaliased physical memory. Additionally, if RAM_ONLY is true, the returned memory ranges must only be from conventional memory, i.e. EfiConventionalMemory.

Required Methods§

Source

fn allocate_raw(&self, count: NonZero<usize>) -> Result<RawFrame, AllocError>

Allocates count number of contiguous frames.

§Errors

Returns an AllocError if the memory could not be allocated. This does not mean there is no free memory, just that is there no region of contiguous memory large enough.

Source

fn allocate_raw_at( &self, at: RawFrame, count: NonZero<usize>, ) -> Result<RawFrame, AllocError>

Allocates count number of contiguous frames with the first frame being at at.

§Errors

Returns an AllocError if the memory could not be allocated. This does not mean there is no free memory, just that is there no region of contiguous memory large enough starting at at.

Source

unsafe fn deallocate_raw(&self, base: RawFrame, count: NonZero<usize>)

Deallocates count frames starting at base.

§Safety

All frames in the range base .. (base + count) must have been allocated by this allocator.

Provided Methods§

Source

fn allocate_one_raw(&self) -> Result<RawFrame, AllocError>

Allocates a single frame.

§Errors

Returns an AllocError if the memory could not be allocated.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<const RAM_ONLY: bool, T: Pmm<RAM_ONLY>> Pmm<RAM_ONLY> for &T

Source§

fn allocate_one_raw(&self) -> Result<RawFrame, AllocError>

Source§

fn allocate_raw(&self, count: NonZero<usize>) -> Result<RawFrame, AllocError>

Source§

fn allocate_raw_at( &self, at: RawFrame, count: NonZero<usize>, ) -> Result<RawFrame, AllocError>

Source§

unsafe fn deallocate_raw(&self, base: RawFrame, count: NonZero<usize>)

Implementors§

Source§

impl<const RAM: bool> Pmm<RAM> for DynPmm<'_, RAM>