mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-21 20:54:29 +02:00
FmpDevicePkg/FmpDxe: Different variable for each FMP Descriptor
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525 Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Eric Jin <eric.jin@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
4f0544b144
commit
67c1e5ee6e
@ -11,6 +11,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#include "FmpDxe.h"
|
#include "FmpDxe.h"
|
||||||
|
#include "VariableSupport.h"
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FILE_GUID from FmpDxe.inf. When FmpDxe.inf is used in a platform, the
|
/// FILE_GUID from FmpDxe.inf. When FmpDxe.inf is used in a platform, the
|
||||||
@ -73,7 +74,13 @@ const FIRMWARE_MANAGEMENT_PRIVATE_DATA mFirmwareManagementPrivateDataTemplate =
|
|||||||
NULL, // VersionName
|
NULL, // VersionName
|
||||||
TRUE, // RuntimeVersionSupported
|
TRUE, // RuntimeVersionSupported
|
||||||
NULL, // FmpDeviceLockEvent
|
NULL, // FmpDeviceLockEvent
|
||||||
FALSE // FmpDeviceLocked
|
FALSE, // FmpDeviceLocked
|
||||||
|
NULL, // FmpDeviceContext
|
||||||
|
NULL, // VersionVariableName
|
||||||
|
NULL, // LsvVariableName
|
||||||
|
NULL, // LastAttemptStatusVariableName
|
||||||
|
NULL, // LastAttemptVersionVariableName
|
||||||
|
NULL // FmpStateVariableName
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -142,7 +149,7 @@ FmpDxeProgress (
|
|||||||
the GUID value from the FmpDeviceLib. If the FmpDeviceLib does not provide
|
the GUID value from the FmpDeviceLib. If the FmpDeviceLib does not provide
|
||||||
a GUID value, then gEfiCallerIdGuid is returned.
|
a GUID value, then gEfiCallerIdGuid is returned.
|
||||||
|
|
||||||
@return The ImageTypeId GUID
|
@retval The ImageTypeId GUID
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_GUID *
|
EFI_GUID *
|
||||||
@ -171,7 +178,7 @@ GetImageTypeIdGuid (
|
|||||||
/**
|
/**
|
||||||
Returns a pointer to the Null-terminated Unicode ImageIdName string.
|
Returns a pointer to the Null-terminated Unicode ImageIdName string.
|
||||||
|
|
||||||
@return Null-terminated Unicode ImageIdName string.
|
@retval Null-terminated Unicode ImageIdName string.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
CHAR16 *
|
CHAR16 *
|
||||||
@ -188,12 +195,15 @@ GetImageTypeNameString (
|
|||||||
2. Check if we have a variable for lowest supported version (this will be updated with each capsule applied)
|
2. Check if we have a variable for lowest supported version (this will be updated with each capsule applied)
|
||||||
3. Check Fixed at build PCD
|
3. Check Fixed at build PCD
|
||||||
|
|
||||||
@return The largest value
|
@param[in] Private Pointer to the private context structure for the
|
||||||
|
Firmware Management Protocol instance.
|
||||||
|
|
||||||
|
@retval The largest value
|
||||||
|
|
||||||
**/
|
**/
|
||||||
UINT32
|
UINT32
|
||||||
GetLowestSupportedVersion (
|
GetLowestSupportedVersion (
|
||||||
VOID
|
FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -230,7 +240,7 @@ GetLowestSupportedVersion (
|
|||||||
//
|
//
|
||||||
// Check the lowest supported version UEFI variable for this device
|
// Check the lowest supported version UEFI variable for this device
|
||||||
//
|
//
|
||||||
VariableLowestSupportedVersion = GetLowestSupportedVersionFromVariable();
|
VariableLowestSupportedVersion = GetLowestSupportedVersionFromVariable (Private);
|
||||||
if (VariableLowestSupportedVersion > ReturnLsv) {
|
if (VariableLowestSupportedVersion > ReturnLsv) {
|
||||||
ReturnLsv = VariableLowestSupportedVersion;
|
ReturnLsv = VariableLowestSupportedVersion;
|
||||||
}
|
}
|
||||||
@ -265,6 +275,20 @@ PopulateDescriptor (
|
|||||||
Private->Descriptor.ImageId = Private->Descriptor.ImageIndex;
|
Private->Descriptor.ImageId = Private->Descriptor.ImageIndex;
|
||||||
Private->Descriptor.ImageIdName = GetImageTypeNameString();
|
Private->Descriptor.ImageIdName = GetImageTypeNameString();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get the hardware instance from FmpDeviceLib
|
||||||
|
//
|
||||||
|
Status = FmpDeviceGetHardwareInstance (&Private->Descriptor.HardwareInstance);
|
||||||
|
if (Status == EFI_UNSUPPORTED) {
|
||||||
|
Private->Descriptor.HardwareInstance = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Generate UEFI Variable names used to store status information for this
|
||||||
|
// FMP instance.
|
||||||
|
//
|
||||||
|
GenerateFmpVariableNames (Private);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the version. Some devices don't support getting the firmware version
|
// Get the version. Some devices don't support getting the firmware version
|
||||||
// at runtime. If FmpDeviceLib does not support returning a version, then
|
// at runtime. If FmpDeviceLib does not support returning a version, then
|
||||||
@ -273,7 +297,7 @@ PopulateDescriptor (
|
|||||||
Status = FmpDeviceGetVersion (&Private->Descriptor.Version);
|
Status = FmpDeviceGetVersion (&Private->Descriptor.Version);
|
||||||
if (Status == EFI_UNSUPPORTED) {
|
if (Status == EFI_UNSUPPORTED) {
|
||||||
Private->RuntimeVersionSupported = FALSE;
|
Private->RuntimeVersionSupported = FALSE;
|
||||||
Private->Descriptor.Version = GetVersionFromVariable();
|
Private->Descriptor.Version = GetVersionFromVariable (Private);
|
||||||
} else if (EFI_ERROR (Status)) {
|
} else if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// Unexpected error. Use default version.
|
// Unexpected error. Use default version.
|
||||||
@ -309,7 +333,7 @@ PopulateDescriptor (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Private->Descriptor.LowestSupportedImageVersion = GetLowestSupportedVersion();
|
Private->Descriptor.LowestSupportedImageVersion = GetLowestSupportedVersion (Private);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get attributes from the FmpDeviceLib
|
// Get attributes from the FmpDeviceLib
|
||||||
@ -341,16 +365,8 @@ PopulateDescriptor (
|
|||||||
Private->Descriptor.Size = 0;
|
Private->Descriptor.Size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Private->Descriptor.LastAttemptVersion = GetLastAttemptVersionFromVariable ();
|
Private->Descriptor.LastAttemptVersion = GetLastAttemptVersionFromVariable (Private);
|
||||||
Private->Descriptor.LastAttemptStatus = GetLastAttemptStatusFromVariable ();
|
Private->Descriptor.LastAttemptStatus = GetLastAttemptStatusFromVariable (Private);
|
||||||
|
|
||||||
//
|
|
||||||
// Get the hardware instance from FmpDeviceLib
|
|
||||||
//
|
|
||||||
Status = FmpDeviceGetHardwareInstance (&Private->Descriptor.HardwareInstance);
|
|
||||||
if (Status == EFI_UNSUPPORTED) {
|
|
||||||
Private->Descriptor.HardwareInstance = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Private->DescriptorPopulated = TRUE;
|
Private->DescriptorPopulated = TRUE;
|
||||||
}
|
}
|
||||||
@ -453,7 +469,7 @@ GetTheImageInfo (
|
|||||||
*ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
|
*ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
|
||||||
|
|
||||||
//
|
//
|
||||||
// make sure the descriptor has already been loaded
|
// Make sure the descriptor has already been loaded or refreshed
|
||||||
//
|
//
|
||||||
PopulateDescriptor (Private);
|
PopulateDescriptor (Private);
|
||||||
|
|
||||||
@ -696,7 +712,7 @@ CheckTheImage (
|
|||||||
FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
|
FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
|
||||||
|
|
||||||
//
|
//
|
||||||
// make sure the descriptor has already been loaded
|
// Make sure the descriptor has already been loaded or refreshed
|
||||||
//
|
//
|
||||||
PopulateDescriptor (Private);
|
PopulateDescriptor (Private);
|
||||||
|
|
||||||
@ -949,7 +965,15 @@ SetTheImage (
|
|||||||
Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
|
Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
|
||||||
FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
|
FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
|
||||||
|
|
||||||
SetLastAttemptVersionInVariable (IncommingFwVersion); //set to 0 to clear any previous results.
|
//
|
||||||
|
// Make sure the descriptor has already been loaded or refreshed
|
||||||
|
//
|
||||||
|
PopulateDescriptor (Private);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set to 0 to clear any previous results.
|
||||||
|
//
|
||||||
|
SetLastAttemptVersionInVariable (Private, IncommingFwVersion);
|
||||||
|
|
||||||
//
|
//
|
||||||
// if we have locked the device, then skip the set operation.
|
// if we have locked the device, then skip the set operation.
|
||||||
@ -988,7 +1012,7 @@ SetTheImage (
|
|||||||
//
|
//
|
||||||
// Set to actual value
|
// Set to actual value
|
||||||
//
|
//
|
||||||
SetLastAttemptVersionInVariable (IncommingFwVersion);
|
SetLastAttemptVersionInVariable (Private, IncommingFwVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1080,7 +1104,7 @@ SetTheImage (
|
|||||||
// Save LastAttemptStatus as error so that if SetImage never returns the error
|
// Save LastAttemptStatus as error so that if SetImage never returns the error
|
||||||
// state is recorded.
|
// state is recorded.
|
||||||
//
|
//
|
||||||
SetLastAttemptStatusInVariable (LastAttemptStatus);
|
SetLastAttemptStatusInVariable (Private, LastAttemptStatus);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Strip off all the headers so the device can process its firmware
|
// Strip off all the headers so the device can process its firmware
|
||||||
@ -1132,23 +1156,21 @@ SetTheImage (
|
|||||||
if (!Private->RuntimeVersionSupported) {
|
if (!Private->RuntimeVersionSupported) {
|
||||||
Version = DEFAULT_VERSION;
|
Version = DEFAULT_VERSION;
|
||||||
GetFmpPayloadHeaderVersion (FmpHeader, FmpPayloadSize, &Version);
|
GetFmpPayloadHeaderVersion (FmpHeader, FmpPayloadSize, &Version);
|
||||||
SetVersionInVariable (Version);
|
SetVersionInVariable (Private, Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update lowest supported variable
|
// Update lowest supported variable
|
||||||
//
|
//
|
||||||
{
|
|
||||||
LowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
|
LowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
|
||||||
GetFmpPayloadHeaderLowestSupportedVersion (FmpHeader, FmpPayloadSize, &LowestSupportedVersion);
|
GetFmpPayloadHeaderLowestSupportedVersion (FmpHeader, FmpPayloadSize, &LowestSupportedVersion);
|
||||||
SetLowestSupportedVersionInVariable (LowestSupportedVersion);
|
SetLowestSupportedVersionInVariable (Private, LowestSupportedVersion);
|
||||||
}
|
|
||||||
|
|
||||||
LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
|
LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
mProgressFunc = NULL;
|
mProgressFunc = NULL;
|
||||||
SetLastAttemptStatusInVariable (LastAttemptStatus);
|
SetLastAttemptStatusInVariable (Private, LastAttemptStatus);
|
||||||
|
|
||||||
if (Progress != NULL) {
|
if (Progress != NULL) {
|
||||||
//
|
//
|
||||||
@ -1359,13 +1381,18 @@ InstallFmpInstance (
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make sure the descriptor has already been loaded or refreshed
|
||||||
|
//
|
||||||
|
PopulateDescriptor (Private);
|
||||||
|
|
||||||
DEBUG ((DEBUG_ERROR, "InstallFmpInstance: Lock events\n"));
|
DEBUG ((DEBUG_ERROR, "InstallFmpInstance: Lock events\n"));
|
||||||
|
|
||||||
if (IsLockFmpDeviceAtLockEventGuidRequired ()) {
|
if (IsLockFmpDeviceAtLockEventGuidRequired ()) {
|
||||||
//
|
//
|
||||||
// Lock all UEFI Variables used by this module.
|
// Lock all UEFI Variables used by this module.
|
||||||
//
|
//
|
||||||
Status = LockAllFmpVariables ();
|
Status = LockAllFmpVariables (Private);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to lock variables. Status = %r.\n", Status));
|
DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to lock variables. Status = %r.\n", Status));
|
||||||
} else {
|
} else {
|
||||||
@ -1417,6 +1444,27 @@ cleanup:
|
|||||||
if (Private->FmpDeviceLockEvent != NULL) {
|
if (Private->FmpDeviceLockEvent != NULL) {
|
||||||
gBS->CloseEvent (Private->FmpDeviceLockEvent);
|
gBS->CloseEvent (Private->FmpDeviceLockEvent);
|
||||||
}
|
}
|
||||||
|
if (Private->Descriptor.VersionName != NULL) {
|
||||||
|
FreePool (Private->Descriptor.VersionName);
|
||||||
|
}
|
||||||
|
if (Private->FmpDeviceContext != NULL) {
|
||||||
|
FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);
|
||||||
|
}
|
||||||
|
if (Private->VersionVariableName != NULL) {
|
||||||
|
FreePool (Private->VersionVariableName);
|
||||||
|
}
|
||||||
|
if (Private->LsvVariableName != NULL) {
|
||||||
|
FreePool (Private->LsvVariableName);
|
||||||
|
}
|
||||||
|
if (Private->LastAttemptStatusVariableName != NULL) {
|
||||||
|
FreePool (Private->LastAttemptStatusVariableName);
|
||||||
|
}
|
||||||
|
if (Private->LastAttemptVersionVariableName != NULL) {
|
||||||
|
FreePool (Private->LastAttemptVersionVariableName);
|
||||||
|
}
|
||||||
|
if (Private->FmpStateVariableName != NULL) {
|
||||||
|
FreePool (Private->FmpStateVariableName);
|
||||||
|
}
|
||||||
FreePool (Private);
|
FreePool (Private);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1473,8 +1521,27 @@ UninstallFmpInstance (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Private->Descriptor.VersionName != NULL) {
|
||||||
|
FreePool (Private->Descriptor.VersionName);
|
||||||
|
}
|
||||||
|
if (Private->FmpDeviceContext != NULL) {
|
||||||
FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);
|
FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);
|
||||||
|
}
|
||||||
|
if (Private->VersionVariableName != NULL) {
|
||||||
|
FreePool (Private->VersionVariableName);
|
||||||
|
}
|
||||||
|
if (Private->LsvVariableName != NULL) {
|
||||||
|
FreePool (Private->LsvVariableName);
|
||||||
|
}
|
||||||
|
if (Private->LastAttemptStatusVariableName != NULL) {
|
||||||
|
FreePool (Private->LastAttemptStatusVariableName);
|
||||||
|
}
|
||||||
|
if (Private->LastAttemptVersionVariableName != NULL) {
|
||||||
|
FreePool (Private->LastAttemptVersionVariableName);
|
||||||
|
}
|
||||||
|
if (Private->FmpStateVariableName != NULL) {
|
||||||
|
FreePool (Private->FmpStateVariableName);
|
||||||
|
}
|
||||||
FreePool (Private);
|
FreePool (Private);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
#include <Library/FmpAuthenticationLib.h>
|
#include <Library/FmpAuthenticationLib.h>
|
||||||
@ -26,9 +27,9 @@
|
|||||||
#include <Library/CapsuleUpdatePolicyLib.h>
|
#include <Library/CapsuleUpdatePolicyLib.h>
|
||||||
#include <Protocol/FirmwareManagement.h>
|
#include <Protocol/FirmwareManagement.h>
|
||||||
#include <Protocol/FirmwareManagementProgress.h>
|
#include <Protocol/FirmwareManagementProgress.h>
|
||||||
|
#include <Protocol/VariableLock.h>
|
||||||
#include <Guid/SystemResourceTable.h>
|
#include <Guid/SystemResourceTable.h>
|
||||||
#include <Guid/EventGroup.h>
|
#include <Guid/EventGroup.h>
|
||||||
#include "VariableSupport.h"
|
|
||||||
|
|
||||||
#define VERSION_STRING_NOT_SUPPORTED L"VERSION STRING NOT SUPPORTED"
|
#define VERSION_STRING_NOT_SUPPORTED L"VERSION STRING NOT SUPPORTED"
|
||||||
#define VERSION_STRING_NOT_AVAILABLE L"VERSION STRING NOT AVAILABLE"
|
#define VERSION_STRING_NOT_AVAILABLE L"VERSION STRING NOT AVAILABLE"
|
||||||
@ -57,6 +58,11 @@ typedef struct {
|
|||||||
//
|
//
|
||||||
BOOLEAN FmpDeviceLocked;
|
BOOLEAN FmpDeviceLocked;
|
||||||
VOID *FmpDeviceContext;
|
VOID *FmpDeviceContext;
|
||||||
|
CHAR16 *VersionVariableName;
|
||||||
|
CHAR16 *LsvVariableName;
|
||||||
|
CHAR16 *LastAttemptStatusVariableName;
|
||||||
|
CHAR16 *LastAttemptVersionVariableName;
|
||||||
|
CHAR16 *FmpStateVariableName;
|
||||||
} FIRMWARE_MANAGEMENT_PRIVATE_DATA;
|
} FIRMWARE_MANAGEMENT_PRIVATE_DATA;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
|||||||
firmware updates.
|
firmware updates.
|
||||||
|
|
||||||
Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
|
Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
|
||||||
Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
@ -12,16 +12,75 @@
|
|||||||
#ifndef __VARIABLE_SUPPORT_H__
|
#ifndef __VARIABLE_SUPPORT_H__
|
||||||
#define __VARIABLE_SUPPORT_H__
|
#define __VARIABLE_SUPPORT_H__
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default values for FMP Controller State information
|
||||||
|
///
|
||||||
#define DEFAULT_VERSION 0x1
|
#define DEFAULT_VERSION 0x1
|
||||||
#define DEFAULT_LOWESTSUPPORTEDVERSION 0x0
|
#define DEFAULT_LOWESTSUPPORTEDVERSION 0x0
|
||||||
#define DEFAULT_LASTATTEMPT 0x0
|
#define DEFAULT_LASTATTEMPTSTATUS 0x0
|
||||||
|
#define DEFAULT_LASTATTEMPTVERSION 0x0
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Base UEFI Variable names for FMP Controller State information stored in
|
||||||
|
/// separate variables.
|
||||||
|
///
|
||||||
#define VARNAME_VERSION L"FmpVersion"
|
#define VARNAME_VERSION L"FmpVersion"
|
||||||
#define VARNAME_LSV L"FmpLsv"
|
#define VARNAME_LSV L"FmpLsv"
|
||||||
|
|
||||||
#define VARNAME_LASTATTEMPTSTATUS L"LastAttemptStatus"
|
#define VARNAME_LASTATTEMPTSTATUS L"LastAttemptStatus"
|
||||||
#define VARNAME_LASTATTEMPTVERSION L"LastAttemptVersion"
|
#define VARNAME_LASTATTEMPTVERSION L"LastAttemptVersion"
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Base UEFI Variable name for FMP Controller State information stored in a
|
||||||
|
/// merged UEFI Variable. If the separate UEFI Variables above are detected,
|
||||||
|
/// then they are merged into a single variable and the separate variables are
|
||||||
|
/// deleted.
|
||||||
|
///
|
||||||
|
#define VARNAME_FMPSTATE L"FmpState"
|
||||||
|
|
||||||
|
///
|
||||||
|
/// FMP Controller State structure that is used to store the state of
|
||||||
|
/// a controller in one combined UEFI Variable.
|
||||||
|
///
|
||||||
|
typedef struct {
|
||||||
|
BOOLEAN VersionValid;
|
||||||
|
BOOLEAN LsvValid;
|
||||||
|
BOOLEAN LastAttemptStatusValid;
|
||||||
|
BOOLEAN LastAttemptVersionValid;
|
||||||
|
UINT32 Version;
|
||||||
|
UINT32 Lsv;
|
||||||
|
UINT32 LastAttemptStatus;
|
||||||
|
UINT32 LastAttemptVersion;
|
||||||
|
} FMP_CONTROLLER_STATE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Generate the names of the UEFI Variables used to store state information for
|
||||||
|
a managed controller. The UEFI Variables names are a combination of a base
|
||||||
|
name and an optional hardware instance value as a 16 character hex value. If
|
||||||
|
the hardware instance value is 0, then the 16 character hex value is not
|
||||||
|
included. These storage for the UEFI Variable names are allocated using the
|
||||||
|
UEFI Boot Service AllocatePool() and the pointers are stored in the Private.
|
||||||
|
The following are examples of variable names produces for hardware instance
|
||||||
|
value 0 and value 0x1234567812345678.
|
||||||
|
|
||||||
|
FmpVersion
|
||||||
|
FmpLsv
|
||||||
|
LastAttemptStatus
|
||||||
|
LastAttemptVersion
|
||||||
|
FmpDxe
|
||||||
|
|
||||||
|
FmpVersion1234567812345678
|
||||||
|
FmpLsv1234567812345678
|
||||||
|
LastAttemptStatus1234567812345678
|
||||||
|
LastAttemptVersion1234567812345678
|
||||||
|
FmpDxe1234567812345678
|
||||||
|
|
||||||
|
@param[in,out] Private Private context structure for the managed controller.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
GenerateFmpVariableNames (
|
||||||
|
IN OUT FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the value used to fill in the Version field of the
|
Returns the value used to fill in the Version field of the
|
||||||
EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
|
EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
|
||||||
@ -29,14 +88,15 @@
|
|||||||
variable. If the UEFI variables does not exist, then a default version value
|
variable. If the UEFI variables does not exist, then a default version value
|
||||||
is returned.
|
is returned.
|
||||||
|
|
||||||
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"
|
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed controller.
|
||||||
|
|
||||||
@return The version of the firmware image in the firmware device.
|
@return The version of the firmware image in the firmware device.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
UINT32
|
UINT32
|
||||||
GetVersionFromVariable (
|
GetVersionFromVariable (
|
||||||
VOID
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,15 +106,16 @@ GetVersionFromVariable (
|
|||||||
variable. If the UEFI variables does not exist, then a default lowest
|
variable. If the UEFI variables does not exist, then a default lowest
|
||||||
supported version value is returned.
|
supported version value is returned.
|
||||||
|
|
||||||
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"
|
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed controller.
|
||||||
|
|
||||||
@return The lowest supported version of the firmware image in the firmware
|
@return The lowest supported version of the firmware image in the firmware
|
||||||
device.
|
device.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
UINT32
|
UINT32
|
||||||
GetLowestSupportedVersionFromVariable (
|
GetLowestSupportedVersionFromVariable (
|
||||||
VOID
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,14 +125,15 @@ GetLowestSupportedVersionFromVariable (
|
|||||||
variable. If the UEFI variables does not exist, then a default last attempt
|
variable. If the UEFI variables does not exist, then a default last attempt
|
||||||
status value is returned.
|
status value is returned.
|
||||||
|
|
||||||
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"
|
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed controller.
|
||||||
|
|
||||||
@return The last attempt status value for the most recent capsule update.
|
@return The last attempt status value for the most recent capsule update.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
UINT32
|
UINT32
|
||||||
GetLastAttemptStatusFromVariable (
|
GetLastAttemptStatusFromVariable (
|
||||||
VOID
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,83 +143,96 @@ GetLastAttemptStatusFromVariable (
|
|||||||
variable. If the UEFI variables does not exist, then a default last attempt
|
variable. If the UEFI variables does not exist, then a default last attempt
|
||||||
version value is returned.
|
version value is returned.
|
||||||
|
|
||||||
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"
|
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed controller.
|
||||||
|
|
||||||
@return The last attempt version value for the most recent capsule update.
|
@return The last attempt version value for the most recent capsule update.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
UINT32
|
UINT32
|
||||||
GetLastAttemptVersionFromVariable (
|
GetLastAttemptVersionFromVariable (
|
||||||
VOID
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Saves the version current of the firmware image in the firmware device to a
|
Saves the version current of the firmware image in the firmware device to a
|
||||||
UEFI variable.
|
UEFI variable.
|
||||||
|
|
||||||
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"
|
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed controller.
|
||||||
@param[in] Version The version of the firmware image in the firmware device.
|
@param[in] Version The version of the firmware image in the firmware device.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
SetVersionInVariable (
|
SetVersionInVariable (
|
||||||
UINT32 Version
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private,
|
||||||
|
IN UINT32 Version
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Saves the lowest supported version current of the firmware image in the
|
Saves the lowest supported version current of the firmware image in the
|
||||||
firmware device to a UEFI variable.
|
firmware device to a UEFI variable.
|
||||||
|
|
||||||
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"
|
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"
|
||||||
|
|
||||||
@param[in] LowestSupportedVersion The lowest supported version of the firmware image
|
|
||||||
in the firmware device.
|
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed
|
||||||
|
controller.
|
||||||
|
@param[in] LowestSupportedVersion The lowest supported version of the
|
||||||
|
firmware image in the firmware device.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
SetLowestSupportedVersionInVariable (
|
SetLowestSupportedVersionInVariable (
|
||||||
UINT32 LowestSupportedVersion
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private,
|
||||||
|
IN UINT32 LowestSupportedVersion
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Saves the last attempt status value of the most recent FMP capsule update to a
|
Saves the last attempt status value of the most recent FMP capsule update to a
|
||||||
UEFI variable.
|
UEFI variable.
|
||||||
|
|
||||||
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"
|
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed
|
||||||
|
controller.
|
||||||
@param[in] LastAttemptStatus The last attempt status of the most recent FMP
|
@param[in] LastAttemptStatus The last attempt status of the most recent FMP
|
||||||
capsule update.
|
capsule update.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
SetLastAttemptStatusInVariable (
|
SetLastAttemptStatusInVariable (
|
||||||
UINT32 LastAttemptStatus
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private,
|
||||||
|
IN UINT32 LastAttemptStatus
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Saves the last attempt version value of the most recent FMP capsule update to
|
Saves the last attempt version value of the most recent FMP capsule update to
|
||||||
a UEFI variable.
|
a UEFI variable.
|
||||||
|
|
||||||
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"
|
UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed
|
||||||
|
controller.
|
||||||
@param[in] LastAttemptVersion The last attempt version value of the most
|
@param[in] LastAttemptVersion The last attempt version value of the most
|
||||||
recent FMP capsule update.
|
recent FMP capsule update.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
SetLastAttemptVersionInVariable (
|
SetLastAttemptVersionInVariable (
|
||||||
UINT32 LastAttemptVersion
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private,
|
||||||
|
IN UINT32 LastAttemptVersion
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Locks all the UEFI Variables that use gEfiCallerIdGuid of the currently
|
Locks all the UEFI Variables that use gEfiCallerIdGuid of the currently
|
||||||
executing module.
|
executing module.
|
||||||
|
|
||||||
|
@param[in] Private Private context structure for the managed controller.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS All UEFI variables are locked.
|
||||||
|
@retval EFI_UNSUPPORTED Variable Lock Protocol not found.
|
||||||
|
@retval Other One of the UEFI variables could not be locked.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
LockAllFmpVariables (
|
LockAllFmpVariables (
|
||||||
VOID
|
IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user