Trait PhysicalAllocator

1.0.0 · Source
pub unsafe trait PhysicalAllocator: Send + Sync {
    // Required methods
    fn allocate_contiguous(
        &self,
        frame_count: usize,
    ) -> Result<Frame, AllocError>;
    unsafe fn deallocate_contiguous(
        &self,
        base: Frame,
        frame_count: NonZero<usize>,
    );
    fn allocate_at(
        &self,
        frame_count: usize,
        location: SpecificLocation,
    ) -> Result<Frame, AllocError>;

    // Provided methods
    fn allocate(
        &self,
        frame_count: usize,
    ) -> Result<AllocateNonContiguousRet, AllocError> { ... }
    fn allocate_one(&self) -> Result<Frame, AllocError> { ... }
    fn try_allocate_zeroed(
        &self,
        frame_count: usize,
    ) -> Result<Frame, ZeroAllocError> { ... }
    fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError> { ... }
    fn push(&mut self, _allocation: AllocationMeta) { ... }
}
Expand description

An allocator that managed physical memory

In future, this may be replaced by a more general resource allocator. In that case, this trait will be deprecated and implementors will be expected to move to the more general trait.

Required Methods§

1.0.0 · Source

fn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>

Allocates a contiguous range of physical memory

1.0.0 · Source

unsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)

§Safety

Must be deallocated with the same allocator that made the allocation

Source

fn allocate_at( &self, frame_count: usize, location: SpecificLocation, ) -> Result<Frame, AllocError>

🔬This is a nightly-only experimental API. (kernel_physical_allocator_location)

Provided Methods§

Source

fn allocate( &self, frame_count: usize, ) -> Result<AllocateNonContiguousRet, AllocError>

🔬This is a nightly-only experimental API. (kernel_physical_allocator_non_contiguous)
1.0.0 · Source

fn allocate_one(&self) -> Result<Frame, AllocError>

Allocates a single Frame

Source

fn try_allocate_zeroed( &self, frame_count: usize, ) -> Result<Frame, ZeroAllocError>

🔬This is a nightly-only experimental API. (kernel_allocation_zeroing #2)

Tries to allocate a contiguous region of frame_count frames from a prezeroed buffer

Source

fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>

🔬This is a nightly-only experimental API. (kernel_allocation_zeroing #2)

Allocates a contiguous region of frame_count frames, manually zeroing them if there were no prezeroed frames

Source

fn push(&mut self, _allocation: AllocationMeta)

🔬This is a nightly-only experimental API. (kernel_allocation_new #5)

Implementations on Foreign Types§

1.0.0 · Source§

impl<'a, T: 'a + PhysicalAllocator + ?Sized> PhysicalAllocator for &'a T
where &'a T: Send + Sync,

Source§

fn allocate( &self, frame_count: usize, ) -> Result<AllocateNonContiguousRet, AllocError>

🔬This is a nightly-only experimental API. (kernel_physical_allocator_non_contiguous)
Source§

fn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>

Source§

fn allocate_one(&self) -> Result<Frame, AllocError>

Source§

fn try_allocate_zeroed( &self, frame_count: usize, ) -> Result<Frame, ZeroAllocError>

🔬This is a nightly-only experimental API. (kernel_allocation_zeroing #2)
Source§

fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>

🔬This is a nightly-only experimental API. (kernel_allocation_zeroing #2)
Source§

unsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)

Source§

fn push(&mut self, _allocation: AllocationMeta)

🔬This is a nightly-only experimental API. (kernel_allocation_new #5)
Source§

fn allocate_at( &self, frame_count: usize, location: SpecificLocation, ) -> Result<Frame, AllocError>

🔬This is a nightly-only experimental API. (kernel_physical_allocator_location)
1.0.0 · Source§

impl<T: PhysicalAllocator + ?Sized> PhysicalAllocator for Arc<T>
where Arc<T>: Send + Sync,

Source§

fn allocate( &self, frame_count: usize, ) -> Result<AllocateNonContiguousRet, AllocError>

🔬This is a nightly-only experimental API. (kernel_physical_allocator_non_contiguous)
Source§

fn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>

Source§

fn allocate_one(&self) -> Result<Frame, AllocError>

Source§

fn try_allocate_zeroed( &self, frame_count: usize, ) -> Result<Frame, ZeroAllocError>

🔬This is a nightly-only experimental API. (kernel_allocation_zeroing #2)
Source§

fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>

🔬This is a nightly-only experimental API. (kernel_allocation_zeroing #2)
Source§

unsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)

Source§

fn push(&mut self, _allocation: AllocationMeta)

🔬This is a nightly-only experimental API. (kernel_allocation_new #5)
Source§

fn allocate_at( &self, frame_count: usize, location: SpecificLocation, ) -> Result<Frame, AllocError>

🔬This is a nightly-only experimental API. (kernel_physical_allocator_location)
1.0.0 · Source§

impl<T: PhysicalAllocator + ?Sized> PhysicalAllocator for Box<T>
where Box<T>: Send + Sync,

Source§

fn allocate( &self, frame_count: usize, ) -> Result<AllocateNonContiguousRet, AllocError>

🔬This is a nightly-only experimental API. (kernel_physical_allocator_non_contiguous)
Source§

fn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>

Source§

fn allocate_one(&self) -> Result<Frame, AllocError>

Source§

fn try_allocate_zeroed( &self, frame_count: usize, ) -> Result<Frame, ZeroAllocError>

🔬This is a nightly-only experimental API. (kernel_allocation_zeroing #2)
Source§

fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>

🔬This is a nightly-only experimental API. (kernel_allocation_zeroing #2)
Source§

unsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)

Source§

fn push(&mut self, _allocation: AllocationMeta)

🔬This is a nightly-only experimental API. (kernel_allocation_new #5)
Source§

fn allocate_at( &self, frame_count: usize, location: SpecificLocation, ) -> Result<Frame, AllocError>

🔬This is a nightly-only experimental API. (kernel_physical_allocator_location)

Implementors§