From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web12.5947.1615364244935055145 for ; Wed, 10 Mar 2021 00:17:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: zhiguang.liu@intel.com) IronPort-SDR: gqK1Bhgg6Gtpg4V4gusslgy4Fiv/XZGOgGIDYqjyYphHow3vO403eDxbsEH0FtCS9WXgjlJ8w6 v3d0a2EAL0nw== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="249782686" X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="249782686" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 00:17:22 -0800 IronPort-SDR: wf6rmzKEHTPfaH4J2w8dL0S9BqvPMp4mSjAY0PmX5HJ6ZlTvMBu9vOwdk+h5oUkALagdc18HJQ rBkYGYkfZ97A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="370092264" Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga003.jf.intel.com with ESMTP; 10 Mar 2021 00:17:20 -0800 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Eric Dong , Liming Gao , Nate DeSimone , Prince Agyeman , Ray Ni , Zhichao Gao Subject: [PATCH] [edk2-platforms]Intel/BoardModulePkg: sort load option in the first boot Date: Wed, 10 Mar 2021 16:16:45 +0800 Message-Id: <20210310081645.652-1-zhiguang.liu@intel.com> X-Mailer: git-send-email 2.30.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Currently, load option is only sorted when setup is the first priority in b= oot 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 opti= on in first boot. Cc: Eric Dong Cc: Liming Gao Cc: Nate DeSimone Cc: Prince Agyeman Cc: Ray Ni Cc: Zhichao Gao Change-Id: Idd4e9547e9ae8aad8296f2f71954951ad3093576 Signed-off-by: Zhiguang Liu --- Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c | = 70 +++++++++++++++++++++++++++++++++++----------------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBds= HookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsH= ookLib.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 ();=0D }=0D =0D -=0D -/**=0D - The function is to consider the boot order which is not in our expectati= on.=0D - In the case that we need to re-sort the boot option.=0D -=0D - @retval TRUE Need to sort Boot Option.=0D - @retval FALSE Don't need to sort Boot Option.=0D -**/=0D -BOOLEAN=0D -IsNeedSortBootOption (=0D - VOID=0D - )=0D -{=0D - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;=0D - UINTN BootOptionCount;=0D -=0D - BootOptions =3D EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOpti= onTypeBoot);=0D -=0D - //=0D - // If setup is the first priority in boot option, we need to sort boot o= ption.=0D - //=0D - if ((BootOptionCount > 1) &&=0D - (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter = Setup"))) =3D=3D 0) ||=0D - ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp", StrLen (L"= BootManagerMenuApp"))) =3D=3D 0))) {=0D - return TRUE;=0D - }=0D -=0D - return FALSE;=0D -}=0D -=0D -=0D /**=0D Connects Root Bridge=0D **/=0D @@ -1332,6 +1301,9 @@ BdsAfterConsoleReadyBeforeBootOptionCallback ( )=0D {=0D EFI_BOOT_MODE LocalBootMode;=0D + EFI_STATUS Status;=0D + BOOLEAN IsFirstBoot;=0D + UINTN DataSize;=0D =0D DEBUG ((DEBUG_INFO, "Event gBdsAfterConsoleReadyBeforeBootOptionEvent ca= llback starts\n"));=0D //=0D @@ -1376,14 +1348,42 @@ BdsAfterConsoleReadyBeforeBootOptionCallback ( //=0D // PXE boot option may appear after boot option enumeration=0D //=0D +=0D + EfiBootManagerRefreshAllBootOption ();=0D +=0D + Status =3D gRT->GetVariable (=0D + L"IsFirstBoot",=0D + &gEfiCallerIdGuid,=0D + NULL,=0D + &DataSize,=0D + &IsFirstBoot=0D + );=0D + if (EFI_ERROR (Status)) {=0D + //=0D + // If can't find the variable, see it as the first boot=0D + //=0D + IsFirstBoot =3D TRUE;=0D + }=0D +=0D + if (IsFirstBoot =3D=3D TRUE) {=0D + //=0D + // In the first boot, sort the boot option=0D + //=0D + EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareB= ootOption);=0D + IsFirstBoot =3D FALSE;=0D + Status =3D gRT->SetVariable (=0D + L"IsFirstBoot",=0D + &gEfiCallerIdGuid,=0D + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_A= CCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,=0D + 1,=0D + &IsFirstBoot=0D + );=0D + }=0D +=0D break;=0D }=0D =0D Print (L"Press F7 for BootMenu!\n");=0D =0D - EfiBootManagerRefreshAllBootOption ();=0D =0D - if (IsNeedSortBootOption()) {=0D - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootO= ption);=0D - }=0D }=0D --=20 2.30.0.windows.2