]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c
OvmfPkg/Csm/LegacyBiosDxe: Fix Legacy16GetTableAddress call for E820 data
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / DxeCapsuleLib / DxeCapsuleLib.c
index 04db1a4f6c0618df6f255d95980e5a6703eabbc9..002b25888b4022f2b9b48cbff757dcdf2a0e788b 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
   Capsule Library instance to process capsule images.\r
 \r
-  Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 #include <PiDxe.h>\r
@@ -82,7 +76,7 @@ ValidateFmpCapsule (
 \r
   if (ItemNum == FmpCapsuleHeader->EmbeddedDriverCount) {\r
     //\r
-    // No payload element \r
+    // No payload element\r
     //\r
     if (((UINT8 *)FmpCapsuleHeader + ItemOffsetList[ItemNum - 1]) < EndOfCapsule) {\r
       return EFI_SUCCESS;\r
@@ -123,7 +117,7 @@ ValidateFmpCapsule (
 }\r
 \r
 /**\r
-  Process Firmware management protocol data capsule.  \r
+  Process Firmware management protocol data capsule.\r
 \r
   @param  CapsuleHeader         Points to a capsule header.\r
 \r
@@ -139,7 +133,6 @@ ProcessFmpCapsuleImage (
 {\r
   EFI_STATUS                                    Status;\r
   EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER        *FmpCapsuleHeader;\r
-  UINT8                                         *EndOfCapsule;\r
   EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER  *ImageHeader;\r
   EFI_HANDLE                                    ImageHandle;\r
   UINT64                                        *ItemOffsetList;\r
@@ -170,7 +163,6 @@ ProcessFmpCapsuleImage (
   DriverDevicePath = NULL;\r
 \r
   FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);\r
-  EndOfCapsule     = (UINT8 *) CapsuleHeader + CapsuleHeader->CapsuleImageSize;\r
 \r
   if (FmpCapsuleHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -187,15 +179,15 @@ ProcessFmpCapsuleImage (
   }\r
 \r
   //\r
-  // 1. ConnectAll to ensure \r
-  //    All the communication protocol required by driver in capsule installed \r
+  // 1. ConnectAll to ensure\r
+  //    All the communication protocol required by driver in capsule installed\r
   //    All FMP protocols are installed\r
   //\r
   BdsLibConnectAll();\r
 \r
 \r
   //\r
-  // 2. Try to load & start all the drivers within capsule \r
+  // 2. Try to load & start all the drivers within capsule\r
   //\r
   SetDevicePathNodeLength (&MemMapNode.Header, sizeof (MemMapNode));\r
   MemMapNode.Header.Type     = HARDWARE_DEVICE_PATH;\r
@@ -232,8 +224,8 @@ ProcessFmpCapsuleImage (
     }\r
 \r
     Status = gBS->StartImage(\r
-                    ImageHandle, \r
-                    &ExitDataSize, \r
+                    ImageHandle,\r
+                    &ExitDataSize,\r
                     NULL\r
                     );\r
     if (EFI_ERROR(Status)) {\r
@@ -243,7 +235,7 @@ ProcessFmpCapsuleImage (
   }\r
 \r
   //\r
-  // Connnect all again to connect drivers within capsule \r
+  // Connnect all again to connect drivers within capsule\r
   //\r
   if (FmpCapsuleHeader->EmbeddedDriverCount > 0) {\r
     BdsLibConnectAll();\r
@@ -320,7 +312,7 @@ ProcessFmpCapsuleImage (
       TempFmpImageInfo = FmpImageInfoBuf;\r
       for (Index2 = 0; Index2 < FmpImageInfoCount; Index2++) {\r
         //\r
-        // Check all the payload entry in capsule payload list \r
+        // Check all the payload entry in capsule payload list\r
         //\r
         for (Index = FmpCapsuleHeader->EmbeddedDriverCount; Index < ItemNum; Index++) {\r
           ImageHeader  = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);\r
@@ -517,4 +509,42 @@ ProcessCapsuleImage (
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  This routine is called to process capsules.\r
+\r
+  Caution: This function may receive untrusted input.\r
+\r
+  The capsules reported in EFI_HOB_UEFI_CAPSULE are processed.\r
+  If there is no EFI_HOB_UEFI_CAPSULE, this routine does nothing.\r
+\r
+  This routine should be called twice in BDS.\r
+  1) The first call must be before EndOfDxe. The system capsules is processed.\r
+     If device capsule FMP protocols are exposted at this time and device FMP\r
+     capsule has zero EmbeddedDriverCount, the device capsules are processed.\r
+     Each individual capsule result is recorded in capsule record variable.\r
+     System may reset in this function, if reset is required by capsule and\r
+     all capsules are processed.\r
+     If not all capsules are processed, reset will be defered to second call.\r
+\r
+  2) The second call must be after EndOfDxe and after ConnectAll, so that all\r
+     device capsule FMP protocols are exposed.\r
+     The system capsules are skipped. If the device capsules are NOT processed\r
+     in first call, they are processed here.\r
+     Each individual capsule result is recorded in capsule record variable.\r
+     System may reset in this function, if reset is required by capsule\r
+     processed in first call and second call.\r
+\r
+  @retval EFI_SUCCESS             There is no error when processing capsules.\r
+  @retval EFI_OUT_OF_RESOURCES    No enough resource to process capsules.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessCapsules (\r
+  VOID\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
 \r