mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/DxeCapsuleLibFmp: Use new Variable Lock interface
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3699 The code in MdeModulePkg\Library\DxeCapsuleLibFmp call the deprecated=20 interface VariableLockRequestToLock.c. So I changed the code in FmpDevicePkg using RegisterBasicVariablePolicy, instead of the=20 deprecated interface. Signed-off-by: Yang Jie <jie.yang@intel.com> Cc: Guomin Jiang <guomin.jiang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
This commit is contained in:
parent
f826b20811
commit
8c8867c5da
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# Capsule library instance for DXE_DRIVER module types.
|
# Capsule library instance for DXE_DRIVER module types.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
|
@ -51,6 +51,7 @@
|
||||||
DisplayUpdateProgressLib
|
DisplayUpdateProgressLib
|
||||||
FileHandleLib
|
FileHandleLib
|
||||||
UefiBootManagerLib
|
UefiBootManagerLib
|
||||||
|
VariablePolicyHelperLib
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax ## CONSUMES
|
||||||
|
@ -74,11 +75,11 @@
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEsrtManagementProtocolGuid ## CONSUMES
|
gEsrtManagementProtocolGuid ## CONSUMES
|
||||||
gEfiFirmwareManagementProtocolGuid ## CONSUMES
|
gEfiFirmwareManagementProtocolGuid ## CONSUMES
|
||||||
gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
|
|
||||||
gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
|
gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiBlockIoProtocolGuid ## CONSUMES
|
gEfiBlockIoProtocolGuid ## CONSUMES
|
||||||
gEfiDiskIoProtocolGuid ## CONSUMES
|
gEfiDiskIoProtocolGuid ## CONSUMES
|
||||||
|
gEdkiiVariablePolicyProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
|
gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
/** @file
|
/** @file
|
||||||
DXE capsule report related function.
|
DXE capsule report related function.
|
||||||
|
|
||||||
Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <PiDxe.h>
|
#include <PiDxe.h>
|
||||||
#include <Protocol/FirmwareManagement.h>
|
#include <Protocol/FirmwareManagement.h>
|
||||||
#include <Protocol/VariableLock.h>
|
|
||||||
#include <Guid/CapsuleReport.h>
|
#include <Guid/CapsuleReport.h>
|
||||||
#include <Guid/FmpCapsule.h>
|
#include <Guid/FmpCapsule.h>
|
||||||
#include <Guid/CapsuleVendor.h>
|
#include <Guid/CapsuleVendor.h>
|
||||||
|
@ -26,6 +25,7 @@
|
||||||
#include <Library/ReportStatusCodeLib.h>
|
#include <Library/ReportStatusCodeLib.h>
|
||||||
#include <Library/DevicePathLib.h>
|
#include <Library/DevicePathLib.h>
|
||||||
#include <Library/CapsuleLib.h>
|
#include <Library/CapsuleLib.h>
|
||||||
|
#include <Library/VariablePolicyHelperLib.h>
|
||||||
|
|
||||||
#include <IndustryStandard/WindowsUxCapsule.h>
|
#include <IndustryStandard/WindowsUxCapsule.h>
|
||||||
|
|
||||||
|
@ -94,6 +94,40 @@ GetNewCapsuleResultIndex (
|
||||||
return CurrentIndex + 1;
|
return CurrentIndex + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Lock Variable by variable policy.
|
||||||
|
|
||||||
|
@param[in] VariableGuid The Guid of the variable to be locked
|
||||||
|
@param[in] VariableName The name of the variable to be locked
|
||||||
|
@param[in] VariablePolicy The pointer of variable lock policy
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
LockVariable (
|
||||||
|
IN CONST EFI_GUID VariableGuid,
|
||||||
|
IN CHAR16 *VariableName,
|
||||||
|
IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
// Set the policies to protect the target variables
|
||||||
|
Status = RegisterBasicVariablePolicy (VariablePolicy,
|
||||||
|
&VariableGuid,
|
||||||
|
VariableName,
|
||||||
|
VARIABLE_POLICY_NO_MIN_SIZE,
|
||||||
|
VARIABLE_POLICY_NO_MAX_SIZE,
|
||||||
|
VARIABLE_POLICY_NO_MUST_ATTR,
|
||||||
|
VARIABLE_POLICY_NO_CANT_ATTR,
|
||||||
|
VARIABLE_POLICY_TYPE_LOCK_NOW);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "DxeCapsuleLibFmp: Failed to lock variable %g %s. Status = %r\n",
|
||||||
|
&VariableGuid,
|
||||||
|
VariableName,
|
||||||
|
Status));
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Write a new capsule status variable.
|
Write a new capsule status variable.
|
||||||
|
|
||||||
|
@ -269,16 +303,17 @@ RecordFmpCapsuleStatusVariable (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize CapsuleMax variables.
|
Initialize CapsuleMax variables.
|
||||||
|
|
||||||
|
@param[in] VariablePolicy The pointer of variable lock policy
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
InitCapsuleMaxVariable (
|
InitCapsuleMaxVariable (
|
||||||
VOID
|
EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
CHAR16 CapsuleMaxStr[sizeof("Capsule####")];
|
CHAR16 CapsuleMaxStr[sizeof("Capsule####")];
|
||||||
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
|
|
||||||
|
|
||||||
UnicodeSPrint(
|
UnicodeSPrint(
|
||||||
CapsuleMaxStr,
|
CapsuleMaxStr,
|
||||||
|
@ -297,25 +332,22 @@ InitCapsuleMaxVariable (
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
// Lock it per UEFI spec.
|
// Lock it per UEFI spec.
|
||||||
Status = gBS->LocateProtocol(&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLock);
|
LockVariable (gEfiCapsuleReportGuid, L"CapsuleMax", VariablePolicy);
|
||||||
if (!EFI_ERROR(Status)) {
|
|
||||||
Status = VariableLock->RequestToLock(VariableLock, L"CapsuleMax", &gEfiCapsuleReportGuid);
|
|
||||||
ASSERT_EFI_ERROR(Status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize CapsuleLast variables.
|
Initialize CapsuleLast variables.
|
||||||
|
|
||||||
|
@param[in] VariablePolicy The pointer of variable lock policy
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
InitCapsuleLastVariable (
|
InitCapsuleLastVariable (
|
||||||
VOID
|
EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_BOOT_MODE BootMode;
|
EFI_BOOT_MODE BootMode;
|
||||||
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
|
|
||||||
VOID *CapsuleResult;
|
VOID *CapsuleResult;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
CHAR16 CapsuleLastStr[sizeof("Capsule####")];
|
CHAR16 CapsuleLastStr[sizeof("Capsule####")];
|
||||||
|
@ -372,11 +404,7 @@ InitCapsuleLastVariable (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock it in normal boot path per UEFI spec.
|
// Lock it in normal boot path per UEFI spec.
|
||||||
Status = gBS->LocateProtocol(&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLock);
|
LockVariable (gEfiCapsuleReportGuid, L"CapsuleLast", VariablePolicy);
|
||||||
if (!EFI_ERROR(Status)) {
|
|
||||||
Status = VariableLock->RequestToLock(VariableLock, L"CapsuleLast", &gEfiCapsuleReportGuid);
|
|
||||||
ASSERT_EFI_ERROR(Status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,26 +458,21 @@ InitCapsuleUpdateVariable (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize capsule relocation info variable.
|
Initialize capsule relocation info variable.
|
||||||
|
|
||||||
|
@param[in] VariablePolicy The pointer of variable lock policy
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
InitCapsuleRelocationInfo (
|
InitCapsuleRelocationInfo (
|
||||||
VOID
|
EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
|
||||||
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
|
|
||||||
|
|
||||||
CoDClearCapsuleRelocationInfo();
|
CoDClearCapsuleRelocationInfo();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Unlock Capsule On Disk relocation Info variable only when Capsule On Disk flag is enabled
|
// Unlock Capsule On Disk relocation Info variable only when Capsule On Disk flag is enabled
|
||||||
//
|
//
|
||||||
if (!CoDCheckCapsuleOnDiskFlag()) {
|
if (!CoDCheckCapsuleOnDiskFlag()) {
|
||||||
Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
|
LockVariable (gEfiCapsuleVendorGuid, COD_RELOCATION_INFO_VAR_NAME, VariablePolicy);
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
Status = VariableLock->RequestToLock (VariableLock, COD_RELOCATION_INFO_VAR_NAME, &gEfiCapsuleVendorGuid);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,10 +484,19 @@ InitCapsuleVariable (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy;
|
||||||
|
|
||||||
|
// Locate the VariablePolicy protocol
|
||||||
|
Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID**)&VariablePolicy);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "DxeCapsuleReportLib %a - Could not locate VariablePolicy protocol! %r\n", __FUNCTION__, Status));
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
InitCapsuleUpdateVariable();
|
InitCapsuleUpdateVariable();
|
||||||
InitCapsuleMaxVariable();
|
InitCapsuleMaxVariable (VariablePolicy);
|
||||||
InitCapsuleLastVariable();
|
InitCapsuleLastVariable (VariablePolicy);
|
||||||
InitCapsuleRelocationInfo();
|
InitCapsuleRelocationInfo (VariablePolicy);
|
||||||
|
|
||||||
//
|
//
|
||||||
// No need to clear L"Capsule####", because OS/APP should refer L"CapsuleLast"
|
// No need to clear L"Capsule####", because OS/APP should refer L"CapsuleLast"
|
||||||
|
|
Loading…
Reference in New Issue