Skip to content

Commit 0ce1c12

Browse files
committed
esrt: Decode LastAttemptStatus
This will help us figure out what's going on when a BIOS update fails. Different updates return different values. Signed-off-by: Daniel Schaefer <[email protected]>
1 parent bba3daa commit 0ce1c12

File tree

1 file changed

+117
-9
lines changed

1 file changed

+117
-9
lines changed

framework_lib/src/esrt/mod.rs

Lines changed: 117 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ impl ResourceType {
270270
}
271271

272272
#[derive(Debug)]
273-
pub enum UpdateStatus {
273+
#[repr(u32)]
274+
/// All defined by EDK2
275+
pub enum GenericUpdateErr {
274276
Success = 0x00,
275277
Unsuccessful = 0x01,
276278
InsufficientResources = 0x02,
@@ -279,9 +281,10 @@ pub enum UpdateStatus {
279281
AuthError = 0x05,
280282
PowerEventAc = 0x06,
281283
PowerEventBattery = 0x07,
282-
Reserved = 0xFF, // TODO: I added this, since there's no unknown type, is there?
284+
UnsatisfiedDependencies = 0x08,
285+
Unknown(u32),
283286
}
284-
impl UpdateStatus {
287+
impl GenericUpdateErr {
285288
fn from_int(i: u32) -> Self {
286289
match i {
287290
0 => Self::Success,
@@ -292,7 +295,114 @@ impl UpdateStatus {
292295
5 => Self::AuthError,
293296
6 => Self::PowerEventAc,
294297
7 => Self::PowerEventBattery,
295-
_ => Self::Reserved,
298+
i => Self::Unknown(i),
299+
}
300+
}
301+
}
302+
303+
#[derive(Debug)]
304+
#[repr(u32)]
305+
pub enum IntelRetimerUpdateErr {
306+
Success = 0x0000,
307+
ImageTableNotProvided = 0x1900,
308+
ImageParameterIsNull = 0x1901,
309+
SignatureIsNotDetected = 0x1902,
310+
RetimerCountHeaderIsZero = 0x1903,
311+
OverOneRetimerCount = 0x1904,
312+
PayloadSizeTooSmall = 0x1905,
313+
PayloadIsOutOfBounds = 0x1906,
314+
ImageNotProvided = 0x1907,
315+
ProgressCallbackError = 0x1908,
316+
TcssRetimerProtocolNotFound = 0x1909,
317+
DriveTbtModeFailed = 0x190A,
318+
Usb2hcProtocolNotFound = 0x190B,
319+
PayloadIsOutOfBounds2 = 0x190C,
320+
UnsupportFirmwareType = 0x190D,
321+
InitializationFailed = 0x190E,
322+
RestoreOriginalModeFailed = 0x190F,
323+
UpdateFailed = 0x1910,
324+
DeviceHandleNotFound = 0x1911,
325+
TooFewRetimerInstances = 0x1912,
326+
SendOfflineModeFailed = 0x1913,
327+
DtbtImageTableNotProvided = 0x1980,
328+
DtbtImageParameterIsNull = 0x1981,
329+
DtbtSignatureIsNotDetected = 0x1982,
330+
DtbtRetimerCountHeaderIsZero = 0x1983,
331+
DtbtOverOneRetimerCount = 0x1984,
332+
DtbtPayloadSizeTooSmall = 0x1985,
333+
DtbtPayloadIsOutOfBounds = 0x1986,
334+
DtbtImageNotProvided = 0x1987,
335+
DtbtProgressCallbackError = 0x1988,
336+
DtbtUsb2hcProtocolNotFound = 0x1989,
337+
DtbtPayloadIsOutOfBounds2 = 0x198A,
338+
DtbtUnsupportFirmwareType = 0x198B,
339+
DtbtInitializationFailed = 0x198C,
340+
DtbtUpdateFailed = 0x198D,
341+
Unknown(u32),
342+
}
343+
impl IntelRetimerUpdateErr {
344+
fn from_int(i: u32) -> Self {
345+
match i {
346+
0 => Self::Success,
347+
i => Self::Unknown(i),
348+
}
349+
}
350+
}
351+
#[derive(Debug)]
352+
pub enum CsmeUpdateErr {
353+
Success,
354+
Unknown(u32),
355+
}
356+
impl CsmeUpdateErr {
357+
fn from_int(i: u32) -> Self {
358+
match i {
359+
0 => Self::Success,
360+
i => Self::Unknown(i),
361+
}
362+
}
363+
}
364+
365+
#[derive(Debug)]
366+
pub enum UpdateStatus {
367+
Success,
368+
/// Defined by EDK2
369+
/// See EDK2 MdePkg/Include/Guid/SystemResourceTable.h
370+
Generic(GenericUpdateErr),
371+
/// Intel specific
372+
IntelRetimer(IntelRetimerUpdateErr),
373+
/// Intel specific
374+
Csme(CsmeUpdateErr),
375+
/// See EDK2 FmpDevicePkg/Include/LastAttemptStatus.h
376+
FmpDxeErr(u32),
377+
/// See EDK2 FmpDevicePkg/Include/LastAttemptStatus.h
378+
FmpDependencyLib(u32),
379+
Unknown(u32),
380+
}
381+
impl UpdateStatus {
382+
fn from_int(i: u32, guid: FrameworkGuidKind) -> Self {
383+
match (i, guid) {
384+
(0, _) => Self::Success,
385+
(0x1000..=0x107F, _) => Self::FmpDxeErr(i),
386+
(0x10A0..=0x10BF, _) => Self::FmpDependencyLib(i),
387+
(0..=8, _) => UpdateStatus::Generic(GenericUpdateErr::from_int(i)),
388+
(
389+
i,
390+
FrameworkGuidKind::TglRetimer01
391+
| FrameworkGuidKind::TglRetimer23
392+
| FrameworkGuidKind::AdlRetimer01
393+
| FrameworkGuidKind::AdlRetimer23
394+
| FrameworkGuidKind::RplRetimer01
395+
| FrameworkGuidKind::RplRetimer23
396+
| FrameworkGuidKind::MtlRetimer01
397+
| FrameworkGuidKind::MtlRetimer23,
398+
) => UpdateStatus::IntelRetimer(IntelRetimerUpdateErr::from_int(i)),
399+
(
400+
i,
401+
FrameworkGuidKind::RplCsme
402+
| FrameworkGuidKind::RplUCsme
403+
| FrameworkGuidKind::MtlCsme,
404+
) => UpdateStatus::Csme(CsmeUpdateErr::from_int(i)),
405+
_ => Self::Unknown(i),
296406
}
297407
}
298408
}
@@ -316,12 +426,10 @@ pub fn print_esrt(esrt: &Esrt) {
316426
println!(" ResourceVersion: {}", esrt.resource_version);
317427

318428
for (i, entry) in esrt.entries.iter().enumerate() {
429+
let guid = match_guid_kind(&entry.fw_class);
319430
println!("ESRT Entry {}", i);
320431
println!(" GUID: {}", entry.fw_class);
321-
println!(
322-
" GUID: {:?}",
323-
match_guid_kind(&entry.fw_class)
324-
);
432+
println!(" GUID: {:?}", guid);
325433
println!(
326434
" Type: {:?}",
327435
ResourceType::from_int(entry.fw_type)
@@ -341,7 +449,7 @@ pub fn print_esrt(esrt: &Esrt) {
341449
);
342450
println!(
343451
" Last Attempt Status: {:?}",
344-
UpdateStatus::from_int(entry.last_attempt_status)
452+
UpdateStatus::from_int(entry.last_attempt_status, guid)
345453
);
346454
}
347455
}

0 commit comments

Comments
 (0)