From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: michael.a.kubacki@intel.com) Received: from mga17.intel.com (mga17.intel.com []) by groups.io with SMTP; Fri, 04 Oct 2019 10:29:32 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2019 10:29:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,257,1566889200"; d="scan'208";a="186324623" Received: from makuback-desk1.amr.corp.intel.com ([10.7.159.162]) by orsmga008.jf.intel.com with ESMTP; 04 Oct 2019 10:29:32 -0700 From: "Kubacki, Michael A" To: devel@edk2.groups.io Cc: Eric Dong , Liming Gao Subject: [edk2-platforms][PATCH V2 3/3] BoardModulePkg/FirmwareBootMediaInfoPei: Add module Date: Fri, 4 Oct 2019 10:29:24 -0700 Message-Id: <20191004172924.20240-4-michael.a.kubacki@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20191004172924.20240-1-michael.a.kubacki@intel.com> References: <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 Cc: Liming Gao Signed-off-by: Michael Kubacki --- 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.
+# +# 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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +/** + 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