pub struct PinnedBufferAllocator { /* private fields */ }Expand description
A specialized buffer allocator that pins memory in coarse chunks (e.g. 1 MiB) for DMA.
The first chunk (chunk 0) is pinned at initialization and remains pinned for the lifetime of the allocator to eliminate pinning latency on requests. Additional chunks are pinned dynamically on demand when buffers spill over into them, and unpinned when all buffers within those chunks are dropped.
This allocator relies on BufferAllocator’s lowest-offset-first allocation strategy so that
allocations pack into the permanently pinned first chunk before spilling over into dynamically
pinned chunks.
Implementations§
Source§impl PinnedBufferAllocator
impl PinnedBufferAllocator
Sourcepub fn new(
block_size: usize,
source: BufferSource,
bti: Bti,
contiguity: u64,
) -> Self
pub fn new( block_size: usize, source: BufferSource, bti: Bti, contiguity: u64, ) -> Self
Creates a new PinnedBufferAllocator with default chunk size (1 MiB).
contiguity specifies the minimum physical address contiguity (in bytes) required by the
hardware/BTI, which determines the granularity of entries in paddrs.
Sourcepub fn with_chunk_size(
block_size: usize,
source: BufferSource,
bti: Bti,
contiguity: u64,
chunk_size: usize,
) -> Self
pub fn with_chunk_size( block_size: usize, source: BufferSource, bti: Bti, contiguity: u64, chunk_size: usize, ) -> Self
Creates a new PinnedBufferAllocator with a custom chunk_size.
contiguity specifies the minimum physical address contiguity (in bytes) required by the
hardware/BTI, which determines the granularity of entries in paddrs.
pub fn block_size(&self) -> usize
pub fn chunk_size(&self) -> usize
pub fn contiguity(&self) -> u64
pub fn buffer_source(&self) -> &BufferSource
pub fn is_trusted(&self) -> bool
Sourcepub fn clean_transfer_buffer(&self)
pub fn clean_transfer_buffer(&self)
Decommits unallocated pages in the buffer so the kernel can reclaim memory.
Sourcepub fn paddrs(&self, range: &Range<usize>) -> Option<(&[zx_paddr_t], u64)>
pub fn paddrs(&self, range: &Range<usize>) -> Option<(&[zx_paddr_t], u64)>
Returns a slice of physical addresses covering range and the contiguity granularity (in
bytes) represented by each address in the slice.
pub fn try_allocate_buffer( &self, size: usize, ) -> Result<PinnedBuffer<'_>, EventListener>
pub fn allocate_buffer_sync(&self, size: usize) -> PinnedBuffer<'_>
pub fn allocate_buffer(&self, size: usize) -> PinnedBufferFuture<'_>
pub fn try_allocate_buffer_owned( self: &Arc<Self>, size: usize, ) -> Result<OwnedBuffer, EventListener>
pub fn allocate_buffer_sync_owned(self: &Arc<Self>, size: usize) -> OwnedBuffer
Trait Implementations§
Source§impl BufferAllocator for PinnedBufferAllocator
impl BufferAllocator for PinnedBufferAllocator
Source§fn free_buffer(&self, range: Range<usize>)
fn free_buffer(&self, range: Range<usize>)
Source§fn identifier(&self) -> usize
fn identifier(&self) -> usize
Source§fn is_trusted(&self) -> bool
fn is_trusted(&self) -> bool
Source§impl Debug for PinnedBufferAllocator
impl Debug for PinnedBufferAllocator
Source§impl Drop for PinnedBufferAllocator
impl Drop for PinnedBufferAllocator
impl Send for PinnedBufferAllocator
impl Sync for PinnedBufferAllocator
Source§impl<'a> TryAllocateBuffer<'a> for PinnedBufferAllocator
impl<'a> TryAllocateBuffer<'a> for PinnedBufferAllocator
type Buffer = BufferImpl<'a, &'a PinnedBufferAllocator, PinnedBufferAllocator>
Source§fn try_allocate_buffer(
&'a self,
size: usize,
) -> Result<PinnedBuffer<'a>, EventListener>
fn try_allocate_buffer( &'a self, size: usize, ) -> Result<PinnedBuffer<'a>, EventListener>
size bytes. Returns an EventListener to wait on if
memory is temporarily unavailable.