public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Agyeman, Prince" <prince.agyeman@intel.com>
To: devel@edk2.groups.io
Cc: Michael Kubacki <michael.a.kubacki@intel.com>,
	Chasel Chiu <chasel.chiu@intel.com>,
	Nate DeSimone <nathaniel.l.desimone@intel.com>
Subject: [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver
Date: Fri, 13 Dec 2019 17:32:29 -0800	[thread overview]
Message-ID: <4917b65e194ea62af08d6a811bc9ae332be2b538.1576282834.git.prince.agyeman@intel.com> (raw)
In-Reply-To: <cover.1576282834.git.prince.agyeman@intel.com>

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.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

Signed-off-by: Prince Agyeman <prince.agyeman@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


  parent reply	other threads:[~2019-12-14  1:32 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-14  1:32 [edk2-platforms] [PATCH 00/11] Add BDS Hook Points Agyeman, Prince
2019-12-14  1:32 ` [edk2-platforms] [PATCH 01/11] MinPlatformPkg: Add BDS Hook Point Guids Agyeman, Prince
2019-12-16  1:31   ` Chiu, Chasel
2019-12-16  8:50     ` [edk2-devel] " Ni, Ray
2019-12-17 23:58       ` Kubacki, Michael A
2019-12-18  0:11         ` Ni, Ray
2019-12-18  1:31   ` Nate DeSimone
2019-12-21  2:36   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 02/11] BoardModulePkg: Add BDS Hook Library Agyeman, Prince
2019-12-18  1:19   ` Nate DeSimone
2019-12-21  2:36   ` Kubacki, Michael A
2019-12-14  1:32 ` Agyeman, Prince [this message]
2019-12-18  1:32   ` [edk2-platforms] [PATCH 03/11] BoardModulePkg: Add BDS Hook DXE Driver Nate DeSimone
2019-12-21  2:36   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 04/11] MinPlatformPkg: Add BDS Board Boot Manager library Agyeman, Prince
2019-12-17  4:24   ` Chiu, Chasel
2019-12-18  1:33   ` Nate DeSimone
2019-12-21  2:36   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 05/11] MinPlatformPkg: Add BDS Hook Points Agyeman, Prince
2019-12-17  5:44   ` Chiu, Chasel
2019-12-18  1:33   ` Nate DeSimone
2019-12-21  2:36   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 06/11] BoardModulePkg: Add Generic BoardBootManagerLib Agyeman, Prince
2019-12-18  1:34   ` Nate DeSimone
2019-12-21  2:36   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 07/11] KabylakeOpenBoardPkg: Add BDS Hook Dxe Driver Agyeman, Prince
2019-12-17  5:44   ` Chiu, Chasel
2019-12-18  1:35   ` Nate DeSimone
2019-12-21  2:36   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 08/11] WhiskeylakeOpenBoardPkg: " Agyeman, Prince
2019-12-17  5:45   ` Chiu, Chasel
2019-12-18  1:35   ` Nate DeSimone
2019-12-21  2:36   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 09/11] SimicsOpenBoardPkg: Add Bds Hook Library Agyeman, Prince
2019-12-18  1:29   ` Nate DeSimone
2019-12-21  2:37   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 10/11] SimicsOpenBoardPkg: Add BDS Board Boot Manager library Agyeman, Prince
2019-12-18  1:35   ` Nate DeSimone
2019-12-21  2:37   ` Kubacki, Michael A
2019-12-14  1:32 ` [edk2-platforms] [PATCH 11/11] SimicsOpenBoardPkg: Add Bds Hook Points Agyeman, Prince
2019-12-18  1:36   ` Nate DeSimone
2019-12-21  2:37   ` Kubacki, Michael A
2020-04-21 20:37 ` [edk2-devel] [edk2-platforms] [PATCH 00/11] Add BDS " Nate DeSimone
2020-04-22 10:31   ` Leif Lindholm
2020-04-22 22:13     ` Nate DeSimone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4917b65e194ea62af08d6a811bc9ae332be2b538.1576282834.git.prince.agyeman@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox