]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
Fix warnings generated by gcc for ia32 builds:
[mirror_edk2.git] / MdeModulePkg / Universal / CapsuleRuntimeDxe / CapsuleService.c
index e74a59151aea97c23f2d7905fc182dce1585fb32..27bc8b346b7b72f4b252849ce4917f3ae7297515 100644 (file)
@@ -47,22 +47,18 @@ Returns:
                                  not set, the capsule has been successfully processed by the firmware.\r
                                  If it set, the ScattlerGatherList is successfully to be set.\r
   EFI_INVALID_PARAMETER          CapsuleCount is less than 1,CapsuleGuid is not supported.\r
-  EFI_DEVICE_ERROR               Failed to SetVariable or AllocatePool or ProcessFirmwareVolume.\r
+  EFI_DEVICE_ERROR               Failed to SetVariable or ProcessFirmwareVolume.\r
 \r
 --*/\r
 {\r
-  UINTN                     CapsuleSize;\r
   UINTN                     ArrayNumber;\r
-  VOID                      *BufferPtr;\r
   EFI_STATUS                Status;\r
-  EFI_HANDLE                FvHandle;\r
   EFI_CAPSULE_HEADER        *CapsuleHeader;\r
 \r
   if (CapsuleCount < 1) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  BufferPtr       = NULL;\r
   CapsuleHeader   = NULL;\r
 \r
   for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {\r
@@ -75,25 +71,22 @@ Returns:
       return EFI_INVALID_PARAMETER;\r
     }\r
     //\r
-    // To remove this check. Capsule update supports non reset image.\r
-    // \r
-    //    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {\r
-    //      return EFI_UNSUPPORTED;\r
-    //    }\r
+    // Check Capsule image without populate flag by firmware support capsule function  \r
+    //\r
+    if (((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) && \r
+        (SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
   }\r
 \r
   //\r
-  // Check capsule guid is suppored by this platform. To do\r
-  //\r
-\r
-  //\r
-  //Assume that capsules have the same flags on reseting or not.\r
+  // Assume that capsules have the same flags on reseting or not.\r
   //\r
   CapsuleHeader = CapsuleHeaderArray[0];\r
 \r
   if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {\r
     //\r
-    //Check if the platform supports update capsule across a system reset\r
+    // Check if the platform supports update capsule across a system reset\r
     //\r
     if (!FeaturePcdGet(PcdSupportUpdateCapsuleRest)) {\r
       return EFI_UNSUPPORTED;\r
@@ -102,7 +95,7 @@ Returns:
     // ScatterGatherList is only referenced if the capsules are defined to persist across\r
     // system reset. \r
     //\r
-    if (ScatterGatherList == (EFI_PHYSICAL_ADDRESS) NULL) {\r
+    if (ScatterGatherList == (EFI_PHYSICAL_ADDRESS) (UINTN) NULL) {\r
       return EFI_INVALID_PARAMETER;\r
     } else {\r
       //\r
@@ -120,43 +113,30 @@ Returns:
       if (Status != EFI_SUCCESS) {\r
         return Status;\r
       }\r
+      //\r
+      // Successfully set the capsule image address into variable.\r
+      //\r
+      return EFI_SUCCESS;\r
     }\r
-    return EFI_SUCCESS;\r
   }\r
 \r
   //\r
   // The rest occurs in the condition of non-reset mode\r
-  // Current Runtime mode doesn't support the non-reset capsule image.\r
+  // Now Runtime mode doesn't support the non-reset capsule image.\r
   //\r
   if (EfiAtRuntime ()) {\r
-    return EFI_INVALID_PARAMETER;\r
+    return EFI_UNSUPPORTED;\r
   }\r
 \r
   //\r
   // Here should be in the boot-time for non-reset capsule image\r
-  // Default process to Update Capsule image into Flash for any guid image.\r
+  // Default process to Update Capsule image into Flash.\r
   //\r
   for (ArrayNumber = 0; ArrayNumber < CapsuleCount ; ArrayNumber++) {\r
-    CapsuleHeader = CapsuleHeaderArray[ArrayNumber];\r
-    CapsuleSize = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize;\r
-\r
-    BufferPtr = AllocatePool (CapsuleSize);\r
-    if (BufferPtr == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    CopyMem (BufferPtr, (UINT8*)CapsuleHeader+ CapsuleHeader->HeaderSize, CapsuleSize);\r
-\r
-    //\r
-    //Call DXE service ProcessFirmwareVolume to process immediatelly\r
-    //\r
-    Status = gDS->ProcessFirmwareVolume (BufferPtr, CapsuleSize, &FvHandle);\r
-    if (Status != EFI_SUCCESS) {\r
-      FreePool (BufferPtr);\r
+    Status = ProcessCapsuleImage (CapsuleHeaderArray[ArrayNumber]);\r
+    if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
-    gDS->Dispatch ();\r
-    FreePool (BufferPtr);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -218,11 +198,12 @@ Returns:
       return EFI_INVALID_PARAMETER;\r
     }\r
     //\r
-    // To remove this check. Capsule update supports non reset image.\r
-    // \r
-    //    if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {\r
-    //      return EFI_UNSUPPORTED;\r
-    //    }\r
+    // Check Capsule image without populate flag by firmware support capsule function  \r
+    //\r
+    if (((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) && \r
+        (SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS)) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
   }\r
 \r
   //\r