From nobody Sun May 5 11:54:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+72653+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72653+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1615425763; cv=none; d=zohomail.com; s=zohoarc; b=eN+rXyxV3sf6D6XX2A4rgw6qGBY71bjs0ukswckFE9JxwDGJYIjuCVHNlapov7n/8vZle+5mg9754dh6HbSehng5y7GylUqT4oAXpSvsgI6UiJzRY9dp2GJ141JhmFVvwIfLodso3/sGkWrPQ9yFSCAVloqhZKavE91AheI0jb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615425763; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=2dWgVs7B0i3INxC64NW1/SJ54bC33o5OsUHp69PV1hI=; b=jKOwah8J+GSDaf6TC9aWWAcd7KqkoZ3KKhMa5k/ANHFRnUJwX/HF9LzBDgCOqQnSlUE47zv8RrDQODP3gfBU9OhG0nhhyGM3Ctijfu/SGNVnJ9UEoXXoLqfYlkH9lRd/dWVrM0gCMxLol7CNvlgjb58BANm8CJrjUPK2E82+QGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+72653+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1615425763723298.5381335610924; Wed, 10 Mar 2021 17:22:43 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id EG4TYY1788612x3tRinAFxUF; Wed, 10 Mar 2021 17:22:43 -0800 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web08.146.1615425761594885859 for ; Wed, 10 Mar 2021 17:22:42 -0800 IronPort-SDR: pf6z59A6QJIa5WFGA8XGzrL51exHeSOAIVClg8jI4O6P2i4nMZA0geRYbXNTYKlULZGMC/88Kz qWTDQX0HFqUA== X-IronPort-AV: E=McAfee;i="6000,8403,9919"; a="273633512" X-IronPort-AV: E=Sophos;i="5.81,238,1610438400"; d="scan'208";a="273633512" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 17:22:41 -0800 IronPort-SDR: EMy3wiiEhsA/rsSkgWuocx3Xk4uUqfRZh4kpw2dO8cMjSpBCEk978WyONOMJtuaM7Mvp5DldnK d1xiz9yzJXMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,238,1610438400"; d="scan'208";a="603331789" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by fmsmga005.fm.intel.com with ESMTP; 10 Mar 2021 17:22:38 -0800 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Eric Dong , Liming Gao , Nate DeSimone , Prince Agyeman , Ray Ni , Zhichao Gao Subject: [edk2-devel] [Patch edk2-platforms V3] Intel/BoardModulePkg: sort load option in the first boot Date: Thu, 11 Mar 2021 09:21:49 +0800 Message-Id: <20210311012149.1042-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhiguang.liu@intel.com X-Gm-Message-State: JPFnNmqdbqjzTaVRHsr9G3lZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615425763; bh=hDktDTWNvTfgob4+AmhNJ5SjDenrW1vrbgL9V+Vo8QI=; h=Cc:Date:From:Reply-To:Subject:To; b=YgWKR9AEwRI/FQVKcBHbZQvAg2ATELjQYsRNH36TrTMO8Bg2Yn9lHoN415t+3aHtnBE JqL6YthtuZ9WCvwt9tKE9hH2/S8GGzlhD/IAtFa4vXq2I7cvEXGvPCtSq0xaMviunEwx2 8mMnaqIF4ucwYY30/ASwoTxUuWrOYIOdisQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Zhiguang Liu Reviewed-by: Eric Dong Reviewed-by: Ray Ni --- Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c | = 72 +++++++++++++++++++++++++++++++++++++----------------------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBds= HookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsH= ookLib.c index d7612fb80a..a37139a007 100644 --- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib= .c +++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib= .c @@ -20,6 +20,8 @@ =20 #include "BoardBdsHook.h" =20 +#define IS_FIRST_BOOT_VAR_NAME L"IsFirstBoot" + GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE gBootMode; BOOLEAN gPPRequireUIConfirm; extern UINTN mBootMenuOptionNumber; @@ -992,37 +994,6 @@ ConnectSequence ( EfiBootManagerConnectAll (); } =20 - -/** - The function is to consider the boot order which is not in our expectati= on. - 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 =3D EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOpti= onTypeBoot); - - // - // If setup is the first priority in boot option, we need to sort boot o= ption. - // - if ((BootOptionCount > 1) && - (((StrnCmp (BootOptions->Description, L"Enter Setup", StrLen (L"Enter = Setup"))) =3D=3D 0) || - ((StrnCmp (BootOptions->Description, L"BootManagerMenuApp", StrLen (L"= BootManagerMenuApp"))) =3D=3D 0))) { - return TRUE; - } - - return FALSE; -} - - /** Connects Root Bridge **/ @@ -1332,6 +1303,9 @@ BdsAfterConsoleReadyBeforeBootOptionCallback ( ) { EFI_BOOT_MODE LocalBootMode; + EFI_STATUS Status; + BOOLEAN IsFirstBoot; + UINTN DataSize; =20 DEBUG ((DEBUG_INFO, "Event gBdsAfterConsoleReadyBeforeBootOptionEvent ca= llback starts\n")); // @@ -1376,14 +1350,42 @@ BdsAfterConsoleReadyBeforeBootOptionCallback ( // // PXE boot option may appear after boot option enumeration // + + EfiBootManagerRefreshAllBootOption (); + DataSize =3D sizeof (BOOLEAN); + Status =3D gRT->GetVariable ( + IS_FIRST_BOOT_VAR_NAME, + &gEfiCallerIdGuid, + NULL, + &DataSize, + &IsFirstBoot + ); + if (EFI_ERROR (Status)) { + // + // If can't find the variable, see it as the first boot + // + IsFirstBoot =3D TRUE; + } + + if (IsFirstBoot) { + // + // In the first boot, sort the boot option + // + EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareB= ootOption); + IsFirstBoot =3D FALSE; + Status =3D gRT->SetVariable ( + IS_FIRST_BOOT_VAR_NAME, + &gEfiCallerIdGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVI= CE_ACCESS, + sizeof (BOOLEAN), + &IsFirstBoot + ); + } + break; } =20 Print (L"Press F7 for BootMenu!\n"); =20 - EfiBootManagerRefreshAllBootOption (); =20 - if (IsNeedSortBootOption()) { - EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareBootO= ption); - } } --=20 2.30.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#72653): https://edk2.groups.io/g/devel/message/72653 Mute This Topic: https://groups.io/mt/81243873/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-