+ Size = StrSize (BaseVariableName) + 16 * sizeof (CHAR16);\r
+ VariableName = AllocateCopyPool (Size, BaseVariableName);\r
+ if (VariableName == NULL) {\r
+ DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to generate variable name %s.\n", mImageIdName, BaseVariableName));\r
+ return VariableName;\r
+ }\r
+\r
+ if (HardwareInstance == 0) {\r
+ return VariableName;\r
+ }\r
+\r
+ UnicodeValueToStringS (\r
+ &VariableName[StrLen (BaseVariableName)],\r
+ Size,\r
+ PREFIX_ZERO | RADIX_HEX,\r
+ HardwareInstance,\r
+ 16\r
+ );\r
+ return VariableName;\r
+}\r
+\r
+/**\r
+ Generate the names of the UEFI Variables used to store state information for\r
+ a managed controller. The UEFI Variables names are a combination of a base\r
+ name and an optional hardware instance value as a 16 character hex value. If\r
+ the hardware instance value is 0, then the 16 character hex value is not\r
+ included. These storage for the UEFI Variable names are allocated using the\r
+ UEFI Boot Service AllocatePool() and the pointers are stored in the Private.\r
+ The following are examples of variable names produces for hardware instance\r
+ value 0 and value 0x1234567812345678.\r
+\r
+ FmpVersion\r
+ FmpLsv\r
+ LastAttemptStatus\r
+ LastAttemptVersion\r
+ FmpState\r
+\r
+ FmpVersion1234567812345678\r
+ FmpLsv1234567812345678\r
+ LastAttemptStatus1234567812345678\r
+ LastAttemptVersion1234567812345678\r
+ FmpState1234567812345678\r
+\r
+ @param[in,out] Private Private context structure for the managed controller.\r
+**/\r
+VOID\r
+GenerateFmpVariableNames (\r
+ IN OUT FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Buffer;\r
+ FMP_CONTROLLER_STATE FmpControllerState;\r
+\r
+ if (Private->VersionVariableName != NULL) {\r
+ FreePool (Private->VersionVariableName);\r
+ }\r
+\r
+ if (Private->LsvVariableName != NULL) {\r
+ FreePool (Private->LsvVariableName);\r
+ }\r
+\r
+ if (Private->LastAttemptStatusVariableName != NULL) {\r
+ FreePool (Private->LastAttemptStatusVariableName);\r
+ }\r
+\r
+ if (Private->LastAttemptVersionVariableName != NULL) {\r
+ FreePool (Private->LastAttemptVersionVariableName);\r
+ }\r
+\r
+ if (Private->FmpStateVariableName != NULL) {\r
+ FreePool (Private->FmpStateVariableName);\r
+ }\r
+\r
+ Private->VersionVariableName = GenerateFmpVariableName (\r
+ Private->Descriptor.HardwareInstance,\r
+ VARNAME_VERSION\r
+ );\r
+ Private->LsvVariableName = GenerateFmpVariableName (\r
+ Private->Descriptor.HardwareInstance,\r
+ VARNAME_LSV\r
+ );\r
+ Private->LastAttemptStatusVariableName = GenerateFmpVariableName (\r
+ Private->Descriptor.HardwareInstance,\r
+ VARNAME_LASTATTEMPTSTATUS\r
+ );\r
+ Private->LastAttemptVersionVariableName = GenerateFmpVariableName (\r
+ Private->Descriptor.HardwareInstance,\r
+ VARNAME_LASTATTEMPTVERSION\r
+ );\r
+ Private->FmpStateVariableName = GenerateFmpVariableName (\r
+ Private->Descriptor.HardwareInstance,\r
+ VARNAME_FMPSTATE\r
+ );\r
+\r
+ DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->VersionVariableName));\r
+ DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->LsvVariableName));\r
+ DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->LastAttemptStatusVariableName));\r
+ DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->LastAttemptVersionVariableName));\r
+ DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName));\r
+\r
+ Buffer = GetFmpControllerState (Private);\r
+ if (Buffer != NULL) {\r