**/\r
\r
#include "FmpDxe.h"\r
+#include "VariableSupport.h"\r
\r
///\r
/// FILE_GUID from FmpDxe.inf. When FmpDxe.inf is used in a platform, the\r
NULL, // VersionName\r
TRUE, // RuntimeVersionSupported\r
NULL, // FmpDeviceLockEvent\r
- FALSE // FmpDeviceLocked\r
+ FALSE, // FmpDeviceLocked\r
+ NULL, // FmpDeviceContext\r
+ NULL, // VersionVariableName\r
+ NULL, // LsvVariableName\r
+ NULL, // LastAttemptStatusVariableName\r
+ NULL, // LastAttemptVersionVariableName\r
+ NULL // FmpStateVariableName\r
};\r
\r
///\r
the GUID value from the FmpDeviceLib. If the FmpDeviceLib does not provide\r
a GUID value, then gEfiCallerIdGuid is returned.\r
\r
- @return The ImageTypeId GUID\r
+ @retval The ImageTypeId GUID\r
\r
**/\r
EFI_GUID *\r
/**\r
Returns a pointer to the Null-terminated Unicode ImageIdName string.\r
\r
- @return Null-terminated Unicode ImageIdName string.\r
+ @retval Null-terminated Unicode ImageIdName string.\r
\r
**/\r
CHAR16 *\r
2. Check if we have a variable for lowest supported version (this will be updated with each capsule applied)\r
3. Check Fixed at build PCD\r
\r
- @return The largest value\r
+ @param[in] Private Pointer to the private context structure for the\r
+ Firmware Management Protocol instance.\r
+\r
+ @retval The largest value\r
\r
**/\r
UINT32\r
GetLowestSupportedVersion (\r
- VOID\r
+ FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private\r
)\r
{\r
EFI_STATUS Status;\r
//\r
// Check the lowest supported version UEFI variable for this device\r
//\r
- VariableLowestSupportedVersion = GetLowestSupportedVersionFromVariable();\r
+ VariableLowestSupportedVersion = GetLowestSupportedVersionFromVariable (Private);\r
if (VariableLowestSupportedVersion > ReturnLsv) {\r
ReturnLsv = VariableLowestSupportedVersion;\r
}\r
Private->Descriptor.ImageId = Private->Descriptor.ImageIndex;\r
Private->Descriptor.ImageIdName = GetImageTypeNameString();\r
\r
+ //\r
+ // Get the hardware instance from FmpDeviceLib\r
+ //\r
+ Status = FmpDeviceGetHardwareInstance (&Private->Descriptor.HardwareInstance);\r
+ if (Status == EFI_UNSUPPORTED) {\r
+ Private->Descriptor.HardwareInstance = 0;\r
+ }\r
+\r
+ //\r
+ // Generate UEFI Variable names used to store status information for this\r
+ // FMP instance.\r
+ //\r
+ GenerateFmpVariableNames (Private);\r
+\r
//\r
// Get the version. Some devices don't support getting the firmware version\r
// at runtime. If FmpDeviceLib does not support returning a version, then\r
Status = FmpDeviceGetVersion (&Private->Descriptor.Version);\r
if (Status == EFI_UNSUPPORTED) {\r
Private->RuntimeVersionSupported = FALSE;\r
- Private->Descriptor.Version = GetVersionFromVariable();\r
+ Private->Descriptor.Version = GetVersionFromVariable (Private);\r
} else if (EFI_ERROR (Status)) {\r
//\r
// Unexpected error. Use default version.\r
);\r
}\r
\r
- Private->Descriptor.LowestSupportedImageVersion = GetLowestSupportedVersion();\r
+ Private->Descriptor.LowestSupportedImageVersion = GetLowestSupportedVersion (Private);\r
\r
//\r
// Get attributes from the FmpDeviceLib\r
Private->Descriptor.Size = 0;\r
}\r
\r
- Private->Descriptor.LastAttemptVersion = GetLastAttemptVersionFromVariable ();\r
- Private->Descriptor.LastAttemptStatus = GetLastAttemptStatusFromVariable ();\r
-\r
- //\r
- // Get the hardware instance from FmpDeviceLib\r
- //\r
- Status = FmpDeviceGetHardwareInstance (&Private->Descriptor.HardwareInstance);\r
- if (Status == EFI_UNSUPPORTED) {\r
- Private->Descriptor.HardwareInstance = 0;\r
- }\r
+ Private->Descriptor.LastAttemptVersion = GetLastAttemptVersionFromVariable (Private);\r
+ Private->Descriptor.LastAttemptStatus = GetLastAttemptStatusFromVariable (Private);\r
\r
Private->DescriptorPopulated = TRUE;\r
}\r
*ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);\r
\r
//\r
- // make sure the descriptor has already been loaded\r
+ // Make sure the descriptor has already been loaded or refreshed\r
//\r
PopulateDescriptor (Private);\r
\r
FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);\r
\r
//\r
- // make sure the descriptor has already been loaded\r
+ // Make sure the descriptor has already been loaded or refreshed\r
//\r
PopulateDescriptor (Private);\r
\r
Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);\r
FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);\r
\r
- SetLastAttemptVersionInVariable (IncommingFwVersion); //set to 0 to clear any previous results.\r
+ //\r
+ // Make sure the descriptor has already been loaded or refreshed\r
+ //\r
+ PopulateDescriptor (Private);\r
+\r
+ //\r
+ // Set to 0 to clear any previous results.\r
+ //\r
+ SetLastAttemptVersionInVariable (Private, IncommingFwVersion);\r
\r
//\r
// if we have locked the device, then skip the set operation.\r
//\r
// Set to actual value\r
//\r
- SetLastAttemptVersionInVariable (IncommingFwVersion);\r
+ SetLastAttemptVersionInVariable (Private, IncommingFwVersion);\r
}\r
\r
\r
// Save LastAttemptStatus as error so that if SetImage never returns the error\r
// state is recorded.\r
//\r
- SetLastAttemptStatusInVariable (LastAttemptStatus);\r
+ SetLastAttemptStatusInVariable (Private, LastAttemptStatus);\r
\r
//\r
// Strip off all the headers so the device can process its firmware\r
if (!Private->RuntimeVersionSupported) {\r
Version = DEFAULT_VERSION;\r
GetFmpPayloadHeaderVersion (FmpHeader, FmpPayloadSize, &Version);\r
- SetVersionInVariable (Version);\r
+ SetVersionInVariable (Private, Version);\r
}\r
\r
//\r
// Update lowest supported variable\r
//\r
- {\r
- LowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;\r
- GetFmpPayloadHeaderLowestSupportedVersion (FmpHeader, FmpPayloadSize, &LowestSupportedVersion);\r
- SetLowestSupportedVersionInVariable (LowestSupportedVersion);\r
- }\r
+ LowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;\r
+ GetFmpPayloadHeaderLowestSupportedVersion (FmpHeader, FmpPayloadSize, &LowestSupportedVersion);\r
+ SetLowestSupportedVersionInVariable (Private, LowestSupportedVersion);\r
\r
LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;\r
\r
cleanup:\r
mProgressFunc = NULL;\r
- SetLastAttemptStatusInVariable (LastAttemptStatus);\r
+ SetLastAttemptStatusInVariable (Private, LastAttemptStatus);\r
\r
if (Progress != NULL) {\r
//\r
goto cleanup;\r
}\r
\r
+ //\r
+ // Make sure the descriptor has already been loaded or refreshed\r
+ //\r
+ PopulateDescriptor (Private);\r
+\r
DEBUG ((DEBUG_ERROR, "InstallFmpInstance: Lock events\n"));\r
\r
if (IsLockFmpDeviceAtLockEventGuidRequired ()) {\r
//\r
// Lock all UEFI Variables used by this module.\r
//\r
- Status = LockAllFmpVariables ();\r
+ Status = LockAllFmpVariables (Private);\r
if (EFI_ERROR (Status)) {\r
DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to lock variables. Status = %r.\n", Status));\r
} else {\r
if (Private->FmpDeviceLockEvent != NULL) {\r
gBS->CloseEvent (Private->FmpDeviceLockEvent);\r
}\r
+ if (Private->Descriptor.VersionName != NULL) {\r
+ FreePool (Private->Descriptor.VersionName);\r
+ }\r
+ if (Private->FmpDeviceContext != NULL) {\r
+ FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);\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
FreePool (Private);\r
}\r
}\r
return Status;\r
}\r
\r
- FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);\r
-\r
+ if (Private->Descriptor.VersionName != NULL) {\r
+ FreePool (Private->Descriptor.VersionName);\r
+ }\r
+ if (Private->FmpDeviceContext != NULL) {\r
+ FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);\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
FreePool (Private);\r
\r
return EFI_SUCCESS;\r