REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2336
This is a sample/generic DXE driver that registers all the BDS hook points or callbacks as defined in BoardBdsHookLib. Cc: Michael Kubacki <michael.a.kuba...@intel.com> Cc: Chasel Chiu <chasel.c...@intel.com> Cc: Nate DeSimone <nathaniel.l.desim...@intel.com> Signed-off-by: Prince Agyeman <prince.agye...@intel.com> --- .../BoardBdsHookDxe/BoardBdsHookDxe.c | 121 ++++++++++++++++++ .../BoardBdsHookDxe/BoardBdsHookDxe.inf | 46 +++++++ 2 files changed, 167 insertions(+) create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c create mode 100644 Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf diff --git a/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c new file mode 100644 index 0000000000..88eb7d70e9 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.c @@ -0,0 +1,121 @@ +/** @file + Bds Hook Point callbacks DXE driver + + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include <Library/UefiDriverEntryPoint.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/DebugLib.h> +#include <Library/UefiLib.h> +#include <Library/BoardBdsHookLib.h> + +#include <Protocol/PciEnumerationComplete.h> + +/** + Initialize DXE Platform. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable Global system service table. + + @retval EFI_SUCCESS Initialization complete. + @exception EFI_UNSUPPORTED The chipset is unsupported by this driver. + @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver. + @retval EFI_DEVICE_ERROR Device error, driver exits abnormally. +**/ +EFI_STATUS +EFIAPI +BdsHookDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_EVENT BeforeConsoleAfterTrustedConsoleEvent; + EFI_EVENT BeforeConsoleBeforeEndOfDxeEvent; + EFI_EVENT AfterConsoleReadyBeforeBootOptionEvent; + EFI_EVENT ReadyToBootEvent; + EFI_EVENT PciEnumCompleteEvent; + EFI_EVENT SmmReadyToLockEvent; + EFI_STATUS Status; + VOID *Registration; + + DEBUG ((DEBUG_INFO, "%a starts\n", __FUNCTION__ )); + + // + // Create event to set proper video resolution and text mode for internal shell. + // + Status = EfiCreateEventReadyToBootEx ( + TPL_CALLBACK, + BdsReadyToBootCallback, + NULL, + &ReadyToBootEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Create PCI Enumeration Completed callback for BDS + // + PciEnumCompleteEvent = EfiCreateProtocolNotifyEvent ( + &gEfiPciEnumerationCompleteProtocolGuid, + TPL_CALLBACK, + BdsPciEnumCompleteCallback, + NULL, + &Registration + ); + ASSERT (PciEnumCompleteEvent != NULL); + + // + // Create PCI Enumeration Completed callback for BDS + // + SmmReadyToLockEvent = EfiCreateProtocolNotifyEvent ( + &gEfiDxeSmmReadyToLockProtocolGuid, + TPL_CALLBACK, + BdsSmmReadyToLockCallback, + NULL, + &Registration + ); + ASSERT (SmmReadyToLockEvent != NULL); + + // + // Create BeforeConsoleAfterTrustedConsole event callback + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + BdsBeforeConsoleAfterTrustedConsoleCallback, + NULL, + &gBdsEventBeforeConsoleAfterTrustedConsoleGuid, + &BeforeConsoleAfterTrustedConsoleEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Create BeforeConsoleBeforeEndOfDxeGuid event callback + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + BdsBeforeConsoleBeforeEndOfDxeGuidCallback, + NULL, + &gBdsEventBeforeConsoleBeforeEndOfDxeGuid, + &BeforeConsoleBeforeEndOfDxeEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Create AfterConsoleReadyBeforeBootOption event callback + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + BdsAfterConsoleReadyBeforeBootOptionCallback, + NULL, + &gBdsEventAfterConsoleReadyBeforeBootOptionGuid, + &AfterConsoleReadyBeforeBootOptionEvent + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf new file mode 100644 index 0000000000..e3871d6dd4 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/BoardBdsHookDxe/BoardBdsHookDxe.inf @@ -0,0 +1,46 @@ +### @file +# Module Information file for the Bds Hook DXE driver. +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### + +[Defines] + INF_VERSION = 0x00010017 + BASE_NAME = BoardBdsHookDxe + FILE_GUID = EEA6491C-0DC5-48AB-B99D-CE77D14D43F2 + VERSION_STRING = 1.0 + MODULE_TYPE = DXE_DRIVER + ENTRY_POINT = BdsHookDxeEntryPoint + +[LibraryClasses] + BaseLib + UefiBootServicesTableLib + UefiDriverEntryPoint + DebugLib + UefiLib + BoardBdsHookLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + SecurityPkg/SecurityPkg.dec + MinPlatformPkg/MinPlatformPkg.dec + BoardModulePkg/BoardModulePkg.dec + +[Sources] + BoardBdsHookDxe.c + +[Protocols] + gEfiPciEnumerationCompleteProtocolGuid + gEfiDxeSmmReadyToLockProtocolGuid + +[Guids] + gBdsEventBeforeConsoleAfterTrustedConsoleGuid + gBdsEventBeforeConsoleBeforeEndOfDxeGuid + gBdsEventAfterConsoleReadyBeforeBootOptionGuid + +[Depex] + TRUE -- 2.19.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52225): https://edk2.groups.io/g/devel/message/52225 Mute This Topic: https://groups.io/mt/68590726/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-