public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kubacki, Michael A" <michael.a.kubacki@intel.com>
To: devel@edk2.groups.io
Cc: Eric Dong <eric.dong@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [edk2-platforms][PATCH V2 3/3] BoardModulePkg/FirmwareBootMediaInfoPei: Add module
Date: Fri,  4 Oct 2019 10:29:24 -0700	[thread overview]
Message-ID: <20191004172924.20240-4-michael.a.kubacki@intel.com> (raw)
In-Reply-To: <20191004172924.20240-1-michael.a.kubacki@intel.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2229

Adds a new module that is responsible for publishing the boot
media device information that will be used in the boot flow for
system initialization decisions dependent upon firmware boot
media.

The module depends on a library class to implement the board-
specific details to get the firmware boot media device. This
allows the module to remain consistent in its responsibility
across implementations and the details to be easily substituted.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
---
 Platform/Intel/BoardModulePkg/BoardModulePkg.dsc                                 |  3 +
 Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf | 46 ++++++++++++
 Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.c   | 76 ++++++++++++++++++++
 3 files changed, 125 insertions(+)

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
index 3d605cf876..5ec68ceebf 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
@@ -31,9 +31,11 @@
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
 
 [LibraryClasses.common.PEIM]
   FirmwareBootMediaLib|IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBootMediaLib.inf
+  FirmwareBootMediaInfoLib|BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/PeiFirmwareBootMediaInfoLib.inf
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
   MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
 
@@ -73,6 +75,7 @@
 ###################################################################################################
 
 [Components]
+  BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf
   BoardModulePkg/Library/CmosAccessLib/CmosAccessLib.inf
   BoardModulePkg/Library/PlatformCmosAccessLibNull/PlatformCmosAccessLibNull.inf
 
diff --git a/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf b/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf
new file mode 100644
index 0000000000..a81932f2a1
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf
@@ -0,0 +1,46 @@
+## @file
+# Firmware Boot Media Info Module
+#
+# This module publishes firmware boot media device information used in the boot flow for system initialization
+# decisions dependent upon the firmware boot media.
+#
+# This module depends upon a library instance to actually perform firmware boot media device detection since the
+# detection mechanism will vary across systems. In many cases, the media type may simply be set to a single firmware
+# boot media device with no run-time logic required. In any case, this module should dispatch as early as possible in
+# the system boot flow so the firmware boot media information is available for other modules. If any dependencies are
+# required to dynamically determine the firmware boot media device, those should be in the DEPEX section of the active
+# FirmwareBootMediaInfoLib such that this module will dispatch once those dependencies are satisfied.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION       = 0x00010017
+  BASE_NAME         = FirmwareBootMediaInfoPei
+  FILE_GUID         = A8F14FA9-FC88-45F4-A622-F06E6C56E632
+  VERSION_STRING    = 1.0
+  MODULE_TYPE       = PEIM
+  ENTRY_POINT       = FirmwareBootMediaInfoPeiEntry
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  FirmwareBootMediaLib
+  FirmwareBootMediaInfoLib
+  HobLib
+  PeimEntryPoint
+  PeiServicesLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
+  BoardModulePkg/BoardModulePkg.dec
+
+[Sources]
+  FirmwareBootMediaInfoPei.c
+
+[Depex]
+  TRUE
diff --git a/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.c b/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.c
new file mode 100644
index 0000000000..7a71071053
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.c
@@ -0,0 +1,76 @@
+/** @file
+  Firmware Boot Media Info Module
+
+  This module publishes firmware boot media device information used in the boot flow for system initialization
+  decisions dependent upon the firmware boot media.
+
+  This module depends upon a library instance to actually perform firmware boot media device detection since the
+  detection mechanism will vary across systems. In many cases, the media type may simply be set to a single firmware
+  boot media device with no run-time logic required. In any case, this module should dispatch as early as possible in
+  the system boot flow so the firmware boot media information is available for other modules. If any dependencies are
+  required to dynamically determine the firmware boot media device, those should be in the DEPEX section of the active
+  FirmwareBootMediaInfoLib such that this module will dispatch once those dependencies are satisfied.
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/FirmwareBootMediaLib.h>
+#include <Library/FirmwareBootMediaInfoLib.h>
+#include <Library/HobLib.h>
+
+/**
+  Produces a gFirmwareBootMediaHobGuid HOB instance.
+
+  @retval     EFI_SUCCESS     The firmware boot media HOB was produced successfully.
+  @retval     EFI_NOT_FOUND   The firmware boot media device information could not be found to produce the
+                              the firmware boot media HOB.
+**/
+EFI_STATUS
+EFIAPI
+ProduceFirmwareBootMediaHob (
+  VOID
+  )
+{
+  FW_BOOT_MEDIA_HOB_DATA FwBootMediaHobData;
+
+  FwBootMediaHobData.BootMedia = IdentifyFirmwareBootMediaType ();
+  if (FwBootMediaHobData.BootMedia == FwBootMediaMax) {
+    return EFI_NOT_FOUND;
+  }
+
+  BuildGuidDataHob (
+    &gFirmwareBootMediaHobGuid,
+    &FwBootMediaHobData,
+    sizeof (FW_BOOT_MEDIA_HOB_DATA)
+    );
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Attempts to publish the firmware boot media HOB.
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Produce the BootMedia Hob successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+FirmwareBootMediaInfoPeiEntry (
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES     **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = ProduceFirmwareBootMediaHob ();
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
-- 
2.16.2.windows.1


  parent reply	other threads:[~2019-10-04 17:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-04 17:29 [edk2-platforms][PATCH V2 0/3] Add FW Boot Media Device Indicator Kubacki, Michael A
2019-10-04 17:29 ` [edk2-platforms][PATCH V2 1/3] IntelSiliconPkg/FirmwareBootMediaLib: Add library Kubacki, Michael A
2019-10-07  1:45   ` Chaganty, Rangasai V
2019-10-09  9:35   ` Ni, Ray
2019-10-09 16:33     ` Kubacki, Michael A
2019-10-10  2:21       ` Ni, Ray
2019-10-10  4:42         ` Kubacki, Michael A
2019-10-10  5:44           ` Ni, Ray
2019-10-04 17:29 ` [edk2-platforms][PATCH V2 2/3] BoardModulePkg/FirmwareBootMediaInfoLib: " Kubacki, Michael A
2019-10-08  7:01   ` Dong, Eric
2019-10-04 17:29 ` Kubacki, Michael A [this message]
2019-10-08  7:02   ` [edk2-platforms][PATCH V2 3/3] BoardModulePkg/FirmwareBootMediaInfoPei: Add module Dong, Eric

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=20191004172924.20240-4-michael.a.kubacki@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