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> { ... }
}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§
Sourcefn allocate_raw(&self, count: NonZero<usize>) -> Result<RawFrame, AllocError>
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
fn allocate_raw_at( &self, at: RawFrame, count: NonZero<usize>, ) -> Result<RawFrame, AllocError>
Sourceunsafe fn deallocate_raw(&self, base: RawFrame, count: NonZero<usize>)
unsafe fn deallocate_raw(&self, base: RawFrame, count: NonZero<usize>)
Deallocates count frames starting at base
§Safety
All frames in the range base .. (count + base) must have been allocated by this allocator
Provided Methods§
Sourcefn allocate_one_raw(&self) -> Result<RawFrame, AllocError>
fn allocate_one_raw(&self) -> Result<RawFrame, AllocError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.