]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file name capsule
authorBob Morgan <bobm@nvidia.com>
Tue, 2 Nov 2021 20:40:23 +0000 (04:40 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 10 Nov 2021 02:21:50 +0000 (02:21 +0000)
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>
MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf

index 4c32c6cdcf37e16bdb34fc7c00e7cafbb200c5b6..814c5400fe890362cc97aca520628e348d161b2f 100644 (file)
@@ -1739,6 +1739,7 @@ RelocateCapsuleToRam (
   UINT8                         *StringBuf;\r
   UINTN                         StringSize;\r
   UINTN                         TotalStringSize;\r
+  UINTN                         CapsulesToProcess;\r
 \r
   CapsuleOnDiskBuf = NULL;\r
   BlockDescriptors = NULL;\r
@@ -1778,6 +1779,13 @@ RelocateCapsuleToRam (
     TotalStringSize += StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);\r
   }\r
 \r
+  // If Persist Across Reset isn't supported, skip the file name strings capsule\r
+  if (!FeaturePcdGet (PcdSupportUpdateCapsuleReset)) {\r
+    CapsulesToProcess = CapsuleOnDiskNum;\r
+    goto BuildGather;\r
+  }\r
+  CapsulesToProcess = CapsuleOnDiskNum + 1;\r
+\r
   FileNameCapsule = AllocateZeroPool (sizeof (EFI_CAPSULE_HEADER) + TotalStringSize);\r
   if (FileNameCapsule == NULL) {\r
     DEBUG ((DEBUG_ERROR, "Fail to allocate memory for name capsule.\n"));\r
@@ -1804,18 +1812,23 @@ RelocateCapsuleToRam (
   //\r
   // 3. Build Gather list for the capsules\r
   //\r
-  Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsuleOnDiskNum + 1, &BlockDescriptors);\r
+BuildGather:\r
+  Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsulesToProcess, &BlockDescriptors);\r
   if (EFI_ERROR (Status) || BlockDescriptors == NULL) {\r
     FreePool (CapsuleBuffer);\r
     FreePool (CapsuleSize);\r
-    FreePool (FileNameCapsule);\r
+    if (FileNameCapsule != NULL) {\r
+      FreePool (FileNameCapsule);\r
+    }\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   //\r
   // 4. Call UpdateCapsule() service\r
   //\r
-  Status = gRT->UpdateCapsule((EFI_CAPSULE_HEADER **) CapsuleBuffer, CapsuleOnDiskNum + 1, (UINTN) BlockDescriptors);\r
+  Status = gRT->UpdateCapsule ((EFI_CAPSULE_HEADER **) CapsuleBuffer,\r
+                               CapsulesToProcess,\r
+                               (UINTN) BlockDescriptors);\r
 \r
   return Status;\r
 }\r
index 05de4299fba92f5ccc8ac7db41722af86d6bbf6b..4932479d420b9013c1651fde267bd29ab654a77f 100644 (file)
@@ -68,6 +68,9 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdCodRelocationDevPath                     ## SOMETIMES_CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdCoDRelocationFileName                    ## CONSUMES\r
 \r
+[FeaturePcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset ## CONSUMES\r
+\r
 [Protocols]\r
   gEsrtManagementProtocolGuid                   ## CONSUMES\r
   gEfiFirmwareManagementProtocolGuid            ## CONSUMES\r