@@ -154,50 +154,41 @@ struct ControllerListRequest {
154154}
155155
156156// Base v2.1, 5.1.10, Figure 189, SES
157- #[ derive( Debug ) ]
157+ #[ derive( Debug , DekuRead , DekuWrite , Eq , PartialEq ) ]
158+ #[ deku(
159+ bits = "bits.0" ,
160+ ctx = "endian: Endian, bits: BitSize" ,
161+ endian = "endian" ,
162+ id_type = "u8"
163+ ) ]
158164#[ repr( u8 ) ]
159165enum SecureEraseSettings {
160166 NoOperation = 0b000 ,
161167 UserDataErase = 0b001 ,
162168 CryptographicErase = 0b010 ,
163169}
164- unsafe impl Discriminant < u8 > for SecureEraseSettings { }
165-
166- impl TryFrom < u32 > for SecureEraseSettings {
167- type Error = ( ) ;
168-
169- fn try_from ( value : u32 ) -> Result < Self , Self :: Error > {
170- match value {
171- 0b000 => Ok ( Self :: NoOperation ) ,
172- 0b001 => Ok ( Self :: UserDataErase ) ,
173- 0b010 => Ok ( Self :: CryptographicErase ) ,
174- _ => Err ( ( ) ) ,
175- }
176- }
177- }
178170
179171// Base v2.1, 5.1.10, Figure 189
180- #[ derive( Debug ) ]
181- #[ expect ( dead_code ) ]
172+ #[ derive( Debug , DekuRead , DekuWrite , Eq , PartialEq ) ]
173+ #[ deku ( ctx = "endian: Endian" , endian = "endian" ) ]
182174struct AdminFormatNvmConfiguration {
183- lbafi : u8 ,
184- mset : bool ,
175+ #[ deku( bits = "3" ) ]
185176 pi : u8 ,
186- pil : bool ,
177+ #[ deku( bits = "1" ) ]
178+ mset : bool ,
179+ #[ deku( bits = "4" ) ]
180+ lbafl : u8 ,
181+ #[ deku( bits = "2" , pad_bits_before = "2" ) ]
182+ lbafu : u8 ,
183+ #[ deku( bits = "3" ) ]
187184 ses : SecureEraseSettings ,
185+ #[ deku( bits = "1" , pad_bytes_after = "2" ) ]
186+ pil : bool ,
188187}
189188
190- impl TryFrom < u32 > for AdminFormatNvmConfiguration {
191- type Error = ( ) ;
192-
193- fn try_from ( value : u32 ) -> Result < Self , Self :: Error > {
194- Ok ( Self {
195- lbafi : ( ( ( ( value >> 12 ) & 0x3 ) << 4 ) | ( value & 0xf ) ) as u8 ,
196- mset : ( ( value >> 4 ) & 1 ) == 1 ,
197- pi : ( ( value >> 5 ) & 0x3 ) as u8 ,
198- pil : ( ( value >> 6 ) & 1 ) == 1 ,
199- ses : TryFrom :: try_from ( ( value >> 9 ) & 0x7 ) ?,
200- } )
189+ impl AdminFormatNvmConfiguration {
190+ fn lbafi ( & self ) -> u8 {
191+ self . lbafu << 4 | self . lbafl
201192 }
202193}
203194
0 commit comments