]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance UpdateCapsule () to support calling multiple times.
authorli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 23 Feb 2010 02:33:17 +0000 (02:33 +0000)
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 23 Feb 2010 02:33:17 +0000 (02:33 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10044 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c

index 2ab29ba339b2cd3f759328de622f1fe7c397e0c5..c627e9b8d631880e29f1ec75c42d22c3bb4192df 100644 (file)
@@ -5,7 +5,7 @@
 #  It installs the Capsule Architectural Protocol defined in PI1.0a to signify \r
 #  the capsule runtime services are ready.\r
 #  \r
-#  Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
+#  Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 #  All rights reserved. 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
@@ -45,6 +45,8 @@
   UefiDriverEntryPoint\r
   CapsuleLib\r
   UefiRuntimeLib\r
+  BaseLib\r
+  PrintLib\r
 \r
 [Guids]\r
   gEfiCapsuleVendorGuid                         ## SOMETIMES_PRODUCED (Process across reset capsule image) ## Variable:L"CapsuleUpdateData" for capsule updated data\r
index fc9fc0e78f6007c34525b8dba75845b6ea58c43d..774730e6f8f37efb147629db94372502b8f74f59 100644 (file)
@@ -27,12 +27,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/PrintLib.h>\r
 \r
 //\r
 // Handle for the installation of Capsule Architecture Protocol.\r
 //\r
 EFI_HANDLE  mNewHandle = NULL;\r
 \r
+//\r
+// The times of calling UpdateCapsule ()\r
+//\r
+UINTN       mTimes      = 0;\r
+\r
 /**\r
   Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended\r
   consumption, the firmware may process the capsule immediately. If the payload should persist\r
@@ -72,6 +79,8 @@ UpdateCapsule (
   EFI_CAPSULE_HEADER        *CapsuleHeader;\r
   BOOLEAN                   NeedReset;\r
   BOOLEAN                   InitiateReset;\r
+  CHAR16                    CapsuleVarName[30];\r
+  CHAR16                    *TempVarName;  \r
   \r
   //\r
   // Capsule Count can't be less than one.\r
@@ -80,9 +89,10 @@ UpdateCapsule (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  NeedReset     = FALSE;\r
-  InitiateReset = FALSE;\r
-  CapsuleHeader = NULL;\r
+  NeedReset         = FALSE;\r
+  InitiateReset     = FALSE;\r
+  CapsuleHeader     = NULL;\r
+  CapsuleVarName[0] = 0;\r
 \r
   for (ArrayNumber = 0; ArrayNumber < CapsuleCount; ArrayNumber++) {\r
     //\r
@@ -159,25 +169,41 @@ UpdateCapsule (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
+  //\r
+  // Construct variable name CapsuleUpdateData, CapsuleUpdateData1, CapsuleUpdateData2...\r
+  // if user calls UpdateCapsule multiple times.\r
+  //\r
+  StrCpy (CapsuleVarName, EFI_CAPSULE_VARIABLE_NAME);\r
+  TempVarName = CapsuleVarName + StrLen (CapsuleVarName);\r
+  if (mTimes > 0) {\r
+    UnicodeValueToString (TempVarName, 0, mTimes, 0);\r
+  }\r
+\r
   //\r
   // ScatterGatherList is only referenced if the capsules are defined to persist across\r
   // system reset. Set its value into NV storage to let pre-boot driver to pick it up \r
   // after coming through a system reset.\r
   //\r
   Status = EfiSetVariable (\r
-             EFI_CAPSULE_VARIABLE_NAME,\r
+             CapsuleVarName,\r
              &gEfiCapsuleVendorGuid,\r
              EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
              sizeof (UINTN),\r
              (VOID *) &ScatterGatherList\r
              );\r
-  if (!EFI_ERROR (Status) && InitiateReset) {\r
-    //\r
-    // Firmware that encounters a capsule which has the CAPSULE_FLAGS_INITIATE_RESET Flag set in its header\r
-    // will initiate a reset of the platform which is compatible with the passed-in capsule request and will \r
-    // not return back to the caller.\r
-    //\r
-    EfiResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+  if (!EFI_ERROR (Status)) {\r
+     //\r
+     // Variable has been set successfully, increase variable index.\r
+     //\r
+     mTimes++;\r
+     if(InitiateReset) {\r
+       //\r
+       // Firmware that encounters a capsule which has the CAPSULE_FLAGS_INITIATE_RESET Flag set in its header\r
+       // will initiate a reset of the platform which is compatible with the passed-in capsule request and will \r
+       // not return back to the caller.\r
+       //\r
+       EfiResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+     }\r
   }\r
   return Status;\r
 }\r