Trait virtio_drivers::Hal

source ·
pub trait Hal {
    fn dma_alloc(pages: usize) -> PhysAddr;
    fn dma_dealloc(paddr: PhysAddr, pages: usize) -> i32;
    fn phys_to_virt(paddr: PhysAddr) -> VirtAddr;
    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.

Deallocates the given contiguous physical DMA memory pages.

Converts a physical address used for virtio to a virtual address which the program can access.

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§