Almost successfully read blocks using SCSI.
This commit is contained in:
@@ -3,7 +3,7 @@ use std::slice;
|
||||
|
||||
use xhcid_interface::{ConfDesc, DeviceReqData, EndpBinaryDirection, EndpDirection, EndpointStatus, IfDesc, Invalid, PortReqTy, PortReqRecipient, PortTransferStatus, XhciClientHandle, XhciClientHandleError, XhciEndpHandle};
|
||||
|
||||
use super::{Protocol, ProtocolError, SendCommandStatus};
|
||||
use super::{Protocol, ProtocolError, SendCommandStatus, SendCommandStatusKind};
|
||||
|
||||
pub const CBW_SIGNATURE: u32 = 0x43425355;
|
||||
|
||||
@@ -206,12 +206,15 @@ impl<'a> Protocol for BulkOnlyTransport<'a> {
|
||||
dbg!(self.bulk_in.status()?, self.bulk_out.status()?);
|
||||
}
|
||||
|
||||
Ok(if csw.status == CswStatus::Passed as u8 {
|
||||
SendCommandStatus::Success
|
||||
} else if csw.status == CswStatus::Failed as u8 {
|
||||
SendCommandStatus::Failed { residue: NonZeroU32::new(csw.data_residue) }
|
||||
} else {
|
||||
return Err(ProtocolError::ProtocolError("bulk-only transport phase error, or other"));
|
||||
Ok(SendCommandStatus {
|
||||
kind: if csw.status == CswStatus::Passed as u8 {
|
||||
SendCommandStatusKind::Success
|
||||
} else if csw.status == CswStatus::Failed as u8 {
|
||||
SendCommandStatusKind::Failed
|
||||
} else {
|
||||
return Err(ProtocolError::ProtocolError("bulk-only transport phase error, or other"));
|
||||
},
|
||||
residue: NonZeroU32::new(csw.data_residue),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,26 @@ pub enum ProtocolError {
|
||||
ProtocolError(&'static str),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
pub enum SendCommandStatus {
|
||||
Success,
|
||||
Failed { residue: Option<NonZeroU32> },
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
|
||||
pub struct SendCommandStatus {
|
||||
pub residue: Option<NonZeroU32>,
|
||||
pub kind: SendCommandStatusKind,
|
||||
}
|
||||
impl Default for SendCommandStatus {
|
||||
|
||||
impl SendCommandStatus {
|
||||
pub fn bytes_transferred(&self, transfer_len: u32) -> u32 {
|
||||
transfer_len - self.residue.map(u32::from).unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
pub enum SendCommandStatusKind {
|
||||
Success,
|
||||
Failed,
|
||||
}
|
||||
|
||||
|
||||
impl Default for SendCommandStatusKind {
|
||||
fn default() -> Self {
|
||||
Self::Success
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user