use crate::{Error, RangedIndex, Result};
use super::ExtCsd;
#[repr(usize)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ExtCsdIndex {
CmdqModeEn = 15,
SecureRemovalType = 16,
ProductStateAwarenessEnablement = 17,
MaxPreLoadingDataSize(RangedIndex<18, 21>),
PreLoadingDataSize(RangedIndex<22, 25>),
FfuStatus = 26,
ModeOperationCodes = 29,
ModeConfig = 30,
BarrierCtrl = 31,
FlushCache = 32,
CacheCtrl = 33,
PowerOffNotification = 34,
PackedFailureIndex = 35,
PackedCommandStatus = 36,
ContextConf(RangedIndex<37, 51>),
ExtendedPartitionsAttribute(RangedIndex<52, 53>),
ExceptionEventsStatus(RangedIndex<54, 55>),
ExceptionEventsCtrl(RangedIndex<56, 57>),
DyncapNeeded = 58,
Class6Ctrl = 59,
IniTimeoutEmu = 60,
DataSectorSize = 61,
UseNativeSector = 62,
NativeSectorSize = 63,
VendorSpecificField(RangedIndex<64, 127>),
ProgramCidCsdDdrSupport = 130,
PeriodicWakeup = 131,
TcaseSupport = 132,
ProductionStateAwareness = 133,
SecBadBlkMgmnt = 134,
EnhStartAddr(RangedIndex<136, 139>),
EnhSizeMult(RangedIndex<140, 142>),
GpSizeMult(RangedIndex<143, 154>),
PartitionSettingCompleted = 155,
PartitionsAttribute = 156,
MaxEnhSizeMult(RangedIndex<157, 159>),
PartitioningSupport = 160,
HpiMgmt = 161,
RstnFunction = 162,
BkopsEn = 163,
BkopsStart = 164,
SanitizeStart = 165,
WrRelParam = 166,
WrRelSet = 167,
RpmbSizeMult = 168,
FwConfig = 169,
UserWp = 171,
BootWp = 173,
BootWpStatus = 174,
EraseGroupDef = 175,
BootBusConditions = 177,
BootConfigProt = 178,
PartitionConfig = 179,
ErasedMemCont = 181,
BusWidth = 183,
StrobeSupport = 184,
HsTiming = 185,
PowerClass = 187,
CmdSetRev = 189,
CmdSet = 191,
ExtCsdRev = 192,
CsdStructure = 194,
DeviceType = 196,
DriverStrength = 197,
OutOfInterruptTime = 198,
PartitionSwitchTime = 199,
PwrCl52_195 = 200,
PwrCl26_195 = 201,
PwrCl52_360 = 202,
PwrCl26_360 = 203,
MinPerfR4_26 = 205,
MinPerfW4_26 = 206,
MinPerfR8_26_4_52 = 207,
MinPerfW8_26_4_52 = 208,
MinPerfR8_52 = 209,
MinPerfW8_52 = 210,
SecureWpInfo = 211,
SecCount(RangedIndex<212, 215>),
SleepNotificationTime = 216,
SATimeout = 217,
ProductionStateAwarenessTimeout = 218,
SCVccq = 219,
SCVcc = 220,
HcWpGrpSize = 221,
RelWrSecC = 222,
EraseTimeoutMult = 223,
HcEraseGrpSize = 224,
AccSize = 225,
BootSizeMult = 226,
BootInfo = 228,
SecTrimMult = 229,
SecEraseMult = 230,
SecFeatureSupport = 231,
TrimMult = 232,
MinPerfDdrR8_52 = 234,
MinPerfDdrW8_52 = 235,
PwrCl200_130 = 236,
PwrCl200_195 = 237,
PwrClDdr52_195 = 238,
PwrClDdr52_360 = 239,
CacheFlushPolicy = 240,
IniTimeoutAp = 241,
CorrectlyPrgSectorsNum(RangedIndex<242, 245>),
BkopsStatus = 246,
PowerOffLongTime = 247,
GenericCmd6Time = 248,
CacheSize(RangedIndex<249, 252>),
PwrClDdr200_360 = 253,
FirmwareVersion(RangedIndex<254, 261>),
DeviceVersion(RangedIndex<262, 263>),
OptimalTrimUnitSize = 264,
OptimalWriteSize = 265,
OptimalReadSize = 266,
PreEolInfo = 267,
DeviceLifeTimeEstTypA = 268,
DeviceLifeTimeEstTypB = 269,
VendorProprietaryHealthReport(RangedIndex<270, 301>),
NumberOfFwSectorsCorrectlyProgrammed(RangedIndex<302, 305>),
CmdqDepth = 307,
CmdqSupport = 308,
BarrierSupport = 486,
FfuArg(RangedIndex<487, 490>),
OperationCodesTimeout = 491,
FfuFeatures = 492,
SupportedModes = 493,
ExtSupport = 494,
LargeUnitSizeM1 = 495,
ContextCapabilities = 496,
TagResSize = 497,
TagUnitSize = 498,
DataTagSupport = 499,
MaxPackedWrites = 500,
MaxPackedReads = 501,
BkopsSupport = 502,
HpiFeatures = 503,
SCmdSet = 504,
ExtSecurityErr = 505,
}
impl ExtCsdIndex {
pub const MAX_PRE_LOADING_DATA_SIZE_START: usize = 18;
pub const MAX_PRE_LOADING_DATA_SIZE_END: usize = 21;
pub const PRE_LOADING_DATA_SIZE_START: usize = 22;
pub const PRE_LOADING_DATA_SIZE_END: usize = 25;
pub const CONTEXT_CONF_START: usize = 37;
pub const CONTEXT_CONF_END: usize = 51;
pub const EXTENDED_PARTITIONS_ATTRIBUTE_START: usize = 52;
pub const EXTENDED_PARTITIONS_ATTRIBUTE_END: usize = 53;
pub const EXCEPTION_EVENTS_STATUS_START: usize = 54;
pub const EXCEPTION_EVENTS_STATUS_END: usize = 55;
pub const EXCEPTION_EVENTS_CTRL_START: usize = 56;
pub const EXCEPTION_EVENTS_CTRL_END: usize = 57;
pub const VENDOR_SPECIFIED_START: usize = 64;
pub const VENDOR_SPECIFIED_END: usize = 127;
pub const ENH_START_ADDR_START: usize = 136;
pub const ENH_START_ADDR_END: usize = 139;
pub const ENH_SIZE_MULT_START: usize = 140;
pub const ENH_SIZE_MULT_END: usize = 142;
pub const GPS_SIZE_MULT_START: usize = 143;
pub const GPS_SIZE_MULT_END: usize = 154;
pub const MAX_ENH_SIZE_MULT_START: usize = 157;
pub const MAX_ENH_SIZE_MULT_END: usize = 159;
pub const SEC_COUNT_START: usize = 212;
pub const SEC_COUNT_END: usize = 215;
pub const CORRECTLY_PRG_SECTORS_NUM_START: usize = 242;
pub const CORRECTLY_PRG_SECTORS_NUM_END: usize = 245;
pub const CACHE_SIZE_START: usize = 249;
pub const CACHE_SIZE_END: usize = 252;
pub const FIRMWARE_VERSION_START: usize = 254;
pub const FIRMWARE_VERSION_END: usize = 261;
pub const DEVICE_VERSION_START: usize = 262;
pub const DEVICE_VERSION_END: usize = 263;
pub const VENDOR_PROPRIETARY_HEALTH_REPORT_START: usize = 270;
pub const VENDOR_PROPRIETARY_HEALTH_REPORT_END: usize = 301;
pub const NUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED_START: usize = 302;
pub const NUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED_END: usize = 305;
pub const FFU_ARG_START: usize = 487;
pub const FFU_ARG_END: usize = 490;
pub const fn new() -> Self {
Self::CmdqModeEn
}
pub const fn try_from_inner(val: usize) -> Result<Self> {
match val {
15 => Ok(Self::CmdqModeEn),
16 => Ok(Self::SecureRemovalType),
17 => Ok(Self::ProductStateAwarenessEnablement),
18..=21 => Ok(Self::MaxPreLoadingDataSize(
RangedIndex::<18, 21>::try_from_unchecked(val),
)),
22..=25 => Ok(Self::PreLoadingDataSize(
RangedIndex::<22, 25>::try_from_unchecked(val),
)),
26 => Ok(Self::FfuStatus),
29 => Ok(Self::ModeOperationCodes),
30 => Ok(Self::ModeConfig),
31 => Ok(Self::BarrierCtrl),
32 => Ok(Self::FlushCache),
33 => Ok(Self::CacheCtrl),
34 => Ok(Self::PowerOffNotification),
35 => Ok(Self::PackedFailureIndex),
36 => Ok(Self::PackedCommandStatus),
37..=51 => Ok(Self::ContextConf(
RangedIndex::<37, 51>::try_from_unchecked(val),
)),
52..=53 => Ok(Self::ExtendedPartitionsAttribute(
RangedIndex::<52, 53>::try_from_unchecked(val),
)),
54..=55 => Ok(Self::ExceptionEventsStatus(
RangedIndex::<54, 55>::try_from_unchecked(val),
)),
56..=57 => Ok(Self::ExceptionEventsCtrl(
RangedIndex::<56, 57>::try_from_unchecked(val),
)),
58 => Ok(Self::DyncapNeeded),
59 => Ok(Self::Class6Ctrl),
60 => Ok(Self::IniTimeoutEmu),
61 => Ok(Self::DataSectorSize),
62 => Ok(Self::UseNativeSector),
63 => Ok(Self::NativeSectorSize),
64..=127 => Ok(Self::VendorSpecificField(
RangedIndex::<64, 127>::try_from_unchecked(val),
)),
130 => Ok(Self::ProgramCidCsdDdrSupport),
131 => Ok(Self::PeriodicWakeup),
132 => Ok(Self::TcaseSupport),
133 => Ok(Self::ProductionStateAwareness),
134 => Ok(Self::SecBadBlkMgmnt),
136..=139 => Ok(Self::EnhStartAddr(
RangedIndex::<136, 139>::try_from_unchecked(val),
)),
140..=142 => Ok(Self::EnhSizeMult(
RangedIndex::<140, 142>::try_from_unchecked(val),
)),
143..=154 => Ok(Self::GpSizeMult(
RangedIndex::<143, 154>::try_from_unchecked(val),
)),
155 => Ok(Self::PartitionSettingCompleted),
156 => Ok(Self::PartitionsAttribute),
157..=159 => Ok(Self::MaxEnhSizeMult(
RangedIndex::<157, 159>::try_from_unchecked(val),
)),
160 => Ok(Self::PartitioningSupport),
161 => Ok(Self::HpiMgmt),
162 => Ok(Self::RstnFunction),
163 => Ok(Self::BkopsEn),
164 => Ok(Self::BkopsStart),
165 => Ok(Self::SanitizeStart),
166 => Ok(Self::WrRelParam),
167 => Ok(Self::WrRelSet),
168 => Ok(Self::RpmbSizeMult),
169 => Ok(Self::FwConfig),
171 => Ok(Self::UserWp),
173 => Ok(Self::BootWp),
174 => Ok(Self::BootWpStatus),
175 => Ok(Self::EraseGroupDef),
177 => Ok(Self::BootBusConditions),
178 => Ok(Self::BootConfigProt),
179 => Ok(Self::PartitionConfig),
181 => Ok(Self::ErasedMemCont),
183 => Ok(Self::BusWidth),
184 => Ok(Self::StrobeSupport),
185 => Ok(Self::HsTiming),
187 => Ok(Self::PowerClass),
189 => Ok(Self::CmdSetRev),
191 => Ok(Self::CmdSet),
192 => Ok(Self::ExtCsdRev),
194 => Ok(Self::CsdStructure),
196 => Ok(Self::DeviceType),
197 => Ok(Self::DriverStrength),
198 => Ok(Self::OutOfInterruptTime),
199 => Ok(Self::PartitionSwitchTime),
200 => Ok(Self::PwrCl52_195),
201 => Ok(Self::PwrCl26_195),
202 => Ok(Self::PwrCl52_360),
203 => Ok(Self::PwrCl26_360),
205 => Ok(Self::MinPerfR4_26),
206 => Ok(Self::MinPerfW4_26),
207 => Ok(Self::MinPerfR8_26_4_52),
208 => Ok(Self::MinPerfW8_26_4_52),
209 => Ok(Self::MinPerfR8_52),
210 => Ok(Self::MinPerfW8_52),
211 => Ok(Self::SecureWpInfo),
212..=215 => Ok(Self::SecCount(RangedIndex::<212, 215>::try_from_unchecked(
val,
))),
216 => Ok(Self::SleepNotificationTime),
217 => Ok(Self::SATimeout),
218 => Ok(Self::ProductionStateAwarenessTimeout),
219 => Ok(Self::SCVccq),
220 => Ok(Self::SCVcc),
221 => Ok(Self::HcWpGrpSize),
222 => Ok(Self::RelWrSecC),
223 => Ok(Self::EraseTimeoutMult),
224 => Ok(Self::HcEraseGrpSize),
225 => Ok(Self::AccSize),
226 => Ok(Self::BootSizeMult),
228 => Ok(Self::BootInfo),
229 => Ok(Self::SecTrimMult),
230 => Ok(Self::SecEraseMult),
231 => Ok(Self::SecFeatureSupport),
232 => Ok(Self::TrimMult),
234 => Ok(Self::MinPerfDdrR8_52),
235 => Ok(Self::MinPerfDdrW8_52),
236 => Ok(Self::PwrCl200_130),
237 => Ok(Self::PwrCl200_195),
238 => Ok(Self::PwrClDdr52_195),
239 => Ok(Self::PwrClDdr52_360),
240 => Ok(Self::CacheFlushPolicy),
241 => Ok(Self::IniTimeoutAp),
242..=245 => Ok(Self::CorrectlyPrgSectorsNum(
RangedIndex::<242, 245>::try_from_unchecked(val),
)),
246 => Ok(Self::BkopsStatus),
247 => Ok(Self::PowerOffLongTime),
248 => Ok(Self::GenericCmd6Time),
249..=252 => Ok(Self::CacheSize(
RangedIndex::<249, 252>::try_from_unchecked(val),
)),
253 => Ok(Self::PwrClDdr200_360),
254..=261 => Ok(Self::FirmwareVersion(
RangedIndex::<254, 261>::try_from_unchecked(val),
)),
262..=263 => Ok(Self::DeviceVersion(
RangedIndex::<262, 263>::try_from_unchecked(val),
)),
264 => Ok(Self::OptimalTrimUnitSize),
265 => Ok(Self::OptimalWriteSize),
266 => Ok(Self::OptimalReadSize),
267 => Ok(Self::PreEolInfo),
268 => Ok(Self::DeviceLifeTimeEstTypA),
269 => Ok(Self::DeviceLifeTimeEstTypB),
270..=301 => Ok(Self::VendorProprietaryHealthReport(
RangedIndex::<270, 301>::try_from_unchecked(val),
)),
302..=305 => Ok(Self::NumberOfFwSectorsCorrectlyProgrammed(
RangedIndex::<302, 305>::try_from_unchecked(val),
)),
307 => Ok(Self::CmdqDepth),
308 => Ok(Self::CmdqSupport),
486 => Ok(Self::BarrierSupport),
487..=490 => Ok(Self::FfuArg(RangedIndex::<487, 490>::try_from_unchecked(
val,
))),
491 => Ok(Self::OperationCodesTimeout),
492 => Ok(Self::FfuFeatures),
493 => Ok(Self::SupportedModes),
494 => Ok(Self::ExtSupport),
495 => Ok(Self::LargeUnitSizeM1),
496 => Ok(Self::ContextCapabilities),
497 => Ok(Self::TagResSize),
498 => Ok(Self::TagUnitSize),
499 => Ok(Self::DataTagSupport),
500 => Ok(Self::MaxPackedWrites),
501 => Ok(Self::MaxPackedReads),
502 => Ok(Self::BkopsSupport),
503 => Ok(Self::HpiFeatures),
504 => Ok(Self::SCmdSet),
505 => Ok(Self::ExtSecurityErr),
_ => Err(Error::invalid_field_value("ext_csd_index", val, 15, 505)),
}
}
pub const fn into_inner(self) -> usize {
match self {
Self::CmdqModeEn => 15,
Self::SecureRemovalType => 16,
Self::ProductStateAwarenessEnablement => 17,
Self::MaxPreLoadingDataSize(index) => index.into_inner(),
Self::PreLoadingDataSize(index) => index.into_inner(),
Self::FfuStatus => 26,
Self::ModeOperationCodes => 29,
Self::ModeConfig => 30,
Self::BarrierCtrl => 31,
Self::FlushCache => 32,
Self::CacheCtrl => 33,
Self::PowerOffNotification => 34,
Self::PackedFailureIndex => 35,
Self::PackedCommandStatus => 36,
Self::ContextConf(index) => index.into_inner(),
Self::ExtendedPartitionsAttribute(index) => index.into_inner(),
Self::ExceptionEventsStatus(index) => index.into_inner(),
Self::ExceptionEventsCtrl(index) => index.into_inner(),
Self::DyncapNeeded => 58,
Self::Class6Ctrl => 59,
Self::IniTimeoutEmu => 60,
Self::DataSectorSize => 61,
Self::UseNativeSector => 62,
Self::NativeSectorSize => 63,
Self::VendorSpecificField(index) => index.into_inner(),
Self::ProgramCidCsdDdrSupport => 130,
Self::PeriodicWakeup => 131,
Self::TcaseSupport => 132,
Self::ProductionStateAwareness => 133,
Self::SecBadBlkMgmnt => 134,
Self::EnhStartAddr(index) => index.into_inner(),
Self::EnhSizeMult(index) => index.into_inner(),
Self::GpSizeMult(index) => index.into_inner(),
Self::PartitionSettingCompleted => 155,
Self::PartitionsAttribute => 156,
Self::MaxEnhSizeMult(index) => index.into_inner(),
Self::PartitioningSupport => 160,
Self::HpiMgmt => 161,
Self::RstnFunction => 162,
Self::BkopsEn => 163,
Self::BkopsStart => 164,
Self::SanitizeStart => 165,
Self::WrRelParam => 166,
Self::WrRelSet => 167,
Self::RpmbSizeMult => 168,
Self::FwConfig => 169,
Self::UserWp => 171,
Self::BootWp => 173,
Self::BootWpStatus => 174,
Self::EraseGroupDef => 175,
Self::BootBusConditions => 177,
Self::BootConfigProt => 178,
Self::PartitionConfig => 179,
Self::ErasedMemCont => 181,
Self::BusWidth => 183,
Self::StrobeSupport => 184,
Self::HsTiming => 185,
Self::PowerClass => 187,
Self::CmdSetRev => 189,
Self::CmdSet => 191,
Self::ExtCsdRev => 192,
Self::CsdStructure => 194,
Self::DeviceType => 196,
Self::DriverStrength => 197,
Self::OutOfInterruptTime => 198,
Self::PartitionSwitchTime => 199,
Self::PwrCl52_195 => 200,
Self::PwrCl26_195 => 201,
Self::PwrCl52_360 => 202,
Self::PwrCl26_360 => 203,
Self::MinPerfR4_26 => 205,
Self::MinPerfW4_26 => 206,
Self::MinPerfR8_26_4_52 => 207,
Self::MinPerfW8_26_4_52 => 208,
Self::MinPerfR8_52 => 209,
Self::MinPerfW8_52 => 210,
Self::SecureWpInfo => 211,
Self::SecCount(index) => index.into_inner(),
Self::SleepNotificationTime => 216,
Self::SATimeout => 217,
Self::ProductionStateAwarenessTimeout => 218,
Self::SCVccq => 219,
Self::SCVcc => 220,
Self::HcWpGrpSize => 221,
Self::RelWrSecC => 222,
Self::EraseTimeoutMult => 223,
Self::HcEraseGrpSize => 224,
Self::AccSize => 225,
Self::BootSizeMult => 226,
Self::BootInfo => 228,
Self::SecTrimMult => 229,
Self::SecEraseMult => 230,
Self::SecFeatureSupport => 231,
Self::TrimMult => 232,
Self::MinPerfDdrR8_52 => 234,
Self::MinPerfDdrW8_52 => 235,
Self::PwrCl200_130 => 236,
Self::PwrCl200_195 => 237,
Self::PwrClDdr52_195 => 238,
Self::PwrClDdr52_360 => 239,
Self::CacheFlushPolicy => 240,
Self::IniTimeoutAp => 241,
Self::CorrectlyPrgSectorsNum(index) => index.into_inner(),
Self::BkopsStatus => 246,
Self::PowerOffLongTime => 247,
Self::GenericCmd6Time => 248,
Self::CacheSize(index) => index.into_inner(),
Self::PwrClDdr200_360 => 253,
Self::FirmwareVersion(index) => index.into_inner(),
Self::DeviceVersion(index) => index.into_inner(),
Self::OptimalTrimUnitSize => 264,
Self::OptimalWriteSize => 265,
Self::OptimalReadSize => 266,
Self::PreEolInfo => 267,
Self::DeviceLifeTimeEstTypA => 268,
Self::DeviceLifeTimeEstTypB => 269,
Self::VendorProprietaryHealthReport(index) => index.into_inner(),
Self::NumberOfFwSectorsCorrectlyProgrammed(index) => index.into_inner(),
Self::CmdqDepth => 307,
Self::CmdqSupport => 308,
Self::BarrierSupport => 486,
Self::FfuArg(index) => index.into_inner(),
Self::OperationCodesTimeout => 491,
Self::FfuFeatures => 492,
Self::SupportedModes => 493,
Self::ExtSupport => 494,
Self::LargeUnitSizeM1 => 495,
Self::ContextCapabilities => 496,
Self::TagResSize => 497,
Self::TagUnitSize => 498,
Self::DataTagSupport => 499,
Self::MaxPackedWrites => 500,
Self::MaxPackedReads => 501,
Self::BkopsSupport => 502,
Self::HpiFeatures => 503,
Self::SCmdSet => 504,
Self::ExtSecurityErr => 505,
}
}
}
impl Default for ExtCsdIndex {
fn default() -> Self {
Self::new()
}
}