From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web09.24421.1631502114658818819 for ; Sun, 12 Sep 2021 20:01:55 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: thiyagux.kesavan.balakrishnan@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10105"; a="201061631" X-IronPort-AV: E=Sophos;i="5.85,288,1624345200"; d="scan'208";a="201061631" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2021 20:01:53 -0700 X-IronPort-AV: E=Sophos;i="5.85,288,1624345200"; d="scan'208";a="696489123" Received: from tkesavax-mobl.gar.corp.intel.com ([10.235.192.196]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2021 20:01:51 -0700 From: "thiyagukb" To: devel@edk2.groups.io Cc: thiyagukb , Zhiguang Liu Subject: [PATCH 2/2] OvmfPkg: Transfer PlatformBootManager library to driver Date: Mon, 13 Sep 2021 08:31:03 +0530 Message-Id: <20210913030103.1845-2-thiyagux.kesavan.balakrishnan@intel.com> X-Mailer: git-send-email 2.33.0.windows.2 In-Reply-To: <20210913030103.1845-1-thiyagux.kesavan.balakrishnan@intel.com> References: <20210913030103.1845-1-thiyagux.kesavan.balakrishnan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Signed-off-by: Zhiguang Liu --- OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 21 +++++---------------- OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h | 1 + OvmfPkg/QemuUniversalPayload/PlatformBootManagerDriver/BdsPlatform.c | 40 ++++++++++++++++++++++++++++++++++++++++ OvmfPkg/QemuUniversalPayload/PlatformBootManagerDriver/PlatformBootManagerDriver.inf | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 16 deletions(-) diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c index 71f63b2448..2eb8682dce 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -12,6 +12,7 @@ #include #include #include +#include // @@ -94,24 +95,12 @@ PlatformRegisterFvBootOption ( EFI_BOOT_MANAGER_LOAD_OPTION NewOption; EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; UINTN BootOptionCount; - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; EFI_DEVICE_PATH_PROTOCOL *DevicePath; - Status = gBS->HandleProtocol ( - gImageHandle, - &gEfiLoadedImageProtocolGuid, - (VOID **) &LoadedImage - ); - ASSERT_EFI_ERROR (Status); - - EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); - DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle); - ASSERT (DevicePath != NULL); - DevicePath = AppendDevicePathNode ( - DevicePath, - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode - ); + Status = GetFileDevicePathFromAnyFv(FileGuid, EFI_SECTION_PE32, 0, &DevicePath); + if (EFI_ERROR (Status)){ + Status = GetFileDevicePathFromAnyFv(FileGuid, EFI_SECTION_USER_INTERFACE, 0, &DevicePath); + } ASSERT (DevicePath != NULL); Status = EfiBootManagerInitializeLoadOption ( diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h index 153e215101..d6ffadfdaf 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h @@ -63,6 +63,7 @@ Abstract: #include #include +#include extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[]; extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode; diff --git a/OvmfPkg/QemuUniversalPayload/PlatformBootManagerDriver/BdsPlatform.c b/OvmfPkg/QemuUniversalPayload/PlatformBootManagerDriver/BdsPlatform.c new file mode 100644 index 0000000000..7dc9a47eff --- /dev/null +++ b/OvmfPkg/QemuUniversalPayload/PlatformBootManagerDriver/BdsPlatform.c @@ -0,0 +1,40 @@ +/** @file + Platform BDS customizations. + + Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + + +STATIC UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL mUniversalPayloadPlatformBootManager = { + PlatformBootManagerBeforeConsole, + PlatformBootManagerAfterConsole, + PlatformBootManagerWaitCallback, + PlatformBootManagerUnableToBoot, +}; + +// Entry point of this driver +// +EFI_STATUS +EFIAPI +InitPlatformBootManagerLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gUniversalPayloadPlatformBootManagerOverrideProtocolGuid, + EFI_NATIVE_INTERFACE, + &mUniversalPayloadPlatformBootManager + ); + return Status; +} \ No newline at end of file diff --git a/OvmfPkg/QemuUniversalPayload/PlatformBootManagerDriver/PlatformBootManagerDriver.inf b/OvmfPkg/QemuUniversalPayload/PlatformBootManagerDriver/PlatformBootManagerDriver.inf new file mode 100644 index 0000000000..6ffb76096a --- /dev/null +++ b/OvmfPkg/QemuUniversalPayload/PlatformBootManagerDriver/PlatformBootManagerDriver.inf @@ -0,0 +1,90 @@ +## @file +# Platform BDS customizations library. +# +# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PlatformBootManager + FILE_GUID = FB65006C-AC9F-4992-AD80-184B2BDBBD13 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = InitPlatformBootManagerLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 EBC +# + +[Sources] + BdsPlatform.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + SourceLevelDebugPkg/SourceLevelDebugPkg.dec + OvmfPkg/OvmfPkg.dec + SecurityPkg/SecurityPkg.dec + ShellPkg/ShellPkg.dec + UefiPayloadPkg/UefiPayloadPkg.dec + +[LibraryClasses] + BaseLib + MemoryAllocationLib + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + BaseMemoryLib + DebugLib + PcdLib + UefiBootManagerLib + BootLogoLib + DevicePathLib + PciLib + NvVarsFileLib + QemuFwCfgLib + QemuFwCfgS3Lib + QemuLoadImageLib + QemuBootOrderLib + ReportStatusCodeLib + UefiLib + PlatformBmPrintScLib + Tcg2PhysicalPresenceLib + XenPlatformLib + DxeServicesLib + UefiDriverEntryPoint + PlatformBootManagerLib + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits ## CONSUMES + +[Pcd.IA32, Pcd.X64] + gEfiMdePkgTokenSpaceGuid.PcdFSBClock + +[Protocols] + gEfiDecompressProtocolGuid + gEfiPciRootBridgeIoProtocolGuid + gEfiS3SaveStateProtocolGuid # PROTOCOL SOMETIMES_CONSUMED + gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED + gEfiLoadedImageProtocolGuid # PROTOCOL SOMETIMES_PRODUCED + gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED + gUniversalPayloadPlatformBootManagerOverrideProtocolGuid # PROTOCOL ALWAYS_PRODUCED + +[Guids] + gEfiEndOfDxeEventGroupGuid + gEfiGlobalVariableGuid + gRootBridgesConnectedEventGroupGuid + gUefiShellFileGuid + +[Depex] + TRUE \ No newline at end of file -- 2.26.2.windows.1