pub struct DmaBufferPool { /* private fields */ }Expand description
DMA Buffer Pool
Implementations§
Source§impl DmaBufferPool
impl DmaBufferPool
Sourcepub fn new(num_buffers: usize) -> Result<Self, KernelError>
pub fn new(num_buffers: usize) -> Result<Self, KernelError>
Create a new DMA buffer pool with physically contiguous frames.
Allocates num_buffers frames from the frame allocator for DMA use.
Frames are filtered to be below 4GB for 32-bit DMA engine compatibility.
Each frame provides one DMA_BUFFER_SIZE buffer. If allocation fails
for some frames, the pool is created with however many were successful.
Sourcepub fn alloc(&mut self) -> Result<&mut DmaBuffer, KernelError>
pub fn alloc(&mut self) -> Result<&mut DmaBuffer, KernelError>
Allocate a buffer from the pool
Sourcepub fn free(&mut self, buffer_index: u16) -> Result<(), KernelError>
pub fn free(&mut self, buffer_index: u16) -> Result<(), KernelError>
Free a buffer back to the pool
Sourcepub fn free_count(&self) -> usize
pub fn free_count(&self) -> usize
Get number of free buffers
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Get total number of buffers
Sourcepub fn stats(&self) -> DmaPoolStats
pub fn stats(&self) -> DmaPoolStats
Get allocation statistics