Skip to main content

DmaOp

Trait DmaOp 

Source
pub trait DmaOp:
    Sync
    + Send
    + 'static {
Show 14 methods // Required methods fn page_size(&self) -> usize; unsafe fn alloc_contiguous( &self, constraints: DmaConstraints, layout: Layout, ) -> Option<DmaAllocHandle>; unsafe fn dealloc_contiguous(&self, handle: DmaAllocHandle); unsafe fn alloc_coherent( &self, constraints: DmaConstraints, layout: Layout, ) -> Option<DmaAllocHandle>; unsafe fn dealloc_coherent(&self, handle: DmaAllocHandle); unsafe fn map_streaming( &self, constraints: DmaConstraints, addr: NonNull<u8>, size: NonZeroUsize, direction: DmaDirection, ) -> Result<DmaMapHandle, DmaError>; unsafe fn unmap_streaming(&self, handle: DmaMapHandle); // Provided methods fn flush(&self, addr: NonNull<u8>, size: usize) { ... } fn invalidate(&self, addr: NonNull<u8>, size: usize) { ... } fn flush_invalidate(&self, addr: NonNull<u8>, size: usize) { ... } fn sync_alloc_for_device( &self, handle: &DmaAllocHandle, offset: usize, size: usize, direction: DmaDirection, ) { ... } fn sync_alloc_for_cpu( &self, handle: &DmaAllocHandle, offset: usize, size: usize, direction: DmaDirection, ) { ... } fn sync_map_for_device( &self, handle: &DmaMapHandle, offset: usize, size: usize, direction: DmaDirection, ) { ... } fn sync_map_for_cpu( &self, handle: &DmaMapHandle, offset: usize, size: usize, direction: DmaDirection, ) { ... }
}

Required Methods§

Source

fn page_size(&self) -> usize

Source

unsafe fn alloc_contiguous( &self, constraints: DmaConstraints, layout: Layout, ) -> Option<DmaAllocHandle>

Allocates a device-visible contiguous DMA address range.

The returned CPU mapping is normal memory. Non-coherent platforms must use sync_alloc_for_device and sync_alloc_for_cpu to transfer ownership between CPU and device.

§Safety

Implementations must return a live allocation described by layout, with a DMA address range satisfying constraints, and that allocation must remain valid until dealloc_contiguous.

Source

unsafe fn dealloc_contiguous(&self, handle: DmaAllocHandle)

§Safety

Must be paired with alloc_contiguous.

Source

unsafe fn alloc_coherent( &self, constraints: DmaConstraints, layout: Layout, ) -> Option<DmaAllocHandle>

Allocates coherent DMA memory.

Coherent memory is CPU/device visible without explicit cache maintenance. Ordering barriers are still the driver’s responsibility.

§Safety

Implementations must return a live allocation described by layout, with a DMA address range satisfying constraints, and with the backend’s coherent mapping policy applied until dealloc_coherent.

Source

unsafe fn dealloc_coherent(&self, handle: DmaAllocHandle)

§Safety

Must be paired with alloc_coherent.

Source

unsafe fn map_streaming( &self, constraints: DmaConstraints, addr: NonNull<u8>, size: NonZeroUsize, direction: DmaDirection, ) -> Result<DmaMapHandle, DmaError>

Maps an existing caller-owned buffer for streaming DMA.

§Safety

addr..addr + size must remain live until unmap_streaming, and CPU access while the device owns the mapping must follow the sync contract.

Source

unsafe fn unmap_streaming(&self, handle: DmaMapHandle)

§Safety

Must be paired with map_streaming.

Provided Methods§

Source

fn flush(&self, addr: NonNull<u8>, size: usize)

Source

fn invalidate(&self, addr: NonNull<u8>, size: usize)

Source

fn flush_invalidate(&self, addr: NonNull<u8>, size: usize)

Source

fn sync_alloc_for_device( &self, handle: &DmaAllocHandle, offset: usize, size: usize, direction: DmaDirection, )

Source

fn sync_alloc_for_cpu( &self, handle: &DmaAllocHandle, offset: usize, size: usize, direction: DmaDirection, )

Source

fn sync_map_for_device( &self, handle: &DmaMapHandle, offset: usize, size: usize, direction: DmaDirection, )

Source

fn sync_map_for_cpu( &self, handle: &DmaMapHandle, offset: usize, size: usize, direction: DmaDirection, )

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§