diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:14 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | b87864896714cf3062a7bc6d577d8fbd62d105e5 (patch) | |
tree | 95bf726dde947a9da3abd39c4fe998f7f1a3ab4f /SignedCapsulePkg | |
parent | 47d20b54f9a65b08aa602a1866c1b59a69088dfc (diff) | |
download | edk2-b87864896714cf3062a7bc6d577d8fbd62d105e5.zip edk2-b87864896714cf3062a7bc6d577d8fbd62d105e5.tar.gz edk2-b87864896714cf3062a7bc6d577d8fbd62d105e5.tar.bz2 |
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>
Diffstat (limited to 'SignedCapsulePkg')
15 files changed, 1340 insertions, 1219 deletions
diff --git a/SignedCapsulePkg/Include/Guid/EdkiiSystemFmpCapsule.h b/SignedCapsulePkg/Include/Guid/EdkiiSystemFmpCapsule.h index 8295f92..946798e 100644 --- a/SignedCapsulePkg/Include/Guid/EdkiiSystemFmpCapsule.h +++ b/SignedCapsulePkg/Include/Guid/EdkiiSystemFmpCapsule.h @@ -7,7 +7,6 @@ **/
-
#ifndef __EDKII_SYSTEM_FMP_CAPSULE_GUID_H__
#define __EDKII_SYSTEM_FMP_CAPSULE_GUID_H__
@@ -90,34 +89,34 @@ #pragma pack(1)
typedef struct {
- UINT32 Signature;
- UINT32 HeaderLength; // Length of EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR, excluding NameString
- UINT32 Length; // Length of the data structure, including NameString
+ UINT32 Signature;
+ UINT32 HeaderLength; // Length of EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR, excluding NameString
+ UINT32 Length; // Length of the data structure, including NameString
// Below structure is similar as UEFI EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetPackageInfo()
- UINT32 PackageVersion;
- UINT32 PackageVersionNameStringOffset; // Offset from head, CHAR16 string including NULL terminate char
+ UINT32 PackageVersion;
+ UINT32 PackageVersionNameStringOffset; // Offset from head, CHAR16 string including NULL terminate char
// Below structure is similar as UEFI EFI_FIRMWARE_IMAGE_DESCRIPTOR
- UINT8 ImageIndex;
- UINT8 Reserved[3];
- EFI_GUID ImageTypeId;
- UINT64 ImageId;
- UINT32 ImageIdNameStringOffset; // Offset from head, CHAR16 string including NULL terminate char
- UINT32 Version;
- UINT32 VersionNameStringOffset; // Offset from head, CHAR16 string including NULL terminate char
- UINT8 Reserved2[4];
- UINT64 Size;
- UINT64 AttributesSupported;
- UINT64 AttributesSetting;
- UINT64 Compatibilities;
- UINT32 LowestSupportedImageVersion;
- UINT32 LastAttemptVersion;
- UINT32 LastAttemptStatus;
- UINT8 Reserved3[4];
- UINT64 HardwareInstance;
+ UINT8 ImageIndex;
+ UINT8 Reserved[3];
+ EFI_GUID ImageTypeId;
+ UINT64 ImageId;
+ UINT32 ImageIdNameStringOffset; // Offset from head, CHAR16 string including NULL terminate char
+ UINT32 Version;
+ UINT32 VersionNameStringOffset; // Offset from head, CHAR16 string including NULL terminate char
+ UINT8 Reserved2[4];
+ UINT64 Size;
+ UINT64 AttributesSupported;
+ UINT64 AttributesSetting;
+ UINT64 Compatibilities;
+ UINT32 LowestSupportedImageVersion;
+ UINT32 LastAttemptVersion;
+ UINT32 LastAttemptStatus;
+ 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()
@@ -138,8 +137,8 @@ typedef struct { +----------------------+
**/
-extern EFI_GUID gEdkiiSystemFirmwareImageDescriptorFileGuid;
-extern EFI_GUID gEdkiiSystemFmpCapsuleConfigFileGuid;
-extern EFI_GUID gEdkiiSystemFmpCapsuleDriverFvFileGuid;
+extern EFI_GUID gEdkiiSystemFirmwareImageDescriptorFileGuid;
+extern EFI_GUID gEdkiiSystemFmpCapsuleConfigFileGuid;
+extern EFI_GUID gEdkiiSystemFmpCapsuleDriverFvFileGuid;
#endif
diff --git a/SignedCapsulePkg/Include/Library/EdkiiSystemCapsuleLib.h b/SignedCapsulePkg/Include/Library/EdkiiSystemCapsuleLib.h index 7c4359b..6b4fb3c 100644 --- a/SignedCapsulePkg/Include/Library/EdkiiSystemCapsuleLib.h +++ b/SignedCapsulePkg/Include/Library/EdkiiSystemCapsuleLib.h @@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#ifndef __EDKII_SYSTEM_CAPSULE_LIB_H__
#define __EDKII_SYSTEM_CAPSULE_LIB_H__
@@ -26,10 +25,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent BOOLEAN
EFIAPI
ExtractSystemFirmwareImageFmpInfo (
- IN VOID *SystemFirmwareImage,
- IN UINTN SystemFirmwareImageSize,
- OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **ImageFmpInfo,
- OUT UINTN *ImageFmpInfoSize
+ IN VOID *SystemFirmwareImage,
+ IN UINTN SystemFirmwareImageSize,
+ OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **ImageFmpInfo,
+ OUT UINTN *ImageFmpInfoSize
);
/**
@@ -46,10 +45,10 @@ ExtractSystemFirmwareImageFmpInfo ( BOOLEAN
EFIAPI
ExtractDriverFvImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **DriverFvImage,
- OUT UINTN *DriverFvImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **DriverFvImage,
+ OUT UINTN *DriverFvImageSize
);
/**
@@ -66,10 +65,10 @@ ExtractDriverFvImage ( BOOLEAN
EFIAPI
ExtractConfigImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **ConfigImage,
- OUT UINTN *ConfigImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **ConfigImage,
+ OUT UINTN *ConfigImageSize
);
/**
@@ -86,10 +85,10 @@ ExtractConfigImage ( BOOLEAN
EFIAPI
ExtractSystemFirmwareImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **SystemFirmwareImage,
- OUT UINTN *SystemFirmwareImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **SystemFirmwareImage,
+ OUT UINTN *SystemFirmwareImageSize
);
/**
@@ -107,11 +106,11 @@ ExtractSystemFirmwareImage ( BOOLEAN
EFIAPI
ExtractAuthenticatedImage (
- IN VOID *Image,
- IN UINTN ImageSize,
- OUT UINT32 *LastAttemptStatus,
- OUT VOID **AuthenticatedImage,
- OUT UINTN *AuthenticatedImageSize
+ IN VOID *Image,
+ IN UINTN ImageSize,
+ OUT UINT32 *LastAttemptStatus,
+ OUT VOID **AuthenticatedImage,
+ OUT UINTN *AuthenticatedImageSize
);
/**
@@ -135,14 +134,13 @@ ExtractAuthenticatedImage ( EFI_STATUS
EFIAPI
CapsuleAuthenticateSystemFirmware (
- IN VOID *Image,
- IN UINTN ImageSize,
- IN BOOLEAN ForceVersionMatch,
- OUT UINT32 *LastAttemptVersion,
- OUT UINT32 *LastAttemptStatus,
- OUT VOID **AuthenticatedImage,
- OUT UINTN *AuthenticatedImageSize
+ IN VOID *Image,
+ IN UINTN ImageSize,
+ IN BOOLEAN ForceVersionMatch,
+ OUT UINT32 *LastAttemptVersion,
+ OUT UINT32 *LastAttemptStatus,
+ OUT VOID **AuthenticatedImage,
+ OUT UINTN *AuthenticatedImageSize
);
#endif
-
diff --git a/SignedCapsulePkg/Include/Library/IniParsingLib.h b/SignedCapsulePkg/Include/Library/IniParsingLib.h index edfdde7..70b1494 100644 --- a/SignedCapsulePkg/Include/Library/IniParsingLib.h +++ b/SignedCapsulePkg/Include/Library/IniParsingLib.h @@ -24,7 +24,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#ifndef __INI_PARSING_LIB_H__
#define __INI_PARSING_LIB_H__
@@ -41,8 +40,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent VOID *
EFIAPI
OpenIniFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize
);
/**
@@ -59,10 +58,10 @@ OpenIniFile ( EFI_STATUS
EFIAPI
GetStringFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT CHAR8 **EntryValue
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT CHAR8 **EntryValue
);
/**
@@ -79,10 +78,10 @@ GetStringFromDataFile ( EFI_STATUS
EFIAPI
GetGuidFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT EFI_GUID *Guid
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT EFI_GUID *Guid
);
/**
@@ -99,10 +98,10 @@ GetGuidFromDataFile ( EFI_STATUS
EFIAPI
GetDecimalUintnFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINTN *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINTN *Data
);
/**
@@ -119,10 +118,10 @@ GetDecimalUintnFromDataFile ( EFI_STATUS
EFIAPI
GetHexUintnFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINTN *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINTN *Data
);
/**
@@ -139,10 +138,10 @@ GetHexUintnFromDataFile ( EFI_STATUS
EFIAPI
GetHexUint64FromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINT64 *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINT64 *Data
);
/**
@@ -153,8 +152,7 @@ GetHexUint64FromDataFile ( VOID
EFIAPI
CloseIniFile (
- IN VOID *Context
+ IN VOID *Context
);
#endif
-
diff --git a/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h b/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h index ea269ea..fe3cf0a 100644 --- a/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h +++ b/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h @@ -6,7 +6,6 @@ **/
-
#ifndef __PLATFORM_FLASH_ACCESS_LIB_H__
#define __PLATFORM_FLASH_ACCESS_LIB_H__
@@ -43,11 +42,11 @@ typedef enum { EFI_STATUS
EFIAPI
PerformFlashWrite (
- IN PLATFORM_FIRMWARE_TYPE FirmwareType,
- IN EFI_PHYSICAL_ADDRESS FlashAddress,
- IN FLASH_ADDRESS_TYPE FlashAddressType,
- IN VOID *Buffer,
- IN UINTN Length
+ IN PLATFORM_FIRMWARE_TYPE FirmwareType,
+ IN EFI_PHYSICAL_ADDRESS FlashAddress,
+ IN FLASH_ADDRESS_TYPE FlashAddressType,
+ IN VOID *Buffer,
+ IN UINTN Length
);
/**
diff --git a/SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c b/SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c index 0f1444b..d65d988 100644 --- a/SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c +++ b/SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.c @@ -30,9 +30,9 @@ #include <Protocol/FirmwareManagement.h>
-EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *mImageFmpInfo;
-UINTN mImageFmpInfoSize;
-EFI_GUID mEdkiiSystemFirmwareFileGuid;
+EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *mImageFmpInfo;
+UINTN mImageFmpInfoSize;
+EFI_GUID mEdkiiSystemFirmwareFileGuid;
/**
Check if a block of buffer is erased.
@@ -46,16 +46,16 @@ EFI_GUID mEdkiiSystemFirmwareFileGuid; **/
BOOLEAN
IsBufferErased (
- IN UINT8 ErasePolarity,
- IN VOID *InBuffer,
- IN UINTN BufferSize
+ IN UINT8 ErasePolarity,
+ IN VOID *InBuffer,
+ IN UINTN BufferSize
)
{
- UINTN Count;
- UINT8 EraseByte;
- UINT8 *Buffer;
+ UINTN Count;
+ UINT8 EraseByte;
+ UINT8 *Buffer;
- if(ErasePolarity == 1) {
+ if (ErasePolarity == 1) {
EraseByte = 0xFF;
} else {
EraseByte = 0;
@@ -86,17 +86,17 @@ IsBufferErased ( **/
BOOLEAN
GetSectionByType (
- IN VOID *SectionBuffer,
- IN UINT32 SectionBufferSize,
- IN EFI_SECTION_TYPE SectionType,
- IN UINTN SectionInstance,
- OUT VOID **OutSectionBuffer,
- OUT UINTN *OutSectionSize
+ IN VOID *SectionBuffer,
+ IN UINT32 SectionBufferSize,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ OUT VOID **OutSectionBuffer,
+ OUT UINTN *OutSectionSize
)
{
- EFI_COMMON_SECTION_HEADER *SectionHeader;
- UINTN SectionSize;
- UINTN Instance;
+ EFI_COMMON_SECTION_HEADER *SectionHeader;
+ UINTN SectionSize;
+ UINTN Instance;
DEBUG ((DEBUG_INFO, "GetSectionByType - Buffer: 0x%08x - 0x%08x\n", SectionBuffer, SectionBufferSize));
@@ -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));
+ *OutSectionSize = SectionSize;
+ 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;
@@ -155,25 +155,25 @@ GetSectionByType ( **/
BOOLEAN
GetFfsByName (
- IN VOID *FdStart,
- IN UINTN FdSize,
- IN EFI_GUID *FileName,
- IN EFI_FV_FILETYPE Type,
- OUT VOID **OutFfsBuffer,
- OUT UINTN *OutFfsBufferSize
+ IN VOID *FdStart,
+ IN UINTN FdSize,
+ IN EFI_GUID *FileName,
+ IN EFI_FV_FILETYPE Type,
+ OUT VOID **OutFfsBuffer,
+ OUT UINTN *OutFfsBufferSize
)
{
- UINTN FvSize;
- EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
- EFI_FIRMWARE_VOLUME_EXT_HEADER *FvExtHeader;
- EFI_FFS_FILE_HEADER *FfsHeader;
- UINT32 FfsSize;
- UINTN TestLength;
- BOOLEAN FvFound;
+ UINTN FvSize;
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FvExtHeader;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ UINT32 FfsSize;
+ UINTN TestLength;
+ BOOLEAN FvFound;
DEBUG ((DEBUG_INFO, "GetFfsByName - FV: 0x%08x - 0x%08x\n", (UINTN)FdStart, (UINTN)FdSize));
- FvFound = FALSE;
+ FvFound = FALSE;
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FdStart;
while ((UINTN)FvHeader < (UINTN)FdStart + FdSize - 1) {
FvSize = (UINTN)FdStart + FdSize - (UINTN)FvHeader;
@@ -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;
//
@@ -195,44 +197,47 @@ GetFfsByName ( //
if (FvHeader->ExtHeaderOffset != 0) {
FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)((UINT8 *)FvHeader + FvHeader->ExtHeaderOffset);
- FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvExtHeader + FvExtHeader->ExtHeaderSize);
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvExtHeader + FvExtHeader->ExtHeaderSize);
} 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))) {
- *OutFfsBuffer = FfsHeader;
+ if (CompareGuid (FileName, &FfsHeader->Name) &&
+ ((Type == EFI_FV_FILETYPE_ALL) || (FfsHeader->Type == Type)))
+ {
+ *OutFfsBuffer = FfsHeader;
*OutFfsBufferSize = FfsSize;
return TRUE;
} else {
//
// 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;
}
@@ -261,29 +267,30 @@ GetFfsByName ( BOOLEAN
EFIAPI
ExtractDriverFvImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **DriverFvImage,
- OUT UINTN *DriverFvImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **DriverFvImage,
+ OUT UINTN *DriverFvImageSize
)
{
- BOOLEAN Result;
- UINT32 FileHeaderSize;
+ BOOLEAN Result;
+ UINT32 FileHeaderSize;
- *DriverFvImage = NULL;
+ *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;
+
+ *DriverFvImage = (UINT8 *)*DriverFvImage + FileHeaderSize;
*DriverFvImageSize = *DriverFvImageSize - FileHeaderSize;
return Result;
@@ -303,29 +310,30 @@ ExtractDriverFvImage ( BOOLEAN
EFIAPI
ExtractConfigImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **ConfigImage,
- OUT UINTN *ConfigImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **ConfigImage,
+ OUT UINTN *ConfigImageSize
)
{
- BOOLEAN Result;
- UINT32 FileHeaderSize;
+ BOOLEAN Result;
+ UINT32 FileHeaderSize;
- *ConfigImage = NULL;
+ *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;
+
+ *ConfigImage = (UINT8 *)*ConfigImage + FileHeaderSize;
*ConfigImageSize = *ConfigImageSize - FileHeaderSize;
return Result;
@@ -348,20 +356,20 @@ ExtractConfigImage ( BOOLEAN
EFIAPI
ExtractAuthenticatedImage (
- IN VOID *Image,
- IN UINTN ImageSize,
- OUT UINT32 *LastAttemptStatus,
- OUT VOID **AuthenticatedImage,
- OUT UINTN *AuthenticatedImageSize
+ IN VOID *Image,
+ IN UINTN ImageSize,
+ OUT UINT32 *LastAttemptStatus,
+ OUT VOID **AuthenticatedImage,
+ OUT UINTN *AuthenticatedImageSize
)
{
- EFI_FIRMWARE_IMAGE_AUTHENTICATION *ImageAuth;
- EFI_STATUS Status;
- GUID *CertType;
- VOID *PublicKeyData;
- UINTN PublicKeyDataLength;
+ EFI_FIRMWARE_IMAGE_AUTHENTICATION *ImageAuth;
+ EFI_STATUS Status;
+ GUID *CertType;
+ 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,82 +377,91 @@ 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));
-
- if (CompareGuid(&gEfiCertPkcs7Guid, CertType)) {
- PublicKeyData = PcdGetPtr(PcdPkcs7CertBuffer);
- PublicKeyDataLength = PcdGetSize(PcdPkcs7CertBuffer);
- } else if (CompareGuid(&gEfiCertTypeRsa2048Sha256Guid, CertType)) {
- PublicKeyData = PcdGetPtr(PcdRsa2048Sha256PublicKeyBuffer);
- PublicKeyDataLength = PcdGetSize(PcdRsa2048Sha256PublicKeyBuffer);
+ 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);
} else {
return FALSE;
}
+
ASSERT (PublicKeyData != NULL);
ASSERT (PublicKeyDataLength != 0);
- Status = AuthenticateFmpImage(
+ Status = AuthenticateFmpImage (
ImageAuth,
ImageSize,
PublicKeyData,
PublicKeyDataLength
);
switch (Status) {
- case RETURN_SUCCESS:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
- break;
- case RETURN_SECURITY_VIOLATION:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR;
- break;
- case RETURN_INVALID_PARAMETER:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
- break;
- case RETURN_UNSUPPORTED:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
- break;
- case RETURN_OUT_OF_RESOURCES:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES;
- break;
- default:
- *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
- break;
- }
- if (EFI_ERROR(Status)) {
+ case RETURN_SUCCESS:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
+ break;
+ case RETURN_SECURITY_VIOLATION:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR;
+ break;
+ case RETURN_INVALID_PARAMETER:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
+ break;
+ case RETURN_UNSUPPORTED:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT;
+ break;
+ case RETURN_OUT_OF_RESOURCES:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES;
+ break;
+ default:
+ *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
+ break;
+ }
+
+ 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;
}
@@ -462,41 +479,45 @@ ExtractAuthenticatedImage ( BOOLEAN
EFIAPI
ExtractSystemFirmwareImageFmpInfo (
- IN VOID *SystemFirmwareImage,
- IN UINTN SystemFirmwareImageSize,
- OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **ImageFmpInfo,
- OUT UINTN *ImageFmpInfoSize
+ IN VOID *SystemFirmwareImage,
+ IN UINTN SystemFirmwareImageSize,
+ OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **ImageFmpInfo,
+ OUT UINTN *ImageFmpInfoSize
)
{
- BOOLEAN Result;
- UINT32 SectionHeaderSize;
- UINT32 FileHeaderSize;
+ BOOLEAN Result;
+ UINT32 SectionHeaderSize;
+ UINT32 FileHeaderSize;
- *ImageFmpInfo = NULL;
+ *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);
+
+ *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);
+
+ *ImageFmpInfo = (VOID *)((UINT8 *)*ImageFmpInfo + SectionHeaderSize);
*ImageFmpInfoSize = *ImageFmpInfoSize - SectionHeaderSize;
return TRUE;
@@ -516,32 +537,34 @@ ExtractSystemFirmwareImageFmpInfo ( BOOLEAN
EFIAPI
ExtractSystemFirmwareImage (
- IN VOID *AuthenticatedImage,
- IN UINTN AuthenticatedImageSize,
- OUT VOID **SystemFirmwareImage,
- OUT UINTN *SystemFirmwareImageSize
+ IN VOID *AuthenticatedImage,
+ IN UINTN AuthenticatedImageSize,
+ OUT VOID **SystemFirmwareImage,
+ OUT UINTN *SystemFirmwareImageSize
)
{
- BOOLEAN Result;
- UINT32 FileHeaderSize;
+ BOOLEAN Result;
+ UINT32 FileHeaderSize;
- *SystemFirmwareImage = NULL;
+ *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;
+ *SystemFirmwareImage = AuthenticatedImage;
*SystemFirmwareImageSize = AuthenticatedImageSize;
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;
+
+ *SystemFirmwareImage = (UINT8 *)*SystemFirmwareImage + FileHeaderSize;
*SystemFirmwareImageSize = *SystemFirmwareImageSize - FileHeaderSize;
return Result;
@@ -568,22 +591,22 @@ ExtractSystemFirmwareImage ( EFI_STATUS
EFIAPI
CapsuleAuthenticateSystemFirmware (
- IN VOID *Image,
- IN UINTN ImageSize,
- IN BOOLEAN ForceVersionMatch,
- OUT UINT32 *LastAttemptVersion,
- OUT UINT32 *LastAttemptStatus,
- OUT VOID **AuthenticatedImage,
- OUT UINTN *AuthenticatedImageSize
+ IN VOID *Image,
+ IN UINTN ImageSize,
+ IN BOOLEAN ForceVersionMatch,
+ OUT UINT32 *LastAttemptVersion,
+ OUT UINT32 *LastAttemptStatus,
+ OUT VOID **AuthenticatedImage,
+ OUT UINTN *AuthenticatedImageSize
)
{
- BOOLEAN Result;
- EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageFmpInfo;
- UINTN ImageFmpInfoSize;
- EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageFmpInfo;
- UINTN CurrentImageFmpInfoSize;
- VOID *SystemFirmwareImage;
- UINTN SystemFirmwareImageSize;
+ BOOLEAN Result;
+ EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageFmpInfo;
+ UINTN ImageFmpInfoSize;
+ EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageFmpInfo;
+ UINTN CurrentImageFmpInfoSize;
+ VOID *SystemFirmwareImage;
+ UINTN SystemFirmwareImageSize;
*LastAttemptVersion = 0;
@@ -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;
+ 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;
}
}
@@ -661,17 +685,18 @@ CapsuleAuthenticateSystemFirmware ( VOID
EFIAPI
EdkiiSystemCapsuleLibPcdCallBack (
- IN CONST GUID *CallBackGuid OPTIONAL,
- IN UINTN CallBackToken,
- IN OUT VOID *TokenData,
- IN UINTN TokenDataSize
+ IN CONST GUID *CallBackGuid OPTIONAL,
+ IN UINTN CallBackToken,
+ IN OUT VOID *TokenData,
+ IN UINTN TokenDataSize
)
{
if (CompareGuid (CallBackGuid, &gEfiSignedCapsulePkgTokenSpaceGuid) &&
- CallBackToken == PcdToken (PcdEdkiiSystemFirmwareImageDescriptor)) {
+ (CallBackToken == PcdToken (PcdEdkiiSystemFirmwareImageDescriptor)))
+ {
mImageFmpInfoSize = TokenDataSize;
- mImageFmpInfo = AllocateCopyPool (mImageFmpInfoSize, TokenData);
- ASSERT(mImageFmpInfo != NULL);
+ mImageFmpInfo = AllocateCopyPool (mImageFmpInfoSize, TokenData);
+ 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;
}
diff --git a/SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c b/SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c index bea45e0..0a44131 100644 --- a/SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c +++ b/SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.c @@ -37,30 +37,30 @@ #include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
-#define IS_HYPHEN(a) ((a) == '-')
-#define IS_NULL(a) ((a) == '\0')
+#define IS_HYPHEN(a) ((a) == '-')
+#define IS_NULL(a) ((a) == '\0')
// This is default allocation. Reallocation will happen if it is not enough.
-#define MAX_LINE_LENGTH 512
+#define MAX_LINE_LENGTH 512
typedef struct _INI_SECTION_ITEM SECTION_ITEM;
struct _INI_SECTION_ITEM {
- CHAR8 *PtrSection;
- UINTN SecNameLen;
- CHAR8 *PtrEntry;
- CHAR8 *PtrValue;
- SECTION_ITEM *PtrNext;
+ CHAR8 *PtrSection;
+ UINTN SecNameLen;
+ CHAR8 *PtrEntry;
+ CHAR8 *PtrValue;
+ SECTION_ITEM *PtrNext;
};
typedef struct _INI_COMMENT_LINE COMMENT_LINE;
struct _INI_COMMENT_LINE {
- CHAR8 *PtrComment;
- COMMENT_LINE *PtrNext;
+ CHAR8 *PtrComment;
+ COMMENT_LINE *PtrNext;
};
typedef struct {
- SECTION_ITEM *SectionHead;
- COMMENT_LINE *CommentHead;
+ SECTION_ITEM *SectionHead;
+ COMMENT_LINE *CommentHead;
} INI_PARSING_LIB_CONTEXT;
/**
@@ -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;
}
@@ -294,28 +319,30 @@ DumpIniSection ( IN VOID *Context
)
{
- INI_PARSING_LIB_CONTEXT *IniContext;
- SECTION_ITEM *PtrSection;
- SECTION_ITEM *Section;
+ INI_PARSING_LIB_CONTEXT *IniContext;
+ SECTION_ITEM *PtrSection;
+ SECTION_ITEM *Section;
if (Context == NULL) {
return;
}
IniContext = Context;
- Section = IniContext->SectionHead;
+ Section = IniContext->SectionHead;
while (Section != NULL) {
PtrSection = Section;
- Section = Section->PtrNext;
+ 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));
}
}
}
@@ -335,26 +362,27 @@ DumpIniSection ( **/
EFI_STATUS
ProfileGetLine (
- IN UINT8 *Buffer,
- IN UINTN BufferSize,
- IN OUT UINT8 *LineBuffer,
- IN OUT UINTN *LineSize
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize,
+ IN OUT UINT8 *LineBuffer,
+ IN OUT UINTN *LineSize
)
{
- UINTN Length;
- UINT8 *PtrBuf;
- UINTN PtrEnd;
+ UINTN Length;
+ UINT8 *PtrBuf;
+ UINTN PtrEnd;
- PtrBuf = Buffer;
- PtrEnd = (UINTN)Buffer + BufferSize;
+ PtrBuf = Buffer;
+ PtrEnd = (UINTN)Buffer + BufferSize;
//
// 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++;
}
@@ -363,14 +391,14 @@ ProfileGetLine ( // The buffer ends without any line break
// or it is the last character of the buffer
//
- Length = BufferSize;
+ Length = BufferSize;
} else if (*(PtrBuf + 1) == 0x0A) {
//
// 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)) {
@@ -379,7 +407,7 @@ ProfileGetLine ( }
SetMem (LineBuffer, *LineSize, 0x0);
- *LineSize = Length;
+ *LineSize = Length;
CopyMem (LineBuffer, Buffer, Length);
return EFI_SUCCESS;
@@ -396,13 +424,13 @@ ProfileGetLine ( **/
VOID
ProfileTrim (
- IN OUT UINT8 *Buffer,
- IN OUT UINTN *BufferSize
+ IN OUT UINT8 *Buffer,
+ IN OUT UINTN *BufferSize
)
{
- UINTN Length;
- UINT8 *PtrBuf;
- UINT8 *PtrEnd;
+ UINTN Length;
+ UINT8 *PtrBuf;
+ UINT8 *PtrEnd;
if (*BufferSize == 0) {
return;
@@ -411,36 +439,40 @@ ProfileTrim ( //
// Trim the tail first, include CR, LF, TAB, and SPACE.
//
- Length = *BufferSize;
- PtrBuf = (UINT8 *) ((UINTN) Buffer + Length - 1);
+ Length = *BufferSize;
+ 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--;
}
//
// all spaces, a blank line, return directly;
//
if (PtrBuf < Buffer) {
- *BufferSize = 0;
+ *BufferSize = 0;
return;
}
- Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;
- PtrEnd = PtrBuf;
- PtrBuf = Buffer;
+ Length = (UINTN)PtrBuf - (UINTN)Buffer + 1;
+ PtrEnd = PtrBuf;
+ PtrBuf = Buffer;
//
// 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++;
}
@@ -448,18 +480,18 @@ ProfileTrim ( // If no heading CR, LF, TAB or SPACE, directly return
//
if (PtrBuf == Buffer) {
- *BufferSize = Length;
+ *BufferSize = Length;
return;
}
- *BufferSize = (UINTN)PtrEnd - (UINTN)PtrBuf + 1;
+ *BufferSize = (UINTN)PtrEnd - (UINTN)PtrBuf + 1;
//
// The first Buffer..PtrBuf characters are CR, LF, TAB or SPACE.
// Now move out all these characters.
//
while (PtrBuf <= PtrEnd) {
- *Buffer = *PtrBuf;
+ *Buffer = *PtrBuf;
Buffer++;
PtrBuf++;
}
@@ -480,12 +512,12 @@ ProfileTrim ( **/
EFI_STATUS
ProfileGetComments (
- IN UINT8 *Buffer,
- IN UINTN BufferSize,
- IN OUT COMMENT_LINE **CommentHead
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize,
+ IN OUT COMMENT_LINE **CommentHead
)
{
- COMMENT_LINE *CommentItem;
+ COMMENT_LINE *CommentItem;
CommentItem = NULL;
CommentItem = AllocatePool (sizeof (COMMENT_LINE));
@@ -493,8 +525,8 @@ ProfileGetComments ( return EFI_OUT_OF_RESOURCES;
}
- CommentItem->PtrNext = *CommentHead;
- *CommentHead = CommentItem;
+ CommentItem->PtrNext = *CommentHead;
+ *CommentHead = CommentItem;
//
// Add a trailing '\0'
@@ -504,6 +536,7 @@ ProfileGetComments ( FreePool (CommentItem);
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (CommentItem->PtrComment, Buffer, BufferSize);
*(CommentItem->PtrComment + BufferSize) = '\0';
@@ -523,34 +556,37 @@ ProfileGetComments ( **/
EFI_STATUS
ProfileGetSection (
- IN UINT8 *Buffer,
- IN UINTN BufferSize,
- IN OUT SECTION_ITEM **SectionHead
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize,
+ IN OUT SECTION_ITEM **SectionHead
)
{
- SECTION_ITEM *SectionItem;
- UINTN Length;
- UINT8 *PtrBuf;
- UINT8 *PtrEnd;
+ SECTION_ITEM *SectionItem;
+ UINTN Length;
+ UINT8 *PtrBuf;
+ UINT8 *PtrEnd;
- ASSERT(BufferSize >= 1);
+ ASSERT (BufferSize >= 1);
//
// The first character of Buffer is '[', now we want for ']'
//
- PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);
- PtrBuf = (UINT8 *)((UINTN)Buffer + 1);
+ PtrEnd = (UINT8 *)((UINTN)Buffer + BufferSize - 1);
+ PtrBuf = (UINT8 *)((UINTN)Buffer + 1);
while (PtrBuf <= PtrEnd) {
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;
@@ -559,11 +595,11 @@ ProfileGetSection ( //
// excluding the heading '[' and tailing ']'
//
- Length = PtrBuf - Buffer - 1;
+ Length = PtrBuf - Buffer - 1;
ProfileTrim (
Buffer + 1,
&Length
- );
+ );
//
// Invalid line if the section name is null
@@ -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;
}
@@ -620,21 +656,21 @@ ProfileGetSection ( **/
EFI_STATUS
ProfileGetEntry (
- IN UINT8 *Buffer,
- IN UINTN BufferSize,
- IN OUT SECTION_ITEM **SectionHead
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize,
+ IN OUT SECTION_ITEM **SectionHead
)
{
- EFI_STATUS Status;
- SECTION_ITEM *SectionItem;
- SECTION_ITEM *PtrSection;
- UINTN Length;
- UINT8 *PtrBuf;
- UINT8 *PtrEnd;
+ EFI_STATUS Status;
+ SECTION_ITEM *SectionItem;
+ SECTION_ITEM *PtrSection;
+ UINTN Length;
+ UINT8 *PtrBuf;
+ UINT8 *PtrEnd;
- Status = EFI_SUCCESS;
- PtrBuf = Buffer;
- PtrEnd = (UINT8 *) ((UINTN)Buffer + BufferSize - 1);
+ Status = EFI_SUCCESS;
+ PtrBuf = Buffer;
+ 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;
@@ -659,11 +698,11 @@ ProfileGetEntry ( //
// excluding the tailing '='
//
- Length = PtrBuf - Buffer;
+ Length = PtrBuf - Buffer;
ProfileTrim (
Buffer,
&Length
- );
+ );
//
// Invalid line if the entry name is null
@@ -672,7 +711,7 @@ ProfileGetEntry ( return EFI_NOT_FOUND;
}
- if (!IsValidName((CHAR8 *)Buffer, Length)) {
+ if (!IsValidName ((CHAR8 *)Buffer, Length)) {
return EFI_INVALID_PARAMETER;
}
@@ -682,7 +721,8 @@ ProfileGetEntry ( if (*SectionHead == NULL) {
return Status;
}
- PtrSection = *SectionHead;
+
+ PtrSection = *SectionHead;
SectionItem = AllocatePool (sizeof (SECTION_ITEM));
if (SectionItem == NULL) {
@@ -703,6 +743,7 @@ ProfileGetEntry ( if (SectionItem->PtrSection == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem (SectionItem->PtrSection, PtrSection->PtrSection, PtrSection->SecNameLen + 1);
//
@@ -710,47 +751,51 @@ 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';
//
// Next search for '#' or ';'
//
- PtrBuf = PtrBuf + 1;
- Buffer = PtrBuf;
+ 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;
+
+ Length = PtrBuf - Buffer;
ProfileTrim (
Buffer,
&Length
- );
+ );
//
// 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';
@@ -778,34 +824,38 @@ ProfileGetEntry ( **/
VOID
FreeAllList (
- IN SECTION_ITEM *Section,
- IN COMMENT_LINE *Comment
+ IN SECTION_ITEM *Section,
+ IN COMMENT_LINE *Comment
)
{
- SECTION_ITEM *PtrSection;
- COMMENT_LINE *PtrComment;
+ SECTION_ITEM *PtrSection;
+ COMMENT_LINE *PtrComment;
while (Section != NULL) {
- PtrSection = Section;
- Section = Section->PtrNext;
+ PtrSection = Section;
+ Section = Section->PtrNext;
if (PtrSection->PtrEntry != NULL) {
FreePool (PtrSection->PtrEntry);
}
+
if (PtrSection->PtrSection != NULL) {
FreePool (PtrSection->PtrSection);
}
+
if (PtrSection->PtrValue != NULL) {
FreePool (PtrSection->PtrValue);
}
+
FreePool (PtrSection);
}
while (Comment != NULL) {
- PtrComment = Comment;
- Comment = Comment->PtrNext;
+ PtrComment = Comment;
+ Comment = Comment->PtrNext;
if (PtrComment->PtrComment != NULL) {
FreePool (PtrComment->PtrComment);
}
+
FreePool (PtrComment);
}
@@ -826,30 +876,31 @@ FreeAllList ( **/
EFI_STATUS
UpdateGetProfileString (
- IN SECTION_ITEM *Section,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT CHAR8 **EntryValue
+ IN SECTION_ITEM *Section,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT CHAR8 **EntryValue
)
{
- *EntryValue = NULL;
+ *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;
+
+ Section = Section->PtrNext;
}
if (Section == NULL) {
return EFI_NOT_FOUND;
}
- *EntryValue = Section->PtrValue;
+ *EntryValue = Section->PtrValue;
return EFI_SUCCESS;
}
@@ -870,27 +921,27 @@ UpdateGetProfileString ( **/
EFI_STATUS
PreProcessDataFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize,
- IN OUT SECTION_ITEM **SectionHead,
- IN OUT COMMENT_LINE **CommentHead
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize,
+ IN OUT SECTION_ITEM **SectionHead,
+ IN OUT COMMENT_LINE **CommentHead
)
{
- EFI_STATUS Status;
- CHAR8 *Source;
- CHAR8 *CurrentPtr;
- CHAR8 *BufferEnd;
- CHAR8 *PtrLine;
- UINTN LineLength;
- UINTN SourceLength;
- UINTN MaxLineLength;
-
- *SectionHead = NULL;
- *CommentHead = NULL;
- BufferEnd = (CHAR8 *) ( (UINTN) DataBuffer + BufferSize);
- CurrentPtr = (CHAR8 *) DataBuffer;
- MaxLineLength = MAX_LINE_LENGTH;
- Status = EFI_SUCCESS;
+ EFI_STATUS Status;
+ CHAR8 *Source;
+ CHAR8 *CurrentPtr;
+ CHAR8 *BufferEnd;
+ CHAR8 *PtrLine;
+ UINTN LineLength;
+ UINTN SourceLength;
+ UINTN MaxLineLength;
+
+ *SectionHead = NULL;
+ *CommentHead = NULL;
+ BufferEnd = (CHAR8 *)((UINTN)DataBuffer + BufferSize);
+ CurrentPtr = (CHAR8 *)DataBuffer;
+ MaxLineLength = MAX_LINE_LENGTH;
+ Status = EFI_SUCCESS;
PtrLine = AllocatePool (MaxLineLength);
if (PtrLine == NULL) {
@@ -898,19 +949,19 @@ PreProcessDataFile ( }
while (CurrentPtr < BufferEnd) {
- Source = CurrentPtr;
- SourceLength = (UINTN)BufferEnd - (UINTN)CurrentPtr;
- LineLength = MaxLineLength;
+ Source = CurrentPtr;
+ SourceLength = (UINTN)BufferEnd - (UINTN)CurrentPtr;
+ LineLength = MaxLineLength;
//
// With the assumption that line length is less than 512
// characters. Otherwise BUFFER_TOO_SMALL will be returned.
//
- Status = ProfileGetLine (
- (UINT8 *) Source,
- SourceLength,
- (UINT8 *) PtrLine,
- &LineLength
- );
+ Status = ProfileGetLine (
+ (UINT8 *)Source,
+ SourceLength,
+ (UINT8 *)PtrLine,
+ &LineLength
+ );
if (EFI_ERROR (Status)) {
if (Status == EFI_BUFFER_TOO_SMALL) {
//
@@ -918,36 +969,39 @@ PreProcessDataFile ( // to the returned LineLength and try again.
//
FreePool (PtrLine);
- PtrLine = NULL;
+ PtrLine = NULL;
PtrLine = AllocatePool (LineLength);
if (PtrLine == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
break;
}
- SourceLength = LineLength;
- Status = ProfileGetLine (
- (UINT8 *) Source,
- SourceLength,
- (UINT8 *) PtrLine,
- &LineLength
- );
+
+ SourceLength = LineLength;
+ Status = ProfileGetLine (
+ (UINT8 *)Source,
+ SourceLength,
+ (UINT8 *)PtrLine,
+ &LineLength
+ );
if (EFI_ERROR (Status)) {
break;
}
- MaxLineLength = LineLength;
+
+ 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
- );
+ );
//
// Blank line
@@ -956,24 +1010,24 @@ PreProcessDataFile ( continue;
}
- if (PtrLine[0] == '#' || PtrLine[0] == ';') {
- Status = ProfileGetComments (
- (UINT8 *) PtrLine,
- LineLength,
- CommentHead
- );
+ if ((PtrLine[0] == '#') || (PtrLine[0] == ';')) {
+ Status = ProfileGetComments (
+ (UINT8 *)PtrLine,
+ LineLength,
+ CommentHead
+ );
} else if (PtrLine[0] == '[') {
- Status = ProfileGetSection (
- (UINT8 *) PtrLine,
- LineLength,
- SectionHead
- );
+ Status = ProfileGetSection (
+ (UINT8 *)PtrLine,
+ LineLength,
+ SectionHead
+ );
} else {
- Status = ProfileGetEntry (
- (UINT8 *) PtrLine,
- LineLength,
- SectionHead
- );
+ Status = ProfileGetEntry (
+ (UINT8 *)PtrLine,
+ LineLength,
+ SectionHead
+ );
}
if (EFI_ERROR (Status)) {
@@ -1002,18 +1056,18 @@ PreProcessDataFile ( VOID *
EFIAPI
OpenIniFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize
)
{
- EFI_STATUS Status;
- INI_PARSING_LIB_CONTEXT *IniContext;
+ 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,29 +1105,29 @@ OpenIniFile ( **/
EFI_STATUS
EFIAPI
-GetStringFromDataFile(
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT CHAR8 **EntryValue
+GetStringFromDataFile (
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT CHAR8 **EntryValue
)
{
- INI_PARSING_LIB_CONTEXT *IniContext;
- EFI_STATUS Status;
+ 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;
}
IniContext = Context;
- *EntryValue = NULL;
- Status = UpdateGetProfileString (
- IniContext->SectionHead,
- SectionName,
- EntryName,
- EntryValue
- );
+ *EntryValue = NULL;
+ Status = UpdateGetProfileString (
+ IniContext->SectionHead,
+ SectionName,
+ EntryName,
+ EntryValue
+ );
return Status;
}
@@ -1090,34 +1145,36 @@ GetStringFromDataFile( EFI_STATUS
EFIAPI
GetGuidFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT EFI_GUID *Guid
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT EFI_GUID *Guid
)
{
- CHAR8 *Value;
- EFI_STATUS Status;
- RETURN_STATUS RStatus;
+ CHAR8 *Value;
+ 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;
}
@@ -1135,33 +1192,35 @@ GetGuidFromDataFile ( EFI_STATUS
EFIAPI
GetDecimalUintnFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINTN *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINTN *Data
)
{
- CHAR8 *Value;
- EFI_STATUS Status;
+ 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;
}
@@ -1179,33 +1238,35 @@ GetDecimalUintnFromDataFile ( EFI_STATUS
EFIAPI
GetHexUintnFromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINTN *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINTN *Data
)
{
- CHAR8 *Value;
- EFI_STATUS Status;
+ 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;
}
@@ -1223,33 +1284,35 @@ GetHexUintnFromDataFile ( EFI_STATUS
EFIAPI
GetHexUint64FromDataFile (
- IN VOID *Context,
- IN CHAR8 *SectionName,
- IN CHAR8 *EntryName,
- OUT UINT64 *Data
+ IN VOID *Context,
+ IN CHAR8 *SectionName,
+ IN CHAR8 *EntryName,
+ OUT UINT64 *Data
)
{
- CHAR8 *Value;
- EFI_STATUS Status;
+ 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;
}
@@ -1261,17 +1324,17 @@ GetHexUint64FromDataFile ( VOID
EFIAPI
CloseIniFile (
- IN VOID *Context
+ IN VOID *Context
)
{
- INI_PARSING_LIB_CONTEXT *IniContext;
+ INI_PARSING_LIB_CONTEXT *IniContext;
if (Context == NULL) {
- return ;
+ return;
}
IniContext = Context;
- FreeAllList(IniContext->SectionHead, IniContext->CommentHead);
+ FreeAllList (IniContext->SectionHead, IniContext->CommentHead);
return;
}
diff --git a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c index fd89a52..1a73b5d 100644 --- a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c +++ b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c @@ -11,7 +11,7 @@ #include <Library/BaseMemoryLib.h>
#include <Library/PlatformFlashAccessLib.h>
-UINT64 mInternalFdAddress;
+UINT64 mInternalFdAddress;
/**
Perform flash write operation with progress indicator. The start and end
@@ -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;
}
@@ -80,11 +81,11 @@ PerformFlashWriteWithProgress ( EFI_STATUS
EFIAPI
PerformFlashWrite (
- IN PLATFORM_FIRMWARE_TYPE FirmwareType,
- IN EFI_PHYSICAL_ADDRESS FlashAddress,
- IN FLASH_ADDRESS_TYPE FlashAddressType,
- IN VOID *Buffer,
- IN UINTN Length
+ IN PLATFORM_FIRMWARE_TYPE FirmwareType,
+ IN EFI_PHYSICAL_ADDRESS FlashAddress,
+ IN FLASH_ADDRESS_TYPE FlashAddressType,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
return PerformFlashWriteWithProgress (
diff --git a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c index 5cd690d..3d4066f 100644 --- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c +++ b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/ParseConfigProfile.c @@ -12,7 +12,7 @@ #include <Library/IniParsingLib.h>
#include <Library/PrintLib.h>
-#define MAX_LINE_LENGTH 512
+#define MAX_LINE_LENGTH 512
/**
Parse Config data file to get the updated data array.
@@ -29,24 +29,24 @@ **/
EFI_STATUS
ParseRecoveryDataFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize,
- IN OUT CONFIG_HEADER *ConfigHeader,
- IN OUT RECOVERY_CONFIG_DATA **RecoveryArray
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize,
+ IN OUT CONFIG_HEADER *ConfigHeader,
+ IN OUT RECOVERY_CONFIG_DATA **RecoveryArray
)
{
- EFI_STATUS Status;
- CHAR8 *SectionName;
- CHAR8 Entry[MAX_LINE_LENGTH];
- UINTN Num;
- UINTN Index;
- EFI_GUID FileGuid;
- VOID *Context;
+ EFI_STATUS Status;
+ CHAR8 *SectionName;
+ CHAR8 Entry[MAX_LINE_LENGTH];
+ UINTN Num;
+ UINTN Index;
+ EFI_GUID FileGuid;
+ VOID *Context;
//
// 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));
+ *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;
}
-
diff --git a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c index d275ef6..b361e90 100644 --- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c +++ b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c @@ -59,15 +59,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent EFI_STATUS
EFIAPI
LoadRecoveryCapsule (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_MODULE_PPI *This
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_MODULE_PPI *This
);
-EFI_PEI_RECOVERY_MODULE_PPI mRecoveryPpi = {
+EFI_PEI_RECOVERY_MODULE_PPI mRecoveryPpi = {
LoadRecoveryCapsule
};
-EFI_PEI_PPI_DESCRIPTOR mRecoveryPpiList = {
+EFI_PEI_PPI_DESCRIPTOR mRecoveryPpiList = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiRecoveryModulePpiGuid,
&mRecoveryPpi
@@ -88,10 +88,10 @@ EFI_PEI_PPI_DESCRIPTOR mRecoveryPpiList = { **/
EFI_STATUS
ParseRecoveryDataFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize,
- IN OUT CONFIG_HEADER *ConfigHeader,
- IN OUT RECOVERY_CONFIG_DATA **RecoveryArray
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize,
+ IN OUT CONFIG_HEADER *ConfigHeader,
+ IN OUT RECOVERY_CONFIG_DATA **RecoveryArray
);
/**
@@ -104,18 +104,18 @@ ParseRecoveryDataFile ( **/
BOOLEAN
IsSystemFmpImage (
- IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *FmpImageHeader
+ IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *FmpImageHeader
)
{
- GUID *Guid;
- UINTN Count;
- UINTN Index;
+ GUID *Guid;
+ 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;
}
@@ -159,16 +159,16 @@ IsFmpCapsuleGuid ( **/
BOOLEAN
IsSystemFmpCapsuleImage (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
- EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
- EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
- UINT64 *ItemOffsetList;
- UINT32 ItemNum;
- UINTN Index;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
+ UINT64 *ItemOffsetList;
+ 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;
@@ -183,8 +183,8 @@ IsSystemFmpCapsuleImage ( ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
for (Index = 0; Index < ItemNum; Index++) {
- ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
- if (!IsSystemFmpImage(ImageHeader)) {
+ ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
+ 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;
}
@@ -240,69 +242,73 @@ IsValidCapsuleHeader ( **/
EFI_STATUS
ValidateFmpCapsule (
- IN EFI_CAPSULE_HEADER *CapsuleHeader,
- OUT BOOLEAN *IsSystemFmp OPTIONAL,
- OUT UINT16 *EmbeddedDriverCount OPTIONAL
+ IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ OUT BOOLEAN *IsSystemFmp OPTIONAL,
+ OUT UINT16 *EmbeddedDriverCount OPTIONAL
)
{
- EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
- UINT8 *EndOfCapsule;
- EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
- UINT8 *EndOfPayload;
- UINT64 *ItemOffsetList;
- UINT32 ItemNum;
- UINTN Index;
- UINTN FmpCapsuleSize;
- UINTN FmpCapsuleHeaderSize;
- UINT64 FmpImageSize;
- UINTN FmpImageHeaderSize;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
+ UINT8 *EndOfCapsule;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
+ UINT8 *EndOfPayload;
+ UINT64 *ItemOffsetList;
+ UINT32 ItemNum;
+ UINTN Index;
+ UINTN FmpCapsuleSize;
+ UINTN FmpCapsuleHeaderSize;
+ UINT64 FmpImageSize;
+ 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;
}
}
@@ -310,37 +316,41 @@ ValidateFmpCapsule ( // Check EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER
for (Index = FmpCapsuleHeader->EmbeddedDriverCount; Index < ItemNum; Index++) {
- ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
+ ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
if (Index == ItemNum - 1) {
EndOfPayload = (UINT8 *)((UINTN)EndOfCapsule - (UINTN)FmpCapsuleHeader);
} 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);
@@ -411,8 +422,8 @@ InitializeRecoveryModule ( EFI_STATUS
EFIAPI
CreateHobForRecoveryCapsule (
- IN VOID *FvImage,
- IN UINTN FvImageSize
+ IN VOID *FvImage,
+ IN UINTN FvImageSize
)
{
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
@@ -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,
@@ -489,47 +503,48 @@ CreateHobForRecoveryCapsule ( **/
EFI_STATUS
RecoverImage (
- IN VOID *SystemFirmwareImage,
- IN UINTN SystemFirmwareImageSize,
- IN VOID *ConfigImage,
- IN UINTN ConfigImageSize
+ IN VOID *SystemFirmwareImage,
+ IN UINTN SystemFirmwareImageSize,
+ IN VOID *ConfigImage,
+ IN UINTN ConfigImageSize
)
{
- EFI_STATUS Status;
- RECOVERY_CONFIG_DATA *ConfigData;
- RECOVERY_CONFIG_DATA *RecoveryConfigData;
- CONFIG_HEADER ConfigHeader;
- UINTN Index;
+ EFI_STATUS Status;
+ RECOVERY_CONFIG_DATA *ConfigData;
+ RECOVERY_CONFIG_DATA *RecoveryConfigData;
+ CONFIG_HEADER ConfigHeader;
+ UINTN Index;
if (ConfigImage == NULL) {
- DEBUG((DEBUG_INFO, "RecoverImage (NoConfig)\n"));
- Status = CreateHobForRecoveryCapsule(
+ DEBUG ((DEBUG_INFO, "RecoverImage (NoConfig)\n"));
+ Status = CreateHobForRecoveryCapsule (
SystemFirmwareImage,
SystemFirmwareImageSize
);
return Status;
}
- ConfigData = NULL;
- ZeroMem (&ConfigHeader, sizeof(ConfigHeader));
- Status = ParseRecoveryDataFile (
- ConfigImage,
- ConfigImageSize,
- &ConfigHeader,
- &ConfigData
- );
- DEBUG((DEBUG_INFO, "ParseRecoveryDataFile - %r\n", Status));
- if (EFI_ERROR(Status)) {
+ ConfigData = NULL;
+ ZeroMem (&ConfigHeader, sizeof (ConfigHeader));
+ Status = ParseRecoveryDataFile (
+ ConfigImage,
+ ConfigImageSize,
+ &ConfigHeader,
+ &ConfigData
+ );
+ 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)));
- Index = 0;
+ 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++;
@@ -569,31 +584,31 @@ ProcessRecoveryImage ( IN UINTN Length
)
{
- UINT32 LastAttemptVersion;
- UINT32 LastAttemptStatus;
- EFI_STATUS Status;
- VOID *SystemFirmwareImage;
- UINTN SystemFirmwareImageSize;
- VOID *ConfigImage;
- UINTN ConfigImageSize;
- VOID *AuthenticatedImage;
- UINTN AuthenticatedImageSize;
+ UINT32 LastAttemptVersion;
+ UINT32 LastAttemptStatus;
+ EFI_STATUS Status;
+ VOID *SystemFirmwareImage;
+ UINTN SystemFirmwareImageSize;
+ VOID *ConfigImage;
+ UINTN ConfigImageSize;
+ VOID *AuthenticatedImage;
+ UINTN AuthenticatedImageSize;
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;
}
@@ -636,7 +651,7 @@ ProcessFmpCapsuleImage ( }
FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
- ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
+ ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
for (ItemIndex = 0; ItemIndex < FmpCapsuleHeader->PayloadItemCount; ItemIndex++) {
ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[ItemIndex]);
@@ -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;
}
}
@@ -679,42 +694,42 @@ ProcessFmpCapsuleImage ( EFI_STATUS
EFIAPI
ProcessRecoveryCapsule (
- IN VOID *CapsuleBuffer,
- IN UINTN CapsuleSize
+ IN VOID *CapsuleBuffer,
+ IN UINTN CapsuleSize
)
{
- EFI_STATUS Status;
- BOOLEAN IsSystemFmp;
- EFI_CAPSULE_HEADER *CapsuleHeader;
+ EFI_STATUS Status;
+ BOOLEAN IsSystemFmp;
+ EFI_CAPSULE_HEADER *CapsuleHeader;
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"));
-
- 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)) {
+ 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)) {
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;
}
@@ -736,8 +751,8 @@ ProcessRecoveryCapsule ( EFI_STATUS
EFIAPI
LoadRecoveryCapsule (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_MODULE_PPI *This
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_MODULE_PPI *This
)
{
EFI_STATUS 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,35 +777,38 @@ LoadRecoveryCapsule ( if (EFI_ERROR (Status)) {
break;
}
+
NumberRecoveryCapsules = 0;
- Status = DeviceRecoveryPpi->GetNumberRecoveryCapsules (
- (EFI_PEI_SERVICES **)PeiServices,
- DeviceRecoveryPpi,
- &NumberRecoveryCapsules
- );
+ Status = DeviceRecoveryPpi->GetNumberRecoveryCapsules (
+ (EFI_PEI_SERVICES **)PeiServices,
+ DeviceRecoveryPpi,
+ &NumberRecoveryCapsules
+ );
DEBUG ((DEBUG_ERROR, "LoadRecoveryCapsule - GetNumberRecoveryCapsules (%d) - %r\n", NumberRecoveryCapsules, Status));
if (EFI_ERROR (Status)) {
continue;
}
+
for (CapsuleInstance = 1; CapsuleInstance <= NumberRecoveryCapsules; CapsuleInstance++) {
CapsuleSize = 0;
- Status = DeviceRecoveryPpi->GetRecoveryCapsuleInfo (
- (EFI_PEI_SERVICES **)PeiServices,
- DeviceRecoveryPpi,
- CapsuleInstance,
- &CapsuleSize,
- &CapsuleType
- );
+ Status = DeviceRecoveryPpi->GetRecoveryCapsuleInfo (
+ (EFI_PEI_SERVICES **)PeiServices,
+ DeviceRecoveryPpi,
+ CapsuleInstance,
+ &CapsuleSize,
+ &CapsuleType
+ );
DEBUG ((DEBUG_ERROR, "LoadRecoveryCapsule - GetRecoveryCapsuleInfo (%d - %x) - %r\n", CapsuleInstance, CapsuleSize, Status));
if (EFI_ERROR (Status)) {
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
//
diff --git a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.h b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.h index 6b38795..09becb5 100644 --- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.h +++ b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.h @@ -24,15 +24,14 @@ //
typedef struct {
- UINTN NumOfRecovery;
+ UINTN NumOfRecovery;
} CONFIG_HEADER;
typedef struct {
- UINTN Index;
- EFI_GUID FileGuid;
- UINTN Length;
- UINTN ImageOffset;
+ UINTN Index;
+ EFI_GUID FileGuid;
+ UINTN Length;
+ UINTN ImageOffset;
} RECOVERY_CONFIG_DATA;
#endif
-
diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c index 878c668..7edbb11 100644 --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/ParseConfigProfile.c @@ -12,7 +12,7 @@ #include <Library/IniParsingLib.h>
#include <Library/PrintLib.h>
-#define MAX_LINE_LENGTH 512
+#define MAX_LINE_LENGTH 512
/**
Parse Config data file to get the updated data array.
@@ -29,25 +29,25 @@ **/
EFI_STATUS
ParseUpdateDataFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize,
- IN OUT CONFIG_HEADER *ConfigHeader,
- IN OUT UPDATE_CONFIG_DATA **UpdateArray
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize,
+ IN OUT CONFIG_HEADER *ConfigHeader,
+ IN OUT UPDATE_CONFIG_DATA **UpdateArray
)
{
- EFI_STATUS Status;
- CHAR8 *SectionName;
- CHAR8 Entry[MAX_LINE_LENGTH];
- UINTN Num;
- UINT64 Num64;
- UINTN Index;
- EFI_GUID FileGuid;
- VOID *Context;
+ EFI_STATUS Status;
+ CHAR8 *SectionName;
+ CHAR8 Entry[MAX_LINE_LENGTH];
+ UINTN Num;
+ UINT64 Num64;
+ UINTN Index;
+ EFI_GUID FileGuid;
+ VOID *Context;
//
// 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));
+ *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;
}
-
diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareCommonDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareCommonDxe.c index 1b6d7e7..077bd0c 100644 --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareCommonDxe.c +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareCommonDxe.c @@ -8,10 +8,10 @@ #include "SystemFirmwareDxe.h"
-EFI_GUID gSystemFmpLastAttemptVariableGuid = SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_GUID;
-EFI_GUID gSystemFmpProtocolGuid = SYSTEM_FMP_PROTOCOL_GUID;
+EFI_GUID gSystemFmpLastAttemptVariableGuid = SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_GUID;
+EFI_GUID gSystemFmpProtocolGuid = SYSTEM_FMP_PROTOCOL_GUID;
-EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol = {
+EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol = {
FmpGetImageInfo,
FmpGetImage,
FmpSetImage,
@@ -61,48 +61,49 @@ EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol = { EFI_STATUS
EFIAPI
FmpGetImageInfo (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- IN OUT UINTN *ImageInfoSize,
- IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
- OUT UINT32 *DescriptorVersion,
- OUT UINT8 *DescriptorCount,
- OUT UINTN *DescriptorSize,
- OUT UINT32 *PackageVersion,
- OUT CHAR16 **PackageVersionName
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ IN OUT UINTN *ImageInfoSize,
+ IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
+ OUT UINT32 *DescriptorVersion,
+ OUT UINT8 *DescriptorCount,
+ OUT UINTN *DescriptorSize,
+ OUT UINT32 *PackageVersion,
+ OUT CHAR16 **PackageVersionName
)
{
- SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate;
- EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor;
+ 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);
- *DescriptorCount = SystemFmpPrivate->DescriptorCount;
- *DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
+ *ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount;
+ *DescriptorSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
+ *DescriptorCount = SystemFmpPrivate->DescriptorCount;
+ *DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
//
// supports 1 ImageInfo descriptor
//
- ImageDescriptor = SystemFmpPrivate->ImageDescriptor;
+ ImageDescriptor = SystemFmpPrivate->ImageDescriptor;
ImageInfo->ImageIndex = ImageDescriptor->ImageIndex;
CopyGuid (&ImageInfo->ImageTypeId, &ImageDescriptor->ImageTypeId);
ImageInfo->ImageId = ImageDescriptor->ImageId;
@@ -111,20 +112,22 @@ 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;
- ImageInfo->Compatibilities = ImageDescriptor->Compatibilities;
+
+ ImageInfo->Size = (UINTN)ImageDescriptor->Size;
+ ImageInfo->AttributesSupported = ImageDescriptor->AttributesSupported;
+ ImageInfo->AttributesSetting = ImageDescriptor->AttributesSetting;
+ ImageInfo->Compatibilities = ImageDescriptor->Compatibilities;
ImageInfo->LowestSupportedImageVersion = ImageDescriptor->LowestSupportedImageVersion;
- ImageInfo->LastAttemptVersion = SystemFmpPrivate->LastAttempt.LastAttemptVersion;
- ImageInfo->LastAttemptStatus = SystemFmpPrivate->LastAttempt.LastAttemptStatus;
- ImageInfo->HardwareInstance = ImageDescriptor->HardwareInstance;
+ ImageInfo->LastAttemptVersion = SystemFmpPrivate->LastAttempt.LastAttemptVersion;
+ ImageInfo->LastAttemptStatus = SystemFmpPrivate->LastAttempt.LastAttemptStatus;
+ ImageInfo->HardwareInstance = ImageDescriptor->HardwareInstance;
//
// package version
@@ -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;
}
@@ -243,12 +246,12 @@ FmpCheckImage ( EFI_STATUS
EFIAPI
FmpGetPackageInfo (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- OUT UINT32 *PackageVersion,
- OUT CHAR16 **PackageVersionName,
- OUT UINT32 *PackageVersionNameMaxLen,
- OUT UINT64 *AttributesSupported,
- OUT UINT64 *AttributesSetting
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ OUT UINT32 *PackageVersion,
+ OUT CHAR16 **PackageVersionName,
+ OUT UINT32 *PackageVersionNameMaxLen,
+ OUT UINT64 *AttributesSupported,
+ OUT UINT64 *AttributesSetting
)
{
return EFI_UNSUPPORTED;
@@ -288,12 +291,12 @@ FmpGetPackageInfo ( EFI_STATUS
EFIAPI
FmpSetPackageInfo (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- IN CONST VOID *Image,
- IN UINTN ImageSize,
- IN CONST VOID *VendorCode,
- IN UINT32 PackageVersion,
- IN CONST CHAR16 *PackageVersionName
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ IN CONST VOID *Image,
+ IN UINTN ImageSize,
+ IN CONST VOID *VendorCode,
+ IN UINT32 PackageVersion,
+ IN CONST CHAR16 *PackageVersionName
)
{
return EFI_UNSUPPORTED;
@@ -311,30 +314,28 @@ InitializePrivateData ( IN SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate
)
{
- EFI_STATUS VarStatus;
- UINTN VarSize;
+ EFI_STATUS VarStatus;
+ UINTN VarSize;
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(
- 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));
+ SystemFmpPrivate->LastAttempt.LastAttemptStatus = 0x0;
+ 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));
return EFI_SUCCESS;
}
-
-
diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareDxe.h b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareDxe.h index d3cc89e..c844386 100644 --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareDxe.h +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareDxe.h @@ -35,32 +35,32 @@ #include <Library/EdkiiSystemCapsuleLib.h>
typedef struct {
- UINT32 LastAttemptVersion;
- UINT32 LastAttemptStatus;
+ UINT32 LastAttemptVersion;
+ UINT32 LastAttemptStatus;
} SYSTEM_FMP_LAST_ATTEMPT_VARIABLE;
#define SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME L"SystemLastAttempVar"
-#define SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_GUID {0x2f564d6f, 0xcc2c, 0x4838, { 0xb9, 0xa8, 0xbe, 0x59, 0x48, 0xb0, 0x3d, 0x59 }}
+#define SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_GUID {0x2f564d6f, 0xcc2c, 0x4838, { 0xb9, 0xa8, 0xbe, 0x59, 0x48, 0xb0, 0x3d, 0x59 }}
#define SYSTEM_FMP_PRIVATE_DATA_SIGNATURE SIGNATURE_32('S', 'Y', 'S', 'F')
-#define SYSTEM_FMP_PROTOCOL_GUID {0x6d16624a, 0x26a6, 0x4cb4, { 0x84, 0xfa, 0x6, 0x78, 0x5a, 0x7e, 0x82, 0x6a }}
+#define SYSTEM_FMP_PROTOCOL_GUID {0x6d16624a, 0x26a6, 0x4cb4, { 0x84, 0xfa, 0x6, 0x78, 0x5a, 0x7e, 0x82, 0x6a }}
//
// SYSTEM FMP private data structure.
//
struct _SYSTEM_FMP_PRIVATE_DATA {
- UINT32 Signature;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL Fmp;
- EFI_HANDLE Handle;
- UINT8 DescriptorCount;
- EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor;
- SYSTEM_FMP_LAST_ATTEMPT_VARIABLE LastAttempt;
+ UINT32 Signature;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL Fmp;
+ EFI_HANDLE Handle;
+ UINT8 DescriptorCount;
+ EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR *ImageDescriptor;
+ SYSTEM_FMP_LAST_ATTEMPT_VARIABLE LastAttempt;
};
-typedef struct _SYSTEM_FMP_PRIVATE_DATA SYSTEM_FMP_PRIVATE_DATA;
+typedef struct _SYSTEM_FMP_PRIVATE_DATA SYSTEM_FMP_PRIVATE_DATA;
/**
Returns a pointer to the SYSTEM_FMP_PRIVATE_DATA structure from the input a as Fmp.
@@ -80,51 +80,49 @@ typedef struct _SYSTEM_FMP_PRIVATE_DATA SYSTEM_FMP_PRIVATE_DATA; SYSTEM_FMP_PRIVATE_DATA_SIGNATURE \
)
-
//
// Update data
//
typedef struct {
- UINTN NumOfUpdates;
+ UINTN NumOfUpdates;
} CONFIG_HEADER;
typedef struct {
- UINTN Index;
- PLATFORM_FIRMWARE_TYPE FirmwareType;
- FLASH_ADDRESS_TYPE AddressType;
- EFI_GUID FileGuid;
- EFI_PHYSICAL_ADDRESS BaseAddress;
- UINTN Length;
- UINTN ImageOffset;
+ UINTN Index;
+ PLATFORM_FIRMWARE_TYPE FirmwareType;
+ FLASH_ADDRESS_TYPE AddressType;
+ EFI_GUID FileGuid;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINTN Length;
+ UINTN ImageOffset;
} UPDATE_CONFIG_DATA;
//
// System Firmware Update SMM Communication
//
-#define SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_FUNCTION_SET_IMAGE 1
+#define SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_FUNCTION_SET_IMAGE 1
typedef struct {
- UINTN Function;
- EFI_STATUS ReturnStatus;
-//UINT8 Data[];
+ UINTN Function;
+ EFI_STATUS ReturnStatus;
+ // UINT8 Data[];
} SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_HEAD;
-#define ABORT_REASON_MAX_SIZE 0x40 // UnicodeStringSize including final L'\0'
+#define ABORT_REASON_MAX_SIZE 0x40 // UnicodeStringSize including final L'\0'
#define CAPSULE_IMAGE_ADDITIONAL_MAX_SIZE (0x20020 + 0xA0000) // Additional size for Capsule Header, FV block alignment + DispatchImage.
typedef struct {
- UINT8 ImageIndex;
- UINTN ImageSize;
- UINTN AbortReasonSize;
- UINT32 LastAttemptVersion;
- UINT32 LastAttemptStatus;
-//UINT8 Data[AbortReasonMaxSize + ImageSize];
+ UINT8 ImageIndex;
+ UINTN ImageSize;
+ UINTN AbortReasonSize;
+ UINT32 LastAttemptVersion;
+ UINT32 LastAttemptStatus;
+ // UINT8 Data[AbortReasonMaxSize + ImageSize];
} SYSTEM_FIRMWARE_UPDATE_COMMUNICATION_SET_IMAGE;
-
/**
Returns information about the current firmware image(s) of the device.
@@ -166,14 +164,14 @@ typedef struct { EFI_STATUS
EFIAPI
FmpGetImageInfo (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- IN OUT UINTN *ImageInfoSize,
- IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
- OUT UINT32 *DescriptorVersion,
- OUT UINT8 *DescriptorCount,
- OUT UINTN *DescriptorSize,
- OUT UINT32 *PackageVersion,
- OUT CHAR16 **PackageVersionName
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ IN OUT UINTN *ImageInfoSize,
+ IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
+ OUT UINT32 *DescriptorVersion,
+ OUT UINT8 *DescriptorCount,
+ OUT UINTN *DescriptorSize,
+ OUT UINT32 *PackageVersion,
+ OUT CHAR16 **PackageVersionName
);
/**
@@ -257,13 +255,13 @@ FmpGetImage ( EFI_STATUS
EFIAPI
FmpSetImage (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- IN UINT8 ImageIndex,
- IN CONST VOID *Image,
- IN UINTN ImageSize,
- IN CONST VOID *VendorCode,
- IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
- OUT CHAR16 **AbortReason
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ IN UINT8 ImageIndex,
+ IN CONST VOID *Image,
+ IN UINTN ImageSize,
+ IN CONST VOID *VendorCode,
+ IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
+ OUT CHAR16 **AbortReason
);
/**
@@ -331,12 +329,12 @@ FmpCheckImage ( EFI_STATUS
EFIAPI
FmpGetPackageInfo (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- OUT UINT32 *PackageVersion,
- OUT CHAR16 **PackageVersionName,
- OUT UINT32 *PackageVersionNameMaxLen,
- OUT UINT64 *AttributesSupported,
- OUT UINT64 *AttributesSetting
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ OUT UINT32 *PackageVersion,
+ OUT CHAR16 **PackageVersionName,
+ OUT UINT32 *PackageVersionNameMaxLen,
+ OUT UINT64 *AttributesSupported,
+ OUT UINT64 *AttributesSetting
);
/**
@@ -373,12 +371,12 @@ FmpGetPackageInfo ( EFI_STATUS
EFIAPI
FmpSetPackageInfo (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- IN CONST VOID *Image,
- IN UINTN ImageSize,
- IN CONST VOID *VendorCode,
- IN UINT32 PackageVersion,
- IN CONST CHAR16 *PackageVersionName
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ IN CONST VOID *Image,
+ IN UINTN ImageSize,
+ IN CONST VOID *VendorCode,
+ IN UINT32 PackageVersion,
+ IN CONST CHAR16 *PackageVersionName
);
/**
@@ -393,9 +391,8 @@ InitializePrivateData ( IN SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate
);
-extern EFI_GUID gSystemFmpLastAttemptVariableGuid;
-extern EFI_GUID mCurrentImageTypeId;
-extern EFI_GUID gSystemFmpProtocolGuid;
+extern EFI_GUID gSystemFmpLastAttemptVariableGuid;
+extern EFI_GUID mCurrentImageTypeId;
+extern EFI_GUID gSystemFmpProtocolGuid;
#endif
-
diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.c index ebd1d0d..e5181a6 100644 --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.c +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.c @@ -18,7 +18,7 @@ //
// SystemFmp driver private data
//
-SYSTEM_FMP_PRIVATE_DATA *mSystemFmpPrivate = NULL;
+SYSTEM_FMP_PRIVATE_DATA *mSystemFmpPrivate = NULL;
/**
Dispatch system FMP images.
@@ -37,57 +37,57 @@ SYSTEM_FMP_PRIVATE_DATA *mSystemFmpPrivate = NULL; **/
EFI_STATUS
DispatchSystemFmpImages (
- IN VOID *Image,
- IN UINTN ImageSize,
- OUT UINT32 *LastAttemptVersion,
- OUT UINT32 *LastAttemptStatus
+ IN VOID *Image,
+ IN UINTN ImageSize,
+ OUT UINT32 *LastAttemptVersion,
+ OUT UINT32 *LastAttemptStatus
)
{
- EFI_STATUS Status;
- VOID *AuthenticatedImage;
- UINTN AuthenticatedImageSize;
- VOID *DispatchFvImage;
- UINTN DispatchFvImageSize;
- EFI_HANDLE FvProtocolHandle;
- EFI_FIRMWARE_VOLUME_HEADER *FvImage;
- BOOLEAN Result;
+ EFI_STATUS Status;
+ VOID *AuthenticatedImage;
+ UINTN AuthenticatedImageSize;
+ VOID *DispatchFvImage;
+ UINTN DispatchFvImageSize;
+ EFI_HANDLE FvProtocolHandle;
+ EFI_FIRMWARE_VOLUME_HEADER *FvImage;
+ BOOLEAN Result;
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"));
}
}
}
@@ -145,78 +145,78 @@ DispatchSystemFmpImages ( EFI_STATUS
EFIAPI
FmpSetImage (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- IN UINT8 ImageIndex,
- IN CONST VOID *Image,
- IN UINTN ImageSize,
- IN CONST VOID *VendorCode,
- IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
- OUT CHAR16 **AbortReason
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ IN UINT8 ImageIndex,
+ IN CONST VOID *Image,
+ IN UINTN ImageSize,
+ IN CONST VOID *VendorCode,
+ IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
+ OUT CHAR16 **AbortReason
)
{
- SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *SystemFmp;
- EFI_STATUS Status;
- EFI_STATUS VarStatus;
+ SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *SystemFmp;
+ 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(
- SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
- &gSystemFmpLastAttemptVariableGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof(SystemFmpPrivate->LastAttempt),
- &SystemFmpPrivate->LastAttempt
- );
- DEBUG((DEBUG_INFO, "(Agent)SetLastAttempt - %r\n", VarStatus));
+ VarStatus = gRT->SetVariable (
+ SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
+ &gSystemFmpLastAttemptVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (SystemFmpPrivate->LastAttempt),
+ &SystemFmpPrivate->LastAttempt
+ );
+ 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);
}
/**
@@ -230,23 +230,23 @@ FmpSetImage ( EFI_STATUS
EFIAPI
SystemFirmwareReportMainDxe (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// 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;
}
diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c index ea795cd..c33b515 100644 --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c @@ -18,9 +18,9 @@ //
// SystemFmp driver private data
//
-SYSTEM_FMP_PRIVATE_DATA *mSystemFmpPrivate = NULL;
+SYSTEM_FMP_PRIVATE_DATA *mSystemFmpPrivate = NULL;
-EFI_GUID mCurrentImageTypeId;
+EFI_GUID mCurrentImageTypeId;
BOOLEAN mNvRamUpdated = FALSE;
@@ -39,10 +39,10 @@ BOOLEAN mNvRamUpdated = FALSE; **/
EFI_STATUS
ParseUpdateDataFile (
- IN UINT8 *DataBuffer,
- IN UINTN BufferSize,
- IN OUT CONFIG_HEADER *ConfigHeader,
- IN OUT UPDATE_CONFIG_DATA **UpdateArray
+ IN UINT8 *DataBuffer,
+ IN UINTN BufferSize,
+ IN OUT CONFIG_HEADER *ConfigHeader,
+ IN OUT UPDATE_CONFIG_DATA **UpdateArray
);
/**
@@ -72,15 +72,16 @@ PerformUpdate ( IN UINTN EndPercentage
)
{
- EFI_STATUS Status;
+ 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;
}
@@ -130,26 +133,27 @@ UpdateImage ( IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress
)
{
- EFI_STATUS Status;
- UPDATE_CONFIG_DATA *ConfigData;
- UPDATE_CONFIG_DATA *UpdateConfigData;
- CONFIG_HEADER ConfigHeader;
- UINTN Index;
- UINTN TotalSize;
- UINTN BytesWritten;
- UINTN StartPercentage;
- UINTN EndPercentage;
+ EFI_STATUS Status;
+ UPDATE_CONFIG_DATA *ConfigData;
+ UPDATE_CONFIG_DATA *UpdateConfigData;
+ CONFIG_HEADER ConfigHeader;
+ UINTN Index;
+ UINTN TotalSize;
+ UINTN BytesWritten;
+ UINTN StartPercentage;
+ 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;
+ EndPercentage = 100;
if (Progress != NULL) {
Progress (StartPercentage);
}
+
Status = PerformFlashWriteWithProgress (
PlatformFirmwareTypeNvRam,
0,
@@ -163,57 +167,60 @@ UpdateImage ( if (Progress != NULL) {
Progress (EndPercentage);
}
- if (!EFI_ERROR(Status)) {
+
+ if (!EFI_ERROR (Status)) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
- mNvRamUpdated = TRUE;
+ mNvRamUpdated = TRUE;
} else {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
}
+
return Status;
}
- DEBUG((DEBUG_INFO, "PlatformUpdate (With Config):\n"));
- ConfigData = NULL;
- ZeroMem (&ConfigHeader, sizeof(ConfigHeader));
- Status = ParseUpdateDataFile (
- ConfigImage,
- ConfigImageSize,
- &ConfigHeader,
- &ConfigData
- );
- DEBUG((DEBUG_INFO, "ParseUpdateDataFile - %r\n", Status));
- if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "PlatformUpdate (With Config):\n"));
+ ConfigData = NULL;
+ ZeroMem (&ConfigHeader, sizeof (ConfigHeader));
+ Status = ParseUpdateDataFile (
+ ConfigImage,
+ ConfigImageSize,
+ &ConfigHeader,
+ &ConfigData
+ );
+ 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;
}
}
- BytesWritten = 0;
- Index = 0;
+ BytesWritten = 0;
+ 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 (
- SystemFirmwareImage,
- SystemFirmwareImageSize,
- UpdateConfigData,
- LastAttemptVersion,
- LastAttemptStatus,
- Progress,
- StartPercentage,
- EndPercentage
- );
+ Status = PerformUpdate (
+ SystemFirmwareImage,
+ SystemFirmwareImageSize,
+ UpdateConfigData,
+ LastAttemptVersion,
+ LastAttemptStatus,
+ Progress,
+ StartPercentage,
+ EndPercentage
+ );
//
// Shall updates be serialized so that if an update is not successfully completed,
// the remaining updates won't be performed.
@@ -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;
@@ -258,38 +265,38 @@ SystemFirmwareAuthenticatedUpdate ( IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress
)
{
- EFI_STATUS Status;
- VOID *SystemFirmwareImage;
- UINTN SystemFirmwareImageSize;
- VOID *ConfigImage;
- UINTN ConfigImageSize;
- VOID *AuthenticatedImage;
- UINTN AuthenticatedImageSize;
+ EFI_STATUS Status;
+ VOID *SystemFirmwareImage;
+ UINTN SystemFirmwareImageSize;
+ VOID *ConfigImage;
+ UINTN ConfigImageSize;
+ VOID *AuthenticatedImage;
+ UINTN AuthenticatedImageSize;
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;
}
@@ -314,14 +321,14 @@ SystemFirmwareAuthenticatedUpdate ( EFI_STATUS
EFIAPI
GetVariableHook (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- OUT UINT32 *Attributes OPTIONAL,
- IN OUT UINTN *DataSize,
- OUT VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ 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;
}
@@ -342,12 +349,12 @@ GetVariableHook ( EFI_STATUS
EFIAPI
GetNextVariableNameHook (
- IN OUT UINTN *VariableNameSize,
- IN OUT CHAR16 *VariableName,
- IN OUT EFI_GUID *VendorGuid
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ 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;
}
@@ -372,14 +379,14 @@ GetNextVariableNameHook ( EFI_STATUS
EFIAPI
SetVariableHook (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ 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;
}
@@ -402,13 +409,13 @@ SetVariableHook ( EFI_STATUS
EFIAPI
QueryVariableInfoHook (
- IN UINT32 Attributes,
- OUT UINT64 *MaximumVariableStorageSize,
- OUT UINT64 *RemainingVariableStorageSize,
- OUT UINT64 *MaximumVariableSize
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
)
{
- DEBUG((DEBUG_INFO, "QueryVariableInfoHook - 0x%x\n", Attributes));
+ DEBUG ((DEBUG_INFO, "QueryVariableInfoHook - 0x%x\n", Attributes));
return EFI_NOT_AVAILABLE_YET;
}
@@ -461,32 +468,32 @@ QueryVariableInfoHook ( EFI_STATUS
EFIAPI
FmpSetImage (
- IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
- IN UINT8 ImageIndex,
- IN CONST VOID *Image,
- IN UINTN ImageSize,
- IN CONST VOID *VendorCode,
- IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
- OUT CHAR16 **AbortReason
+ IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This,
+ IN UINT8 ImageIndex,
+ IN CONST VOID *Image,
+ IN UINTN ImageSize,
+ IN CONST VOID *VendorCode,
+ IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
+ OUT CHAR16 **AbortReason
)
{
- EFI_STATUS Status;
- EFI_STATUS VarStatus;
- SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate;
+ EFI_STATUS Status;
+ 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,
- gRT->Hdr.HeaderSize,
- &gRT->Hdr.CRC32
- );
+ (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;
}
@@ -568,16 +575,16 @@ GetFmpImageDescriptors ( // Determine the size required for the set of EFI_FIRMWARE_IMAGE_DESCRIPTORs.
//
ImageInfoSize = 0;
- Status = Fmp->GetImageInfo (
- Fmp, // FMP Pointer
- &ImageInfoSize, // Buffer Size (in this case 0)
- NULL, // NULL so we can get size
- &FmpImageInfoDescriptorVer, // DescriptorVersion
- FmpImageInfoCount, // DescriptorCount
- DescriptorSize, // DescriptorSize
- &PackageVersion, // PackageVersion
- &PackageVersionName // PackageVersionName
- );
+ Status = Fmp->GetImageInfo (
+ Fmp, // FMP Pointer
+ &ImageInfoSize, // Buffer Size (in this case 0)
+ NULL, // NULL so we can get size
+ &FmpImageInfoDescriptorVer, // DescriptorVersion
+ FmpImageInfoCount, // DescriptorCount
+ DescriptorSize, // DescriptorSize
+ &PackageVersion, // PackageVersion
+ &PackageVersionName // PackageVersionName
+ );
if (Status != EFI_BUFFER_TOO_SMALL) {
DEBUG ((DEBUG_ERROR, "SystemFirmwareUpdateDxe: Unexpected Failure. Status = %r\n", Status));
return NULL;
@@ -597,16 +604,16 @@ GetFmpImageDescriptors ( // Retrieve the set of EFI_FIRMWARE_IMAGE_DESCRIPTORs.
//
PackageVersionName = NULL;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize, // ImageInfoSize
- FmpImageInfoBuf, // ImageInfo
- &FmpImageInfoDescriptorVer, // DescriptorVersion
- FmpImageInfoCount, // DescriptorCount
- DescriptorSize, // DescriptorSize
- &PackageVersion, // PackageVersion
- &PackageVersionName // PackageVersionName
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize, // ImageInfoSize
+ FmpImageInfoBuf, // ImageInfo
+ &FmpImageInfoDescriptorVer, // DescriptorVersion
+ FmpImageInfoCount, // DescriptorCount
+ DescriptorSize, // DescriptorSize
+ &PackageVersion, // PackageVersion
+ &PackageVersionName // PackageVersionName
+ );
//
// Free unused PackageVersionName return buffer
@@ -621,6 +628,7 @@ GetFmpImageDescriptors ( if (FmpImageInfoBuf != NULL) {
FreePool (FmpImageInfoBuf);
}
+
return NULL;
}
@@ -656,16 +664,16 @@ FindMatchingFmpHandles ( UINTN DescriptorSize;
BOOLEAN MatchFound;
- *HandleCount = 0;
+ *HandleCount = 0;
TempHandleCount = 0;
- HandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- ProtocolGuid,
- NULL,
- &TempHandleCount,
- &HandleBuffer
- );
+ HandleBuffer = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ ProtocolGuid,
+ NULL,
+ &TempHandleCount,
+ &HandleBuffer
+ );
if (EFI_ERROR (Status)) {
return NULL;
}
@@ -688,21 +696,24 @@ FindMatchingFmpHandles ( for (Index2 = 0; Index2 < FmpImageInfoCount; Index2++) {
for (Index3 = 0; Index3 < mSystemFmpPrivate->DescriptorCount; Index3++) {
MatchFound = CompareGuid (
- &FmpImageInfoBuf->ImageTypeId,
- &mSystemFmpPrivate->ImageDescriptor[Index3].ImageTypeId
- );
+ &FmpImageInfoBuf->ImageTypeId,
+ &mSystemFmpPrivate->ImageDescriptor[Index3].ImageTypeId
+ );
if (MatchFound) {
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);
}
@@ -832,7 +846,7 @@ SystemFirmwareUpdateMainDxe ( //
// Look for a handle with matching Firmware Management Protocol
//
- HandleCount = 0;
+ HandleCount = 0;
HandleBuffer = FindMatchingFmpHandles (
&gEfiFirmwareManagementProtocolGuid,
&HandleCount
@@ -840,38 +854,38 @@ SystemFirmwareUpdateMainDxe ( DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Found %d matching FMP instances\n", HandleCount));
switch (HandleCount) {
- case 0:
- //
- // Install FMP protocol onto a new handle.
- //
- DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Install FMP onto a new handle\n"));
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mSystemFmpPrivate->Handle,
- &gEfiFirmwareManagementProtocolGuid,
- &mSystemFmpPrivate->Fmp,
- NULL
- );
- break;
- case 1:
- //
- // Install System FMP protocol onto handle with matching FMP Protocol
- //
- DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Install System FMP onto matching FMP handle\n"));
- mSystemFmpPrivate->Handle = HandleBuffer[0];
- Status = gBS->InstallMultipleProtocolInterfaces (
- &HandleBuffer[0],
- &gSystemFmpProtocolGuid,
- &mSystemFmpPrivate->Fmp,
- NULL
- );
- break;
- default:
- //
- // More than one matching handle is not expected. Unload driver.
- //
- DEBUG ((DEBUG_ERROR, "SystemFirmwareUpdateDxe: More than one matching FMP handle. Unload driver.\n"));
- Status = EFI_DEVICE_ERROR;
- break;
+ case 0:
+ //
+ // Install FMP protocol onto a new handle.
+ //
+ DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Install FMP onto a new handle\n"));
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mSystemFmpPrivate->Handle,
+ &gEfiFirmwareManagementProtocolGuid,
+ &mSystemFmpPrivate->Fmp,
+ NULL
+ );
+ break;
+ case 1:
+ //
+ // Install System FMP protocol onto handle with matching FMP Protocol
+ //
+ DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Install System FMP onto matching FMP handle\n"));
+ mSystemFmpPrivate->Handle = HandleBuffer[0];
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &HandleBuffer[0],
+ &gSystemFmpProtocolGuid,
+ &mSystemFmpPrivate->Fmp,
+ NULL
+ );
+ break;
+ default:
+ //
+ // More than one matching handle is not expected. Unload driver.
+ //
+ DEBUG ((DEBUG_ERROR, "SystemFirmwareUpdateDxe: More than one matching FMP handle. Unload driver.\n"));
+ Status = EFI_DEVICE_ERROR;
+ break;
}
if (HandleBuffer != NULL) {
|