diff --git a/MdeModulePkg/Include/Library/CapsuleLib.h b/MdeModulePkg/Include/Library/CapsuleLib.h index 92904ebfb6..e0b42225cf 100644 --- a/MdeModulePkg/Include/Library/CapsuleLib.h +++ b/MdeModulePkg/Include/Library/CapsuleLib.h @@ -50,6 +50,27 @@ ProcessCapsuleImage ( IN EFI_CAPSULE_HEADER *CapsuleHeader ); +// MU_CHANGE - Add a routine to allow firmware-specific handling for capsules +// that need to persist across reset. + +/** + The firmware-specific implementation that stages the capsule image + for processing after reset if it recognized the format of this capsule + image. + + Caution: This function may receive untrusted input. + + @param[in] CapsuleHeader Pointer to the UEFI capsule image to be processed. + + @retval EFI_SUCESS Capsule Image processed successfully. + @retval EFI_UNSUPPORTED Capsule image is not supported by the firmware. +**/ +EFI_STATUS +EFIAPI +StageCapsuleImage ( + IN EFI_CAPSULE_HEADER *CapsuleHeader + ); + /** This routine is called to process capsules. diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 2433c76a8c..01c7fb7184 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -1615,6 +1615,26 @@ ProcessCapsuleImage ( return ProcessThisCapsuleImage (CapsuleHeader, NULL, NULL); } +/** MU_CHANGE - START + The firmware implements to process the capsule image. + + @param CapsuleHeader Points to a capsule header. + + @retval EFI_SUCESS Process Capsule Image successfully. + @retval EFI_UNSUPPORTED Capsule image is not supported by the firmware. + @retval EFI_DEVICE_ERROR Something went wrong staging the capsule +**/ +EFI_STATUS +EFIAPI +StageCapsuleImage ( + IN EFI_CAPSULE_HEADER *CapsuleHeader + ) +{ + return EFI_SUCCESS; +} + +// MU_CHANGE - END + /** Callback function executed when the EndOfDxe event group is signaled. diff --git a/MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c index aced356324..4e3f964c31 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c +++ b/MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c @@ -2,6 +2,7 @@ Null Dxe Capsule Library instance does nothing and returns unsupport status. Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -167,3 +168,25 @@ CoDRemoveTempFile ( { return EFI_UNSUPPORTED; } + +// MU_CHANGE [BEGIN] - Provide simpler interface without assumptions of staging medium. + +/** + The firmware implements to process the capsule image. + + @param CapsuleHeader Points to a capsule header. + + @retval EFI_SUCESS Process Capsule Image successfully. + @retval EFI_UNSUPPORTED Capsule image is not supported by the firmware. + @retval EFI_DEVICE_ERROR Something went wrong staging the capsule +**/ +EFI_STATUS +EFIAPI +StageCapsuleImage ( + IN EFI_CAPSULE_HEADER *CapsuleHeader + ) +{ + return EFI_UNSUPPORTED; +} + +// MU_CHANGE [END] - Provide simpler interface without assumptions of staging medium. diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c index 05945d54fa..7b81839df2 100644 --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c @@ -178,6 +178,15 @@ UpdateCapsule ( if ((CapsuleHeader->Flags & CAPSULE_FLAGS_INITIATE_RESET) != 0) { InitiateReset = TRUE; } + + // MU_CHANGE - Stage Runtime Capsules (in case special handling is needed) + // To persist across reset. + Status = StageCapsuleImage (CapsuleHeader); + if (EFI_ERROR (Status)) { + return Status; + } + + // MU_CHANGE - End } }