From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: zhiguang.liu@intel.com) 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" 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" 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: [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> X-Mailer: git-send-email 2.30.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=0D + This file defines the Univeral Payload Platform BootManager Protocol.=0D +=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#ifndef __PLATFORM_BOOT_MANAGER_OVERRIDE_H__=0D +#define __PLATFORM_BOOT_MANAGER_OVERRIDE_H__=0D +=0D +=0D +/**=0D + Do the platform specific action before the console is connected.=0D +=0D + Such as:=0D + Update console variable;=0D + Register new Driver#### or Boot####;=0D + Signal ReadyToLock event.=0D +=0D + This function will override the default behavior in PlatformBootManagerL= ib=0D +**/=0D +typedef=0D +VOID=0D +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE) (=0D + VOID=0D + );=0D +=0D +/**=0D + Do the platform specific action after the console is connected.=0D +=0D + Such as:=0D + Dynamically switch output mode;=0D + Signal console ready platform customized event;=0D + Run diagnostics like memory testing;=0D + Connect certain devices;=0D + Dispatch aditional option roms.=0D +=0D + This function will override the default behavior in PlatformBootManagerL= ib=0D +**/=0D +typedef=0D +VOID=0D +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE) (=0D + VOID=0D + );=0D +=0D +/**=0D + This function is called each second during the boot manager waits the ti= meout.=0D + This function will override the default behavior in PlatformBootManagerL= ib=0D +=0D + @param TimeoutRemain The remaining timeout.=0D +**/=0D +typedef=0D +VOID=0D +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK) (=0D + UINT16 TimeoutRemain=0D + );=0D +=0D +/**=0D + The function is called when no boot option could be launched,=0D + including platform recovery options and options pointing to applications= =0D + built into firmware volumes.=0D +=0D + If this function returns, BDS attempts to enter an infinite loop.=0D + This function will override the default behavior in PlatformBootManagerL= ib=0D +**/=0D +typedef=0D +VOID=0D +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT) (=0D + VOID=0D + );=0D +=0D +///=0D +/// Provides an interface to override the default behavior in PlatformBoot= ManagerLib,=0D +/// so platform can provide its own platform specific logic through this p= rotocol=0D +///=0D +typedef struct {=0D + PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE BeforeConsole;= =0D + PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE AfterConsole;=0D + PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK WaitCallback;=0D + PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT UnableToBoot;=0D +} PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL;=0D +=0D +extern GUID gPldPlatformBootManagerOverrideProtocolGuid;=0D +=0D +#endif=0D 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=0D by IBV/OEM.=0D =0D -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D =0D #include "PlatformBootManager.h"=0D #include "PlatformConsole.h"=0D +#include =0D +=0D +PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL *mPldPlatformBootManagerOverr= ideInstance =3D NULL;=0D =0D VOID=0D InstallReadyToLock (=0D @@ -156,6 +159,16 @@ PlatformBootManagerBeforeConsole ( EFI_INPUT_KEY F2;=0D EFI_INPUT_KEY Down;=0D EFI_BOOT_MANAGER_LOAD_OPTION BootOption;=0D + EFI_STATUS Status;=0D +=0D + Status =3D gBS->LocateProtocol (&gPldPlatformBootManagerOverrideProtocol= Guid, NULL, (VOID **) &mPldPlatformBootManagerOverrideInstance);=0D + if (EFI_ERROR (Status)) {=0D + mPldPlatformBootManagerOverrideInstance =3D NULL;=0D + }=0D + if (mPldPlatformBootManagerOverrideInstance !=3D NULL){=0D + mPldPlatformBootManagerOverrideInstance->BeforeConsole();=0D + return;=0D + }=0D =0D //=0D // Register ENTER as CONTINUE key=0D @@ -213,6 +226,10 @@ PlatformBootManagerAfterConsole ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;=0D EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;=0D =0D + if (mPldPlatformBootManagerOverrideInstance !=3D NULL){=0D + mPldPlatformBootManagerOverrideInstance->AfterConsole();=0D + return;=0D + }=0D Black.Blue =3D Black.Green =3D Black.Red =3D Black.Reserved =3D 0;=0D White.Blue =3D White.Green =3D White.Red =3D White.Reserved =3D 0xFF;=0D =0D @@ -244,6 +261,9 @@ PlatformBootManagerWaitCallback ( UINT16 TimeoutRemain=0D )=0D {=0D + if (mPldPlatformBootManagerOverrideInstance !=3D NULL){=0D + mPldPlatformBootManagerOverrideInstance->WaitCallback (TimeoutRemain);= =0D + }=0D return;=0D }=0D =0D @@ -260,6 +280,9 @@ PlatformBootManagerUnableToBoot ( VOID=0D )=0D {=0D + if (mPldPlatformBootManagerOverrideInstance !=3D NULL){=0D + mPldPlatformBootManagerOverrideInstance->UnableToBoot();=0D + }=0D return;=0D }=0D =0D 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=0D # Include all platform action which can be customized by IBV/OEM.=0D #=0D -# Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2012 - 2021, Intel Corporation. All rights reserved.
= =0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -57,6 +57,7 @@ gEfiBootLogoProtocolGuid ## CONSUMES=0D gEfiDxeSmmReadyToLockProtocolGuid=0D gEfiSmmAccess2ProtocolGuid=0D + gPldPlatformBootManagerOverrideProtocolGuid=0D =0D [Pcd]=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut=0D 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 @@ #=0D # Provides drivers and definitions to create uefi payload for bootloaders.= =0D #=0D -# Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -43,6 +43,8 @@ #=0D gPlatformGOPPolicyGuid =3D { 0xec2e931b, 0x3281, 0x48a5= , { 0x81, 0x07, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d } }=0D =0D + gPldPlatformBootManagerOverrideProtocolGuid =3D { 0xdb3fc2df, 0x7376, 0x= 4a8d, { 0x82, 0xab, 0x91, 0x54, 0xa1, 0x36, 0xa6, 0x5a } }=0D +=0D ##########################################################################= ######=0D #=0D # PCD Declarations section - list of all PCDs Declared by this Package=0D --=20 2.30.0.windows.2