@@ -270,7 +270,8 @@ impl ResourceType {
270270}
271271
272272#[ derive( Debug ) ]
273- pub enum UpdateStatus {
273+ #[ repr( u32 ) ]
274+ pub enum BiosUpdateErr {
274275 Success = 0x00 ,
275276 Unsuccessful = 0x01 ,
276277 InsufficientResources = 0x02 ,
@@ -279,9 +280,9 @@ pub enum UpdateStatus {
279280 AuthError = 0x05 ,
280281 PowerEventAc = 0x06 ,
281282 PowerEventBattery = 0x07 ,
282- Reserved = 0xFF , // TODO: I added this, since there's no unknown type, is there?
283+ Unknown ( u32 ) ,
283284}
284- impl UpdateStatus {
285+ impl BiosUpdateErr {
285286 fn from_int ( i : u32 ) -> Self {
286287 match i {
287288 0 => Self :: Success ,
@@ -292,7 +293,123 @@ impl UpdateStatus {
292293 5 => Self :: AuthError ,
293294 6 => Self :: PowerEventAc ,
294295 7 => Self :: PowerEventBattery ,
295- _ => Self :: Reserved ,
296+ i => Self :: Unknown ( i) ,
297+ }
298+ }
299+ }
300+
301+ #[ derive( Debug ) ]
302+ #[ repr( u32 ) ]
303+ pub enum IntelRetimerUpdateErr {
304+ Success = 0x0000 ,
305+ ImageTableNotProvided = 0x1900 ,
306+ ImageParameterIsNull = 0x1901 ,
307+ SignatureIsNotDetected = 0x1902 ,
308+ RetimerCountHeaderIsZero = 0x1903 ,
309+ OverOneRetimerCount = 0x1904 ,
310+ PayloadSizeTooSmall = 0x1905 ,
311+ PayloadIsOutOfBounds = 0x1906 ,
312+ ImageNotProvided = 0x1907 ,
313+ ProgressCallbackError = 0x1908 ,
314+ TcssRetimerProtocolNotFound = 0x1909 ,
315+ DriveTbtModeFailed = 0x190A ,
316+ Usb2hcProtocolNotFound = 0x190B ,
317+ PayloadIsOutOfBounds2 = 0x190C ,
318+ UnsupportFirmwareType = 0x190D ,
319+ InitializationFailed = 0x190E ,
320+ RestoreOriginalModeFailed = 0x190F ,
321+ UpdateFailed = 0x1910 ,
322+ DeviceHandleNotFound = 0x1911 ,
323+ TooFewRetimerInstances = 0x1912 ,
324+ SendOfflineModeFailed = 0x1913 ,
325+ DtbtImageTableNotProvided = 0x1980 ,
326+ DtbtImageParameterIsNull = 0x1981 ,
327+ DtbtSignatureIsNotDetected = 0x1982 ,
328+ DtbtRetimerCountHeaderIsZero = 0x1983 ,
329+ DtbtOverOneRetimerCount = 0x1984 ,
330+ DtbtPayloadSizeTooSmall = 0x1985 ,
331+ DtbtPayloadIsOutOfBounds = 0x1986 ,
332+ DtbtImageNotProvided = 0x1987 ,
333+ DtbtProgressCallbackError = 0x1988 ,
334+ DtbtUsb2hcProtocolNotFound = 0x1989 ,
335+ DtbtPayloadIsOutOfBounds2 = 0x198A ,
336+ DtbtUnsupportFirmwareType = 0x198B ,
337+ DtbtInitializationFailed = 0x198C ,
338+ DtbtUpdateFailed = 0x198D ,
339+ Unknown ( u32 ) ,
340+ }
341+ impl IntelRetimerUpdateErr {
342+ fn from_int ( i : u32 ) -> Self {
343+ match i {
344+ 0 => Self :: Success ,
345+ i => Self :: Unknown ( i) ,
346+ }
347+ }
348+ }
349+ #[ derive( Debug ) ]
350+ pub enum CsmeUpdateErr {
351+ Success ,
352+ Unknown ( u32 ) ,
353+ }
354+ impl CsmeUpdateErr {
355+ fn from_int ( i : u32 ) -> Self {
356+ match i {
357+ 0 => Self :: Success ,
358+ i => Self :: Unknown ( i) ,
359+ }
360+ }
361+ }
362+
363+ #[ derive( Debug ) ]
364+ pub enum UpdateStatus {
365+ Success ,
366+ /// Framework specific
367+ Bios ( BiosUpdateErr ) ,
368+ /// Intel specific
369+ IntelRetimer ( IntelRetimerUpdateErr ) ,
370+ /// Intel specific
371+ Csme ( CsmeUpdateErr ) ,
372+ /// See EDK2 FmpDevicePkg/Include/LastAttemptStatus.h
373+ FmpDxeErr ( u32 ) ,
374+ /// See EDK2 FmpDevicePkg/Include/LastAttemptStatus.h
375+ FmpDependencyLib ( u32 ) ,
376+ Unknown ( u32 ) ,
377+ }
378+ impl UpdateStatus {
379+ fn from_int ( i : u32 , guid : FrameworkGuidKind ) -> Self {
380+ match ( i, guid) {
381+ ( 0 , _) => Self :: Success ,
382+ ( 0x1000 ..=0x107F , _) => Self :: FmpDxeErr ( i) ,
383+ ( 0x10A0 ..=0x10BF , _) => Self :: FmpDependencyLib ( i) ,
384+ (
385+ i,
386+ FrameworkGuidKind :: TglBios
387+ | FrameworkGuidKind :: AdlBios
388+ | FrameworkGuidKind :: RplBios
389+ | FrameworkGuidKind :: MtlBios
390+ | FrameworkGuidKind :: Fw12RplBios
391+ | FrameworkGuidKind :: Amd16Ai300Bios
392+ | FrameworkGuidKind :: Amd13Ai300Bios
393+ | FrameworkGuidKind :: DesktopAmdAi300Bios ,
394+ ) => UpdateStatus :: Bios ( BiosUpdateErr :: from_int ( i) ) ,
395+ (
396+ i,
397+ FrameworkGuidKind :: TglRetimer01
398+ | FrameworkGuidKind :: TglRetimer23
399+ | FrameworkGuidKind :: AdlRetimer01
400+ | FrameworkGuidKind :: AdlRetimer23
401+ | FrameworkGuidKind :: RplRetimer01
402+ | FrameworkGuidKind :: RplRetimer23
403+ | FrameworkGuidKind :: MtlRetimer01
404+ | FrameworkGuidKind :: MtlRetimer23 ,
405+ ) => UpdateStatus :: IntelRetimer ( IntelRetimerUpdateErr :: from_int ( i) ) ,
406+ (
407+ i,
408+ FrameworkGuidKind :: RplCsme
409+ | FrameworkGuidKind :: RplUCsme
410+ | FrameworkGuidKind :: MtlCsme ,
411+ ) => UpdateStatus :: Csme ( CsmeUpdateErr :: from_int ( i) ) ,
412+ _ => Self :: Unknown ( i) ,
296413 }
297414 }
298415}
@@ -316,12 +433,10 @@ pub fn print_esrt(esrt: &Esrt) {
316433 println ! ( " ResourceVersion: {}" , esrt. resource_version) ;
317434
318435 for ( i, entry) in esrt. entries . iter ( ) . enumerate ( ) {
436+ let guid = match_guid_kind ( & entry. fw_class ) ;
319437 println ! ( "ESRT Entry {}" , i) ;
320438 println ! ( " GUID: {}" , entry. fw_class) ;
321- println ! (
322- " GUID: {:?}" ,
323- match_guid_kind( & entry. fw_class)
324- ) ;
439+ println ! ( " GUID: {:?}" , guid) ;
325440 println ! (
326441 " Type: {:?}" ,
327442 ResourceType :: from_int( entry. fw_type)
@@ -341,7 +456,7 @@ pub fn print_esrt(esrt: &Esrt) {
341456 ) ;
342457 println ! (
343458 " Last Attempt Status: {:?}" ,
344- UpdateStatus :: from_int( entry. last_attempt_status)
459+ UpdateStatus :: from_int( entry. last_attempt_status, guid )
345460 ) ;
346461 }
347462}
0 commit comments