[edk2-devel] [PATCH 2/2] OvmfPkg: Transfer PlatformBootManager library to driver
thiyagukb
thiyagux.kesavan.balakrishnan at intel.com
Mon Sep 13 03:01:03 UTC 2021
Signed-off-by: Zhiguang Liu <zhiguang.liu at intel.com>
---
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 <Library/PlatformBmPrintScLib.h>
#include <Library/Tcg2PhysicalPresenceLib.h>
#include <Library/XenPlatformLib.h>
+#include <Library/DxeServicesLib.h>
//
@@ -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 <Guid/DebugAgentGuid.h>
#include <OvmfPlatforms.h>
+#include <Library/PlatformBootManagerLib.h>
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.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Uefi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/PlatformBootManagerLib.h>
+#include <Protocol/PlatformBootManagerOverride.h>
+
+
+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.<BR>
+# 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80555): https://edk2.groups.io/g/devel/message/80555
Mute This Topic: https://groups.io/mt/85567528/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list