From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web09.4780.1622019195748869143 for ; Wed, 26 May 2021 01:53:16 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: zhiguang.liu@intel.com) IronPort-SDR: QpaUDTCZbvLG0V/+MC7vrujz8JUCjPBBmZC0ocrXszq+fO4S4XWtsX1vpUVK/qhpUsbe8h9zJ/ tNj2LYGTeyoA== X-IronPort-AV: E=McAfee;i="6200,9189,9995"; a="200517127" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="200517127" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 01:53:13 -0700 IronPort-SDR: QicGvG2pTrT4TVJ3o89j6hvO3+ZQdLFEQsbqWAe0pISz9NSb3cTbSfF0qivEnxi3fXCxYVamlw T5SduUKuAI3Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="476838484" Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga001.jf.intel.com with ESMTP; 26 May 2021 01:53:09 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You Subject: [PATCH] UefiPayloadPkg: Get platform specific logic from protocol for BDS driver Date: Wed, 26 May 2021 16:52:44 +0800 Message-Id: <20210526085244.1992-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, 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. Cc: Maurice Ma Cc: Guo Dong Cc: Benjamin You Signed-off-by: Zhiguang Liu --- UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h |= 44 ++++++++++++++++++++++++++++++++++++++++++++ UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c |= 25 ++++++++++++++++++++++++- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |= 3 ++- UefiPayloadPkg/UefiPayloadPkg.dec |= 4 +++- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h = b/UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h new file mode 100644 index 0000000000..0641cc4218 --- /dev/null +++ b/UefiPayloadPkg/Include/Protocol/PlatformBootManagerOverride.h @@ -0,0 +1,44 @@ +/** @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 +typedef=0D +VOID=0D +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE) (=0D + VOID=0D + );=0D +=0D +typedef=0D +VOID=0D +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE) (=0D + VOID=0D + );=0D +=0D +typedef=0D +VOID=0D +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK) (=0D + UINT16 TimeoutRemain=0D + );=0D +=0D +typedef=0D +VOID=0D +(EFIAPI *PLD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT) (=0D + VOID=0D + );=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