From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.4557.1623289763434685868 for ; Wed, 09 Jun 2021 18:49:23 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: zhiguang.liu@intel.com) IronPort-SDR: 6S5T3WR0kUb3LGQ0XHL9oGVd3C4yIYftBSdR2+n+SPKE8f2mR5WxYyNWx0QGSMhnMuo/nWwh6H 7kY4f5YyEfhw== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="205239564" X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="205239564" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 18:49:22 -0700 IronPort-SDR: syDTTP2V6J6Z3s9m2n6v8JwzE2ATG/A1vpVp6k8ZwGERvku/lZiCwYMDFGQ5BvQ5VGZJ4cx3la WC8eLLEseDMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="448514269" Received: from fieedk002.ccr.corp.intel.com ([10.239.158.144]) by orsmga008.jf.intel.com with ESMTP; 09 Jun 2021 18:49:20 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Maurice Ma , Guo Dong , Benjamin You Subject: [Patch V3] UefiPayloadPkg: Get platform specific logic from protocol for BDS driver Date: Thu, 10 Jun 2021 09:49:17 +0800 Message-Id: <20210610014917.2082-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 V3: Avoid using "PLD" term 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..59544e417c --- /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 *UNIVERSAL_PAYLOAD_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 *UNIVERSAL_PAYLOAD_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 *UNIVERSAL_PAYLOAD_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 *UNIVERSAL_PAYLOAD_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 + UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE B= eforeConsole;=0D + UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE A= fterConsole;=0D + UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK W= aitCallback;=0D + UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT U= nableToBoot;=0D +} UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL;=0D +=0D +extern GUID gUniversalPayloadPlatformBootManagerOverrideProtocolGuid;=0D +=0D +#endif=0D diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= ger.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index 7fa3a048b7..fce48d26a1 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 +UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL *mUniversalPayl= oadPlatformBootManagerOverrideInstance =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 (&gUniversalPayloadPlatformBootManagerOve= rrideProtocolGuid, NULL, (VOID **) &mUniversalPayloadPlatformBootManagerOve= rrideInstance);=0D + if (EFI_ERROR (Status)) {=0D + mUniversalPayloadPlatformBootManagerOverrideInstance =3D NULL;=0D + }=0D + if (mUniversalPayloadPlatformBootManagerOverrideInstance !=3D NULL){=0D + mUniversalPayloadPlatformBootManagerOverrideInstance->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 (mUniversalPayloadPlatformBootManagerOverrideInstance !=3D NULL){=0D + mUniversalPayloadPlatformBootManagerOverrideInstance->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 (mUniversalPayloadPlatformBootManagerOverrideInstance !=3D NULL){=0D + mUniversalPayloadPlatformBootManagerOverrideInstance->WaitCallback (Ti= meoutRemain);=0D + }=0D return;=0D }=0D =0D @@ -260,6 +280,9 @@ PlatformBootManagerUnableToBoot ( VOID=0D )=0D {=0D + if (mUniversalPayloadPlatformBootManagerOverrideInstance !=3D NULL){=0D + mUniversalPayloadPlatformBootManagerOverrideInstance->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..600a535282 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 + gUniversalPayloadPlatformBootManagerOverrideProtocolGuid=0D =0D [Pcd]=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut=0D diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayload= Pkg.dec index 99cb3311a6..105e1f5a1c 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 + gUniversalPayloadPlatformBootManagerOverrideProtocolGuid =3D { 0xdb3fc2d= f, 0x7376, 0x4a8d, { 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