summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorBob Morgan <bobm@nvidia.com>2021-11-03 04:40:23 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-11-10 02:21:50 +0000
commitaab6bb3d32e207c89364504e4a195f9f0cf5ce31 (patch)
tree3aedc17b2af45841e8fe5563aefe89e1d672cf68 /MdeModulePkg
parentc974257821208fc6191779d1ddea918499f165b8 (diff)
downloadedk2-aab6bb3d32e207c89364504e4a195f9f0cf5ce31.tar.gz
edk2-aab6bb3d32e207c89364504e4a195f9f0cf5ce31.tar.bz2
edk2-aab6bb3d32e207c89364504e4a195f9f0cf5ce31.zip
MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file name capsule
Enhance RelocateCapsuleToRam() to skip creation of the Capsule on Disk file name capsule if PcdSupportUpdateCapsuleReset feature is not enabled. This avoids an EFI_UNSUPPORTED return status from UpdateCapsule() when the file name capsule is encountered and PcdSupportUpdateCapsuleReset is FALSE. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Guomin Jiang <guomin.jiang@intel.com> Signed-off-by: Bob Morgan <bobm@nvidia.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c19
-rw-r--r--MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf3
2 files changed, 19 insertions, 3 deletions
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
index 4c32c6cdcf..814c5400fe 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
@@ -1739,6 +1739,7 @@ RelocateCapsuleToRam (
UINT8 *StringBuf;
UINTN StringSize;
UINTN TotalStringSize;
+ UINTN CapsulesToProcess;
CapsuleOnDiskBuf = NULL;
BlockDescriptors = NULL;
@@ -1778,6 +1779,13 @@ RelocateCapsuleToRam (
TotalStringSize += StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);
}
+ // If Persist Across Reset isn't supported, skip the file name strings capsule
+ if (!FeaturePcdGet (PcdSupportUpdateCapsuleReset)) {
+ CapsulesToProcess = CapsuleOnDiskNum;
+ goto BuildGather;
+ }
+ CapsulesToProcess = CapsuleOnDiskNum + 1;
+
FileNameCapsule = AllocateZeroPool (sizeof (EFI_CAPSULE_HEADER) + TotalStringSize);
if (FileNameCapsule == NULL) {
DEBUG ((DEBUG_ERROR, "Fail to allocate memory for name capsule.\n"));
@@ -1804,18 +1812,23 @@ RelocateCapsuleToRam (
//
// 3. Build Gather list for the capsules
//
- Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsuleOnDiskNum + 1, &BlockDescriptors);
+BuildGather:
+ Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsulesToProcess, &BlockDescriptors);
if (EFI_ERROR (Status) || BlockDescriptors == NULL) {
FreePool (CapsuleBuffer);
FreePool (CapsuleSize);
- FreePool (FileNameCapsule);
+ if (FileNameCapsule != NULL) {
+ FreePool (FileNameCapsule);
+ }
return EFI_OUT_OF_RESOURCES;
}
//
// 4. Call UpdateCapsule() service
//
- Status = gRT->UpdateCapsule((EFI_CAPSULE_HEADER **) CapsuleBuffer, CapsuleOnDiskNum + 1, (UINTN) BlockDescriptors);
+ Status = gRT->UpdateCapsule ((EFI_CAPSULE_HEADER **) CapsuleBuffer,
+ CapsulesToProcess,
+ (UINTN) BlockDescriptors);
return Status;
}
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index 05de4299fb..4932479d42 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -68,6 +68,9 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdCodRelocationDevPath ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCoDRelocationFileName ## CONSUMES
+[FeaturePcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset ## CONSUMES
+
[Protocols]
gEsrtManagementProtocolGuid ## CONSUMES
gEfiFirmwareManagementProtocolGuid ## CONSUMES