summaryrefslogtreecommitdiff
path: root/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c')
-rw-r--r--FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c b/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c
index 02ed600..cca83db 100644
--- a/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c
+++ b/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c
@@ -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;
}