ProcessRecoveryCapsule(), ProcessFmpCapsuleImage(), ProcessRecoveryImage(),\r
ValidateFmpCapsule() will receive untrusted input and do basic validation.\r
\r
-Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
#include <Uefi.h>\r
#include <PiPei.h>\r
//\r
-// The protocols, PPI and GUID defintions for this module\r
+// The protocols, PPI and GUID definitions for this module\r
//\r
#include <Ppi/MasterBootMode.h>\r
#include <Ppi/BootInRecoveryMode.h>\r
}\r
\r
/**\r
- This function assumes the input Capusule image already passes basic check in\r
+ This function assumes the input Capsule image already passes basic check in\r
ValidateFmpCapsule().\r
\r
Criteria of system FMP capsule is:\r
@param[out] IsSystemFmp If it is a system FMP.\r
@param[out] EmbeddedDriverCount The EmbeddedDriverCount in the FMP capsule.\r
\r
- @retval EFI_SUCESS Input capsule is a correct FMP capsule.\r
+ @retval EFI_SUCCESS Input capsule is a correct FMP capsule.\r
@retval EFI_INVALID_PARAMETER Input capsule is not a correct FMP capsule.\r
**/\r
EFI_STATUS\r
ValidateFmpCapsule (\r
IN EFI_CAPSULE_HEADER *CapsuleHeader,\r
- OUT BOOLEAN *IsSystemFmp, OPTIONAL\r
+ OUT BOOLEAN *IsSystemFmp OPTIONAL,\r
OUT UINT16 *EmbeddedDriverCount OPTIONAL\r
)\r
{\r
DEBUG((DEBUG_ERROR, "ImageHeader->Version(0x%x) Unknown\n", ImageHeader->Version));\r
return EFI_INVALID_PARAMETER;\r
}\r
- if (ImageHeader->Version < EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {\r
+ ///\r
+ /// Current Init ImageHeader version is 3. UpdateHardwareInstance field was added in version 2\r
+ /// and ImageCapsuleSupport field was added in version 3\r
+ ///\r
+ if (ImageHeader->Version == 1) {\r
FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);\r
+ } else if (ImageHeader->Version == 2){\r
+ FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);\r
}\r
\r
// No overflow\r
@param[in] FvImage Points to the DXE FV image.\r
@param[in] FvImageSize The length of the DXE FV image in bytes.\r
\r
- @retval EFI_SUCESS Create hob and install FvInfo PPI successfully.\r
+ @retval EFI_SUCCESS Create hob and install FvInfo PPI successfully.\r
@retval EFI_VOLUME_CORRUPTED The input data is not an FV.\r
@retval EFI_OUT_OF_RESOURCES No enough resource to process the input data.\r
**/\r
@param[in] ConfigImage Points to the config file image.\r
@param[in] ConfigImageSize The length of the config file image in bytes.\r
\r
- @retval EFI_SUCESS Process Recovery Image successfully.\r
+ @retval EFI_SUCCESS Process Recovery Image successfully.\r
**/\r
EFI_STATUS\r
RecoverImage (\r
@param[in] Image Points to the recovery image.\r
@param[in] Length The length of the recovery image in bytes.\r
\r
- @retval EFI_SUCESS Process Recovery Image successfully.\r
+ @retval EFI_SUCCESS Process Recovery Image successfully.\r
@retval EFI_SECURITY_VIOLATION Recovery image is not processed due to security violation.\r
**/\r
EFI_STATUS\r
@param[in] CapsuleHeader Points to a capsule header.\r
@param[in] IsSystemFmp If this capsule is a system FMP capsule.\r
\r
- @retval EFI_SUCESS Process Capsule Image successfully.\r
+ @retval EFI_SUCCESS Process Capsule Image successfully.\r
@retval EFI_UNSUPPORTED Capsule image is not supported by the firmware.\r
@retval EFI_VOLUME_CORRUPTED FV volume in the capsule is corrupted.\r
@retval EFI_OUT_OF_RESOURCES Not enough memory.\r
} else {\r
//\r
// If the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER is version 1, only match ImageTypeId.\r
- // Header should exclude UpdateHardwareInstance field\r
+ // Header should exclude UpdateHardwareInstance field.\r
+ // If version is 2 Header should exclude ImageCapsuleSupport field.\r
//\r
- Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);\r
+ if (ImageHeader->Version == 1) {\r
+ Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);\r
+ } else {\r
+ Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);\r
+ }\r
}\r
\r
Status = ProcessRecoveryImage (Image, ImageHeader->UpdateImageSize);\r
Status = DeviceRecoveryPpi->GetRecoveryCapsuleInfo (\r
(EFI_PEI_SERVICES **)PeiServices,\r
DeviceRecoveryPpi,\r
- FeaturePcdGet(PcdFrameworkCompatibilitySupport) ? CapsuleInstance - 1 : CapsuleInstance,\r
+ CapsuleInstance,\r
&CapsuleSize,\r
&CapsuleType\r
);\r
Status = DeviceRecoveryPpi->LoadRecoveryCapsule (\r
(EFI_PEI_SERVICES **)PeiServices,\r
DeviceRecoveryPpi,\r
- FeaturePcdGet(PcdFrameworkCompatibilitySupport) ? CapsuleInstance - 1 : CapsuleInstance,\r
+ CapsuleInstance,\r
CapsuleBuffer\r
);\r
DEBUG ((DEBUG_ERROR, "LoadRecoveryCapsule - LoadRecoveryCapsule (%d) - %r\n", CapsuleInstance, Status));\r