ros666::drivers::block::virtio_block

Struct HalImpl

Source
pub struct HalImpl;
Expand description

实现 Hal trait 以适配 VirtIO 块设备

Hal trait 定义了一些底层的硬件操作,例如分配/释放 DMA 内存,将物理地址映射到虚拟地址等。

virtio_drivers 通过 Hal trait 与内核内存空间进行交互,以实现 DMA 内存的分配和释放,以及将物理地址映射到虚拟地址。

Trait Implementations§

Source§

impl Hal for HalImpl

Source§

fn dma_alloc( pages: usize, _direction: BufferDirection, ) -> (PhysAddr, NonNull<u8>)

Allocates and zeroes the given number of contiguous physical pages of DMA memory for VirtIO use. Read more
Source§

unsafe fn dma_dealloc(paddr: PhysAddr, _vaddr: NonNull<u8>, pages: usize) -> i32

Deallocates the given contiguous physical DMA memory pages. Read more
Source§

unsafe fn mmio_phys_to_virt(paddr: PhysAddr, _size: usize) -> NonNull<u8>

Converts a physical address used for MMIO to a virtual address which the driver can access. Read more
Source§

unsafe fn share(buffer: NonNull<[u8]>, _direction: BufferDirection) -> PhysAddr

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

unsafe fn unshare( _paddr: PhysAddr, _buffer: NonNull<[u8]>, _direction: BufferDirection, )

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.