46 IN UINT32 DependenciesSize,
47 OUT UINT32 *LastAttemptStatus OPTIONAL
55 UINT32 LocalLastAttemptStatus;
56 UINT32 *DescriptorVer;
57 UINT8 FmpImageInfoCount;
58 UINTN *DescriptorSize;
59 UINT32 PackageVersion;
60 CHAR16 *PackageVersionName;
61 UINTN NumberOfFmpInstance;
64 UINTN FmpVersionsCount;
68 FmpImageInfoBuf =
NULL;
70 DescriptorSize =
NULL;
71 NumberOfFmpInstance = 0;
75 PackageVersionName =
NULL;
80 Status =
gBS->LocateHandleBuffer (
82 &gEfiFirmwareManagementProtocolGuid,
87 if (EFI_ERROR (Status)) {
88 DEBUG ((DEBUG_ERROR,
"CheckFmpDependency: Get Firmware Management Protocol failed. (%r)", Status));
95 if (FmpImageInfoBuf ==
NULL) {
97 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_INFO_BUFFER_FAILED;
102 if (DescriptorVer ==
NULL ) {
104 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_VER_BUFFER_FAILED;
109 if (DescriptorSize ==
NULL ) {
111 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_SIZE_BUFFER_FAILED;
116 if (FmpVersions ==
NULL) {
118 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_VER_BUFFER_FAILED;
122 for (Index = 0; Index < NumberOfFmpInstance; Index++) {
123 Status =
gBS->HandleProtocol (
125 &gEfiFirmwareManagementProtocolGuid,
128 if (EFI_ERROR (Status)) {
133 Status = Fmp->GetImageInfo (
143 if (Status != EFI_BUFFER_TOO_SMALL) {
148 if (FmpImageInfoBuf[Index] ==
NULL) {
152 Status = Fmp->GetImageInfo (
155 FmpImageInfoBuf[Index],
156 &DescriptorVer[Index],
158 &DescriptorSize[Index],
162 if (EFI_ERROR (Status)) {
164 FmpImageInfoBuf[Index] =
NULL;
168 if (PackageVersionName !=
NULL) {
170 PackageVersionName =
NULL;
173 CopyGuid (&FmpVersions[FmpVersionsCount].ImageTypeId, &FmpImageInfoBuf[Index]->ImageTypeId);
174 FmpVersions[FmpVersionsCount].Version = FmpImageInfoBuf[Index]->
Version;
181 if (Dependencies !=
NULL) {
182 IsSatisfied =
EvaluateDependency (Dependencies, DependenciesSize, FmpVersions, FmpVersionsCount, &LocalLastAttemptStatus);
186 DEBUG ((DEBUG_ERROR,
"CheckFmpDependency: %g\'s dependency is not satisfied!\n", ImageTypeId));
191 if (FmpImageInfoBuf !=
NULL) {
192 for (Index = 0; Index < NumberOfFmpInstance; Index++) {
193 if (FmpImageInfoBuf[Index] !=
NULL) {
201 if (DescriptorVer !=
NULL) {
205 if (DescriptorSize !=
NULL) {
209 if (FmpVersions !=
NULL) {
213 if (LastAttemptStatus !=
NULL) {
214 *LastAttemptStatus = LocalLastAttemptStatus;
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
BOOLEAN EFIAPI CheckFmpDependency(IN EFI_GUID ImageTypeId, IN UINT32 Version, IN EFI_FIRMWARE_IMAGE_DEP *Dependencies OPTIONAL, IN UINT32 DependenciesSize, OUT UINT32 *LastAttemptStatus OPTIONAL)
BOOLEAN EFIAPI EvaluateDependency(IN EFI_FIRMWARE_IMAGE_DEP *Dependencies, IN UINTN DependenciesSize, IN FMP_DEPEX_CHECK_VERSION_DATA *FmpVersions OPTIONAL, IN UINTN FmpVersionsCount, OUT UINT32 *LastAttemptStatus OPTIONAL)
@ LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_FMP_PROTOCOL_NOT_FOUND
#define DEBUG(Expression)
#define LAST_ATTEMPT_STATUS_SUCCESS