pub struct MassStorageDevice {
pub device_address: u8,
pub bulk_in_ep: u8,
pub bulk_out_ep: u8,
pub lun: u8,
pub max_lun: u8,
pub cached_block_size: u32,
pub cached_total_blocks: u64,
pub state: MassStorageState,
pub last_sense: Option<SenseData>,
}Expand description
USB Mass Storage device using Bulk-Only Transport (BOT)
Fields§
§device_address: u8USB device address on the bus
bulk_in_ep: u8Bulk-In endpoint address
bulk_out_ep: u8Bulk-Out endpoint address
lun: u8Active Logical Unit Number
max_lun: u8Maximum number of LUNs supported by the device
cached_block_size: u32Cached block (sector) size in bytes
cached_total_blocks: u64Cached total block count
state: MassStorageStateCurrent device state
last_sense: Option<SenseData>Last sense data from REQUEST SENSE
Implementations§
Source§impl MassStorageDevice
impl MassStorageDevice
Sourcepub fn new(device_address: u8, bulk_in_ep: u8, bulk_out_ep: u8) -> Self
pub fn new(device_address: u8, bulk_in_ep: u8, bulk_out_ep: u8) -> Self
Create a new mass storage device handle.
device_address: USB device address on the bus
bulk_in_ep: endpoint address for Bulk-In transfers
bulk_out_ep: endpoint address for Bulk-Out transfers
Sourcepub fn build_inquiry_cdb(allocation_length: u8) -> [u8; 6]
pub fn build_inquiry_cdb(allocation_length: u8) -> [u8; 6]
Build a SCSI INQUIRY command (6-byte CDB)
Sourcepub fn build_test_unit_ready_cdb() -> [u8; 6]
pub fn build_test_unit_ready_cdb() -> [u8; 6]
Build a SCSI TEST UNIT READY command (6-byte CDB)
Sourcepub fn build_request_sense_cdb(allocation_length: u8) -> [u8; 6]
pub fn build_request_sense_cdb(allocation_length: u8) -> [u8; 6]
Build a SCSI REQUEST SENSE command (6-byte CDB)
Sourcepub fn build_read_capacity_10_cdb() -> [u8; 10]
pub fn build_read_capacity_10_cdb() -> [u8; 10]
Build a SCSI READ CAPACITY(10) command (10-byte CDB)
Sourcepub fn build_read_10_cdb(lba: u32, transfer_length: u16) -> [u8; 10]
pub fn build_read_10_cdb(lba: u32, transfer_length: u16) -> [u8; 10]
Build a SCSI READ(10) command (10-byte CDB)
Sourcepub fn build_write_10_cdb(lba: u32, transfer_length: u16) -> [u8; 10]
pub fn build_write_10_cdb(lba: u32, transfer_length: u16) -> [u8; 10]
Build a SCSI WRITE(10) command (10-byte CDB)
Sourcepub fn initialize(&mut self) -> Result<InquiryData, KernelError>
pub fn initialize(&mut self) -> Result<InquiryData, KernelError>
Initialize the device: INQUIRY, TEST UNIT READY, READ CAPACITY.
On success, cached_block_size and cached_total_blocks are populated
and the device transitions to the Ready state.
Sourcepub fn request_sense(&mut self) -> Result<SenseData, KernelError>
pub fn request_sense(&mut self) -> Result<SenseData, KernelError>
Issue a SCSI REQUEST SENSE command and cache the result
Trait Implementations§
Source§impl BlockDevice for MassStorageDevice
impl BlockDevice for MassStorageDevice
Source§fn read_blocks(
&self,
lba: u64,
count: u32,
buf: &mut [u8],
) -> Result<usize, KernelError>
fn read_blocks( &self, lba: u64, count: u32, buf: &mut [u8], ) -> Result<usize, KernelError>
count blocks starting at logical block address lba into buf.
Returns the number of bytes actually read.Source§fn write_blocks(
&self,
lba: u64,
count: u32,
buf: &[u8],
) -> Result<usize, KernelError>
fn write_blocks( &self, lba: u64, count: u32, buf: &[u8], ) -> Result<usize, KernelError>
count blocks starting at logical block address lba from buf.
Returns the number of bytes actually written.