From nobody Mon Nov 25 09:27:53 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+72610+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+72610+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1615364246; cv=none; d=zohomail.com; s=zohoarc; b=evA24xSDxOCxaKiTxQWkB8ni+NhrEB7rsGuPk+lrNtx+m4RNaPX9PDwnjk7aojm7RBYWR51W4pZxae1fJeRgalr65ga5S49+UcqQV5GkEdJy6l45XEl3aJZmO8dFl8uMAE8uziiSGFn6FlBiXy/Qg17Yg1X+ZnBMT5No2OxBgZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615364246; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=JCErG+DaSl8B6RIIji+uk2eYEVJ+4O/5KzujZQDXjbA=; b=nouLXJR9pzeZOMfvijWGB/7koAOAc6tyxTNA/BGVEeBt10eOqij/dfhB4+1h2sk5xvQJK4vqFTAeNXsO/2v/VmYx33U5YUqqtVzmthak9sZK+uUDU4b98vK7jPnVmQe2yRIPEhgJShWK8/yfXPJpyZIuw8OPTbrt9CttxTJgmYg= 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+72610+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 1615364246151469.28340172777814; Wed, 10 Mar 2021 00:17:26 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id TFg0YY1788612x5bhHDUw5nb; Wed, 10 Mar 2021 00:17:25 -0800 X-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 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" X-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" X-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: [edk2-devel] [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> 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: vNKSVqiD6L7OLJ26G4p9NmZjx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615364245; bh=gVr0uXimii6flbQGqmlulq9RI05ng1qF2znvcgboi0U=; h=Cc:Date:From:Reply-To:Subject:To; b=MeEBwNOD2vbxgxBPzkKORQCJITLqR0Mb6XLIDrX83p/8YP8UqIznXpq4/TlKFXbdDNH AjEtghBI1DekjzvJ3z+LNwGbofD476d6GROJ4c/E58H2H6Mg9HzS0FeEzwFHdAfHgzoq9 dctW4r7Ch7SxRuAmf/z+86K9Y5f0sjJNUuo= 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 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 (); } =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 +1301,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 +1348,42 @@ BdsAfterConsoleReadyBeforeBootOptionCallback ( // // PXE boot option may appear after boot option enumeration // + + EfiBootManagerRefreshAllBootOption (); + + Status =3D 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 =3D TRUE; + } + + if (IsFirstBoot =3D=3D TRUE) { + // + // In the first boot, sort the boot option + // + EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, CompareB= ootOption); + IsFirstBoot =3D FALSE; + Status =3D gRT->SetVariable ( + L"IsFirstBoot", + &gEfiCallerIdGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_A= CCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS, + 1, + &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 (#72610): https://edk2.groups.io/g/devel/message/72610 Mute This Topic: https://groups.io/mt/81222690/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-