]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c
IntelFrameworkModulePkg/BdsDxe: Remove the useless Perf codes
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / Capsules.c
index 0c2f3c1b7944fae5e2e7ddd5537dc79248b575d2..6c7fc7ced4c996ebe3bef5449a36b26d4b8002fb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   BDS routines to handle capsules.\r
 \r
-Copyright (c) 2004 - 2009, 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,19 +52,22 @@ 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
   //\r
   if (BootMode != BOOT_ON_FLASH_UPDATE) {\r
+    DEBUG ((EFI_D_ERROR, "Boot mode is not correct for capsule update.\n"));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   \r
@@ -82,6 +85,10 @@ BdsProcessCapsules (
     //\r
     // We didn't find a hob, so had no errors.\r
     //\r
+    DEBUG ((EFI_D_ERROR, "We can not find capsule data in capsule update boot mode.\n"));\r
+    DEBUG ((EFI_D_ERROR, "Please check the followings are correct if unexpected capsule update error happens.\n"));\r
+    DEBUG ((EFI_D_ERROR, "1. CapsuleX64 is built as X64 module when PEI is IA32 and DXE is X64\n"));\r
+    DEBUG ((EFI_D_ERROR, "2. Capsule data should persist in memory across a system reset.\n"));\r
     PlatformBdsLockNonUpdatableFlash ();\r
     return EFI_SUCCESS;\r
   }\r
@@ -185,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
@@ -192,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