From nobody Thu May 16 15:58:19 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+75968+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+75968+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1622644112; cv=none; d=zohomail.com; s=zohoarc; b=bYkR67hFKkXDCS5n6VafKNoS5ZOOLtAb9kOFf2ckJQE1BzyNRTBSGKZY1Evj0yturNZXKbE/CIXOtQmULCNK21KlFJFuxTiK2XrawNlPEnwBak6jMRkVsLMmkvwCsZzDZkq+J8E6f3BKhCSB53geLJ5TJrhyn5VpPN3oFJP9PKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622644112; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=VMZ7wPOBXiOBooxUvv0DDPDBkGexNIVOeuhYvjNBLfE=; b=P/Q2SA3q3eIfcHFKM6mmr1dv/Ztfb58MxiD6H6TKIcPaA9grKO3lwpb+/rpCM3xfCSMCYCt1w2Hc0uxR6IJV6rXrkZIQElWkX80v7SJFNG3yhZgLMo7UV9HZOw2k0url7i4qcYL1hvx9+6+6aTJd800ISZ60wvuhTae18KXpi3s= 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+75968+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 1622644112636693.5131185510129; Wed, 2 Jun 2021 07:28:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RR5AYY1788612xDbCNgCaW4i; Wed, 02 Jun 2021 07:28:32 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.13968.1622644106264769077 for ; Wed, 02 Jun 2021 07:28:26 -0700 IronPort-SDR: x6VdAet36yLiim+asMJjYfKwkBRqGLyWIJBHmpc7I9y4em3/9ywoLgSKBgrTaa2zrDxDabZJ3x 1y4oyUWIIe8Q== X-IronPort-AV: E=McAfee;i="6200,9189,10003"; a="203793855" X-IronPort-AV: E=Sophos;i="5.83,242,1616482800"; d="scan'208";a="203793855" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2021 07:28:24 -0700 IronPort-SDR: 2seO3nhCdIc5vI8Z2VhjPigwA9x2voZ5msAPTObK8/u1OvOzlqxZCfsAWaniiQDnrHbIZi7MMm u8vPRGnHUkQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,242,1616482800"; d="scan'208";a="447422002" X-Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by fmsmga008.fm.intel.com with ESMTP; 02 Jun 2021 07:28:22 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You Subject: [edk2-devel] [Patch V2] UefiPayloadPkg: Get platform specific logic from protocol for BDS driver Date: Wed, 2 Jun 2021 22:28:15 +0800 Message-Id: <20210602142815.1531-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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: RuahVoMSXKouwq9oY4W19TxBx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1622644112; bh=oSyJCzO3iyTvzqnjaRA8YNMWxhCF2wjGDXx5CdrtYxw=; h=Cc:Date:From:Reply-To:Subject:To; b=WwogLrphQeOMolyaatUDXv+70aQaKeoNAUw+ApqzCaSOZdhJ+ZGrxtflW0yLYRG6BpY Prt/zUW6Gddt89u5Av3mBRB/iq96TYQRxx5A3FkB43h4rON3d9gwm9gGSWi8yUhuMdQVC JkabTCl+qaIkq+4u5EejPHUKJJZk+PVkfOI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" V1: Currently, BDS driver will link a PlatformBootManagerLib, which contains pl= atform sepcific logic. This patch get the platform specific logic from a protocol,= so that platform logic for Boot manager can be in another binary. V2: Add function comments in PlatformBootManagerOverride.h Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Reviewed-by: Guo Dong Signed-off-by: Zhiguang Liu --- UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h |= 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++ UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c |= 25 ++++++++++++++++++++++++- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |= 3 ++- UefiPayloadPkg/UefiPayloadPkg.dec |= 4 +++- 4 files changed, 114 insertions(+), 3 deletions(-) diff --git a/UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h = b/UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h new file mode 100644 index 0000000000..75e0ae41c5 --- /dev/null +++ b/UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h @@ -0,0 +1,85 @@ +/** @file + This file defines the Univeral Payload Platform BootManager Protocol. + + Copyright (c) 2021, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef __PLATFORM_BOOT_MANAGER_OVERRIDE_H__ +#define __PLATFORM_BOOT_MANAGER_OVERRIDE_H__ + + +/** + Do the platform specific action before the console is connected. + + Such as: + Update console variable; + Register new Driver#### or Boot####; + Signal ReadyToLock event. + + This function will override the default behavior in PlatformBootManagerL= ib +**/ +typedef +VOID +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE) ( + VOID + ); + +/** + Do the platform specific action after the console is connected. + + Such as: + Dynamically switch output mode; + Signal console ready platform customized event; + Run diagnostics like memory testing; + Connect certain devices; + Dispatch aditional option roms. + + This function will override the default behavior in PlatformBootManagerL= ib +**/ +typedef +VOID +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE) ( + VOID + ); + +/** + This function is called each second during the boot manager waits the ti= meout. + This function will override the default behavior in PlatformBootManagerL= ib + + @param TimeoutRemain The remaining timeout. +**/ +typedef +VOID +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK) ( + UINT16 TimeoutRemain + ); + +/** + The function is called when no boot option could be launched, + including platform recovery options and options pointing to applications + built into firmware volumes. + + If this function returns, BDS attempts to enter an infinite loop. + This function will override the default behavior in PlatformBootManagerL= ib +**/ +typedef +VOID +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT) ( + VOID + ); + +/// +/// Provides an interface to override the default behavior in PlatformBoot= ManagerLib, +/// so platform can provide its own platform specific logic through this p= rotocol +/// +typedef struct { + PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE BeforeConsole; + PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE AfterConsole; + PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK WaitCallback; + PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT UnableToBoot; +} PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL; + +extern GUID gPldPlatformBootManagerOverrideProtocolGuid; + +#endif diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= ger.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index 7fa3a048b7..525977c15e 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c @@ -2,13 +2,16 @@ This file include all platform action which can be customized by IBV/OEM. =20 -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include "PlatformBootManager.h" #include "PlatformConsole.h" +#include + +PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL *mPldPlatformBootManagerOverr= ideInstance =3D NULL; =20 VOID InstallReadyToLock ( @@ -156,6 +159,16 @@ PlatformBootManagerBeforeConsole ( EFI_INPUT_KEY F2; EFI_INPUT_KEY Down; EFI_BOOT_MANAGER_LOAD_OPTION BootOption; + EFI_STATUS Status; + + Status =3D gBS->LocateProtocol (&gPldPlatformBootManagerOverrideProtocol= Guid, NULL, (VOID **) &mPldPlatformBootManagerOverrideInstance); + if (EFI_ERROR (Status)) { + mPldPlatformBootManagerOverrideInstance =3D NULL; + } + if (mPldPlatformBootManagerOverrideInstance !=3D NULL){ + mPldPlatformBootManagerOverrideInstance->BeforeConsole(); + return; + } =20 // // Register ENTER as CONTINUE key @@ -213,6 +226,10 @@ PlatformBootManagerAfterConsole ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black; EFI_GRAPHICS_OUTPUT_BLT_PIXEL White; =20 + if (mPldPlatformBootManagerOverrideInstance !=3D NULL){ + mPldPlatformBootManagerOverrideInstance->AfterConsole(); + return; + } Black.Blue =3D Black.Green =3D Black.Red =3D Black.Reserved =3D 0; White.Blue =3D White.Green =3D White.Red =3D White.Reserved =3D 0xFF; =20 @@ -244,6 +261,9 @@ PlatformBootManagerWaitCallback ( UINT16 TimeoutRemain ) { + if (mPldPlatformBootManagerOverrideInstance !=3D NULL){ + mPldPlatformBootManagerOverrideInstance->WaitCallback (TimeoutRemain); + } return; } =20 @@ -260,6 +280,9 @@ PlatformBootManagerUnableToBoot ( VOID ) { + if (mPldPlatformBootManagerOverrideInstance !=3D NULL){ + mPldPlatformBootManagerOverrideInstance->UnableToBoot(); + } return; } =20 diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf index 1f5a0bcad0..14997c1183 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf @@ -1,7 +1,7 @@ ## @file # Include all platform action which can be customized by IBV/OEM. # -# Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2012 - 2021, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -57,6 +57,7 @@ gEfiBootLogoProtocolGuid ## CONSUMES gEfiDxeSmmReadyToLockProtocolGuid gEfiSmmAccess2ProtocolGuid + gPldPlatformBootManagerOverrideProtocolGuid =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayload= Pkg.dec index 99cb3311a6..d9c5775e76 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -3,7 +3,7 @@ # # Provides drivers and definitions to create uefi payload for bootloaders. # -# Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -43,6 +43,8 @@ # gPlatformGOPPolicyGuid =3D { 0xec2e931b, 0x3281, 0x48a5= , { 0x81, 0x07, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d } } =20 + gPldPlatformBootManagerOverrideProtocolGuid =3D { 0xdb3fc2df, 0x7376, 0x= 4a8d, { 0x82, 0xab, 0x91, 0x54, 0xa1, 0x36, 0xa6, 0x5a } } + ##########################################################################= ###### # # PCD Declarations section - list of all PCDs Declared by this Package --=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 (#75968): https://edk2.groups.io/g/devel/message/75968 Mute This Topic: https://groups.io/mt/83259712/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-