FmpDevicePkg: Add Last Attempt Status support to dependency libs
The FMP dependency libraries are leveraged during firmware update to check for dependencies required to update the image. This change adds granular Last Attempt Status code support to these services so failures can be more easily observed during the firmware update process via Last Attempt Status codes. Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Guomin Jiang <guomin.jiang@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Acked-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Wei6 Xu <wei6.xu@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
004ce0ab04
commit
207414cba4
@@ -17,6 +17,9 @@
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Guid/SystemResourceTable.h>
|
||||
#include <LastAttemptStatus.h>
|
||||
#include <FmpLastAttemptStatus.h>
|
||||
|
||||
/**
|
||||
Check dependency for firmware update.
|
||||
@@ -25,6 +28,10 @@
|
||||
@param[in] Version New version.
|
||||
@param[in] Dependencies Fmp dependency.
|
||||
@param[in] DependenciesSize Size, in bytes, of the Fmp dependency.
|
||||
@param[out] LastAttemptStatus An optional pointer to a UINT32 that holds the
|
||||
last attempt status to report back to the caller.
|
||||
This function will set the value to LAST_ATTEMPT_STATUS_SUCCESS
|
||||
if an error code is not set.
|
||||
|
||||
@retval TRUE Dependencies are satisfied.
|
||||
@retval FALSE Dependencies are unsatisfied or dependency check fails.
|
||||
@@ -36,7 +43,8 @@ CheckFmpDependency (
|
||||
IN EFI_GUID ImageTypeId,
|
||||
IN UINT32 Version,
|
||||
IN EFI_FIRMWARE_IMAGE_DEP *Dependencies, OPTIONAL
|
||||
IN UINT32 DependenciesSize
|
||||
IN UINT32 DependenciesSize,
|
||||
OUT UINT32 *LastAttemptStatus OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -44,6 +52,7 @@ CheckFmpDependency (
|
||||
UINTN Index;
|
||||
EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
|
||||
UINTN ImageInfoSize;
|
||||
UINT32 LocalLastAttemptStatus;
|
||||
UINT32 *DescriptorVer;
|
||||
UINT8 FmpImageInfoCount;
|
||||
UINTN *DescriptorSize;
|
||||
@@ -55,14 +64,15 @@ CheckFmpDependency (
|
||||
UINTN FmpVersionsCount;
|
||||
BOOLEAN IsSatisfied;
|
||||
|
||||
FmpImageInfoBuf = NULL;
|
||||
DescriptorVer = NULL;
|
||||
DescriptorSize = NULL;
|
||||
NumberOfFmpInstance = 0;
|
||||
FmpVersions = NULL;
|
||||
FmpVersionsCount = 0;
|
||||
IsSatisfied = TRUE;
|
||||
PackageVersionName = NULL;
|
||||
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
|
||||
FmpImageInfoBuf = NULL;
|
||||
DescriptorVer = NULL;
|
||||
DescriptorSize = NULL;
|
||||
NumberOfFmpInstance = 0;
|
||||
FmpVersions = NULL;
|
||||
FmpVersionsCount = 0;
|
||||
IsSatisfied = TRUE;
|
||||
PackageVersionName = NULL;
|
||||
|
||||
//
|
||||
// Get ImageDescriptors of all FMP instances, and archive them for dependency evaluation.
|
||||
@@ -77,30 +87,35 @@ CheckFmpDependency (
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "CheckFmpDependency: Get Firmware Management Protocol failed. (%r)", Status));
|
||||
IsSatisfied = FALSE;
|
||||
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_FMP_PROTOCOL_NOT_FOUND;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
FmpImageInfoBuf = AllocateZeroPool (sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR *) * NumberOfFmpInstance);
|
||||
if (FmpImageInfoBuf == NULL) {
|
||||
IsSatisfied = FALSE;
|
||||
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_INFO_BUFFER_FAILED;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
DescriptorVer = AllocateZeroPool (sizeof(UINT32) * NumberOfFmpInstance);
|
||||
if (DescriptorVer == NULL ) {
|
||||
IsSatisfied = FALSE;
|
||||
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_VER_BUFFER_FAILED;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
DescriptorSize = AllocateZeroPool (sizeof(UINTN) * NumberOfFmpInstance);
|
||||
if (DescriptorSize == NULL ) {
|
||||
IsSatisfied = FALSE;
|
||||
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_SIZE_BUFFER_FAILED;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
FmpVersions = AllocateZeroPool (sizeof(FMP_DEPEX_CHECK_VERSION_DATA) * NumberOfFmpInstance);
|
||||
if (FmpVersions == NULL) {
|
||||
IsSatisfied = FALSE;
|
||||
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_VER_BUFFER_FAILED;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -164,7 +179,7 @@ CheckFmpDependency (
|
||||
// Evaluate firmware image's depex, against the version of other Fmp instances.
|
||||
//
|
||||
if (Dependencies != NULL) {
|
||||
IsSatisfied = EvaluateDependency (Dependencies, DependenciesSize, FmpVersions, FmpVersionsCount);
|
||||
IsSatisfied = EvaluateDependency (Dependencies, DependenciesSize, FmpVersions, FmpVersionsCount, &LocalLastAttemptStatus);
|
||||
}
|
||||
|
||||
if (!IsSatisfied) {
|
||||
@@ -194,5 +209,9 @@ cleanup:
|
||||
FreePool (FmpVersions);
|
||||
}
|
||||
|
||||
if (LastAttemptStatus != NULL) {
|
||||
*LastAttemptStatus = LocalLastAttemptStatus;
|
||||
}
|
||||
|
||||
return IsSatisfied;
|
||||
}
|
||||
|
Reference in New Issue
Block a user