From nobody Tue May 14 05:21:14 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+76311+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+76311+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1623289764; cv=none; d=zohomail.com; s=zohoarc; b=MAt6B0//vEr7sYoQuuRG3bYV7FwM8Yai6Qs9adSeDpCehje8Z1c9q4EwZ/sz5XJ37WklrknhJ4DSydqT4Sj/eLTOSpQUbZ+xs+ABp+mAKO3Bjayoli4Ieb017eaXb6IjmLyI/fu6aE+3n25F3D2QP6ZXYksPfnUaezP6MBpx3lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623289764; 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=JVgvvGezzOOZIysLdhNbLlfnrmOQnMz1An24uIyN3e8=; b=ZA+5kRadEy5ObIXJ4rHzFgMTQrkQPsuwQHeUQhNCFqtY2DSq3MO9YKFtGx7tT9EoQ7iffQcUjeEORAILM/90/R2/3X7/pIaLIW35YHadYSyz6ZmbwTssMwS1gT0O+t+UVacw71mXqgGJZTWT2mR4g6ZtMWq3CalbaMclR7kYlRY= 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+76311+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 1623289764540645.9449104952201; Wed, 9 Jun 2021 18:49:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qejUYY1788612xKteGsFeFh4; Wed, 09 Jun 2021 18:49:24 -0700 X-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 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" X-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" X-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: [edk2-devel] [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> 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: RvlzdZuRcbvwuQyVIVk4sS1Xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1623289764; bh=vEfoa7L2Ua2hyflW9xrhwc1ZyKpNkZooqR4NlzYPWb4=; h=Cc:Date:From:Reply-To:Subject:To; b=KZsbybsncCdfwzCGfZxR81dBA/P37etmgoNfbDduCSCh39J5wvzNPTUoaRUh27AY6Yg RTpgl33lLa8MiOF0NcrXxcXSS8Bi6v6vnFm9hZPBW2GmkWw4ZuCO8WG52M+ozF+sgc4XE ckAJmT4MM2uyot3qpnPFZeFqjen3R2nfCac= 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 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 + 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 *UNIVERSAL_PAYLOAD_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 *UNIVERSAL_PAYLOAD_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 *UNIVERSAL_PAYLOAD_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 *UNIVERSAL_PAYLOAD_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 { + UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE B= eforeConsole; + UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE A= fterConsole; + UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK W= aitCallback; + UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT U= nableToBoot; +} UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL; + +extern GUID gUniversalPayloadPlatformBootManagerOverrideProtocolGuid; + +#endif 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 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 + +UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL *mUniversalPayl= oadPlatformBootManagerOverrideInstance =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 (&gUniversalPayloadPlatformBootManagerOve= rrideProtocolGuid, NULL, (VOID **) &mUniversalPayloadPlatformBootManagerOve= rrideInstance); + if (EFI_ERROR (Status)) { + mUniversalPayloadPlatformBootManagerOverrideInstance =3D NULL; + } + if (mUniversalPayloadPlatformBootManagerOverrideInstance !=3D NULL){ + mUniversalPayloadPlatformBootManagerOverrideInstance->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 (mUniversalPayloadPlatformBootManagerOverrideInstance !=3D NULL){ + mUniversalPayloadPlatformBootManagerOverrideInstance->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 (mUniversalPayloadPlatformBootManagerOverrideInstance !=3D NULL){ + mUniversalPayloadPlatformBootManagerOverrideInstance->WaitCallback (Ti= meoutRemain); + } return; } =20 @@ -260,6 +280,9 @@ PlatformBootManagerUnableToBoot ( VOID ) { + if (mUniversalPayloadPlatformBootManagerOverrideInstance !=3D NULL){ + mUniversalPayloadPlatformBootManagerOverrideInstance->UnableToBoot(); + } return; } =20 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 # 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 + gUniversalPayloadPlatformBootManagerOverrideProtocolGuid =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut 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 @@ # # 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 + gUniversalPayloadPlatformBootManagerOverrideProtocolGuid =3D { 0xdb3fc2d= f, 0x7376, 0x4a8d, { 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 (#76311): https://edk2.groups.io/g/devel/message/76311 Mute This Topic: https://groups.io/mt/83436007/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-