@@ -378,7 +378,7 @@ pub struct SanitizeStateInformation {
378378struct SanitizeStatusLogPageResponse {
379379 sprog : u16 ,
380380 sstat : SanitizeStatus ,
381- scdw10 : u32 ,
381+ scdw10 : AdminSanitizeConfiguration ,
382382 eto : u32 ,
383383 etbe : u32 ,
384384 etce : u32 ,
@@ -555,7 +555,14 @@ flags! {
555555}
556556
557557// Base v2.1, 5.1.13.2.1, Figure 312, SANICAP, NODMMAS
558- #[ derive( Clone , Copy , Debug , Default ) ]
558+ #[ derive( Clone , Copy , Debug , Default , DekuRead , DekuWrite ) ]
559+ #[ deku(
560+ bits = "bits.0" ,
561+ bit_order = "order" ,
562+ ctx = "endian: Endian, bits: BitSize, order: Order" ,
563+ endian = "endian" ,
564+ id_type = "u8"
565+ ) ]
559566#[ repr( u8 ) ]
560567pub enum NoDeallocateModifiesMediaAfterSanitize {
561568 Undefined = 0b00 ,
@@ -564,41 +571,26 @@ pub enum NoDeallocateModifiesMediaAfterSanitize {
564571 Modified = 0b10 ,
565572 Reserved = 0b11 ,
566573}
567- unsafe impl Discriminant < u8 > for NoDeallocateModifiesMediaAfterSanitize { }
568574
569575// Base v2.1, 5.1.13.2.1, Figure 312, SANICAP
570- #[ derive( Clone , Copy , Debug ) ]
571- pub struct SanitizeCapabilities {
572- ces : bool ,
573- bes : bool ,
574- ows : bool ,
575- vers : bool ,
576- ndi : bool ,
577- nodmmas : NoDeallocateModifiesMediaAfterSanitize ,
578- }
579-
580- impl From < SanitizeCapabilities > for u32 {
581- fn from ( value : SanitizeCapabilities ) -> Self {
582- ( ( ( value. nodmmas . id ( ) & 0b11 ) as u32 ) << 30 )
583- | ( ( value. ndi as u32 ) << 29 )
584- | ( ( value. vers as u32 ) << 3 )
585- | ( ( value. ows as u32 ) << 2 )
586- | ( ( value. bes as u32 ) << 1 )
587- | ( value. ces as u32 )
576+ flags ! {
577+ pub enum SanitizeCapabilityFlags : u32 {
578+ Ces = 1 << 0 ,
579+ Bes = 1 << 1 ,
580+ Ows = 1 << 2 ,
581+ Vers = 1 << 3 ,
582+ Ndi = 1 << 29 ,
588583 }
589584}
590585
591- impl Default for SanitizeCapabilities {
592- fn default ( ) -> Self {
593- Self {
594- ces : true ,
595- bes : true ,
596- ows : true ,
597- vers : false ,
598- ndi : true ,
599- nodmmas : NoDeallocateModifiesMediaAfterSanitize :: Unmodified ,
600- }
601- }
586+ // Base v2.1, 5.1.13.2.1, Figure 312, SANICAP
587+ #[ derive( Clone , Copy , Debug , DekuRead , DekuWrite ) ]
588+ #[ deku( bit_order = "lsb" , ctx = "endian: Endian" , endian = "endian" ) ]
589+ pub struct SanitizeCapabilities {
590+ #[ deku( bits = 30 ) ]
591+ caps : WireFlagSet < SanitizeCapabilityFlags > ,
592+ #[ deku( bits = 2 ) ]
593+ nodmmas : NoDeallocateModifiesMediaAfterSanitize ,
602594}
603595
604596// Base v2.1, 5.1.13.2.1, Figure 312, FNA
@@ -651,7 +643,7 @@ struct AdminIdentifyControllerResponse {
651643 fwug : u8 ,
652644 kas : u16 ,
653645 #[ deku( seek_from_current = "6" ) ]
654- sanicap : u32 ,
646+ sanicap : SanitizeCapabilities ,
655647 #[ deku( seek_from_current = "54" ) ]
656648 cqt : u16 ,
657649 #[ deku( seek_from_current = "124" ) ]
@@ -800,17 +792,23 @@ struct NvmNamespaceManagementCreate {
800792}
801793
802794// Base v2.1, 5.1.22, Figure 372, SANACT
803- #[ derive( Clone , Copy , Debug ) ]
795+ #[ derive( Clone , Copy , Debug , Default , DekuRead , DekuWrite , Eq , PartialEq ) ]
796+ #[ deku(
797+ bits = "bits.0" ,
798+ ctx = "endian: Endian, bits: BitSize" ,
799+ endian = "endian" ,
800+ id_type = "u8"
801+ ) ]
804802#[ repr( u8 ) ]
805803enum SanitizeAction {
804+ #[ default]
806805 Reserved = 0x00 ,
807806 ExitFailureMode = 0x01 ,
808807 StartBlockErase = 0x02 ,
809808 StartOverwrite = 0x03 ,
810809 StartCryptoErase = 0x04 ,
811810 ExitMediaVerificationState = 0x05 ,
812811}
813- unsafe impl Discriminant < u8 > for SanitizeAction { }
814812
815813impl TryFrom < u32 > for SanitizeAction {
816814 type Error = ( ) ;
@@ -829,40 +827,21 @@ impl TryFrom<u32> for SanitizeAction {
829827}
830828
831829// Base v2.1, 5.1.22, Figure 372
832- #[ derive( Clone , Copy , Debug ) ]
830+ #[ derive( Clone , Copy , Debug , Default , DekuRead , DekuWrite , Eq , PartialEq ) ]
831+ #[ deku( ctx = "endian: Endian" , endian = "endian" ) ]
833832pub struct AdminSanitizeConfiguration {
834- sanact : SanitizeAction ,
835- ause : bool ,
833+ #[ deku( bits = "4" ) ]
836834 owpass : u8 ,
837- oipbp : bool ,
838- ndas : bool ,
835+ #[ deku( bits = "1" ) ]
836+ ause : bool ,
837+ #[ deku( bits = "3" ) ]
838+ sanact : SanitizeAction ,
839+ #[ deku( bits = "1" , pad_bits_before = "5" ) ]
839840 emvs : bool ,
840- }
841-
842- impl TryFrom < u32 > for AdminSanitizeConfiguration {
843- type Error = ( ) ;
844-
845- fn try_from ( value : u32 ) -> Result < Self , Self :: Error > {
846- Ok ( Self {
847- sanact : TryInto :: try_into ( value & 0x7 ) ?,
848- ause : ( ( value >> 3 ) & 1 ) == 1 ,
849- owpass : ( ( value >> 4 ) & 0xf ) as u8 ,
850- oipbp : ( ( value >> 8 ) & 1 ) == 1 ,
851- ndas : ( ( value >> 9 ) & 1 ) == 1 ,
852- emvs : ( ( value >> 10 ) & 1 ) == 1 ,
853- } )
854- }
855- }
856-
857- impl From < AdminSanitizeConfiguration > for u32 {
858- fn from ( value : AdminSanitizeConfiguration ) -> Self {
859- ( ( value. emvs as u32 ) << 10 )
860- | ( ( value. ndas as u32 ) << 9 )
861- | ( ( value. oipbp as u32 ) << 8 )
862- | ( ( ( value. owpass & 0xf ) as u32 ) << 4 )
863- | ( ( value. ause as u32 ) << 3 )
864- | value. sanact . id ( ) as u32
865- }
841+ #[ deku( bits = "1" ) ]
842+ ndas : bool ,
843+ #[ deku( bits = "1" , pad_bytes_after = "2" ) ]
844+ oipbp : bool ,
866845}
867846
868847// Base v2.1, 5.1.25, Figure 385
0 commit comments