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 · Sourcefn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>
fn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>
Allocates a contiguous range of physical memory
1.0.0 · Sourceunsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)
unsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)
§Safety
Must be deallocated with the same allocator that made the allocation
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§
fn allocate( &self, frame_count: usize, ) -> Result<AllocateNonContiguousRet, AllocError>
🔬This is a nightly-only experimental API. (
kernel_physical_allocator_non_contiguous
)1.0.0 · Sourcefn allocate_one(&self) -> Result<Frame, AllocError>
fn allocate_one(&self) -> Result<Frame, AllocError>
Allocates a single Frame
Sourcefn try_allocate_zeroed(
&self,
frame_count: usize,
) -> Result<Frame, ZeroAllocError>
🔬This is a nightly-only experimental API. (kernel_allocation_zeroing
#2)
fn try_allocate_zeroed( &self, frame_count: usize, ) -> Result<Frame, ZeroAllocError>
kernel_allocation_zeroing
#2)Tries to allocate a contiguous region of frame_count
frames from a prezeroed buffer
Sourcefn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>
🔬This is a nightly-only experimental API. (kernel_allocation_zeroing
#2)
fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>
kernel_allocation_zeroing
#2)Allocates a contiguous region of frame_count
frames, manually zeroing them if there were no prezeroed frames
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 Twhere
&'a T: Send + Sync,
impl<'a, T: 'a + PhysicalAllocator + ?Sized> PhysicalAllocator for &'a Twhere
&'a T: Send + Sync,
Source§fn allocate(
&self,
frame_count: usize,
) -> Result<AllocateNonContiguousRet, AllocError>
fn allocate( &self, frame_count: usize, ) -> Result<AllocateNonContiguousRet, AllocError>
🔬This is a nightly-only experimental API. (
kernel_physical_allocator_non_contiguous
)fn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>
fn allocate_one(&self) -> Result<Frame, AllocError>
Source§fn try_allocate_zeroed(
&self,
frame_count: usize,
) -> Result<Frame, ZeroAllocError>
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>
fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>
🔬This is a nightly-only experimental API. (
kernel_allocation_zeroing
#2)unsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)
Source§fn push(&mut self, _allocation: AllocationMeta)
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>
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,
impl<T: PhysicalAllocator + ?Sized> PhysicalAllocator for Arc<T>where
Arc<T>: Send + Sync,
Source§fn allocate(
&self,
frame_count: usize,
) -> Result<AllocateNonContiguousRet, AllocError>
fn allocate( &self, frame_count: usize, ) -> Result<AllocateNonContiguousRet, AllocError>
🔬This is a nightly-only experimental API. (
kernel_physical_allocator_non_contiguous
)fn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>
fn allocate_one(&self) -> Result<Frame, AllocError>
Source§fn try_allocate_zeroed(
&self,
frame_count: usize,
) -> Result<Frame, ZeroAllocError>
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>
fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>
🔬This is a nightly-only experimental API. (
kernel_allocation_zeroing
#2)unsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)
Source§fn push(&mut self, _allocation: AllocationMeta)
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>
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,
impl<T: PhysicalAllocator + ?Sized> PhysicalAllocator for Box<T>where
Box<T>: Send + Sync,
Source§fn allocate(
&self,
frame_count: usize,
) -> Result<AllocateNonContiguousRet, AllocError>
fn allocate( &self, frame_count: usize, ) -> Result<AllocateNonContiguousRet, AllocError>
🔬This is a nightly-only experimental API. (
kernel_physical_allocator_non_contiguous
)fn allocate_contiguous(&self, frame_count: usize) -> Result<Frame, AllocError>
fn allocate_one(&self) -> Result<Frame, AllocError>
Source§fn try_allocate_zeroed(
&self,
frame_count: usize,
) -> Result<Frame, ZeroAllocError>
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>
fn allocate_zeroed(&self, frame_count: usize) -> Result<Frame, AllocError>
🔬This is a nightly-only experimental API. (
kernel_allocation_zeroing
#2)unsafe fn deallocate_contiguous(&self, base: Frame, frame_count: NonZero<usize>)
Source§fn push(&mut self, _allocation: AllocationMeta)
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>
fn allocate_at( &self, frame_count: usize, location: SpecificLocation, ) -> Result<Frame, AllocError>
🔬This is a nightly-only experimental API. (
kernel_physical_allocator_location
)