]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c
Enable UEFI firmware to support FMP capsule format.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / Capsules.c
index 07c12195fcf09c5f079eb5a64bf12d1c31dfb48a..6c7fc7ced4c996ebe3bef5449a36b26d4b8002fb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   BDS routines to handle capsules.\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>\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
@@ -52,14 +52,16 @@ BdsProcessCapsules (
   VOID                        **CapsulePtr;\r
   VOID                        **CapsulePtrCache;\r
   EFI_GUID                    *CapsuleGuidCache; \r
+  BOOLEAN                     NeedReset;\r
 \r
-  CapsuleNumber = 0;\r
+  CapsuleNumber      = 0;\r
   CapsuleTotalNumber = 0;\r
-  CacheIndex   = 0;\r
-  CacheNumber  = 0;\r
-  CapsulePtr        = NULL;\r
-  CapsulePtrCache   = NULL;\r
-  CapsuleGuidCache  = NULL;\r
+  CacheIndex         = 0;\r
+  CacheNumber        = 0;\r
+  CapsulePtr         = NULL;\r
+  CapsulePtrCache    = NULL;\r
+  CapsuleGuidCache   = NULL;\r
+  NeedReset          = FALSE;\r
 \r
   //\r
   // We don't do anything else if the boot mode is not flash-update\r
@@ -190,6 +192,13 @@ BdsProcessCapsules (
   for (Index = 0; Index < CapsuleTotalNumber; Index++) {\r
     CapsuleHeader = (EFI_CAPSULE_HEADER*) CapsulePtr [Index];\r
     if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {\r
+      //\r
+      // Always reset system after all capsule processed if FMP capsule exist\r
+      //\r
+      if (CompareGuid (&gEfiFmpCapsuleGuid, &CapsuleHeader->CapsuleGuid)){\r
+        NeedReset = TRUE;\r
+      }\r
+\r
       //\r
       // Call capsule library to process capsule image.\r
       //\r
@@ -197,6 +206,19 @@ BdsProcessCapsules (
     }\r
   }\r
 \r
+  if (NeedReset) {\r
+    Print(L"Capsule Request Cold Reboot.\n");\r
+\r
+    for (Index = 5; Index > 0; Index--) {\r
+      Print(L"\rResetting system in %d seconds ...", Index);\r
+      gBS->Stall (1000000);\r
+    }\r
+\r
+    gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+\r
+    CpuDeadLoop ();\r
+  }\r
+\r
   PlatformBdsLockNonUpdatableFlash ();\r
   \r
   //\r