+/**\r
+ Generates a Null-terminated Unicode string UEFI Variable name from a base name\r
+ and a hardware instance. If the hardware instance value is 0, then the base\r
+ name is returned. If the hardware instance value is non-zero, then the 64-bit\r
+ hardware instance value is converted to a 16 character hex string and appended\r
+ to base name. The UEFI Variable name returned is allocated using the UEFI\r
+ Boot Service AllocatePool().\r
+\r
+ @param[in] HardwareInstance 64-bit hardware instance value.\r
+ @param[in] BaseVariableName Null-terminated Unicode string that is the base\r
+ name of the UEFI Variable.\r
+\r
+ @return Pointer to the allocated UEFI Variable name. Returns NULL if the\r
+ UEFI Variable can not be allocated.\r
+**/\r
+static\r
+CHAR16 *\r
+GenerateFmpVariableName (\r
+ IN UINT64 HardwareInstance,\r
+ IN CHAR16 *BaseVariableName\r
+ )\r
+{\r
+ CHAR16 *VariableName;\r
+\r
+ VariableName = CatSPrint (NULL, BaseVariableName);\r
+ if (VariableName == NULL) {\r
+ DEBUG ((DEBUG_ERROR, "Failed to generate FMP variable name %s.\n", BaseVariableName));\r
+ return VariableName;\r
+ }\r
+ if (HardwareInstance == 0) {\r
+ return VariableName;\r
+ }\r
+ VariableName = CatSPrint (VariableName, L"%016lx", HardwareInstance);\r
+ if (VariableName == NULL) {\r
+ DEBUG ((DEBUG_ERROR, "Failed to generate FMP variable name %s.\n", BaseVariableName));\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
+ if (Private->LsvVariableName != NULL) {\r
+ FreePool (Private->LsvVariableName);\r
+ }\r
+ if (Private->LastAttemptStatusVariableName != NULL) {\r
+ FreePool (Private->LastAttemptStatusVariableName);\r
+ }\r
+ if (Private->LastAttemptVersionVariableName != NULL) {\r
+ FreePool (Private->LastAttemptVersionVariableName);\r
+ }\r
+ if (Private->FmpStateVariableName != NULL) {\r
+ FreePool (Private->FmpStateVariableName);\r
+ }\r