summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-01-08 07:16:22 +0000
committerniruiyu <niruiyu@Edk2>2016-01-08 07:16:22 +0000
commit2e26862c6d64e9b58174b5732a76d79dc265d8bf (patch)
tree957af5912368db68adae12fb10926a38f6c65ebe /MdeModulePkg
parent20fe1625567d0bc502a63818e3f416613bab813c (diff)
downloadedk2-2e26862c6d64e9b58174b5732a76d79dc265d8bf.tar.gz
edk2-2e26862c6d64e9b58174b5732a76d79dc265d8bf.tar.bz2
edk2-2e26862c6d64e9b58174b5732a76d79dc265d8bf.zip
MdeModulePkg: DeleteLoadOptionVariable() removes Boot####
Change EfiBootManagerDeleteLoadOptionVariable() to not just remove #### from BootOrder but also remove Boot#### variable. The old behavior tries to do less for performance but it leaves unreferenced Boot#### which cannot be reclaimed in variable reclaim operation though the Boot#### will be eventually be overwritten by EfiBootManagerAddLoadOptionVariable(). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19626 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
index 999647cfac..696e995bb6 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
@@ -1,7 +1,7 @@
/** @file
Load option library functions which relate with creating and processing load options.
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -564,7 +564,6 @@ EfiBootManagerDeleteLoadOptionVariable (
{
UINT16 *OptionOrder;
UINTN OptionOrderSize;
- EFI_STATUS Status;
UINTN Index;
CHAR16 OptionName[BM_OPTION_NAME_LEN];
@@ -572,11 +571,10 @@ EfiBootManagerDeleteLoadOptionVariable (
return EFI_INVALID_PARAMETER;
}
- Status = EFI_NOT_FOUND;
-
if (OptionType == LoadOptionTypeDriver || OptionType == LoadOptionTypeSysPrep || OptionType == LoadOptionTypeBoot) {
//
- // If the associated *Order exists, just remove the reference in *Order.
+ // If the associated *Order exists, firstly remove the reference in *Order for
+ // Driver####, SysPrep#### and Boot####.
//
GetEfiGlobalVariable2 (mBmLoadOptionOrderName[OptionType], (VOID **) &OptionOrder, &OptionOrderSize);
ASSERT ((OptionOrder != NULL && OptionOrderSize != 0) || (OptionOrder == NULL && OptionOrderSize == 0));
@@ -585,34 +583,32 @@ EfiBootManagerDeleteLoadOptionVariable (
if (OptionOrder[Index] == OptionNumber) {
OptionOrderSize -= sizeof (UINT16);
CopyMem (&OptionOrder[Index], &OptionOrder[Index + 1], OptionOrderSize - Index * sizeof (UINT16));
- Status = gRT->SetVariable (
- mBmLoadOptionOrderName[OptionType],
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- OptionOrderSize,
- OptionOrder
- );
+ gRT->SetVariable (
+ mBmLoadOptionOrderName[OptionType],
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ OptionOrderSize,
+ OptionOrder
+ );
break;
}
}
if (OptionOrder != NULL) {
FreePool (OptionOrder);
}
- } else if (OptionType == LoadOptionTypePlatformRecovery) {
- //
- // PlatformRecovery#### doesn't have assiciated PlatformRecoveryOrder, remove the PlatformRecovery#### itself.
- //
- UnicodeSPrint (OptionName, sizeof (OptionName), L"%s%04x", mBmLoadOptionName[OptionType], OptionNumber);
- Status = gRT->SetVariable (
- OptionName,
- &gEfiGlobalVariableGuid,
- 0,
- 0,
- NULL
- );
}
- return Status;
+ //
+ // Remove the Driver####, SysPrep####, Boot#### or PlatformRecovery#### itself.
+ //
+ UnicodeSPrint (OptionName, sizeof (OptionName), L"%s%04x", mBmLoadOptionName[OptionType], OptionNumber);
+ return gRT->SetVariable (
+ OptionName,
+ &gEfiGlobalVariableGuid,
+ 0,
+ 0,
+ NULL
+ );
}
/**