* [PATCH] [edk2-platforms]Intel/BoardModulePkg: sort load option in the first boot
@ 2021-03-10 8:16 Zhiguang Liu
0 siblings, 0 replies; only message in thread
From: Zhiguang Liu @ 2021-03-10 8:16 UTC (permalink / raw)
To: devel
Cc: Eric Dong, Liming Gao, Nate DeSimone, Prince Agyeman, Ray Ni,
Zhichao Gao
Currently, load option is only sorted when setup is the first priority in boot
option. However, Below change in UefiBootManagerLib puts setup in the end, which
causes the sort function won't be called.
MdeModulePkg/UefiBootManagerLib: Put BootMenu at the end of BootOrder
SHA-1: 7f34681c488aee2563eaa2afcc6a2c8aa7c5b912
This patch will set a NV variable in the first boot, and sort the boot option
in first boot.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Change-Id: Idd4e9547e9ae8aad8296f2f71954951ad3093576
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c | 70 +++++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
index d7612fb8..5b65e5f3 100644
--- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
@@ -992,37 +992,6 @@ ConnectSequence (
EfiBootManagerConnectAll ();
}
-
-/**
- The function is to consider the boot order which is not in our expectation.
- In the case that we need to re-sort the boot option.
-
- @retval TRUE Need to sort Boot Option.
- @retval FALSE Don't need to sort Boot Option.
-**/
-BOOLEAN
-IsNeedSortBootOption (
- VOID
- )
-{
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
-
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
-
- //
- // If setup is the first priority in boot option, we need to sort boot option.
- //
- if ((BootOptionCount > 1) &&
- (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter Setup"))) == 0) ||
- ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp", StrLen (L"BootManagerMenuApp"))) == 0))) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-
/**
Connects Root Bridge
**/
@@ -1332,6 +1301,9 @@ BdsAfterConsoleReadyBeforeBootOptionCallback (
)
{
EFI_BOOT_MODE LocalBootMode;
+ EFI_STATUS Status;
+ BOOLEAN IsFirstBoot;
+ UINTN DataSize;
DEBUG ((DEBUG_INFO, "Event gBdsAfterConsoleReadyBeforeBootOptionEvent callback starts\n"));
//
@@ -1376,14 +1348,42 @@ BdsAfterConsoleReadyBeforeBootOptionCallback (
//
// PXE boot option may appear after boot option enumeration
//
+
+ EfiBootManagerRefreshAllBootOption ();
+
+ Status = gRT->GetVariable (
+ L"IsFirstBoot",
+ &gEfiCallerIdGuid,
+ NULL,
+ &DataSize,
+ &IsFirstBoot
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // If can't find the variable, see it as the first boot
+ //
+ IsFirstBoot = TRUE;
+ }
+
+ if (IsFirstBoot == TRUE) {
+ //
+ // In the first boot, sort the boot option
+ //
+ EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootOption);
+ IsFirstBoot = FALSE;
+ Status = gRT->SetVariable (
+ L"IsFirstBoot",
+ &gEfiCallerIdGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ 1,
+ &IsFirstBoot
+ );
+ }
+
break;
}
Print (L"Press F7 for BootMenu!\n");
- EfiBootManagerRefreshAllBootOption ();
- if (IsNeedSortBootOption()) {
- EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootOption);
- }
}
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-10 8:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-10 8:16 [PATCH] [edk2-platforms]Intel/BoardModulePkg: sort load option in the first boot Zhiguang Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox