#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
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
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
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