pub struct RamDisk {
data: SpinLock<Vec<u8>>,
block_size: usize,
device_id: usize,
}Expand description
内存模拟的块设备
用于测试和开发
Fields§
§data: SpinLock<Vec<u8>>存储数据
block_size: usize块大小
device_id: usize设备 ID
Implementations§
Trait Implementations§
Source§impl BlockDriver for RamDisk
impl BlockDriver for RamDisk
Source§fn read_block(&self, block_id: usize, buf: &mut [u8]) -> bool
fn read_block(&self, block_id: usize, buf: &mut [u8]) -> bool
读取块设备数据 Read more
Source§fn write_block(&self, block_id: usize, buf: &[u8]) -> bool
fn write_block(&self, block_id: usize, buf: &[u8]) -> bool
写入块设备数据 Read more
Source§fn block_size(&self) -> usize
fn block_size(&self) -> usize
获取块大小(字节) Read more
Source§fn total_blocks(&self) -> usize
fn total_blocks(&self) -> usize
获取总块数 Read more
Source§impl Driver for RamDisk
impl Driver for RamDisk
fn try_handle_interrupt(&self, _irq: Option<usize>) -> bool
fn device_type(&self) -> DeviceType
fn get_id(&self) -> String
Source§fn as_block(&self) -> Option<&dyn BlockDriver>
fn as_block(&self) -> Option<&dyn BlockDriver>
将驱动程序转换为块设备驱动程序(如果适用)
Source§fn as_net_arc(self: Arc<Self>) -> Option<Arc<dyn NetDevice>>
fn as_net_arc(self: Arc<Self>) -> Option<Arc<dyn NetDevice>>
将驱动程序转换为网络驱动程序 Arc(如果适用)
Source§fn as_block_arc(self: Arc<Self>) -> Option<Arc<dyn BlockDriver>>
fn as_block_arc(self: Arc<Self>) -> Option<Arc<dyn BlockDriver>>
将驱动程序转换为块设备驱动程序 Arc(如果适用)
Source§fn as_rtc_arc(self: Arc<Self>) -> Option<Arc<dyn RtcDriver>>
fn as_rtc_arc(self: Arc<Self>) -> Option<Arc<dyn RtcDriver>>
将驱动程序转换为实时时钟驱动程序 Arc(如果适用)
Source§fn as_serial(&self) -> Option<&dyn SerialDriver>
fn as_serial(&self) -> Option<&dyn SerialDriver>
将驱动程序转换为串口驱动程序(如果适用)