mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
strip trailing whitespace on mass-storage
This commit is contained in:
parent
b4e632130a
commit
7d9874e522
27 changed files with 114 additions and 114 deletions
|
|
@ -11,7 +11,7 @@ use crate::{
|
|||
|
||||
/// Trait signifying a single bit in a byte. 7 = most significant bit, 0 = least significant bit
|
||||
pub trait Bit: IsLess<U8> + Unsigned {
|
||||
/// The mask used to discard bits before this bit (i.e. if this bit is 5, ANDing this mask with
|
||||
/// The mask used to discard bits before this bit (i.e. if this bit is 5, ANDing this mask with
|
||||
/// a u8 will ensure bits 7 and 6 are 0.
|
||||
const HEAD_MASK: u8 = ((1_u16 << (Self::USIZE + 1)) - 1) as u8;
|
||||
/// The mask used to extract the single bit from a byte
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl Endian for BigEndian {
|
|||
// Case 2: More than 1 byte but the LSB at the end of the input
|
||||
// is already in position 0 so no shifting is required
|
||||
} else if E::USIZE == 0 {
|
||||
// Since we aren't shrinking the data down by aligning the fields, the output
|
||||
// Since we aren't shrinking the data down by aligning the fields, the output
|
||||
// buffer must be at least as long as the input
|
||||
assert!(output_bytes.len() >= input_bytes.len());
|
||||
|
||||
|
|
@ -52,13 +52,13 @@ impl Endian for BigEndian {
|
|||
output_bytes[o_start] &= S::HEAD_MASK;
|
||||
}
|
||||
|
||||
// Note: Case 3 and 4 could be merged with some minor tweaks around the input start
|
||||
// Note: Case 3 and 4 could be merged with some minor tweaks around the input start
|
||||
// and an extra negative offset to output index for case 4 but I've left them
|
||||
// split up for ease of debugging while testing edge cases for now.
|
||||
// Case 3: More than 1 byte and LSB at the end ISN'T at position 0 and we aren't
|
||||
// shrinking the data down by aligning the fields. We need to shift every byte
|
||||
} else if S::USIZE >= E::USIZE {
|
||||
// Since we aren't shrinking the data down by aligning the fields, the output
|
||||
// Since we aren't shrinking the data down by aligning the fields, the output
|
||||
// buffer must be at least as long as the input
|
||||
assert!(output_bytes.len() >= input_bytes.len());
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ impl Endian for BigEndian {
|
|||
let o_start = o_len - i_len;
|
||||
|
||||
for i in 0..i_len {
|
||||
output_bytes[o_start + i] =
|
||||
output_bytes[o_start + i] =
|
||||
match i {
|
||||
// No prior byte, just masked and shifted left by the number of bits
|
||||
// we need to fill the space in the last byte
|
||||
|
|
@ -80,12 +80,12 @@ impl Endian for BigEndian {
|
|||
_ => (input_bytes[i-1] << (8-E::USIZE))
|
||||
| (input_bytes[i] >> E::USIZE),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Case 4: More than 1 byte and LSB at the end ISN'T at position 0 and we ARE
|
||||
// Case 4: More than 1 byte and LSB at the end ISN'T at position 0 and we ARE
|
||||
// shrinking the data down by 1 byte by aligning the fields. We need to shift every byte
|
||||
} else {
|
||||
// Since we are shrinking the data down by aligning the fields, the output
|
||||
// Since we are shrinking the data down by aligning the fields, the output
|
||||
// buffer can be 1 smaller than the input
|
||||
assert!(output_bytes.len() >= input_bytes.len() - 1);
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ impl Endian for BigEndian {
|
|||
let o_start = o_len - (i_len - 1);
|
||||
|
||||
for i in 1..i_len {
|
||||
output_bytes[o_start + i - 1] =
|
||||
output_bytes[o_start + i - 1] =
|
||||
match i {
|
||||
// No prior byte, just masked and shifted left by the number of bits
|
||||
// we need to fill the space in the last byte
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl Endian for LittleEndian {
|
|||
// Case 2: More than 1 byte but the MSB at the beginning of the input
|
||||
// is already in position 7 so no shifting is required
|
||||
} else if S::USIZE == 7 {
|
||||
// Since we aren't shrinking the data down by aligning the fields, the output
|
||||
// Since we aren't shrinking the data down by aligning the fields, the output
|
||||
// buffer must be at least as long as the input
|
||||
assert!(output_bytes.len() >= input_bytes.len());
|
||||
|
||||
|
|
@ -50,19 +50,19 @@ impl Endian for LittleEndian {
|
|||
output_bytes[i_len-1] >>= E::USIZE;
|
||||
}
|
||||
|
||||
// Note: Case 3 and 4 could be merged with some minor tweaks around the input start
|
||||
// Note: Case 3 and 4 could be merged with some minor tweaks around the input start
|
||||
// and an extra negative offset to output index for case 4 but I've left them
|
||||
// split up for ease of debugging while testing edge cases for now.
|
||||
// Case 3: More than 1 byte, MSB at the beginning ISN'T at position 7 and we aren't
|
||||
// shrinking the data down by aligning the fields. We need to shift every byte
|
||||
} else {
|
||||
let n_bytes = if S::USIZE >= E::USIZE {
|
||||
// Since we aren't shrinking the data down by aligning the fields, the output
|
||||
// Since we aren't shrinking the data down by aligning the fields, the output
|
||||
// buffer must be at least as long as the input
|
||||
assert!(output_bytes.len() >= input_bytes.len());
|
||||
i_len
|
||||
} else {
|
||||
// Since we are shrinking the data down by aligning the fields, the output
|
||||
// Since we are shrinking the data down by aligning the fields, the output
|
||||
// buffer can be 1 smaller than the input
|
||||
assert!(output_bytes.len() >= input_bytes.len() - 1);
|
||||
i_len - 1
|
||||
|
|
@ -92,8 +92,8 @@ impl Endian for LittleEndian {
|
|||
|
||||
output_bytes[i] |= val << S::USIZE+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn restore_field_bits<S: Bit, E: Bit>(input_bytes: &[u8], output_bytes: &mut [u8]) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use core::convert::Infallible;
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Error {
|
||||
/// Pack or Unpack method called with a slice of insufficient length
|
||||
/// Check the `PACK_BYTES_LEN` on the struct impl
|
||||
/// Check the `PACK_BYTES_LEN` on the struct impl
|
||||
InsufficientBytes,
|
||||
|
||||
/// Attempted to unpack an enum but the value found didn't match any
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ pub trait PackedSize where Self: Sized {
|
|||
}
|
||||
|
||||
/// Trait that enables endian aware conversion to/from bytes for packable types
|
||||
///
|
||||
///
|
||||
/// Mostly for primitives. Currently expected to accept/return arrays by proc macro.
|
||||
/// Benchmarking showed allocating a new 1 to 8 byte array during to/from bytes
|
||||
/// Benchmarking showed allocating a new 1 to 8 byte array during to/from bytes
|
||||
/// performed exactly the same as manual bit shifting or various other shenanigans.
|
||||
///
|
||||
/// TODO: Above perf statement likely only holds true up to a certain size. Currently
|
||||
/// nested structs and packing/unpacking them to/from &mut [u8] is not supported.
|
||||
/// nested structs and packing/unpacking them to/from &mut [u8] is not supported.
|
||||
pub trait PackedBytes<B>: PackedSize {
|
||||
type Error;
|
||||
fn to_bytes<En: Endian>(&self) -> Result<B, Self::Error>;
|
||||
|
|
@ -29,9 +29,9 @@ pub trait PackedBytes<B>: PackedSize {
|
|||
/// Trait that enables packing and unpacking to/from byte slices
|
||||
///
|
||||
/// This is the trait that the proc macro implements on structs. Supports arbitrary
|
||||
/// field alignment - i.e. fields needn't start or end on 8-bit byte boundaries.
|
||||
/// For example, 2 bools, a 10-bit number and a 4-bit number could be packed into
|
||||
/// a pair of bytes such that the 10-bit number straddles them and doesn't align with
|
||||
/// field alignment - i.e. fields needn't start or end on 8-bit byte boundaries.
|
||||
/// For example, 2 bools, a 10-bit number and a 4-bit number could be packed into
|
||||
/// a pair of bytes such that the 10-bit number straddles them and doesn't align with
|
||||
/// any byte boundaries
|
||||
///
|
||||
/// Allowing arbitray field alignment should be zero-cost as the field definitions
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ const PKD_ATTR: &str = "pkd";
|
|||
///
|
||||
/// However, this derive also supports inferring field alignments from the width of the field type, where the
|
||||
/// last field ended, etc. This is provided so projects can use it for the complex explicit case mentioned above
|
||||
/// but also use it for the more trivial alignments you'd expect from repr(C) or repr(Packed). `width` and
|
||||
/// but also use it for the more trivial alignments you'd expect from repr(C) or repr(Packed). `width` and
|
||||
/// `space` were added to allow the case where most of the struct is as you'd expect but a handful of fields
|
||||
/// are slightly different. This was working at the time of implementation but has no tests around it currently
|
||||
/// so may get broken. //TODO: add tests for all supported cases.
|
||||
|
|
@ -339,7 +339,7 @@ usize_field!(StartBit, "StartBit", "StartBit");
|
|||
usize_field!(EndBit, "EndBit", "EndBit");
|
||||
|
||||
|
||||
fn get_attr<'a, I, Ta: 'a, Tb, F>(iter: I, _span: Span, scope: Scope, default: Tb, filter_map: F) -> Result<Tb, Error>
|
||||
fn get_attr<'a, I, Ta: 'a, Tb, F>(iter: I, _span: Span, scope: Scope, default: Tb, filter_map: F) -> Result<Tb, Error>
|
||||
where
|
||||
I: Iterator<Item = &'a Ta>,
|
||||
Tb: Clone + Name + Debug,
|
||||
|
|
@ -709,7 +709,7 @@ fn derive_struct(
|
|||
if end_set {
|
||||
if w != end - bit {
|
||||
error_or_diagnostic(f.name.span(),
|
||||
format!("Field specifies width of {} but calculated width is {}. Check width, start/end byte/bit attributes",
|
||||
format!("Field specifies width of {} but calculated width is {}. Check width, start/end byte/bit attributes",
|
||||
w, end - bit))?;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -76,31 +76,31 @@ mod tests {
|
|||
match p.little_endian {
|
||||
true => <u8 as PackedBytes<[u8; 1]>>::to_bytes::<LittleEndian>(&(p.n as u8)),
|
||||
false => <u8 as PackedBytes<[u8; 1]>>::to_bytes::<BigEndian>(&(p.n as u8)),
|
||||
}.unwrap().to_vec()
|
||||
}.unwrap().to_vec()
|
||||
},
|
||||
2 => {
|
||||
match p.little_endian {
|
||||
true => <u16 as PackedBytes<[u8; 2]>>::to_bytes::<LittleEndian>(&(p.n as u16)),
|
||||
false => <u16 as PackedBytes<[u8; 2]>>::to_bytes::<BigEndian>(&(p.n as u16)),
|
||||
}.unwrap().to_vec()
|
||||
}.unwrap().to_vec()
|
||||
},
|
||||
3..=4 => {
|
||||
match p.little_endian {
|
||||
true => <u32 as PackedBytes<[u8; 4]>>::to_bytes::<LittleEndian>(&(p.n as u32)),
|
||||
false => <u32 as PackedBytes<[u8; 4]>>::to_bytes::<BigEndian>(&(p.n as u32)),
|
||||
}.unwrap().to_vec()
|
||||
}.unwrap().to_vec()
|
||||
},
|
||||
5..=8 => {
|
||||
match p.little_endian {
|
||||
true => <u64 as PackedBytes<[u8; 8]>>::to_bytes::<LittleEndian>(&(p.n as u64)),
|
||||
false => <u64 as PackedBytes<[u8; 8]>>::to_bytes::<BigEndian>(&(p.n as u64)),
|
||||
}.unwrap().to_vec()
|
||||
}.unwrap().to_vec()
|
||||
},
|
||||
_ => {
|
||||
match p.little_endian {
|
||||
true => <u128 as PackedBytes<[u8; 16]>>::to_bytes::<LittleEndian>(&p.n),
|
||||
false => <u128 as PackedBytes<[u8; 16]>>::to_bytes::<BigEndian>(&p.n),
|
||||
}.unwrap().to_vec()
|
||||
}.unwrap().to_vec()
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ mod tests {
|
|||
|
||||
let mut aligned_field_bytes = Vec::new();
|
||||
aligned_field_bytes.resize(p.total_bytes, 0);
|
||||
|
||||
|
||||
match (p.start, p.end, p.little_endian) {
|
||||
(7, 7, true) => LittleEndian::align_field_bits::<U7, U7>(&restored_field_bytes, &mut aligned_field_bytes),
|
||||
(7, 7, false) => BigEndian::align_field_bits::<U7, U7>(&restored_field_bytes, &mut aligned_field_bytes),
|
||||
|
|
@ -538,10 +538,10 @@ mod tests {
|
|||
}
|
||||
|
||||
if let Err(e) = pretty_error(
|
||||
&aligned_field_bytes,
|
||||
&aligned_field_bytes,
|
||||
&restored_field_bytes2,
|
||||
&restored_field_bytes,
|
||||
p.start as usize,
|
||||
p.start as usize,
|
||||
p.end as usize,
|
||||
) {
|
||||
panic!("restored->aligned->restored round trip failed: {}", e);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ pub enum BlockDeviceError {
|
|||
WriteError,
|
||||
|
||||
/// Error during erase; most likely value read back after erase was wrong
|
||||
///
|
||||
/// STM32 flash programming app note implies this is possible but doesn't say under what
|
||||
///
|
||||
/// STM32 flash programming app note implies this is possible but doesn't say under what
|
||||
/// circumstances. Is the flash knackered if this happens?
|
||||
EraseError,
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ pub trait BlockDevice {
|
|||
|
||||
/// Write the `block` buffer to the block indicated by `lba`
|
||||
fn write_block(&mut self, lba: u32, block: &[u8]) -> Result<(), BlockDeviceError>;
|
||||
|
||||
|
||||
/// Get the maxium valid lba (logical block address)
|
||||
fn max_lba(&self) -> u32;
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ impl Command {
|
|||
OpCode::Read6 => Ok(Command::Read(checked_extract::<Read6Command>(cbw)?.into())),
|
||||
OpCode::Read10 => Ok(Command::Read(checked_extract::<Read10Command>(cbw)?.into())),
|
||||
OpCode::Read12 => Ok(Command::Read(checked_extract::<Read12Command>(cbw)?.into())),
|
||||
OpCode::ReadCapacity10 => Ok(Command::ReadCapacity(checked_extract(cbw)?)),
|
||||
OpCode::ReadCapacity10 => Ok(Command::ReadCapacity(checked_extract(cbw)?)),
|
||||
OpCode::ReadFormatCapacities => Ok(Command::ReadFormatCapacities(checked_extract(cbw)?)),
|
||||
OpCode::Inquiry => Ok(Command::Inquiry(checked_extract(cbw)?)),
|
||||
OpCode::TestUnitReady => Ok(Command::TestUnitReady(checked_extract(cbw)?)),
|
||||
|
|
@ -68,8 +68,8 @@ impl Command {
|
|||
}
|
||||
|
||||
|
||||
fn checked_extract<T>(cbw: &CommandBlockWrapper_NEW) -> Result<T, Error>
|
||||
where
|
||||
fn checked_extract<T>(cbw: &CommandBlockWrapper_NEW) -> Result<T, Error>
|
||||
where
|
||||
T: ParsePackedStruct,
|
||||
Error: From<<T as Packed>::Error>,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use packing::Packed;
|
|||
pub struct Control {
|
||||
#[pkd(7, 6, 0, 0)]
|
||||
pub vendor_specific: u8,
|
||||
|
||||
|
||||
#[pkd(2, 2, 0, 0)]
|
||||
pub normal_aca: bool,
|
||||
}
|
||||
|
|
@ -15,22 +15,22 @@ use crate::scsi::{
|
|||
pub struct FormatCommand {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 6, 1, 1)]
|
||||
pub format_protection_information: u8,
|
||||
|
||||
|
||||
#[pkd(5, 5, 1, 1)]
|
||||
pub long_list: bool,
|
||||
|
||||
|
||||
#[pkd(4, 4, 1, 1)]
|
||||
pub format_data: bool,
|
||||
|
||||
|
||||
#[pkd(3, 3, 1, 1)]
|
||||
pub complete_list: bool,
|
||||
|
||||
|
||||
#[pkd(2, 0, 1, 1)]
|
||||
pub defect_list_format: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 5, 5)]
|
||||
pub control: Control,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use crate::scsi::{
|
|||
pub struct InquiryCommand {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
/// If set, return vital data related to the page_code field
|
||||
#[pkd(0, 0, 1, 1)]
|
||||
pub enable_vital_product_data: bool,
|
||||
|
|
@ -39,20 +39,20 @@ impl ParsePackedStruct for InquiryCommand {}
|
|||
|
||||
|
||||
/*
|
||||
if evpd
|
||||
if evpd
|
||||
return data related to page_code (spc-4 section 7.8)
|
||||
if unsupported(page_code)
|
||||
return CHECK_CONDITION and set SENSE:
|
||||
if unsupported(page_code)
|
||||
return CHECK_CONDITION and set SENSE:
|
||||
key: ILLEGAL_REQUEST
|
||||
additional code: INVALID_FIELD_IN_CBD
|
||||
|
||||
|
||||
if !evpd
|
||||
return standard inquiry data (spc-4 section 6.4.2)
|
||||
if page_code != 0
|
||||
return CHECK_CONDITION and set SENSE:
|
||||
return CHECK_CONDITION and set SENSE:
|
||||
key: ILLEGAL_REQUEST
|
||||
additional code: INVALID_FIELD_IN_CBD
|
||||
*/
|
||||
additional code: INVALID_FIELD_IN_CBD
|
||||
*/
|
||||
|
||||
|
||||
#[test]
|
||||
|
|
@ -63,19 +63,19 @@ fn test_inquiry() {
|
|||
|
||||
bytes[0] |= 0b00000001;
|
||||
cmd.enable_vital_product_data = true;
|
||||
assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap());
|
||||
assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap());
|
||||
|
||||
bytes[1] = 0x99;
|
||||
cmd.page_code = 0x99;
|
||||
assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap());
|
||||
assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap());
|
||||
|
||||
let al = 9999;
|
||||
bytes[2] = ((al >> 8) & 0xFF) as u8;
|
||||
bytes[3] = ((al >> 0) & 0xFF) as u8;
|
||||
cmd.allocation_length = al;
|
||||
assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap());
|
||||
assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap());
|
||||
|
||||
bytes[4] = 0x31;
|
||||
cmd.control = 0x31;
|
||||
assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap());
|
||||
assert_eq!(cmd, InquiryCommand::unpack(&bytes).unwrap());
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ pub struct ModeSelectXCommand {
|
|||
pub struct ModeSelect6Command {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(4, 4, 1, 1)]
|
||||
pub page_format: bool,
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ impl From<ModeSelect6Command> for ModeSelectXCommand {
|
|||
pub struct ModeSelect10Command {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(4, 4, 1, 1)]
|
||||
pub page_format: bool,
|
||||
|
||||
|
|
|
|||
|
|
@ -39,29 +39,29 @@ pub struct ModeSenseXCommand {
|
|||
pub struct ModeSense6Command {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(3, 3, 1, 1)]
|
||||
pub disable_block_descriptors: bool,
|
||||
|
||||
|
||||
#[pkd(7, 6, 2, 2)]
|
||||
pub page_control: PageControl,
|
||||
|
||||
|
||||
#[pkd(5, 0, 2, 2)]
|
||||
pub page_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 3, 3)]
|
||||
pub subpage_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 4, 4)]
|
||||
pub allocation_length: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 5, 5)]
|
||||
pub control: Control,
|
||||
}
|
||||
impl ParsePackedStruct for ModeSense6Command {}
|
||||
impl From<ModeSense6Command> for ModeSenseXCommand {
|
||||
fn from(m: ModeSense6Command) -> Self {
|
||||
Self {
|
||||
Self {
|
||||
command_length: CommandLength::C6,
|
||||
page_control: m.page_control,
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ impl From<ModeSense6Command> for ModeSenseXCommand {
|
|||
pub struct ModeSense10Command {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(4, 4, 1, 1)]
|
||||
pub long_lba_accepted: bool,
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ pub struct ModeSense10Command {
|
|||
|
||||
#[pkd(5, 0, 2, 2)]
|
||||
pub page_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 3, 3)]
|
||||
pub subpage_code: u8,
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ impl From<ModeSense10Command> for ModeSenseXCommand {
|
|||
fn from(m: ModeSense10Command) -> Self {
|
||||
Self {
|
||||
command_length: CommandLength::C10,
|
||||
page_control: m.page_control,
|
||||
page_control: m.page_control,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ use crate::scsi::{
|
|||
pub struct PreventAllowMediumRemovalCommand {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(1, 0, 4, 4)]
|
||||
pub prevent: u8,
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ pub struct Read10Command {
|
|||
pub lba: u32,
|
||||
|
||||
#[pkd(4, 0, 6, 6)]
|
||||
pub group_number: u8,
|
||||
pub group_number: u8,
|
||||
|
||||
#[pkd(7, 0, 7, 8)]
|
||||
pub transfer_length: u16,
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ pub struct ReportLunsCommand {
|
|||
|
||||
#[pkd(7, 0, 2, 2)]
|
||||
pub select_report: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 6, 9)]
|
||||
pub allocation_length: u32,
|
||||
|
||||
|
||||
#[pkd(7, 0, 11, 11)]
|
||||
pub control: Control,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ use crate::scsi::{
|
|||
pub struct RequestSenseCommand {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(0, 0, 1, 1)]
|
||||
pub descriptor_format: bool,
|
||||
|
||||
|
||||
#[pkd(7, 0, 4, 4)]
|
||||
pub allocation_length: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 5, 5)]
|
||||
pub control: Control,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,28 +12,28 @@ use crate::scsi::{
|
|||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug, Packed)]
|
||||
#[packed(big_endian, lsb0)]
|
||||
pub struct SendDiagnosticCommand {
|
||||
pub struct SendDiagnosticCommand {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 5, 1, 1)]
|
||||
pub self_test_code: u8,
|
||||
|
||||
|
||||
#[pkd(4, 4, 1, 1)]
|
||||
pub page_format: bool,
|
||||
|
||||
|
||||
#[pkd(2, 2, 1, 1)]
|
||||
pub self_test: bool,
|
||||
|
||||
|
||||
#[pkd(1, 1, 1, 1)]
|
||||
pub device_offline: bool,
|
||||
|
||||
|
||||
#[pkd(0, 0, 1, 1)]
|
||||
pub unit_offline: bool,
|
||||
|
||||
|
||||
#[pkd(7, 0, 3, 4)]
|
||||
pub parameter_list_length: u16,
|
||||
|
||||
|
||||
#[pkd(7, 0, 5, 5)]
|
||||
pub control: Control,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,25 +15,25 @@ use crate::scsi::{
|
|||
pub struct StartStopUnitCommand {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(0, 0, 1, 1)]
|
||||
pub immediate: bool,
|
||||
|
||||
|
||||
#[pkd(3, 0, 3, 3)]
|
||||
pub power_condition_modifier: u8,
|
||||
|
||||
|
||||
#[pkd(7, 4, 4, 4)]
|
||||
pub power_condition: u8,
|
||||
|
||||
|
||||
#[pkd(2, 2, 4, 4)]
|
||||
pub no_flush: bool,
|
||||
|
||||
|
||||
#[pkd(1, 1, 4, 4)]
|
||||
pub load_eject: bool,
|
||||
|
||||
|
||||
#[pkd(0, 0, 4, 4)]
|
||||
pub start: bool,
|
||||
|
||||
|
||||
#[pkd(7, 0, 5, 5)]
|
||||
pub control: Control,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@ use crate::scsi::{
|
|||
pub struct SynchronizeCache10Command {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(1, 1, 1, 1)]
|
||||
pub immediate: bool,
|
||||
|
||||
|
||||
#[pkd(7, 0, 2, 5)]
|
||||
pub lba: u32,
|
||||
|
||||
|
||||
#[pkd(4, 0, 6, 6)]
|
||||
pub group_number: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 7, 8)]
|
||||
pub number_of_blocks: u16,
|
||||
|
||||
|
||||
#[pkd(7, 0, 9, 9)]
|
||||
pub control: Control,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use crate::scsi::{
|
|||
pub struct TestUnitReadyCommand {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 5, 5)]
|
||||
pub control: Control,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,25 +15,25 @@ use crate::scsi::{
|
|||
pub struct Verify10Command {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 5, 1, 1)]
|
||||
pub vr_protect: u8,
|
||||
|
||||
|
||||
#[pkd(4, 4, 1, 1)]
|
||||
pub dpo: bool,
|
||||
|
||||
|
||||
#[pkd(1, 1, 1, 1)]
|
||||
pub byte_check: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 2, 5)]
|
||||
pub lba: u32,
|
||||
|
||||
|
||||
#[pkd(4, 0, 6, 6)]
|
||||
pub group_number: u8,
|
||||
|
||||
|
||||
#[pkd(7, 0, 7, 8)]
|
||||
pub verification_length: u16,
|
||||
|
||||
|
||||
#[pkd(7, 0, 9, 9)]
|
||||
pub control: Control,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ impl From<Write6Command> for WriteXCommand {
|
|||
pub struct Write10Command {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 5, 1, 1)]
|
||||
pub wr_protect: u8,
|
||||
|
||||
#[pkd(4, 4, 1, 1)]
|
||||
pub dpo: bool,
|
||||
|
||||
|
||||
#[pkd(3, 3, 1, 1)]
|
||||
pub fua: bool,
|
||||
|
||||
|
|
@ -86,13 +86,13 @@ impl From<Write10Command> for WriteXCommand {
|
|||
pub struct Write12Command {
|
||||
#[pkd(7, 0, 0, 0)]
|
||||
pub op_code: u8,
|
||||
|
||||
|
||||
#[pkd(7, 5, 1, 1)]
|
||||
pub wr_protect: u8,
|
||||
|
||||
#[pkd(4, 4, 1, 1)]
|
||||
pub dpo: bool,
|
||||
|
||||
|
||||
#[pkd(3, 3, 1, 1)]
|
||||
pub fua: bool,
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// SPDX-LIcense-Identifier: Apache 2.0
|
||||
|
||||
// There are many more variants (see asc-num.txt) but these are the ones the scsi code
|
||||
// currently uses
|
||||
// currently uses
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum AdditionalSenseCode {
|
||||
/// ASC 0x20, ASCQ: 0x0 - INVALID COMMAND OPERATION CODE
|
||||
|
|
@ -74,13 +74,13 @@ impl packing::PackedBytes<[u8; 2]> for AdditionalSenseCode {
|
|||
fn to_bytes<En: packing::Endian>(&self) -> Result<[u8; 2], Self::Error> {
|
||||
Ok([self.asc(), self.ascq()])
|
||||
}
|
||||
|
||||
|
||||
fn from_bytes<En: packing::Endian>(bytes: [u8; 2]) -> Result<Self, Self::Error> {
|
||||
let [asc, ascq] = bytes;
|
||||
Self::from(asc, ascq).ok_or(packing::Error::InvalidEnumDiscriminant)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Default for AdditionalSenseCode {
|
||||
fn default() -> Self {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use packing::Packed;
|
|||
#[derive(Clone, Copy, Eq, PartialEq, Debug, Packed)]
|
||||
pub enum ResponseCode {
|
||||
FixedSenseData = 0x70,
|
||||
DescriptorSenseData = 0x72,
|
||||
DescriptorSenseData = 0x72,
|
||||
}
|
||||
impl Default for ResponseCode {
|
||||
fn default() -> Self {
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ pub enum VersionDescriptor {
|
|||
BCCNoVersionClaimed = 0x0380,
|
||||
/// MMC-4 (no version claimed)
|
||||
MMC4NoVersionClaimed = 0x03A0,
|
||||
/// MMC-4 T10/1545-D revision 5"},
|
||||
/// MMC-4 T10/1545-D revision 5"},
|
||||
MMC4T101545DRevision5 = 0x03B0,
|
||||
/// MMC-4 T10/1545-D revision 5a
|
||||
MMC4T101545DRevision5a = 0x03B1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue