SignedCapsulePkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the SignedCapsulePkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:14 -08:00
committed by mergify[bot]
parent 47d20b54f9
commit b878648967
15 changed files with 1336 additions and 1215 deletions

View File

@ -7,7 +7,6 @@
**/
#ifndef __EDKII_SYSTEM_FMP_CAPSULE_GUID_H__
#define __EDKII_SYSTEM_FMP_CAPSULE_GUID_H__
@ -115,9 +114,9 @@ typedef struct {
UINT8 Reserved3[4];
UINT64 HardwareInstance;
// real string data
//CHAR16 ImageIdNameStr[]; // CHAR16 string including NULL terminate char
//CHAR16 VersionNameStr[]; // CHAR16 string including NULL terminate char
//CHAR16 PackageVersionNameStr[]; // CHAR16 string including NULL terminate char
// CHAR16 ImageIdNameStr[]; // CHAR16 string including NULL terminate char
// CHAR16 VersionNameStr[]; // CHAR16 string including NULL terminate char
// CHAR16 PackageVersionNameStr[]; // CHAR16 string including NULL terminate char
} EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR;
#pragma pack()

View File

@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __EDKII_SYSTEM_CAPSULE_LIB_H__
#define __EDKII_SYSTEM_CAPSULE_LIB_H__
@ -145,4 +144,3 @@ CapsuleAuthenticateSystemFirmware (
);
#endif

View File

@ -24,7 +24,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __INI_PARSING_LIB_H__
#define __INI_PARSING_LIB_H__
@ -157,4 +156,3 @@ CloseIniFile (
);
#endif

View File

@ -6,7 +6,6 @@
**/
#ifndef __PLATFORM_FLASH_ACCESS_LIB_H__
#define __PLATFORM_FLASH_ACCESS_LIB_H__

View File

@ -55,7 +55,7 @@ IsBufferErased (
UINT8 EraseByte;
UINT8 *Buffer;
if(ErasePolarity == 1) {
if (ErasePolarity == 1) {
EraseByte = 0xFF;
} else {
EraseByte = 0;
@ -108,20 +108,20 @@ GetSectionByType (
Instance = 0;
while ((UINTN)SectionHeader < (UINTN)SectionBuffer + SectionBufferSize) {
DEBUG ((DEBUG_INFO, "GetSectionByType - Section: 0x%08x\n", SectionHeader));
if (IS_SECTION2(SectionHeader)) {
SectionSize = SECTION2_SIZE(SectionHeader);
if (IS_SECTION2 (SectionHeader)) {
SectionSize = SECTION2_SIZE (SectionHeader);
} else {
SectionSize = SECTION_SIZE(SectionHeader);
SectionSize = SECTION_SIZE (SectionHeader);
}
if (SectionHeader->Type == SectionType) {
if (Instance == SectionInstance) {
*OutSectionBuffer = (UINT8 *)SectionHeader;
*OutSectionSize = SectionSize;
DEBUG((DEBUG_INFO, "GetSectionByType - 0x%x - 0x%x\n", *OutSectionBuffer, *OutSectionSize));
DEBUG ((DEBUG_INFO, "GetSectionByType - 0x%x - 0x%x\n", *OutSectionBuffer, *OutSectionSize));
return TRUE;
} else {
DEBUG((DEBUG_INFO, "GetSectionByType - find section instance %x\n", Instance));
DEBUG ((DEBUG_INFO, "GetSectionByType - find section instance %x\n", Instance));
Instance++;
}
} else {
@ -134,7 +134,7 @@ GetSectionByType (
//
// Next Section
//
SectionHeader = (EFI_COMMON_SECTION_HEADER *)((UINTN)SectionHeader + ALIGN_VALUE(SectionSize, 4));
SectionHeader = (EFI_COMMON_SECTION_HEADER *)((UINTN)SectionHeader + ALIGN_VALUE (SectionSize, 4));
}
return FALSE;
@ -182,12 +182,14 @@ GetFfsByName (
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)((UINTN)FvHeader + SIZE_4KB);
continue;
}
DEBUG((DEBUG_INFO, "checking FV....0x%08x - 0x%x\n", FvHeader, FvHeader->FvLength));
DEBUG ((DEBUG_INFO, "checking FV....0x%08x - 0x%x\n", FvHeader, FvHeader->FvLength));
FvFound = TRUE;
if (FvHeader->FvLength > FvSize) {
DEBUG((DEBUG_ERROR, "GetFfsByName - FvSize: 0x%08x, MaxSize - 0x%08x\n", (UINTN)FvHeader->FvLength, (UINTN)FvSize));
DEBUG ((DEBUG_ERROR, "GetFfsByName - FvSize: 0x%08x, MaxSize - 0x%08x\n", (UINTN)FvHeader->FvLength, (UINTN)FvSize));
return FALSE;
}
FvSize = (UINTN)FvHeader->FvLength;
//
@ -199,26 +201,29 @@ GetFfsByName (
} else {
FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvHeader + FvHeader->HeaderLength);
}
FfsHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FvHeader + ALIGN_VALUE((UINTN)FfsHeader - (UINTN)FvHeader, 8));
FfsHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FvHeader + ALIGN_VALUE ((UINTN)FfsHeader - (UINTN)FvHeader, 8));
while ((UINTN)FfsHeader < (UINTN)FvHeader + FvSize - 1) {
DEBUG((DEBUG_INFO, "GetFfsByName - FFS: 0x%08x\n", FfsHeader));
DEBUG ((DEBUG_INFO, "GetFfsByName - FFS: 0x%08x\n", FfsHeader));
TestLength = (UINTN)((UINTN)FvHeader + FvSize - (UINTN)FfsHeader);
if (TestLength > sizeof(EFI_FFS_FILE_HEADER)) {
TestLength = sizeof(EFI_FFS_FILE_HEADER);
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
TestLength = sizeof (EFI_FFS_FILE_HEADER);
}
if (IsBufferErased(1, FfsHeader, TestLength)) {
if (IsBufferErased (1, FfsHeader, TestLength)) {
break;
}
if (IS_FFS_FILE2(FfsHeader)) {
FfsSize = FFS_FILE2_SIZE(FfsHeader);
if (IS_FFS_FILE2 (FfsHeader)) {
FfsSize = FFS_FILE2_SIZE (FfsHeader);
} else {
FfsSize = FFS_FILE_SIZE(FfsHeader);
FfsSize = FFS_FILE_SIZE (FfsHeader);
}
if (CompareGuid(FileName, &FfsHeader->Name) &&
((Type == EFI_FV_FILETYPE_ALL) || (FfsHeader->Type == Type))) {
if (CompareGuid (FileName, &FfsHeader->Name) &&
((Type == EFI_FV_FILETYPE_ALL) || (FfsHeader->Type == Type)))
{
*OutFfsBuffer = FfsHeader;
*OutFfsBufferSize = FfsSize;
return TRUE;
@ -226,13 +231,13 @@ GetFfsByName (
//
// Any other type is not allowed
//
DEBUG((DEBUG_INFO, "GetFfsByName - other FFS type 0x%x, name %g\n", FfsHeader->Type, &FfsHeader->Name));
DEBUG ((DEBUG_INFO, "GetFfsByName - other FFS type 0x%x, name %g\n", FfsHeader->Type, &FfsHeader->Name));
}
//
// Next File
//
FfsHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FfsHeader + ALIGN_VALUE(FfsSize, 8));
FfsHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FfsHeader + ALIGN_VALUE (FfsSize, 8));
}
//
@ -242,8 +247,9 @@ GetFfsByName (
}
if (!FvFound) {
DEBUG((DEBUG_ERROR, "GetFfsByName - NO FV Found\n"));
DEBUG ((DEBUG_ERROR, "GetFfsByName - NO FV Found\n"));
}
return FALSE;
}
@ -273,16 +279,17 @@ ExtractDriverFvImage (
*DriverFvImage = NULL;
*DriverFvImageSize = 0;
Result = GetFfsByName(AuthenticatedImage, AuthenticatedImageSize, &gEdkiiSystemFmpCapsuleDriverFvFileGuid, EFI_FV_FILETYPE_RAW, DriverFvImage, DriverFvImageSize);
Result = GetFfsByName (AuthenticatedImage, AuthenticatedImageSize, &gEdkiiSystemFmpCapsuleDriverFvFileGuid, EFI_FV_FILETYPE_RAW, DriverFvImage, DriverFvImageSize);
if (!Result) {
return FALSE;
}
if (IS_FFS_FILE2(*DriverFvImage)) {
FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
if (IS_FFS_FILE2 (*DriverFvImage)) {
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
*DriverFvImage = (UINT8 *)*DriverFvImage + FileHeaderSize;
*DriverFvImageSize = *DriverFvImageSize - FileHeaderSize;
@ -315,16 +322,17 @@ ExtractConfigImage (
*ConfigImage = NULL;
*ConfigImageSize = 0;
Result = GetFfsByName(AuthenticatedImage, AuthenticatedImageSize, &gEdkiiSystemFmpCapsuleConfigFileGuid, EFI_FV_FILETYPE_RAW, ConfigImage, ConfigImageSize);
Result = GetFfsByName (AuthenticatedImage, AuthenticatedImageSize, &gEdkiiSystemFmpCapsuleConfigFileGuid, EFI_FV_FILETYPE_RAW, ConfigImage, ConfigImageSize);
if (!Result) {
return FALSE;
}
if (IS_FFS_FILE2(*ConfigImage)) {
FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
if (IS_FFS_FILE2 (*ConfigImage)) {
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
*ConfigImage = (UINT8 *)*ConfigImage + FileHeaderSize;
*ConfigImageSize = *ConfigImageSize - FileHeaderSize;
@ -361,7 +369,7 @@ ExtractAuthenticatedImage (
VOID *PublicKeyData;
UINTN PublicKeyDataLength;
DEBUG((DEBUG_INFO, "ExtractAuthenticatedImage - Image: 0x%08x - 0x%08x\n", (UINTN)Image, (UINTN)ImageSize));
DEBUG ((DEBUG_INFO, "ExtractAuthenticatedImage - Image: 0x%08x - 0x%08x\n", (UINTN)Image, (UINTN)ImageSize));
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
if ((Image == NULL) || (ImageSize == 0)) {
@ -369,47 +377,53 @@ ExtractAuthenticatedImage (
}
ImageAuth = (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image;
if (ImageSize < sizeof(EFI_FIRMWARE_IMAGE_AUTHENTICATION)) {
DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - ImageSize too small\n"));
if (ImageSize < sizeof (EFI_FIRMWARE_IMAGE_AUTHENTICATION)) {
DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - ImageSize too small\n"));
return FALSE;
}
if (ImageAuth->AuthInfo.Hdr.dwLength <= OFFSET_OF(WIN_CERTIFICATE_UEFI_GUID, CertData)) {
DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - dwLength too small\n"));
if (ImageAuth->AuthInfo.Hdr.dwLength <= OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData)) {
DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - dwLength too small\n"));
return FALSE;
}
if ((UINTN) ImageAuth->AuthInfo.Hdr.dwLength > MAX_UINTN - sizeof(UINT64)) {
DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - dwLength too big\n"));
if ((UINTN)ImageAuth->AuthInfo.Hdr.dwLength > MAX_UINTN - sizeof (UINT64)) {
DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - dwLength too big\n"));
return FALSE;
}
if (ImageSize <= sizeof(ImageAuth->MonotonicCount) + ImageAuth->AuthInfo.Hdr.dwLength) {
DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - ImageSize too small\n"));
if (ImageSize <= sizeof (ImageAuth->MonotonicCount) + ImageAuth->AuthInfo.Hdr.dwLength) {
DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - ImageSize too small\n"));
return FALSE;
}
if (ImageAuth->AuthInfo.Hdr.wRevision != 0x0200) {
DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - wRevision: 0x%02x, expect - 0x%02x\n", (UINTN)ImageAuth->AuthInfo.Hdr.wRevision, (UINTN)0x0200));
DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - wRevision: 0x%02x, expect - 0x%02x\n", (UINTN)ImageAuth->AuthInfo.Hdr.wRevision, (UINTN)0x0200));
return FALSE;
}
if (ImageAuth->AuthInfo.Hdr.wCertificateType != WIN_CERT_TYPE_EFI_GUID) {
DEBUG((DEBUG_ERROR, "ExtractAuthenticatedImage - wCertificateType: 0x%02x, expect - 0x%02x\n", (UINTN)ImageAuth->AuthInfo.Hdr.wCertificateType, (UINTN)WIN_CERT_TYPE_EFI_GUID));
DEBUG ((DEBUG_ERROR, "ExtractAuthenticatedImage - wCertificateType: 0x%02x, expect - 0x%02x\n", (UINTN)ImageAuth->AuthInfo.Hdr.wCertificateType, (UINTN)WIN_CERT_TYPE_EFI_GUID));
return FALSE;
}
CertType = &ImageAuth->AuthInfo.CertType;
DEBUG((DEBUG_INFO, "ExtractAuthenticatedImage - CertType: %g\n", CertType));
DEBUG ((DEBUG_INFO, "ExtractAuthenticatedImage - CertType: %g\n", CertType));
if (CompareGuid(&gEfiCertPkcs7Guid, CertType)) {
PublicKeyData = PcdGetPtr(PcdPkcs7CertBuffer);
PublicKeyDataLength = PcdGetSize(PcdPkcs7CertBuffer);
} else if (CompareGuid(&gEfiCertTypeRsa2048Sha256Guid, CertType)) {
PublicKeyData = PcdGetPtr(PcdRsa2048Sha256PublicKeyBuffer);
PublicKeyDataLength = PcdGetSize(PcdRsa2048Sha256PublicKeyBuffer);
if (CompareGuid (&gEfiCertPkcs7Guid, CertType)) {
PublicKeyData = PcdGetPtr (PcdPkcs7CertBuffer);
PublicKeyDataLength = PcdGetSize (PcdPkcs7CertBuffer);
} else if (CompareGuid (&gEfiCertTypeRsa2048Sha256Guid, CertType)) {
PublicKeyData = PcdGetPtr (PcdRsa2048Sha256PublicKeyBuffer);
PublicKeyDataLength = PcdGetSize (PcdRsa2048Sha256PublicKeyBuffer);
} else {
return FALSE;
}
ASSERT (PublicKeyData != NULL);
ASSERT (PublicKeyDataLength != 0);
Status = AuthenticateFmpImage(
Status = AuthenticateFmpImage (
ImageAuth,
ImageSize,
PublicKeyData,
@ -435,16 +449,19 @@ ExtractAuthenticatedImage (
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
break;
}
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return FALSE;
}
if (AuthenticatedImage != NULL) {
*AuthenticatedImage = (UINT8 *)ImageAuth + ImageAuth->AuthInfo.Hdr.dwLength + sizeof(ImageAuth->MonotonicCount);
*AuthenticatedImage = (UINT8 *)ImageAuth + ImageAuth->AuthInfo.Hdr.dwLength + sizeof (ImageAuth->MonotonicCount);
}
if (AuthenticatedImageSize != NULL) {
*AuthenticatedImageSize = ImageSize - ImageAuth->AuthInfo.Hdr.dwLength - sizeof(ImageAuth->MonotonicCount);
*AuthenticatedImageSize = ImageSize - ImageAuth->AuthInfo.Hdr.dwLength - sizeof (ImageAuth->MonotonicCount);
}
return TRUE;
}
@ -475,27 +492,31 @@ ExtractSystemFirmwareImageFmpInfo (
*ImageFmpInfo = NULL;
*ImageFmpInfoSize = 0;
Result = GetFfsByName(SystemFirmwareImage, SystemFirmwareImageSize, &gEdkiiSystemFirmwareImageDescriptorFileGuid, EFI_FV_FILETYPE_ALL, (VOID **)ImageFmpInfo, ImageFmpInfoSize);
Result = GetFfsByName (SystemFirmwareImage, SystemFirmwareImageSize, &gEdkiiSystemFirmwareImageDescriptorFileGuid, EFI_FV_FILETYPE_ALL, (VOID **)ImageFmpInfo, ImageFmpInfoSize);
if (!Result) {
return FALSE;
}
if (IS_FFS_FILE2 (*ImageFmpInfo)) {
FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
*ImageFmpInfo = (VOID *)((UINT8 *)*ImageFmpInfo + FileHeaderSize);
*ImageFmpInfoSize = *ImageFmpInfoSize - FileHeaderSize;
Result = GetSectionByType(*ImageFmpInfo, (UINT32)*ImageFmpInfoSize, EFI_SECTION_RAW, 0, (VOID **)ImageFmpInfo, ImageFmpInfoSize);
Result = GetSectionByType (*ImageFmpInfo, (UINT32)*ImageFmpInfoSize, EFI_SECTION_RAW, 0, (VOID **)ImageFmpInfo, ImageFmpInfoSize);
if (!Result) {
return FALSE;
}
if (IS_SECTION2(*ImageFmpInfo)) {
SectionHeaderSize = sizeof(EFI_RAW_SECTION2);
if (IS_SECTION2 (*ImageFmpInfo)) {
SectionHeaderSize = sizeof (EFI_RAW_SECTION2);
} else {
SectionHeaderSize = sizeof(EFI_RAW_SECTION);
SectionHeaderSize = sizeof (EFI_RAW_SECTION);
}
*ImageFmpInfo = (VOID *)((UINT8 *)*ImageFmpInfo + SectionHeaderSize);
*ImageFmpInfoSize = *ImageFmpInfoSize - SectionHeaderSize;
@ -528,7 +549,7 @@ ExtractSystemFirmwareImage (
*SystemFirmwareImage = NULL;
*SystemFirmwareImageSize = 0;
Result = GetFfsByName(AuthenticatedImage, AuthenticatedImageSize, &mEdkiiSystemFirmwareFileGuid, EFI_FV_FILETYPE_RAW, SystemFirmwareImage, SystemFirmwareImageSize);
Result = GetFfsByName (AuthenticatedImage, AuthenticatedImageSize, &mEdkiiSystemFirmwareFileGuid, EFI_FV_FILETYPE_RAW, SystemFirmwareImage, SystemFirmwareImageSize);
if (!Result) {
// no nested FV, just return all data.
*SystemFirmwareImage = AuthenticatedImage;
@ -536,11 +557,13 @@ ExtractSystemFirmwareImage (
return TRUE;
}
if (IS_FFS_FILE2 (*SystemFirmwareImage)) {
FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
} else {
FileHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
FileHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
}
*SystemFirmwareImage = (UINT8 *)*SystemFirmwareImage + FileHeaderSize;
*SystemFirmwareImageSize = *SystemFirmwareImageSize - FileHeaderSize;
@ -592,55 +615,56 @@ CapsuleAuthenticateSystemFirmware (
// Do not touch FMP protocol and its private structure.
//
if (mImageFmpInfo == NULL) {
DEBUG((DEBUG_INFO, "ImageFmpInfo is not set\n"));
DEBUG ((DEBUG_INFO, "ImageFmpInfo is not set\n"));
return EFI_SECURITY_VIOLATION;
}
Result = ExtractAuthenticatedImage((VOID *)Image, ImageSize, LastAttemptStatus, AuthenticatedImage, AuthenticatedImageSize);
Result = ExtractAuthenticatedImage ((VOID *)Image, ImageSize, LastAttemptStatus, AuthenticatedImage, AuthenticatedImageSize);
if (!Result) {
DEBUG((DEBUG_INFO, "ExtractAuthenticatedImage - fail\n"));
DEBUG ((DEBUG_INFO, "ExtractAuthenticatedImage - fail\n"));
return EFI_SECURITY_VIOLATION;
}
DEBUG((DEBUG_INFO, "AuthenticatedImage - 0x%x - 0x%x\n", *AuthenticatedImage, *AuthenticatedImageSize));
DEBUG ((DEBUG_INFO, "AuthenticatedImage - 0x%x - 0x%x\n", *AuthenticatedImage, *AuthenticatedImageSize));
Result = ExtractSystemFirmwareImage(*AuthenticatedImage, *AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);
Result = ExtractSystemFirmwareImage (*AuthenticatedImage, *AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);
if (!Result) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
DEBUG((DEBUG_INFO, "ExtractSystemFirmwareImage - fail\n"));
DEBUG ((DEBUG_INFO, "ExtractSystemFirmwareImage - fail\n"));
return EFI_SECURITY_VIOLATION;
}
DEBUG((DEBUG_INFO, "SystemFirmwareImage - 0x%x - 0x%x\n", SystemFirmwareImage, SystemFirmwareImageSize));
Result = ExtractSystemFirmwareImageFmpInfo(SystemFirmwareImage, SystemFirmwareImageSize, &ImageFmpInfo, &ImageFmpInfoSize);
DEBUG ((DEBUG_INFO, "SystemFirmwareImage - 0x%x - 0x%x\n", SystemFirmwareImage, SystemFirmwareImageSize));
Result = ExtractSystemFirmwareImageFmpInfo (SystemFirmwareImage, SystemFirmwareImageSize, &ImageFmpInfo, &ImageFmpInfoSize);
if (!Result) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
DEBUG((DEBUG_INFO, "ExtractSystemFirmwareImageFmpInfo - fail\n"));
DEBUG ((DEBUG_INFO, "ExtractSystemFirmwareImageFmpInfo - fail\n"));
return EFI_SECURITY_VIOLATION;
}
*LastAttemptVersion = ImageFmpInfo->Version;
DEBUG((DEBUG_INFO, "ImageFmpInfo - 0x%x - 0x%x\n", ImageFmpInfo, ImageFmpInfoSize));
DEBUG((DEBUG_INFO, "NewImage Version - 0x%x\n", ImageFmpInfo->Version));
DEBUG((DEBUG_INFO, "NewImage LowestSupportedImageVersion - 0x%x\n", ImageFmpInfo->LowestSupportedImageVersion));
DEBUG ((DEBUG_INFO, "ImageFmpInfo - 0x%x - 0x%x\n", ImageFmpInfo, ImageFmpInfoSize));
DEBUG ((DEBUG_INFO, "NewImage Version - 0x%x\n", ImageFmpInfo->Version));
DEBUG ((DEBUG_INFO, "NewImage LowestSupportedImageVersion - 0x%x\n", ImageFmpInfo->LowestSupportedImageVersion));
CurrentImageFmpInfo = mImageFmpInfo;
CurrentImageFmpInfoSize = mImageFmpInfoSize;
DEBUG((DEBUG_INFO, "ImageFmpInfo - 0x%x - 0x%x\n", CurrentImageFmpInfo, CurrentImageFmpInfoSize));
DEBUG((DEBUG_INFO, "Current Version - 0x%x\n", CurrentImageFmpInfo->Version));
DEBUG((DEBUG_INFO, "Current LowestSupportedImageVersion - 0x%x\n", CurrentImageFmpInfo->LowestSupportedImageVersion));
DEBUG ((DEBUG_INFO, "ImageFmpInfo - 0x%x - 0x%x\n", CurrentImageFmpInfo, CurrentImageFmpInfoSize));
DEBUG ((DEBUG_INFO, "Current Version - 0x%x\n", CurrentImageFmpInfo->Version));
DEBUG ((DEBUG_INFO, "Current LowestSupportedImageVersion - 0x%x\n", CurrentImageFmpInfo->LowestSupportedImageVersion));
if (ForceVersionMatch) {
if (CurrentImageFmpInfo->Version != ImageFmpInfo->Version) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION;
DEBUG((DEBUG_INFO, "ForceVersionMatch check - fail\n"));
DEBUG ((DEBUG_INFO, "ForceVersionMatch check - fail\n"));
return EFI_SECURITY_VIOLATION;
}
} else {
if (ImageFmpInfo->Version < CurrentImageFmpInfo->LowestSupportedImageVersion) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION;
DEBUG((DEBUG_INFO, "LowestSupportedImageVersion check - fail\n"));
DEBUG ((DEBUG_INFO, "LowestSupportedImageVersion check - fail\n"));
return EFI_SECURITY_VIOLATION;
}
}
@ -668,10 +692,11 @@ EdkiiSystemCapsuleLibPcdCallBack (
)
{
if (CompareGuid (CallBackGuid, &gEfiSignedCapsulePkgTokenSpaceGuid) &&
CallBackToken == PcdToken (PcdEdkiiSystemFirmwareImageDescriptor)) {
(CallBackToken == PcdToken (PcdEdkiiSystemFirmwareImageDescriptor)))
{
mImageFmpInfoSize = TokenDataSize;
mImageFmpInfo = AllocateCopyPool (mImageFmpInfoSize, TokenData);
ASSERT(mImageFmpInfo != NULL);
ASSERT (mImageFmpInfo != NULL);
//
// Cancel Callback after get the real set value
//
@ -683,8 +708,9 @@ EdkiiSystemCapsuleLibPcdCallBack (
}
if (CompareGuid (CallBackGuid, &gEfiSignedCapsulePkgTokenSpaceGuid) &&
CallBackToken == PcdToken (PcdEdkiiSystemFirmwareFileGuid)) {
CopyGuid(&mEdkiiSystemFirmwareFileGuid, TokenData);
(CallBackToken == PcdToken (PcdEdkiiSystemFirmwareFileGuid)))
{
CopyGuid (&mEdkiiSystemFirmwareFileGuid, TokenData);
//
// Cancel Callback after get the real set value
//
@ -707,13 +733,14 @@ EdkiiSystemCapsuleLibConstructor (
VOID
)
{
mImageFmpInfoSize = PcdGetSize(PcdEdkiiSystemFirmwareImageDescriptor);
mImageFmpInfo = PcdGetPtr(PcdEdkiiSystemFirmwareImageDescriptor);
mImageFmpInfoSize = PcdGetSize (PcdEdkiiSystemFirmwareImageDescriptor);
mImageFmpInfo = PcdGetPtr (PcdEdkiiSystemFirmwareImageDescriptor);
//
// Verify Firmware Image Descriptor first
//
if (mImageFmpInfoSize < sizeof (EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR) ||
mImageFmpInfo->Signature != EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE) {
if ((mImageFmpInfoSize < sizeof (EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR)) ||
(mImageFmpInfo->Signature != EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR_SIGNATURE))
{
//
// SystemFirmwareImageDescriptor is not set.
// Register PCD set callback to hook PCD value set.
@ -727,10 +754,10 @@ EdkiiSystemCapsuleLibConstructor (
);
} else {
mImageFmpInfo = AllocateCopyPool (mImageFmpInfoSize, mImageFmpInfo);
ASSERT(mImageFmpInfo != NULL);
ASSERT (mImageFmpInfo != NULL);
}
CopyGuid(&mEdkiiSystemFirmwareFileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid));
CopyGuid (&mEdkiiSystemFirmwareFileGuid, PcdGetPtr (PcdEdkiiSystemFirmwareFileGuid));
//
// Verify GUID value first
//
@ -741,5 +768,6 @@ EdkiiSystemCapsuleLibConstructor (
EdkiiSystemCapsuleLibPcdCallBack
);
}
return EFI_SUCCESS;
}

View File

@ -78,17 +78,20 @@ IsValidDigitalChar (
IN BOOLEAN IncludeHex
)
{
if (DigitalChar >= '0' && DigitalChar <= '9') {
if ((DigitalChar >= '0') && (DigitalChar <= '9')) {
return TRUE;
}
if (IncludeHex) {
if (DigitalChar >= 'a' && DigitalChar <= 'f') {
if ((DigitalChar >= 'a') && (DigitalChar <= 'f')) {
return TRUE;
}
if (DigitalChar >= 'A' && DigitalChar <= 'F') {
if ((DigitalChar >= 'A') && (DigitalChar <= 'F')) {
return TRUE;
}
}
return FALSE;
}
@ -105,18 +108,22 @@ IsValidNameChar (
IN CHAR8 NameChar
)
{
if (NameChar >= 'a' && NameChar <= 'z') {
if ((NameChar >= 'a') && (NameChar <= 'z')) {
return TRUE;
}
if (NameChar >= 'A' && NameChar <= 'Z') {
if ((NameChar >= 'A') && (NameChar <= 'Z')) {
return TRUE;
}
if (NameChar >= '0' && NameChar <= '9') {
if ((NameChar >= '0') && (NameChar <= '9')) {
return TRUE;
}
if (NameChar == '_') {
return TRUE;
}
return FALSE;
}
@ -138,11 +145,13 @@ IsValidDigital (
)
{
UINTN Index;
for (Index = 0; Index < Length; Index++) {
if (!IsValidDigitalChar(Digital[Index], IncludeHex)) {
if (!IsValidDigitalChar (Digital[Index], IncludeHex)) {
return FALSE;
}
}
return TRUE;
}
@ -161,7 +170,7 @@ IsValidDecimalString (
IN UINTN Length
)
{
return IsValidDigital(Decimal, Length, FALSE);
return IsValidDigital (Decimal, Length, FALSE);
}
/**
@ -182,13 +191,16 @@ IsValidHexString (
if (Length <= 2) {
return FALSE;
}
if (Hex[0] != '0') {
return FALSE;
}
if (Hex[1] != 'x' && Hex[1] != 'X') {
if ((Hex[1] != 'x') && (Hex[1] != 'X')) {
return FALSE;
}
return IsValidDigital(&Hex[2], Length - 2, TRUE);
return IsValidDigital (&Hex[2], Length - 2, TRUE);
}
/**
@ -207,11 +219,13 @@ IsValidName (
)
{
UINTN Index;
for (Index = 0; Index < Length; Index++) {
if (!IsValidNameChar(Name[Index])) {
if (!IsValidNameChar (Name[Index])) {
return FALSE;
}
}
return TRUE;
}
@ -230,36 +244,46 @@ IsValidGuid (
IN UINTN Length
)
{
if (Length != sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") - 1) {
if (Length != sizeof ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") - 1) {
return FALSE;
}
if (!IS_HYPHEN(Value[8])) {
if (!IS_HYPHEN (Value[8])) {
return FALSE;
}
if (!IS_HYPHEN(Value[13])) {
if (!IS_HYPHEN (Value[13])) {
return FALSE;
}
if (!IS_HYPHEN(Value[18])) {
if (!IS_HYPHEN (Value[18])) {
return FALSE;
}
if (!IS_HYPHEN(Value[23])) {
if (!IS_HYPHEN (Value[23])) {
return FALSE;
}
if (!IsValidDigital(&Value[0], 8, TRUE)) {
if (!IsValidDigital (&Value[0], 8, TRUE)) {
return FALSE;
}
if (!IsValidDigital(&Value[9], 4, TRUE)) {
if (!IsValidDigital (&Value[9], 4, TRUE)) {
return FALSE;
}
if (!IsValidDigital(&Value[14], 4, TRUE)) {
if (!IsValidDigital (&Value[14], 4, TRUE)) {
return FALSE;
}
if (!IsValidDigital(&Value[19], 4, TRUE)) {
if (!IsValidDigital (&Value[19], 4, TRUE)) {
return FALSE;
}
if (!IsValidDigital(&Value[24], 12, TRUE)) {
if (!IsValidDigital (&Value[24], 12, TRUE)) {
return FALSE;
}
return TRUE;
}
@ -278,9 +302,10 @@ IsValidValue (
IN UINTN Length
)
{
if (IsValidName(Value, Length) || IsValidGuid(Value, Length)) {
if (IsValidName (Value, Length) || IsValidGuid (Value, Length)) {
return TRUE;
}
return FALSE;
}
@ -309,13 +334,15 @@ DumpIniSection (
PtrSection = Section;
Section = Section->PtrNext;
if (PtrSection->PtrSection != NULL) {
DEBUG((DEBUG_VERBOSE, "Section - %a\n", PtrSection->PtrSection));
DEBUG ((DEBUG_VERBOSE, "Section - %a\n", PtrSection->PtrSection));
}
if (PtrSection->PtrEntry != NULL) {
DEBUG ((DEBUG_VERBOSE, " Entry - %a\n", PtrSection->PtrEntry));
}
if (PtrSection->PtrValue != NULL) {
DEBUG((DEBUG_VERBOSE, " Value - %a\n", PtrSection->PtrValue));
DEBUG ((DEBUG_VERBOSE, " Value - %a\n", PtrSection->PtrValue));
}
}
}
@ -352,9 +379,10 @@ ProfileGetLine (
// 0x0D indicates a line break. Otherwise there is no line break
//
while ((UINTN)PtrBuf < PtrEnd) {
if (*PtrBuf == 0x0D || *PtrBuf == 0x0A) {
if ((*PtrBuf == 0x0D) || (*PtrBuf == 0x0A)) {
break;
}
PtrBuf++;
}
@ -368,9 +396,9 @@ ProfileGetLine (
//
// Further check if a 0x0A follows. If yes, count 0xA
//
Length = (UINTN) PtrBuf - (UINTN) Buffer + 2;
Length = (UINTN)PtrBuf - (UINTN)Buffer + 2;
} else {
Length = (UINTN) PtrBuf - (UINTN) Buffer + 1;
Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;
}
if (Length > (*LineSize)) {
@ -412,13 +440,15 @@ ProfileTrim (
// Trim the tail first, include CR, LF, TAB, and SPACE.
//
Length = *BufferSize;
PtrBuf = (UINT8 *) ((UINTN) Buffer + Length - 1);
PtrBuf = (UINT8 *)((UINTN)Buffer + Length - 1);
while (PtrBuf >= Buffer) {
if ((*PtrBuf != 0x0D) && (*PtrBuf != 0x0A )
&& (*PtrBuf != 0x20) && (*PtrBuf != 0x09)) {
if ( (*PtrBuf != 0x0D) && (*PtrBuf != 0x0A)
&& (*PtrBuf != 0x20) && (*PtrBuf != 0x09))
{
break;
}
PtrBuf --;
PtrBuf--;
}
//
@ -437,10 +467,12 @@ ProfileTrim (
// Now skip the heading CR, LF, TAB and SPACE
//
while (PtrBuf <= PtrEnd) {
if ((*PtrBuf != 0x0D) && (*PtrBuf != 0x0A )
&& (*PtrBuf != 0x20) && (*PtrBuf != 0x09)) {
if ( (*PtrBuf != 0x0D) && (*PtrBuf != 0x0A)
&& (*PtrBuf != 0x20) && (*PtrBuf != 0x09))
{
break;
}
PtrBuf++;
}
@ -504,6 +536,7 @@ ProfileGetComments (
FreePool (CommentItem);
return EFI_OUT_OF_RESOURCES;
}
CopyMem (CommentItem->PtrComment, Buffer, BufferSize);
*(CommentItem->PtrComment + BufferSize) = '\0';
@ -533,7 +566,7 @@ ProfileGetSection (
UINT8 *PtrBuf;
UINT8 *PtrEnd;
ASSERT(BufferSize >= 1);
ASSERT (BufferSize >= 1);
//
// The first character of Buffer is '[', now we want for ']'
//
@ -543,14 +576,17 @@ ProfileGetSection (
if (*PtrBuf == ']') {
break;
}
PtrBuf ++;
PtrBuf++;
}
if (PtrBuf > PtrEnd) {
//
// Not found. Invalid line
//
return EFI_NOT_FOUND;
}
if (PtrBuf <= Buffer + 1) {
// Empty name
return EFI_NOT_FOUND;
@ -572,7 +608,7 @@ ProfileGetSection (
return EFI_NOT_FOUND;
}
if (!IsValidName((CHAR8 *)Buffer + 1, Length)) {
if (!IsValidName ((CHAR8 *)Buffer + 1, Length)) {
return EFI_INVALID_PARAMETER;
}
@ -634,7 +670,7 @@ ProfileGetEntry (
Status = EFI_SUCCESS;
PtrBuf = Buffer;
PtrEnd = (UINT8 *) ((UINTN)Buffer + BufferSize - 1);
PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);
//
// First search for '='
@ -643,14 +679,17 @@ ProfileGetEntry (
if (*PtrBuf == '=') {
break;
}
PtrBuf++;
}
if (PtrBuf > PtrEnd) {
//
// Not found. Invalid line
//
return EFI_NOT_FOUND;
}
if (PtrBuf <= Buffer) {
// Empty name
return EFI_NOT_FOUND;
@ -672,7 +711,7 @@ ProfileGetEntry (
return EFI_NOT_FOUND;
}
if (!IsValidName((CHAR8 *)Buffer, Length)) {
if (!IsValidName ((CHAR8 *)Buffer, Length)) {
return EFI_INVALID_PARAMETER;
}
@ -682,6 +721,7 @@ ProfileGetEntry (
if (*SectionHead == NULL) {
return Status;
}
PtrSection = *SectionHead;
SectionItem = AllocatePool (sizeof (SECTION_ITEM));
@ -703,6 +743,7 @@ ProfileGetEntry (
if (SectionItem->PtrSection == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (SectionItem->PtrSection, PtrSection->PtrSection, PtrSection->SecNameLen + 1);
//
@ -710,9 +751,10 @@ ProfileGetEntry (
//
SectionItem->PtrEntry = AllocatePool (Length + 1);
if (SectionItem->PtrEntry == NULL) {
FreePool(SectionItem->PtrSection);
FreePool (SectionItem->PtrSection);
return EFI_OUT_OF_RESOURCES;
}
CopyMem (SectionItem->PtrEntry, Buffer, Length);
*(SectionItem->PtrEntry + Length) = '\0';
@ -722,17 +764,20 @@ ProfileGetEntry (
PtrBuf = PtrBuf + 1;
Buffer = PtrBuf;
while (PtrBuf <= PtrEnd) {
if (*PtrBuf == '#' || *PtrBuf == ';') {
if ((*PtrBuf == '#') || (*PtrBuf == ';')) {
break;
}
PtrBuf++;
}
if (PtrBuf <= Buffer) {
// Empty name
FreePool(SectionItem->PtrEntry);
FreePool(SectionItem->PtrSection);
FreePool (SectionItem->PtrEntry);
FreePool (SectionItem->PtrSection);
return EFI_NOT_FOUND;
}
Length = PtrBuf - Buffer;
ProfileTrim (
Buffer,
@ -743,14 +788,14 @@ ProfileGetEntry (
// Invalid line if the entry value is null
//
if (Length == 0) {
FreePool(SectionItem->PtrEntry);
FreePool(SectionItem->PtrSection);
FreePool (SectionItem->PtrEntry);
FreePool (SectionItem->PtrSection);
return EFI_NOT_FOUND;
}
if (!IsValidValue((CHAR8 *)Buffer, Length)) {
FreePool(SectionItem->PtrEntry);
FreePool(SectionItem->PtrSection);
if (!IsValidValue ((CHAR8 *)Buffer, Length)) {
FreePool (SectionItem->PtrEntry);
FreePool (SectionItem->PtrSection);
return EFI_INVALID_PARAMETER;
}
@ -759,10 +804,11 @@ ProfileGetEntry (
//
SectionItem->PtrValue = AllocatePool (Length + 1);
if (SectionItem->PtrValue == NULL) {
FreePool(SectionItem->PtrEntry);
FreePool(SectionItem->PtrSection);
FreePool (SectionItem->PtrEntry);
FreePool (SectionItem->PtrSection);
return EFI_OUT_OF_RESOURCES;
}
CopyMem (SectionItem->PtrValue, Buffer, Length);
*(SectionItem->PtrValue + Length) = '\0';
@ -791,12 +837,15 @@ FreeAllList (
if (PtrSection->PtrEntry != NULL) {
FreePool (PtrSection->PtrEntry);
}
if (PtrSection->PtrSection != NULL) {
FreePool (PtrSection->PtrSection);
}
if (PtrSection->PtrValue != NULL) {
FreePool (PtrSection->PtrValue);
}
FreePool (PtrSection);
}
@ -806,6 +855,7 @@ FreeAllList (
if (PtrComment->PtrComment != NULL) {
FreePool (PtrComment->PtrComment);
}
FreePool (PtrComment);
}
@ -835,13 +885,14 @@ UpdateGetProfileString (
*EntryValue = NULL;
while (Section != NULL) {
if (AsciiStrCmp ((CONST CHAR8 *) Section->PtrSection, (CONST CHAR8 *) SectionName) == 0) {
if (AsciiStrCmp ((CONST CHAR8 *)Section->PtrSection, (CONST CHAR8 *)SectionName) == 0) {
if (Section->PtrEntry != NULL) {
if (AsciiStrCmp ((CONST CHAR8 *) Section->PtrEntry, (CONST CHAR8 *) EntryName) == 0) {
if (AsciiStrCmp ((CONST CHAR8 *)Section->PtrEntry, (CONST CHAR8 *)EntryName) == 0) {
break;
}
}
}
Section = Section->PtrNext;
}
@ -887,8 +938,8 @@ PreProcessDataFile (
*SectionHead = NULL;
*CommentHead = NULL;
BufferEnd = (CHAR8 *) ( (UINTN) DataBuffer + BufferSize);
CurrentPtr = (CHAR8 *) DataBuffer;
BufferEnd = (CHAR8 *)((UINTN)DataBuffer + BufferSize);
CurrentPtr = (CHAR8 *)DataBuffer;
MaxLineLength = MAX_LINE_LENGTH;
Status = EFI_SUCCESS;
@ -906,9 +957,9 @@ PreProcessDataFile (
// characters. Otherwise BUFFER_TOO_SMALL will be returned.
//
Status = ProfileGetLine (
(UINT8 *) Source,
(UINT8 *)Source,
SourceLength,
(UINT8 *) PtrLine,
(UINT8 *)PtrLine,
&LineLength
);
if (EFI_ERROR (Status)) {
@ -924,28 +975,31 @@ PreProcessDataFile (
Status = EFI_OUT_OF_RESOURCES;
break;
}
SourceLength = LineLength;
Status = ProfileGetLine (
(UINT8 *) Source,
(UINT8 *)Source,
SourceLength,
(UINT8 *) PtrLine,
(UINT8 *)PtrLine,
&LineLength
);
if (EFI_ERROR (Status)) {
break;
}
MaxLineLength = LineLength;
} else {
break;
}
}
CurrentPtr = (CHAR8 *) ( (UINTN) CurrentPtr + LineLength);
CurrentPtr = (CHAR8 *)((UINTN)CurrentPtr + LineLength);
//
// Line got. Trim the line before processing it.
//
ProfileTrim (
(UINT8 *) PtrLine,
(UINT8 *)PtrLine,
&LineLength
);
@ -956,21 +1010,21 @@ PreProcessDataFile (
continue;
}
if (PtrLine[0] == '#' || PtrLine[0] == ';') {
if ((PtrLine[0] == '#') || (PtrLine[0] == ';')) {
Status = ProfileGetComments (
(UINT8 *) PtrLine,
(UINT8 *)PtrLine,
LineLength,
CommentHead
);
} else if (PtrLine[0] == '[') {
Status = ProfileGetSection (
(UINT8 *) PtrLine,
(UINT8 *)PtrLine,
LineLength,
SectionHead
);
} else {
Status = ProfileGetEntry (
(UINT8 *) PtrLine,
(UINT8 *)PtrLine,
LineLength,
SectionHead
);
@ -1009,11 +1063,11 @@ OpenIniFile (
EFI_STATUS Status;
INI_PARSING_LIB_CONTEXT *IniContext;
if (DataBuffer == NULL || BufferSize == 0) {
if ((DataBuffer == NULL) || (BufferSize == 0)) {
return NULL;
}
IniContext = AllocateZeroPool(sizeof(INI_PARSING_LIB_CONTEXT));
IniContext = AllocateZeroPool (sizeof (INI_PARSING_LIB_CONTEXT));
if (IniContext == NULL) {
return NULL;
}
@ -1027,12 +1081,13 @@ OpenIniFile (
&IniContext->SectionHead,
&IniContext->CommentHead
);
if (EFI_ERROR(Status)) {
FreePool(IniContext);
if (EFI_ERROR (Status)) {
FreePool (IniContext);
return NULL;
}
DEBUG_CODE_BEGIN ();
DumpIniSection(IniContext);
DumpIniSection (IniContext);
DEBUG_CODE_END ();
return IniContext;
}
@ -1050,7 +1105,7 @@ OpenIniFile (
**/
EFI_STATUS
EFIAPI
GetStringFromDataFile(
GetStringFromDataFile (
IN VOID *Context,
IN CHAR8 *SectionName,
IN CHAR8 *EntryName,
@ -1060,7 +1115,7 @@ GetStringFromDataFile(
INI_PARSING_LIB_CONTEXT *IniContext;
EFI_STATUS Status;
if (Context == NULL || SectionName == NULL || EntryName == NULL || EntryValue == NULL) {
if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (EntryValue == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -1100,24 +1155,26 @@ GetGuidFromDataFile (
EFI_STATUS Status;
RETURN_STATUS RStatus;
if (Context == NULL || SectionName == NULL || EntryName == NULL || Guid == NULL) {
if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Guid == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = GetStringFromDataFile(
Status = GetStringFromDataFile (
Context,
SectionName,
EntryName,
&Value
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
ASSERT (Value != NULL);
RStatus = AsciiStrToGuid (Value, Guid);
if (RETURN_ERROR (RStatus) || (Value[GUID_STRING_LENGTH] != '\0')) {
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
@ -1144,24 +1201,26 @@ GetDecimalUintnFromDataFile (
CHAR8 *Value;
EFI_STATUS Status;
if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {
if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = GetStringFromDataFile(
Status = GetStringFromDataFile (
Context,
SectionName,
EntryName,
&Value
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
ASSERT (Value != NULL);
if (!IsValidDecimalString(Value, AsciiStrLen(Value))) {
if (!IsValidDecimalString (Value, AsciiStrLen (Value))) {
return EFI_NOT_FOUND;
}
*Data = AsciiStrDecimalToUintn(Value);
*Data = AsciiStrDecimalToUintn (Value);
return EFI_SUCCESS;
}
@ -1188,24 +1247,26 @@ GetHexUintnFromDataFile (
CHAR8 *Value;
EFI_STATUS Status;
if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {
if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = GetStringFromDataFile(
Status = GetStringFromDataFile (
Context,
SectionName,
EntryName,
&Value
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
ASSERT (Value != NULL);
if (!IsValidHexString(Value, AsciiStrLen(Value))) {
if (!IsValidHexString (Value, AsciiStrLen (Value))) {
return EFI_NOT_FOUND;
}
*Data = AsciiStrHexToUintn(Value);
*Data = AsciiStrHexToUintn (Value);
return EFI_SUCCESS;
}
@ -1232,24 +1293,26 @@ GetHexUint64FromDataFile (
CHAR8 *Value;
EFI_STATUS Status;
if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {
if ((Context == NULL) || (SectionName == NULL) || (EntryName == NULL) || (Data == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = GetStringFromDataFile(
Status = GetStringFromDataFile (
Context,
SectionName,
EntryName,
&Value
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
ASSERT (Value != NULL);
if (!IsValidHexString(Value, AsciiStrLen(Value))) {
if (!IsValidHexString (Value, AsciiStrLen (Value))) {
return EFI_NOT_FOUND;
}
*Data = AsciiStrHexToUint64(Value);
*Data = AsciiStrHexToUint64 (Value);
return EFI_SUCCESS;
}
@ -1267,11 +1330,11 @@ CloseIniFile (
INI_PARSING_LIB_CONTEXT *IniContext;
if (Context == NULL) {
return ;
return;
}
IniContext = Context;
FreeAllList(IniContext->SectionHead, IniContext->CommentHead);
FreeAllList (IniContext->SectionHead, IniContext->CommentHead);
return;
}

View File

@ -59,7 +59,8 @@ PerformFlashWriteWithProgress (
if (FlashAddressType == FlashAddressTypeRelativeAddress) {
FlashAddress = FlashAddress + mInternalFdAddress;
}
CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length);
CopyMem ((VOID *)(UINTN)(FlashAddress), Buffer, Length);
return EFI_SUCCESS;
}

View File

@ -46,7 +46,7 @@ ParseRecoveryDataFile (
//
// First process the data buffer and get all sections and entries
//
Context = OpenIniFile(DataBuffer, BufferSize);
Context = OpenIniFile (DataBuffer, BufferSize);
if (Context == NULL) {
return EFI_INVALID_PARAMETER;
}
@ -54,26 +54,26 @@ ParseRecoveryDataFile (
//
// Now get NumOfUpdate
//
Status = GetDecimalUintnFromDataFile(
Status = GetDecimalUintnFromDataFile (
Context,
"Head",
"NumOfRecovery",
&Num
);
if (EFI_ERROR(Status) || (Num == 0)) {
DEBUG((DEBUG_ERROR, "NumOfRecovery not found\n"));
CloseIniFile(Context);
if (EFI_ERROR (Status) || (Num == 0)) {
DEBUG ((DEBUG_ERROR, "NumOfRecovery not found\n"));
CloseIniFile (Context);
return EFI_NOT_FOUND;
}
ConfigHeader->NumOfRecovery = Num;
*RecoveryArray = AllocateZeroPool ((sizeof (RECOVERY_CONFIG_DATA) * Num));
if (*RecoveryArray == NULL) {
CloseIniFile(Context);
CloseIniFile (Context);
return EFI_OUT_OF_RESOURCES;
}
for (Index = 0 ; Index < ConfigHeader->NumOfRecovery; Index++) {
for (Index = 0; Index < ConfigHeader->NumOfRecovery; Index++) {
//
// Get the section name of each update
//
@ -85,15 +85,15 @@ ParseRecoveryDataFile (
Index,
0
);
Status = GetStringFromDataFile(
Status = GetStringFromDataFile (
Context,
"Head",
Entry,
&SectionName
);
if (EFI_ERROR(Status) || (SectionName == NULL)) {
DEBUG((DEBUG_ERROR, "[%d] %a not found\n", Index, Entry));
CloseIniFile(Context);
if (EFI_ERROR (Status) || (SectionName == NULL)) {
DEBUG ((DEBUG_ERROR, "[%d] %a not found\n", Index, Entry));
CloseIniFile (Context);
return EFI_NOT_FOUND;
}
@ -105,58 +105,59 @@ ParseRecoveryDataFile (
//
// FileGuid
//
Status = GetGuidFromDataFile(
Status = GetGuidFromDataFile (
Context,
SectionName,
"FileGuid",
&FileGuid
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] FileGuid not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] FileGuid not found\n", Index));
return EFI_NOT_FOUND;
}
CopyGuid(&((*RecoveryArray)[Index].FileGuid), &FileGuid);
CopyGuid (&((*RecoveryArray)[Index].FileGuid), &FileGuid);
//
// Length
//
Status = GetHexUintnFromDataFile(
Status = GetHexUintnFromDataFile (
Context,
SectionName,
"Length",
&Num
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] Length not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] Length not found\n", Index));
return EFI_NOT_FOUND;
}
(*RecoveryArray)[Index].Length = Num;
//
// ImageOffset
//
Status = GetHexUintnFromDataFile(
Status = GetHexUintnFromDataFile (
Context,
SectionName,
"ImageOffset",
&Num
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] ImageOffset not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] ImageOffset not found\n", Index));
return EFI_NOT_FOUND;
}
(*RecoveryArray)[Index].ImageOffset = Num;
}
//
// Now all configuration data got. Free those temporary buffers
//
CloseIniFile(Context);
CloseIniFile (Context);
return EFI_SUCCESS;
}

View File

@ -111,11 +111,11 @@ IsSystemFmpImage (
UINTN Count;
UINTN Index;
Guid = PcdGetPtr(PcdSystemFmpCapsuleImageTypeIdGuid);
Count = PcdGetSize(PcdSystemFmpCapsuleImageTypeIdGuid) / sizeof(GUID);
Guid = PcdGetPtr (PcdSystemFmpCapsuleImageTypeIdGuid);
Count = PcdGetSize (PcdSystemFmpCapsuleImageTypeIdGuid) / sizeof (GUID);
for (Index = 0; Index < Count; Index++, Guid++) {
if (CompareGuid(&FmpImageHeader->UpdateImageTypeId, Guid)) {
if (CompareGuid (&FmpImageHeader->UpdateImageTypeId, Guid)) {
return TRUE;
}
}
@ -136,7 +136,7 @@ IsFmpCapsuleGuid (
IN EFI_GUID *CapsuleGuid
)
{
if (CompareGuid(&gEfiFmpCapsuleGuid, CapsuleGuid)) {
if (CompareGuid (&gEfiFmpCapsuleGuid, CapsuleGuid)) {
return TRUE;
}
@ -168,7 +168,7 @@ IsSystemFmpCapsuleImage (
UINT32 ItemNum;
UINTN Index;
FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);
FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
if (FmpCapsuleHeader->EmbeddedDriverCount != 0) {
return FALSE;
@ -184,7 +184,7 @@ IsSystemFmpCapsuleImage (
for (Index = 0; Index < ItemNum; Index++) {
ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
if (!IsSystemFmpImage(ImageHeader)) {
if (!IsSystemFmpImage (ImageHeader)) {
return FALSE;
}
}
@ -213,9 +213,11 @@ IsValidCapsuleHeader (
if (CapsuleHeader->CapsuleImageSize != CapsuleSize) {
return FALSE;
}
if (CapsuleHeader->HeaderSize >= CapsuleHeader->CapsuleImageSize) {
return FALSE;
}
return TRUE;
}
@ -258,51 +260,55 @@ ValidateFmpCapsule (
UINTN FmpImageHeaderSize;
if (CapsuleHeader->HeaderSize >= CapsuleHeader->CapsuleImageSize) {
DEBUG((DEBUG_ERROR, "HeaderSize(0x%x) >= CapsuleImageSize(0x%x)\n", CapsuleHeader->HeaderSize, CapsuleHeader->CapsuleImageSize));
DEBUG ((DEBUG_ERROR, "HeaderSize(0x%x) >= CapsuleImageSize(0x%x)\n", CapsuleHeader->HeaderSize, CapsuleHeader->CapsuleImageSize));
return EFI_INVALID_PARAMETER;
}
FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);
EndOfCapsule = (UINT8 *) CapsuleHeader + CapsuleHeader->CapsuleImageSize;
FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
EndOfCapsule = (UINT8 *)CapsuleHeader + CapsuleHeader->CapsuleImageSize;
FmpCapsuleSize = (UINTN)EndOfCapsule - (UINTN)FmpCapsuleHeader;
if (FmpCapsuleSize < sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER)) {
DEBUG((DEBUG_ERROR, "FmpCapsuleSize(0x%x) < EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER\n", FmpCapsuleSize));
if (FmpCapsuleSize < sizeof (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER)) {
DEBUG ((DEBUG_ERROR, "FmpCapsuleSize(0x%x) < EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER\n", FmpCapsuleSize));
return EFI_INVALID_PARAMETER;
}
// Check EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER
if (FmpCapsuleHeader->Version != EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION) {
DEBUG((DEBUG_ERROR, "FmpCapsuleHeader->Version(0x%x) != EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION\n", FmpCapsuleHeader->Version));
DEBUG ((DEBUG_ERROR, "FmpCapsuleHeader->Version(0x%x) != EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION\n", FmpCapsuleHeader->Version));
return EFI_INVALID_PARAMETER;
}
ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
// No overflow
ItemNum = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;
if ((FmpCapsuleSize - sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER))/sizeof(UINT64) < ItemNum) {
DEBUG((DEBUG_ERROR, "ItemNum(0x%x) too big\n", ItemNum));
if ((FmpCapsuleSize - sizeof (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER))/sizeof (UINT64) < ItemNum) {
DEBUG ((DEBUG_ERROR, "ItemNum(0x%x) too big\n", ItemNum));
return EFI_INVALID_PARAMETER;
}
FmpCapsuleHeaderSize = sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER) + sizeof(UINT64)*ItemNum;
FmpCapsuleHeaderSize = sizeof (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER) + sizeof (UINT64)*ItemNum;
// Check ItemOffsetList
for (Index = 0; Index < ItemNum; Index++) {
if (ItemOffsetList[Index] >= FmpCapsuleSize) {
DEBUG((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) >= FmpCapsuleSize(0x%x)\n", Index, ItemOffsetList[Index], FmpCapsuleSize));
DEBUG ((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) >= FmpCapsuleSize(0x%x)\n", Index, ItemOffsetList[Index], FmpCapsuleSize));
return EFI_INVALID_PARAMETER;
}
if (ItemOffsetList[Index] < FmpCapsuleHeaderSize) {
DEBUG((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) < FmpCapsuleHeaderSize(0x%x)\n", Index, ItemOffsetList[Index], FmpCapsuleHeaderSize));
DEBUG ((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) < FmpCapsuleHeaderSize(0x%x)\n", Index, ItemOffsetList[Index], FmpCapsuleHeaderSize));
return EFI_INVALID_PARAMETER;
}
//
// All the address in ItemOffsetList must be stored in ascending order
//
if (Index > 0) {
if (ItemOffsetList[Index] <= ItemOffsetList[Index - 1]) {
DEBUG((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) < ItemOffsetList[%d](0x%x)\n", Index, ItemOffsetList[Index], Index, ItemOffsetList[Index - 1]));
DEBUG ((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) < ItemOffsetList[%d](0x%x)\n", Index, ItemOffsetList[Index], Index, ItemOffsetList[Index - 1]));
return EFI_INVALID_PARAMETER;
}
}
@ -316,31 +322,35 @@ ValidateFmpCapsule (
} else {
EndOfPayload = (UINT8 *)(UINTN)ItemOffsetList[Index+1];
}
FmpImageSize = (UINTN)EndOfPayload - ItemOffsetList[Index];
if (FmpImageSize < OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance)) {
DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) < EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER\n", FmpImageSize));
if (FmpImageSize < OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance)) {
DEBUG ((DEBUG_ERROR, "FmpImageSize(0x%lx) < EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER\n", FmpImageSize));
return EFI_INVALID_PARAMETER;
}
FmpImageHeaderSize = sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER);
FmpImageHeaderSize = sizeof (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER);
if ((ImageHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) ||
(ImageHeader->Version < 1)) {
DEBUG((DEBUG_ERROR, "ImageHeader->Version(0x%x) Unknown\n", ImageHeader->Version));
(ImageHeader->Version < 1))
{
DEBUG ((DEBUG_ERROR, "ImageHeader->Version(0x%x) Unknown\n", ImageHeader->Version));
return EFI_INVALID_PARAMETER;
}
///
/// Current Init ImageHeader version is 3. UpdateHardwareInstance field was added in version 2
/// and ImageCapsuleSupport field was added in version 3
///
if (ImageHeader->Version == 1) {
FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
} else if (ImageHeader->Version == 2){
FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
FmpImageHeaderSize = OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
} else if (ImageHeader->Version == 2) {
FmpImageHeaderSize = OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
}
// No overflow
if (FmpImageSize != (UINT64)FmpImageHeaderSize + (UINT64)ImageHeader->UpdateImageSize + (UINT64)ImageHeader->UpdateVendorCodeSize) {
DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) mismatch, UpdateImageSize(0x%x) UpdateVendorCodeSize(0x%x)\n", FmpImageSize, ImageHeader->UpdateImageSize, ImageHeader->UpdateVendorCodeSize));
DEBUG ((DEBUG_ERROR, "FmpImageSize(0x%lx) mismatch, UpdateImageSize(0x%x) UpdateVendorCodeSize(0x%x)\n", FmpImageSize, ImageHeader->UpdateImageSize, ImageHeader->UpdateVendorCodeSize));
return EFI_INVALID_PARAMETER;
}
}
@ -351,9 +361,10 @@ ValidateFmpCapsule (
//
EndOfPayload = (UINT8 *)(FmpCapsuleHeader + 1);
if (EndOfPayload != EndOfCapsule) {
DEBUG((DEBUG_ERROR, "EndOfPayload(0x%x) mismatch, EndOfCapsule(0x%x)\n", EndOfPayload, EndOfCapsule));
DEBUG ((DEBUG_ERROR, "EndOfPayload(0x%x) mismatch, EndOfCapsule(0x%x)\n", EndOfPayload, EndOfCapsule));
return EFI_INVALID_PARAMETER;
}
return EFI_UNSUPPORTED;
}
@ -361,7 +372,7 @@ ValidateFmpCapsule (
// Check in system FMP capsule
//
if (IsSystemFmp != NULL) {
*IsSystemFmp = IsSystemFmpCapsuleImage(CapsuleHeader);
*IsSystemFmp = IsSystemFmpCapsuleImage (CapsuleHeader);
}
if (EmbeddedDriverCount != NULL) {
@ -389,8 +400,8 @@ InitializeRecoveryModule (
EFI_STATUS Status;
UINTN BootMode;
BootMode = GetBootModeHob();
ASSERT(BootMode == BOOT_IN_RECOVERY_MODE);
BootMode = GetBootModeHob ();
ASSERT (BootMode == BOOT_IN_RECOVERY_MODE);
Status = (**PeiServices).InstallPpi (PeiServices, &mRecoveryPpiList);
ASSERT_EFI_ERROR (Status);
@ -423,14 +434,15 @@ CreateHobForRecoveryCapsule (
//
// FvImage should be at its required alignment.
//
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvImage;
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvImage;
//
// Validate FV Header, if not as expected, return
//
if (ReadUnaligned32 (&FvHeader->Signature) != EFI_FVH_SIGNATURE) {
DEBUG((DEBUG_ERROR, "CreateHobForRecoveryCapsule (Fv Signature Error)\n"));
DEBUG ((DEBUG_ERROR, "CreateHobForRecoveryCapsule (Fv Signature Error)\n"));
return EFI_VOLUME_CORRUPTED;
}
//
// If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
// can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
@ -447,26 +459,28 @@ CreateHobForRecoveryCapsule (
if (FvAlignment < 8) {
FvAlignment = 8;
}
//
// Allocate the aligned buffer for the FvImage.
//
if ((UINTN) FvHeader % FvAlignment != 0) {
DEBUG((DEBUG_INFO, "CreateHobForRecoveryCapsule (FvHeader 0x%lx is not aligned)\n", (UINT64)(UINTN)FvHeader));
if ((UINTN)FvHeader % FvAlignment != 0) {
DEBUG ((DEBUG_INFO, "CreateHobForRecoveryCapsule (FvHeader 0x%lx is not aligned)\n", (UINT64)(UINTN)FvHeader));
FvLength = ReadUnaligned64 (&FvHeader->FvLength);
NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINTN) FvLength), FvAlignment);
NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINTN)FvLength), FvAlignment);
if (NewFvBuffer == NULL) {
DEBUG((DEBUG_ERROR, "CreateHobForRecoveryCapsule (Not enough resource to allocate 0x%lx bytes)\n", FvLength));
DEBUG ((DEBUG_ERROR, "CreateHobForRecoveryCapsule (Not enough resource to allocate 0x%lx bytes)\n", FvLength));
return EFI_OUT_OF_RESOURCES;
}
CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
CopyMem (NewFvBuffer, FvHeader, (UINTN)FvLength);
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)NewFvBuffer;
}
}
BuildFvHob((UINT64)(UINTN)FvHeader, FvHeader->FvLength);
DEBUG((DEBUG_INFO, "BuildFvHob (FV in recovery) - 0x%lx - 0x%lx\n", (UINT64)(UINTN)FvHeader, FvHeader->FvLength));
BuildFvHob ((UINT64)(UINTN)FvHeader, FvHeader->FvLength);
DEBUG ((DEBUG_INFO, "BuildFvHob (FV in recovery) - 0x%lx - 0x%lx\n", (UINT64)(UINTN)FvHeader, FvHeader->FvLength));
PeiServicesInstallFvInfoPpi(
PeiServicesInstallFvInfoPpi (
&FvHeader->FileSystemGuid,
(VOID *)FvHeader,
(UINT32)FvHeader->FvLength,
@ -502,8 +516,8 @@ RecoverImage (
UINTN Index;
if (ConfigImage == NULL) {
DEBUG((DEBUG_INFO, "RecoverImage (NoConfig)\n"));
Status = CreateHobForRecoveryCapsule(
DEBUG ((DEBUG_INFO, "RecoverImage (NoConfig)\n"));
Status = CreateHobForRecoveryCapsule (
SystemFirmwareImage,
SystemFirmwareImageSize
);
@ -511,25 +525,26 @@ RecoverImage (
}
ConfigData = NULL;
ZeroMem (&ConfigHeader, sizeof(ConfigHeader));
ZeroMem (&ConfigHeader, sizeof (ConfigHeader));
Status = ParseRecoveryDataFile (
ConfigImage,
ConfigImageSize,
&ConfigHeader,
&ConfigData
);
DEBUG((DEBUG_INFO, "ParseRecoveryDataFile - %r\n", Status));
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_INFO, "ParseRecoveryDataFile - %r\n", Status));
if (EFI_ERROR (Status)) {
return Status;
}
DEBUG((DEBUG_INFO, "ConfigHeader.NumOfRecovery - 0x%x\n", ConfigHeader.NumOfRecovery));
DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid)));
DEBUG ((DEBUG_INFO, "ConfigHeader.NumOfRecovery - 0x%x\n", ConfigHeader.NumOfRecovery));
DEBUG ((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr (PcdEdkiiSystemFirmwareFileGuid)));
Index = 0;
RecoveryConfigData = ConfigData;
while (Index < ConfigHeader.NumOfRecovery) {
if (CompareGuid(&RecoveryConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &RecoveryConfigData->FileGuid));
if (CompareGuid (&RecoveryConfigData->FileGuid, PcdGetPtr (PcdEdkiiSystemFirmwareFileGuid))) {
DEBUG ((DEBUG_INFO, "FileGuid - %g (processing)\n", &RecoveryConfigData->FileGuid));
Status = CreateHobForRecoveryCapsule (
(UINT8 *)SystemFirmwareImage + RecoveryConfigData->ImageOffset,
RecoveryConfigData->Length
@ -542,7 +557,7 @@ RecoverImage (
break;
}
} else {
DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &RecoveryConfigData->FileGuid));
DEBUG ((DEBUG_INFO, "FileGuid - %g (ignored)\n", &RecoveryConfigData->FileGuid));
}
Index++;
@ -582,18 +597,18 @@ ProcessRecoveryImage (
AuthenticatedImage = NULL;
AuthenticatedImageSize = 0;
Status = CapsuleAuthenticateSystemFirmware(Image, Length, TRUE, &LastAttemptVersion, &LastAttemptStatus, &AuthenticatedImage, &AuthenticatedImageSize);
if (EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "CapsuleAuthenticateSystemFirmware - %r\n", Status));
Status = CapsuleAuthenticateSystemFirmware (Image, Length, TRUE, &LastAttemptVersion, &LastAttemptStatus, &AuthenticatedImage, &AuthenticatedImageSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "CapsuleAuthenticateSystemFirmware - %r\n", Status));
return Status;
}
ExtractSystemFirmwareImage(AuthenticatedImage, AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);
ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);
ExtractSystemFirmwareImage (AuthenticatedImage, AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);
ExtractConfigImage (AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);
Status = RecoverImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize);
if (EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "RecoverImage - %r\n", Status));
Status = RecoverImage (SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "RecoverImage - %r\n", Status));
return Status;
}
@ -649,14 +664,14 @@ ProcessFmpCapsuleImage (
// If version is 2 Header should exclude ImageCapsuleSupport field.
//
if (ImageHeader->Version == 1) {
Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
Image = (UINT8 *)ImageHeader + OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
} else {
Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
Image = (UINT8 *)ImageHeader + OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
}
}
Status = ProcessRecoveryImage (Image, ImageHeader->UpdateImageSize);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return Status;
}
}
@ -689,32 +704,32 @@ ProcessRecoveryCapsule (
CapsuleHeader = CapsuleBuffer;
if (!IsValidCapsuleHeader (CapsuleHeader, CapsuleSize)) {
DEBUG((DEBUG_ERROR, "CapsuleImageSize incorrect\n"));
DEBUG ((DEBUG_ERROR, "CapsuleImageSize incorrect\n"));
return EFI_SECURITY_VIOLATION;
}
//
// Check FMP capsule layout
//
if (IsFmpCapsuleGuid(&CapsuleHeader->CapsuleGuid)) {
DEBUG((DEBUG_INFO, "CreateHobForRecoveryCapsule\n"));
if (IsFmpCapsuleGuid (&CapsuleHeader->CapsuleGuid)) {
DEBUG ((DEBUG_INFO, "CreateHobForRecoveryCapsule\n"));
DEBUG((DEBUG_INFO, "ProcessCapsuleImage for FmpCapsule ...\n"));
DEBUG((DEBUG_INFO, "ValidateFmpCapsule ...\n"));
Status = ValidateFmpCapsule(CapsuleHeader, &IsSystemFmp, NULL);
DEBUG((DEBUG_INFO, "ValidateFmpCapsule - %r\n", Status));
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_INFO, "ProcessCapsuleImage for FmpCapsule ...\n"));
DEBUG ((DEBUG_INFO, "ValidateFmpCapsule ...\n"));
Status = ValidateFmpCapsule (CapsuleHeader, &IsSystemFmp, NULL);
DEBUG ((DEBUG_INFO, "ValidateFmpCapsule - %r\n", Status));
if (EFI_ERROR (Status)) {
return Status;
}
//
// Process EFI FMP Capsule
//
DEBUG((DEBUG_INFO, "ProcessFmpCapsuleImage ...\n"));
Status = ProcessFmpCapsuleImage(CapsuleHeader, IsSystemFmp);
DEBUG((DEBUG_INFO, "ProcessFmpCapsuleImage - %r\n", Status));
DEBUG ((DEBUG_INFO, "ProcessFmpCapsuleImage ...\n"));
Status = ProcessFmpCapsuleImage (CapsuleHeader, IsSystemFmp);
DEBUG ((DEBUG_INFO, "ProcessFmpCapsuleImage - %r\n", Status));
DEBUG((DEBUG_INFO, "CreateHobForRecoveryCapsule Done\n"));
DEBUG ((DEBUG_INFO, "CreateHobForRecoveryCapsule Done\n"));
return Status;
}
@ -749,7 +764,7 @@ LoadRecoveryCapsule (
EFI_GUID CapsuleType;
VOID *CapsuleBuffer;
DEBUG((DEBUG_INFO | DEBUG_LOAD, "Recovery Entry\n"));
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Recovery Entry\n"));
for (Instance = 0; ; Instance++) {
Status = PeiServicesLocatePpi (
@ -762,6 +777,7 @@ LoadRecoveryCapsule (
if (EFI_ERROR (Status)) {
break;
}
NumberRecoveryCapsules = 0;
Status = DeviceRecoveryPpi->GetNumberRecoveryCapsules (
(EFI_PEI_SERVICES **)PeiServices,
@ -772,6 +788,7 @@ LoadRecoveryCapsule (
if (EFI_ERROR (Status)) {
continue;
}
for (CapsuleInstance = 1; CapsuleInstance <= NumberRecoveryCapsules; CapsuleInstance++) {
CapsuleSize = 0;
Status = DeviceRecoveryPpi->GetRecoveryCapsuleInfo (
@ -786,11 +803,12 @@ LoadRecoveryCapsule (
break;
}
CapsuleBuffer = AllocatePages (EFI_SIZE_TO_PAGES(CapsuleSize));
CapsuleBuffer = AllocatePages (EFI_SIZE_TO_PAGES (CapsuleSize));
if (CapsuleBuffer == NULL) {
DEBUG ((DEBUG_ERROR, "LoadRecoveryCapsule - AllocatePool fail\n"));
continue;
}
Status = DeviceRecoveryPpi->LoadRecoveryCapsule (
(EFI_PEI_SERVICES **)PeiServices,
DeviceRecoveryPpi,
@ -799,9 +817,10 @@ LoadRecoveryCapsule (
);
DEBUG ((DEBUG_ERROR, "LoadRecoveryCapsule - LoadRecoveryCapsule (%d) - %r\n", CapsuleInstance, Status));
if (EFI_ERROR (Status)) {
FreePages (CapsuleBuffer, EFI_SIZE_TO_PAGES(CapsuleSize));
FreePages (CapsuleBuffer, EFI_SIZE_TO_PAGES (CapsuleSize));
break;
}
//
// good, load capsule buffer
//

View File

@ -35,4 +35,3 @@ typedef struct {
} RECOVERY_CONFIG_DATA;
#endif

View File

@ -47,7 +47,7 @@ ParseUpdateDataFile (
//
// First process the data buffer and get all sections and entries
//
Context = OpenIniFile(DataBuffer, BufferSize);
Context = OpenIniFile (DataBuffer, BufferSize);
if (Context == NULL) {
return EFI_INVALID_PARAMETER;
}
@ -55,26 +55,26 @@ ParseUpdateDataFile (
//
// Now get NumOfUpdate
//
Status = GetDecimalUintnFromDataFile(
Status = GetDecimalUintnFromDataFile (
Context,
"Head",
"NumOfUpdate",
&Num
);
if (EFI_ERROR(Status) || (Num == 0)) {
DEBUG((DEBUG_ERROR, "NumOfUpdate not found\n"));
CloseIniFile(Context);
if (EFI_ERROR (Status) || (Num == 0)) {
DEBUG ((DEBUG_ERROR, "NumOfUpdate not found\n"));
CloseIniFile (Context);
return EFI_NOT_FOUND;
}
ConfigHeader->NumOfUpdates = Num;
*UpdateArray = AllocateZeroPool ((sizeof (UPDATE_CONFIG_DATA) * Num));
if (*UpdateArray == NULL) {
CloseIniFile(Context);
CloseIniFile (Context);
return EFI_OUT_OF_RESOURCES;
}
for (Index = 0 ; Index < ConfigHeader->NumOfUpdates ; Index++) {
for (Index = 0; Index < ConfigHeader->NumOfUpdates; Index++) {
//
// Get the section name of each update
//
@ -86,15 +86,15 @@ ParseUpdateDataFile (
Index,
0
);
Status = GetStringFromDataFile(
Status = GetStringFromDataFile (
Context,
"Head",
Entry,
&SectionName
);
if (EFI_ERROR(Status) || (SectionName == NULL)) {
DEBUG((DEBUG_ERROR, "[%d] %a not found\n", Index, Entry));
CloseIniFile(Context);
if (EFI_ERROR (Status) || (SectionName == NULL)) {
DEBUG ((DEBUG_ERROR, "[%d] %a not found\n", Index, Entry));
CloseIniFile (Context);
return EFI_NOT_FOUND;
}
@ -107,106 +107,110 @@ ParseUpdateDataFile (
//
// FirmwareType
//
Status = GetDecimalUintnFromDataFile(
Status = GetDecimalUintnFromDataFile (
Context,
SectionName,
"FirmwareType",
&Num
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] FirmwareType not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] FirmwareType not found\n", Index));
return EFI_NOT_FOUND;
}
(*UpdateArray)[Index].FirmwareType = (PLATFORM_FIRMWARE_TYPE) Num;
(*UpdateArray)[Index].FirmwareType = (PLATFORM_FIRMWARE_TYPE)Num;
//
// AddressType
//
Status = GetDecimalUintnFromDataFile(
Status = GetDecimalUintnFromDataFile (
Context,
SectionName,
"AddressType",
&Num
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] AddressType not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] AddressType not found\n", Index));
return EFI_NOT_FOUND;
}
(*UpdateArray)[Index].AddressType = (FLASH_ADDRESS_TYPE) Num;
(*UpdateArray)[Index].AddressType = (FLASH_ADDRESS_TYPE)Num;
//
// BaseAddress
//
Status = GetHexUint64FromDataFile(
Status = GetHexUint64FromDataFile (
Context,
SectionName,
"BaseAddress",
&Num64
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] BaseAddress not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] BaseAddress not found\n", Index));
return EFI_NOT_FOUND;
}
(*UpdateArray)[Index].BaseAddress = (EFI_PHYSICAL_ADDRESS) Num64;
(*UpdateArray)[Index].BaseAddress = (EFI_PHYSICAL_ADDRESS)Num64;
//
// FileGuid
//
Status = GetGuidFromDataFile(
Status = GetGuidFromDataFile (
Context,
SectionName,
"FileGuid",
&FileGuid
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] FileGuid not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] FileGuid not found\n", Index));
return EFI_NOT_FOUND;
}
CopyGuid(&((*UpdateArray)[Index].FileGuid), &FileGuid);
CopyGuid (&((*UpdateArray)[Index].FileGuid), &FileGuid);
//
// Length
//
Status = GetHexUintnFromDataFile(
Status = GetHexUintnFromDataFile (
Context,
SectionName,
"Length",
&Num
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] Length not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] Length not found\n", Index));
return EFI_NOT_FOUND;
}
(*UpdateArray)[Index].Length = (UINTN) Num;
(*UpdateArray)[Index].Length = (UINTN)Num;
//
// ImageOffset
//
Status = GetHexUintnFromDataFile(
Status = GetHexUintnFromDataFile (
Context,
SectionName,
"ImageOffset",
&Num
);
if (EFI_ERROR(Status)) {
CloseIniFile(Context);
DEBUG((DEBUG_ERROR, "[%d] ImageOffset not found\n", Index));
if (EFI_ERROR (Status)) {
CloseIniFile (Context);
DEBUG ((DEBUG_ERROR, "[%d] ImageOffset not found\n", Index));
return EFI_NOT_FOUND;
}
(*UpdateArray)[Index].ImageOffset = (UINTN) Num;
(*UpdateArray)[Index].ImageOffset = (UINTN)Num;
}
//
// Now all configuration data got. Free those temporary buffers
//
CloseIniFile(Context);
CloseIniFile (Context);
return EFI_SUCCESS;
}

View File

@ -74,28 +74,29 @@ FmpGetImageInfo (
SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate;
EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor;
SystemFmpPrivate = SYSTEM_FMP_PRIVATE_DATA_FROM_FMP(This);
SystemFmpPrivate = SYSTEM_FMP_PRIVATE_DATA_FROM_FMP (This);
if(ImageInfoSize == NULL) {
if (ImageInfoSize == NULL) {
return EFI_INVALID_PARAMETER;
}
if (*ImageInfoSize < sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount) {
*ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount;
if (*ImageInfoSize < sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount) {
*ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount;
return EFI_BUFFER_TOO_SMALL;
}
if (ImageInfo == NULL ||
DescriptorVersion == NULL ||
DescriptorCount == NULL ||
DescriptorSize == NULL ||
PackageVersion == NULL ||
PackageVersionName == NULL) {
if ((ImageInfo == NULL) ||
(DescriptorVersion == NULL) ||
(DescriptorCount == NULL) ||
(DescriptorSize == NULL) ||
(PackageVersion == NULL) ||
(PackageVersionName == NULL))
{
return EFI_INVALID_PARAMETER;
}
*ImageInfoSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount;
*DescriptorSize = sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR);
*ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount;
*DescriptorSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
*DescriptorCount = SystemFmpPrivate->DescriptorCount;
*DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
@ -111,12 +112,14 @@ FmpGetImageInfo (
} else {
ImageInfo->ImageIdName = NULL;
}
ImageInfo->Version = ImageDescriptor->Version;
if (ImageDescriptor->VersionNameStringOffset != 0) {
ImageInfo->VersionName = (CHAR16 *)((UINTN)ImageDescriptor + ImageDescriptor->VersionNameStringOffset);
} else {
ImageInfo->VersionName = NULL;
}
ImageInfo->Size = (UINTN)ImageDescriptor->Size;
ImageInfo->AttributesSupported = ImageDescriptor->AttributesSupported;
ImageInfo->AttributesSetting = ImageDescriptor->AttributesSetting;
@ -132,7 +135,7 @@ FmpGetImageInfo (
*PackageVersion = ImageDescriptor->PackageVersion;
if (ImageDescriptor->PackageVersionNameStringOffset != 0) {
*PackageVersionName = (VOID *)((UINTN)ImageDescriptor + ImageDescriptor->PackageVersionNameStringOffset);
*PackageVersionName = AllocateCopyPool(StrSize(*PackageVersionName), *PackageVersionName);
*PackageVersionName = AllocateCopyPool (StrSize (*PackageVersionName), *PackageVersionName);
} else {
*PackageVersionName = NULL;
}
@ -317,24 +320,22 @@ InitializePrivateData (
SystemFmpPrivate->Signature = SYSTEM_FMP_PRIVATE_DATA_SIGNATURE;
SystemFmpPrivate->Handle = NULL;
SystemFmpPrivate->DescriptorCount = 1;
CopyMem(&SystemFmpPrivate->Fmp, &mFirmwareManagementProtocol, sizeof(EFI_FIRMWARE_MANAGEMENT_PROTOCOL));
CopyMem (&SystemFmpPrivate->Fmp, &mFirmwareManagementProtocol, sizeof (EFI_FIRMWARE_MANAGEMENT_PROTOCOL));
SystemFmpPrivate->ImageDescriptor = PcdGetPtr(PcdEdkiiSystemFirmwareImageDescriptor);
SystemFmpPrivate->ImageDescriptor = PcdGetPtr (PcdEdkiiSystemFirmwareImageDescriptor);
SystemFmpPrivate->LastAttempt.LastAttemptVersion = 0x0;
SystemFmpPrivate->LastAttempt.LastAttemptStatus = 0x0;
VarSize = sizeof(SystemFmpPrivate->LastAttempt);
VarStatus = gRT->GetVariable(
VarSize = sizeof (SystemFmpPrivate->LastAttempt);
VarStatus = gRT->GetVariable (
SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
&gSystemFmpLastAttemptVariableGuid,
NULL,
&VarSize,
&SystemFmpPrivate->LastAttempt
);
DEBUG((DEBUG_INFO, "GetLastAttempt - %r\n", VarStatus));
DEBUG((DEBUG_INFO, "GetLastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
DEBUG ((DEBUG_INFO, "GetLastAttempt - %r\n", VarStatus));
DEBUG ((DEBUG_INFO, "GetLastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
return EFI_SUCCESS;
}

View File

@ -80,7 +80,6 @@ typedef struct _SYSTEM_FMP_PRIVATE_DATA SYSTEM_FMP_PRIVATE_DATA;
SYSTEM_FMP_PRIVATE_DATA_SIGNATURE \
)
//
// Update data
//
@ -108,7 +107,7 @@ typedef struct {
typedef struct {
UINTN Function;
EFI_STATUS ReturnStatus;
//UINT8 Data[];
// UINT8 Data[];
} SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_HEAD;
#define ABORT_REASON_MAX_SIZE 0x40 // UnicodeStringSize including final L'\0'
@ -121,10 +120,9 @@ typedef struct {
UINTN AbortReasonSize;
UINT32 LastAttemptVersion;
UINT32 LastAttemptStatus;
//UINT8 Data[AbortReasonMaxSize + ImageSize];
// UINT8 Data[AbortReasonMaxSize + ImageSize];
} SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_SET_IMAGE;
/**
Returns information about the current firmware image(s) of the device.
@ -398,4 +396,3 @@ extern EFI_GUID mCurrentImageTypeId;
extern EFI_GUID gSystemFmpProtocolGuid;
#endif

View File

@ -55,39 +55,39 @@ DispatchSystemFmpImages (
AuthenticatedImage = NULL;
AuthenticatedImageSize = 0;
DEBUG((DEBUG_INFO, "DispatchSystemFmpImages\n"));
DEBUG ((DEBUG_INFO, "DispatchSystemFmpImages\n"));
//
// Verify
//
Status = CapsuleAuthenticateSystemFirmware(Image, ImageSize, FALSE, LastAttemptVersion, LastAttemptStatus, &AuthenticatedImage, &AuthenticatedImageSize);
if (EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "SystemFirmwareAuthenticateImage - %r\n", Status));
Status = CapsuleAuthenticateSystemFirmware (Image, ImageSize, FALSE, LastAttemptVersion, LastAttemptStatus, &AuthenticatedImage, &AuthenticatedImageSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "SystemFirmwareAuthenticateImage - %r\n", Status));
return Status;
}
//
// Get FV
//
Result = ExtractDriverFvImage(AuthenticatedImage, AuthenticatedImageSize, &DispatchFvImage, &DispatchFvImageSize);
Result = ExtractDriverFvImage (AuthenticatedImage, AuthenticatedImageSize, &DispatchFvImage, &DispatchFvImageSize);
if (Result) {
DEBUG((DEBUG_INFO, "ExtractDriverFvImage\n"));
DEBUG ((DEBUG_INFO, "ExtractDriverFvImage\n"));
//
// Dispatch
//
if (((EFI_FIRMWARE_VOLUME_HEADER *)DispatchFvImage)->FvLength == DispatchFvImageSize) {
FvImage = AllocatePages(EFI_SIZE_TO_PAGES(DispatchFvImageSize));
FvImage = AllocatePages (EFI_SIZE_TO_PAGES (DispatchFvImageSize));
if (FvImage != NULL) {
CopyMem(FvImage, DispatchFvImage, DispatchFvImageSize);
Status = gDS->ProcessFirmwareVolume(
CopyMem (FvImage, DispatchFvImage, DispatchFvImageSize);
Status = gDS->ProcessFirmwareVolume (
(VOID *)FvImage,
(UINTN)FvImage->FvLength,
&FvProtocolHandle
);
DEBUG((DEBUG_INFO, "ProcessFirmwareVolume - %r\n", Status));
if (!EFI_ERROR(Status)) {
gDS->Dispatch();
DEBUG((DEBUG_INFO, "Dispatch Done\n"));
DEBUG ((DEBUG_INFO, "ProcessFirmwareVolume - %r\n", Status));
if (!EFI_ERROR (Status)) {
gDS->Dispatch ();
DEBUG ((DEBUG_INFO, "Dispatch Done\n"));
}
}
}
@ -159,64 +159,64 @@ FmpSetImage (
EFI_STATUS Status;
EFI_STATUS VarStatus;
if (Image == NULL || ImageSize == 0 || AbortReason == NULL) {
if ((Image == NULL) || (ImageSize == 0) || (AbortReason == NULL)) {
return EFI_INVALID_PARAMETER;
}
SystemFmpPrivate = SYSTEM_FMP_PRIVATE_DATA_FROM_FMP(This);
SystemFmpPrivate = SYSTEM_FMP_PRIVATE_DATA_FROM_FMP (This);
*AbortReason = NULL;
if (ImageIndex == 0 || ImageIndex > SystemFmpPrivate->DescriptorCount) {
if ((ImageIndex == 0) || (ImageIndex > SystemFmpPrivate->DescriptorCount)) {
return EFI_INVALID_PARAMETER;
}
//
// Process FV
//
Status = DispatchSystemFmpImages((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus);
DEBUG((DEBUG_INFO, "(Agent)SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
if (EFI_ERROR(Status)) {
VarStatus = gRT->SetVariable(
Status = DispatchSystemFmpImages ((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus);
DEBUG ((DEBUG_INFO, "(Agent)SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
if (EFI_ERROR (Status)) {
VarStatus = gRT->SetVariable (
SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
&gSystemFmpLastAttemptVariableGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof(SystemFmpPrivate->LastAttempt),
sizeof (SystemFmpPrivate->LastAttempt),
&SystemFmpPrivate->LastAttempt
);
DEBUG((DEBUG_INFO, "(Agent)SetLastAttempt - %r\n", VarStatus));
DEBUG ((DEBUG_INFO, "(Agent)SetLastAttempt - %r\n", VarStatus));
return Status;
}
//
// Pass Thru to System FMP Protocol on same handle as FMP Protocol
//
Status = gBS->HandleProtocol(
Status = gBS->HandleProtocol (
SystemFmpPrivate->Handle,
&gSystemFmpProtocolGuid,
(VOID **)&SystemFmp
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
Status = gBS->LocateProtocol (
&gSystemFmpProtocolGuid,
NULL,
(VOID **)&SystemFmp
);
if (EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "(Agent)SetImage - SystemFmpProtocol - %r\n", Status));
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "(Agent)SetImage - SystemFmpProtocol - %r\n", Status));
SystemFmpPrivate->LastAttempt.LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
VarStatus = gRT->SetVariable(
VarStatus = gRT->SetVariable (
SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
&gSystemFmpLastAttemptVariableGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof(SystemFmpPrivate->LastAttempt),
sizeof (SystemFmpPrivate->LastAttempt),
&SystemFmpPrivate->LastAttempt
);
DEBUG((DEBUG_INFO, "(Agent)SetLastAttempt - %r\n", VarStatus));
DEBUG ((DEBUG_INFO, "(Agent)SetLastAttempt - %r\n", VarStatus));
return Status;
}
}
return SystemFmp->SetImage(SystemFmp, ImageIndex, Image, ImageSize, VendorCode, Progress, AbortReason);
return SystemFmp->SetImage (SystemFmp, ImageIndex, Image, ImageSize, VendorCode, Progress, AbortReason);
}
/**
@ -239,14 +239,14 @@ SystemFirmwareReportMainDxe (
//
// Initialize SystemFmpPrivateData
//
mSystemFmpPrivate = AllocateZeroPool (sizeof(SYSTEM_FMP_PRIVATE_DATA));
mSystemFmpPrivate = AllocateZeroPool (sizeof (SYSTEM_FMP_PRIVATE_DATA));
if (mSystemFmpPrivate == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = InitializePrivateData(mSystemFmpPrivate);
if (EFI_ERROR(Status)) {
FreePool(mSystemFmpPrivate);
Status = InitializePrivateData (mSystemFmpPrivate);
if (EFI_ERROR (Status)) {
FreePool (mSystemFmpPrivate);
mSystemFmpPrivate = NULL;
return Status;
}
@ -261,7 +261,7 @@ SystemFirmwareReportMainDxe (
&mSystemFmpPrivate->Fmp
);
if (EFI_ERROR (Status)) {
FreePool(mSystemFmpPrivate);
FreePool (mSystemFmpPrivate);
mSystemFmpPrivate = NULL;
return Status;
}

View File

@ -74,13 +74,14 @@ PerformUpdate (
{
EFI_STATUS Status;
DEBUG((DEBUG_INFO, "PlatformUpdate:"));
DEBUG((DEBUG_INFO, " BaseAddress - 0x%lx,", ConfigData->BaseAddress));
DEBUG((DEBUG_INFO, " ImageOffset - 0x%x,", ConfigData->ImageOffset));
DEBUG((DEBUG_INFO, " Legnth - 0x%x\n", ConfigData->Length));
DEBUG ((DEBUG_INFO, "PlatformUpdate:"));
DEBUG ((DEBUG_INFO, " BaseAddress - 0x%lx,", ConfigData->BaseAddress));
DEBUG ((DEBUG_INFO, " ImageOffset - 0x%x,", ConfigData->ImageOffset));
DEBUG ((DEBUG_INFO, " Legnth - 0x%x\n", ConfigData->Length));
if (Progress != NULL) {
Progress (StartPercentage);
}
Status = PerformFlashWriteWithProgress (
ConfigData->FirmwareType,
ConfigData->BaseAddress,
@ -94,7 +95,8 @@ PerformUpdate (
if (Progress != NULL) {
Progress (EndPercentage);
}
if (!EFI_ERROR(Status)) {
if (!EFI_ERROR (Status)) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
if (ConfigData->FirmwareType == PlatformFirmwareTypeNvRam) {
mNvRamUpdated = TRUE;
@ -102,6 +104,7 @@ PerformUpdate (
} else {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
}
return Status;
}
@ -141,15 +144,16 @@ UpdateImage (
UINTN EndPercentage;
if (ConfigImage == NULL) {
DEBUG((DEBUG_INFO, "PlatformUpdate (NoConfig):"));
DEBUG((DEBUG_INFO, " BaseAddress - 0x%x,", 0));
DEBUG((DEBUG_INFO, " Length - 0x%x\n", SystemFirmwareImageSize));
DEBUG ((DEBUG_INFO, "PlatformUpdate (NoConfig):"));
DEBUG ((DEBUG_INFO, " BaseAddress - 0x%x,", 0));
DEBUG ((DEBUG_INFO, " Length - 0x%x\n", SystemFirmwareImageSize));
// ASSUME the whole System Firmware include NVRAM region.
StartPercentage = 0;
EndPercentage = 100;
if (Progress != NULL) {
Progress (StartPercentage);
}
Status = PerformFlashWriteWithProgress (
PlatformFirmwareTypeNvRam,
0,
@ -163,35 +167,38 @@ UpdateImage (
if (Progress != NULL) {
Progress (EndPercentage);
}
if (!EFI_ERROR(Status)) {
if (!EFI_ERROR (Status)) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
mNvRamUpdated = TRUE;
} else {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
}
return Status;
}
DEBUG((DEBUG_INFO, "PlatformUpdate (With Config):\n"));
DEBUG ((DEBUG_INFO, "PlatformUpdate (With Config):\n"));
ConfigData = NULL;
ZeroMem (&ConfigHeader, sizeof(ConfigHeader));
ZeroMem (&ConfigHeader, sizeof (ConfigHeader));
Status = ParseUpdateDataFile (
ConfigImage,
ConfigImageSize,
&ConfigHeader,
&ConfigData
);
DEBUG((DEBUG_INFO, "ParseUpdateDataFile - %r\n", Status));
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_INFO, "ParseUpdateDataFile - %r\n", Status));
if (EFI_ERROR (Status)) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
return EFI_INVALID_PARAMETER;
}
DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.NumOfUpdates));
DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid)));
DEBUG ((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.NumOfUpdates));
DEBUG ((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr (PcdEdkiiSystemFirmwareFileGuid)));
TotalSize = 0;
for (Index = 0; Index < ConfigHeader.NumOfUpdates; Index++) {
if (CompareGuid(&ConfigData[Index].FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
if (CompareGuid (&ConfigData[Index].FileGuid, PcdGetPtr (PcdEdkiiSystemFirmwareFileGuid))) {
TotalSize = TotalSize + ConfigData[Index].Length;
}
}
@ -200,8 +207,8 @@ UpdateImage (
Index = 0;
UpdateConfigData = ConfigData;
while (Index < ConfigHeader.NumOfUpdates) {
if (CompareGuid(&UpdateConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData->FileGuid));
if (CompareGuid (&UpdateConfigData->FileGuid, PcdGetPtr (PcdEdkiiSystemFirmwareFileGuid))) {
DEBUG ((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData->FileGuid));
StartPercentage = (BytesWritten * 100) / TotalSize;
EndPercentage = ((BytesWritten + UpdateConfigData->Length) * 100) / TotalSize;
Status = PerformUpdate (
@ -222,7 +229,7 @@ UpdateImage (
break;
}
} else {
DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->FileGuid));
DEBUG ((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->FileGuid));
}
BytesWritten += UpdateConfigData->Length;
@ -269,27 +276,27 @@ SystemFirmwareAuthenticatedUpdate (
AuthenticatedImage = NULL;
AuthenticatedImageSize = 0;
DEBUG((DEBUG_INFO, "SystemFirmwareAuthenticatedUpdate...\n"));
DEBUG ((DEBUG_INFO, "SystemFirmwareAuthenticatedUpdate...\n"));
Status = CapsuleAuthenticateSystemFirmware(Image, ImageSize, FALSE, LastAttemptVersion, LastAttemptStatus, &AuthenticatedImage, &AuthenticatedImageSize);
if (EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "SystemFirmwareAuthenticateImage - %r\n", Status));
Status = CapsuleAuthenticateSystemFirmware (Image, ImageSize, FALSE, LastAttemptVersion, LastAttemptStatus, &AuthenticatedImage, &AuthenticatedImageSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "SystemFirmwareAuthenticateImage - %r\n", Status));
return Status;
}
DEBUG((DEBUG_INFO, "ExtractSystemFirmwareImage ...\n"));
ExtractSystemFirmwareImage(AuthenticatedImage, AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);
DEBUG((DEBUG_INFO, "ExtractConfigImage ...\n"));
ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);
DEBUG ((DEBUG_INFO, "ExtractSystemFirmwareImage ...\n"));
ExtractSystemFirmwareImage (AuthenticatedImage, AuthenticatedImageSize, &SystemFirmwareImage, &SystemFirmwareImageSize);
DEBUG ((DEBUG_INFO, "ExtractConfigImage ...\n"));
ExtractConfigImage (AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);
DEBUG((DEBUG_INFO, "UpdateImage ...\n"));
Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus, Progress);
if (EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "UpdateImage - %r\n", Status));
DEBUG ((DEBUG_INFO, "UpdateImage ...\n"));
Status = UpdateImage (SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus, Progress);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "UpdateImage - %r\n", Status));
return Status;
}
DEBUG((DEBUG_INFO, "SystemFirmwareAuthenticatedUpdate Done\n"));
DEBUG ((DEBUG_INFO, "SystemFirmwareAuthenticatedUpdate Done\n"));
return EFI_SUCCESS;
}
@ -321,7 +328,7 @@ GetVariableHook (
OUT VOID *Data
)
{
DEBUG((DEBUG_INFO, "GetVariableHook - %S, %g\n", VariableName, VendorGuid));
DEBUG ((DEBUG_INFO, "GetVariableHook - %S, %g\n", VariableName, VendorGuid));
return EFI_NOT_AVAILABLE_YET;
}
@ -347,7 +354,7 @@ GetNextVariableNameHook (
IN OUT EFI_GUID *VendorGuid
)
{
DEBUG((DEBUG_INFO, "GetNextVariableNameHook - %S, %g\n", VariableName, VendorGuid));
DEBUG ((DEBUG_INFO, "GetNextVariableNameHook - %S, %g\n", VariableName, VendorGuid));
return EFI_NOT_AVAILABLE_YET;
}
@ -379,7 +386,7 @@ SetVariableHook (
IN VOID *Data
)
{
DEBUG((DEBUG_INFO, "SetVariableHook - %S, %g, 0x%x (0x%x)\n", VariableName, VendorGuid, Attributes, DataSize));
DEBUG ((DEBUG_INFO, "SetVariableHook - %S, %g, 0x%x (0x%x)\n", VariableName, VendorGuid, Attributes, DataSize));
return EFI_NOT_AVAILABLE_YET;
}
@ -408,7 +415,7 @@ QueryVariableInfoHook (
OUT UINT64 *MaximumVariableSize
)
{
DEBUG((DEBUG_INFO, "QueryVariableInfoHook - 0x%x\n", Attributes));
DEBUG ((DEBUG_INFO, "QueryVariableInfoHook - 0x%x\n", Attributes));
return EFI_NOT_AVAILABLE_YET;
}
@ -474,19 +481,19 @@ FmpSetImage (
EFI_STATUS VarStatus;
SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate;
if (Image == NULL || ImageSize == 0 || AbortReason == NULL) {
if ((Image == NULL) || (ImageSize == 0) || (AbortReason == NULL)) {
return EFI_INVALID_PARAMETER;
}
SystemFmpPrivate = SYSTEM_FMP_PRIVATE_DATA_FROM_FMP(This);
SystemFmpPrivate = SYSTEM_FMP_PRIVATE_DATA_FROM_FMP (This);
*AbortReason = NULL;
if (ImageIndex == 0 || ImageIndex > SystemFmpPrivate->DescriptorCount) {
if ((ImageIndex == 0) || (ImageIndex > SystemFmpPrivate->DescriptorCount)) {
return EFI_INVALID_PARAMETER;
}
Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus, Progress);
DEBUG((DEBUG_INFO, "SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
Status = SystemFirmwareAuthenticatedUpdate ((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus, Progress);
DEBUG ((DEBUG_INFO, "SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
//
// If NVRAM is updated, we should no longer touch variable services, because
@ -501,20 +508,20 @@ FmpSetImage (
gRT->Hdr.CRC32 = 0;
gBS->CalculateCrc32 (
(UINT8 *) &gRT->Hdr,
(UINT8 *)&gRT->Hdr,
gRT->Hdr.HeaderSize,
&gRT->Hdr.CRC32
);
}
VarStatus = gRT->SetVariable(
VarStatus = gRT->SetVariable (
SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
&gSystemFmpLastAttemptVariableGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof(SystemFmpPrivate->LastAttempt),
sizeof (SystemFmpPrivate->LastAttempt),
&SystemFmpPrivate->LastAttempt
);
DEBUG((DEBUG_INFO, "SetLastAttempt - %r\n", VarStatus));
DEBUG ((DEBUG_INFO, "SetLastAttempt - %r\n", VarStatus));
return Status;
}
@ -621,6 +628,7 @@ GetFmpImageDescriptors (
if (FmpImageInfoBuf != NULL) {
FreePool (FmpImageInfoBuf);
}
return NULL;
}
@ -695,14 +703,17 @@ FindMatchingFmpHandles (
break;
}
}
if (MatchFound) {
break;
}
//
// Increment the buffer pointer ahead by the size of the descriptor
//
FmpImageInfoBuf = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)(((UINT8 *)FmpImageInfoBuf) + DescriptorSize);
}
if (MatchFound) {
HandleBuffer[*HandleCount] = HandleBuffer[Index];
(*HandleCount)++;
@ -719,6 +730,7 @@ FindMatchingFmpHandles (
FreePool (HandleBuffer);
return NULL;
}
return HandleBuffer;
}
@ -752,7 +764,7 @@ UninstallMatchingSystemFmpProtocols (
DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Found %d matching System FMP instances\n", HandleCount));
for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol(
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gSystemFmpProtocolGuid,
(VOID **)&SystemFmp
@ -760,6 +772,7 @@ UninstallMatchingSystemFmpProtocols (
if (EFI_ERROR (Status)) {
continue;
}
DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Uninstall SystemFmp produced by another capsule\n"));
Status = gBS->UninstallProtocolInterface (
HandleBuffer[Index],
@ -772,6 +785,7 @@ UninstallMatchingSystemFmpProtocols (
return Status;
}
}
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}