From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web10.2430.1576287158438932734 for ; Fri, 13 Dec 2019 17:32:39 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: prince.agyeman@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Dec 2019 17:32:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,311,1571727600"; d="scan'208";a="297091514" Received: from paagyema-desk2.amr.corp.intel.com ([10.24.15.84]) by orsmga001.jf.intel.com with ESMTP; 13 Dec 2019 17:32:38 -0800 From: "Agyeman, Prince" To: devel@edk2.groups.io Cc: Michael Kubacki , Chasel Chiu , Nate DeSimone Subject: [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver Date: Fri, 13 Dec 2019 17:32:29 -0800 Message-Id: <4917b65e194ea62af08d6a811bc9ae332be2b538.1576282834.git.prince.agyeman@intel.com> X-Mailer: git-send-email 2.19.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Chasel Chiu Cc: Nate DeSimone Signed-off-by: Prince Agyeman --- .../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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +#include + +/** + 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.
+# +# 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