MdeModulePkg PlatformVarCleanupLib: Locate VarCheck protocol when using

Do not locate VarCheck protocol in Constructor, then the
gEdkiiVarCheckProtocolGuid could be removed from [Depex].
It will be more flexible for the library Consumer to work without VarCheck
protocol installed, for example at recovery boot mode with EmuRuntimeDxe.

The unused UefiLib is also been removed from [LibraryClasses] in *.inf.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
This commit is contained in:
Star Zeng 2016-03-17 13:31:44 +08:00
parent 5811eea0fd
commit 58f025afd5
2 changed files with 11 additions and 11 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Sample platform variable cleanup library implementation. Sample platform variable cleanup library implementation.
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -100,6 +100,15 @@ IsUserVariable (
EFI_STATUS Status; EFI_STATUS Status;
VAR_CHECK_VARIABLE_PROPERTY Property; VAR_CHECK_VARIABLE_PROPERTY Property;
if (mVarCheck == NULL) {
gBS->LocateProtocol (
&gEdkiiVarCheckProtocolGuid,
NULL,
(VOID **) &mVarCheck
);
}
ASSERT (mVarCheck != NULL);
ZeroMem (&Property, sizeof (Property)); ZeroMem (&Property, sizeof (Property));
Status = mVarCheck->VariablePropertyGet ( Status = mVarCheck->VariablePropertyGet (
Name, Name,
@ -1225,13 +1234,6 @@ PlatformVarCleanupLibConstructor (
mLastVarErrorFlag = InternalGetVarErrorFlag (); mLastVarErrorFlag = InternalGetVarErrorFlag ();
DEBUG ((EFI_D_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag)); DEBUG ((EFI_D_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag));
Status = gBS->LocateProtocol (
&gEdkiiVarCheckProtocolGuid,
NULL,
(VOID **) &mVarCheck
);
ASSERT_EFI_ERROR (Status);
// //
// Register EFI_END_OF_DXE_EVENT_GROUP_GUID event. // Register EFI_END_OF_DXE_EVENT_GROUP_GUID event.
// //

View File

@ -1,7 +1,7 @@
## @file ## @file
# Sample platform variable cleanup library instance. # Sample platform variable cleanup library instance.
# #
# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions # are licensed and made available under the terms and conditions
@ -44,7 +44,6 @@
[LibraryClasses] [LibraryClasses]
UefiBootServicesTableLib UefiBootServicesTableLib
UefiRuntimeServicesTableLib UefiRuntimeServicesTableLib
UefiLib
BaseLib BaseLib
DebugLib DebugLib
BaseMemoryLib BaseMemoryLib
@ -68,6 +67,5 @@
gEfiHiiConfigRoutingProtocolGuid ## SOMETIMES_CONSUMES gEfiHiiConfigRoutingProtocolGuid ## SOMETIMES_CONSUMES
[Depex] [Depex]
gEdkiiVarCheckProtocolGuid AND
gEfiVariableArchProtocolGuid gEfiVariableArchProtocolGuid