Trait virtio_drivers::Hal

source ·
pub trait Hal {
    fn dma_alloc(
        pages: usize,
        direction: BufferDirection
    ) -> (PhysAddr, NonNull<u8>); fn dma_dealloc(paddr: PhysAddr, vaddr: NonNull<u8>, pages: usize) -> i32; fn mmio_phys_to_virt(paddr: PhysAddr, size: usize) -> NonNull<u8>; fn share(buffer: NonNull<[u8]>, direction: BufferDirection) -> PhysAddr; fn unshare(paddr: PhysAddr, buffer: NonNull<[u8]>, direction: BufferDirection); }
Expand description

The interface which a particular hardware implementation must implement.

Required Methods§

Allocates the given number of contiguous physical pages of DMA memory for VirtIO use.

Returns both the physical address which the device can use to access the memory, and a pointer to the start of it which the driver can use to access it.

Deallocates the given contiguous physical DMA memory pages.

Converts a physical address used for MMIO to a virtual address which the driver can access.

This is only used for MMIO addresses within BARs read from the device, for the PCI transport. It may check that the address range up to the given size is within the region expected for MMIO.

Shares the given memory range with the device, and returns the physical address that the device can use to access it.

This may involve mapping the buffer into an IOMMU, giving the host permission to access the memory, or copying it to a special region where it can be accessed.

Unshares the given memory range from the device and (if necessary) copies it back to the original buffer.

Implementors§