From nobody Fri Apr 26 18:07:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48482+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48482+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1570210172; cv=none; d=zoho.com; s=zohoarc; b=K422NK+ECJmvZ76XGgS7aY+zQ/vZusDWBif8tRK9bqhQm9rTR9766jZ9yb6zquhKz4h754LYZr7ZphDzgaYRhCtnqNzo7P3537hSy4Du9By3gxGOxROlxjR2yvhNX3WQrRTwE1Htoa4XARhFmcRnFj5vpSm7RoSIoXj5cP6kNj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570210172; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=vIrAJEQRd9likEjGWYoGFh4j8X7rHQRaaUcBN2wmPTQ=; b=D1Ne4xIeNLUHRyO4KUXzSxcLLDIDDFjCHSF3cvI1hBUpx6hHErtFT7PcWQQCsi5rUXQfAVbET7Y3ElnlXCtqKDoFVB63Mxardzza71lVTPgsbQxa73j9xfzc0m0WqeMjVZ6j0LInk0+fToQK0OfD2ZNRRsbkGxRxC4GzWaHuAHc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48482+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570210172946243.35211149795703; Fri, 4 Oct 2019 10:29:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OjHnYY1788612xvjXXA0m8zh; Fri, 04 Oct 2019 10:29:32 -0700 X-Received: from mga17.intel.com (mga17.intel.com []) by groups.io with SMTP; Fri, 04 Oct 2019 10:29:31 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-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:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,257,1566889200"; d="scan'208";a="186324615" X-Received: from makuback-desk1.amr.corp.intel.com ([10.7.159.162]) by orsmga008.jf.intel.com with ESMTP; 04 Oct 2019 10:29:31 -0700 From: "Kubacki, Michael A" To: devel@edk2.groups.io Cc: Sai Chaganty , Ray Ni Subject: [edk2-devel] [edk2-platforms][PATCH V2 1/3] IntelSiliconPkg/FirmwareBootMediaLib: Add library Date: Fri, 4 Oct 2019 10:29:22 -0700 Message-Id: <20191004172924.20240-2-michael.a.kubacki@intel.com> In-Reply-To: <20191004172924.20240-1-michael.a.kubacki@intel.com> References: <20191004172924.20240-1-michael.a.kubacki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.a.kubacki@intel.com X-Gm-Message-State: 2hzpYSU7JZoM0kk9RybqYsqBx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570210172; bh=VBJXzC49EATR8hxVQlwezFuC8TbJMxgld00QDm5+yvM=; h=Cc:Date:From:Reply-To:Subject:To; b=vMcZAHxEXDSebsnnebLRN/wkmvqDZP5U4I2ik7t+Ijm8rN/9K1VU9MGcHOq0ovG7zbI G5h5XNyuQ8BRasIkaz7o+gOf849JeTr+6I4HQfGeukKVJeIiNpnN/6hElZ1KmT+vo/54I Qh83WhhgjbSCxNcXrq5k5Dw36M/IA+VnhiA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2229 Adds a new library that is used to make system initialization decisions in the boot flow dependent upon firmware boot media. Note that the firmware boot media is the storage media that the boot firmware is stored on. It is not the OS storage media which may be stored upon a different non-volatile storage device. Any Intel board, platform, or silicon code that must take action conditionally based on the firmware boot media must use this library API. Cc: Sai Chaganty Cc: Ray Ni Signed-off-by: Michael Kubacki Reviewed-by: Sai Chaganty --- Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec = | 8 +- Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dsc = | 4 +- Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmware= BootMediaLib.inf | 43 ++++++++ Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBoo= tMediaLib.inf | 38 +++++++ Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h = | 106 +++++++++++++++++++ Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmware= BootMediaLib.c | 107 +++++++++++++++++++ Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/FirmwareBootMe= diaLib.c | 109 ++++++++++++++++++++ Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBoo= tMediaLib.c | 82 +++++++++++++++ 8 files changed, 495 insertions(+), 2 deletions(-) diff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec b/Silicon/In= tel/IntelSiliconPkg/IntelSiliconPkg.dec index fe5bfa0dc6..f70e3b977d 100644 --- a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec +++ b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec @@ -3,7 +3,7 @@ # # This package provides common open source Intel silicon modules. # -# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -22,6 +22,10 @@ # MicrocodeFlashAccessLib|Include/Library/MicrocodeFlashAccessLib.h =20 + ## @libraryclass Provides services to identify the firmware boot media = device. + # + FirmwareBootMediaLib|Include/Library/FirmwareBootMediaLib.h + [Guids] ## GUID for Package token space # {A9F8D54E-1107-4F0A-ADD0-4587E7A4A735} @@ -35,6 +39,8 @@ ## Include/Guid/MicrocodeFmp.h gMicrocodeFmpImageTypeIdGuid =3D { 0x96d4fdcd, 0x1502, 0x424d, { 0x= 9d, 0x4c, 0x9b, 0x12, 0xd2, 0xdc, 0xae, 0x5c } } =20 + gFirmwareBootMediaHobGuid =3D { 0x8c7340ea, 0xde8b, 0x4e06, {0xa4, 0x78,= 0xec, 0x8b, 0x62, 0xd7, 0xa, 0x8b } } + [Ppis] gEdkiiVTdInfoPpiGuid =3D { 0x8a59fcb3, 0xf191, 0x400c, { 0x97, 0x67, 0x6= 7, 0xaf, 0x2b, 0x25, 0x68, 0x4a } } =20 diff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dsc b/Silicon/In= tel/IntelSiliconPkg/IntelSiliconPkg.dsc index 58b5b656ef..3fb8a08b50 100644 --- a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dsc +++ b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dsc @@ -1,7 +1,7 @@ ## @file # This package provides common open source Intel silicon modules. # -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -80,6 +80,8 @@ IntelSiliconPkg/Feature/VTd/PlatformVTdInfoSamplePei/PlatformVTdInfoSamp= lePei.inf IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.inf IntelSiliconPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/Micr= ocodeFlashAccessLibNull.inf + IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBootMediaLib.inf + IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmwareBootMediaLib= .inf =20 [BuildOptions] *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES diff --git a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/Dx= eSmmFirmwareBootMediaLib.inf b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxe= SmmBootMediaLib/DxeSmmFirmwareBootMediaLib.inf new file mode 100644 index 0000000000..83ed5f04af --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFir= mwareBootMediaLib.inf @@ -0,0 +1,43 @@ +## @file +# Firmware Boot Media Library +# +# The firmware boot media device is used to make system initialization dec= isions in the boot flow dependent +# upon firmware boot media. Note that the firmware boot media is the stora= ge media that the boot firmware is stored on. +# It is not the OS storage media which may be stored upon a different non-= volatile storage device. +# +# This library contains an implementation for the DXE and SMM boot phases. +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DxeSmmFirmwareBootMediaLib + FILE_GUID =3D 72F07B0B-54F5-47FD-9EDB-D796BE2B87E9 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + PI_SPECIFICATION_VERSION =3D 0x0001000A + LIBRARY_CLASS =3D FirmwareBootMediaLib|DXE_DRIVER DXE_S= MM_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER + CONSTRUCTOR =3D DxeSmmFirmwareBootMediaLibInit +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Sources] + FirmwareBootMediaLib.c + DxeSmmFirmwareBootMediaLib.c + +[Packages] + MdePkg/MdePkg.dec + IntelSiliconPkg/IntelSiliconPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + HobLib + +[Guids] + gFirmwareBootMediaHobGuid ## CONSUMES diff --git a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/Pe= iFirmwareBootMediaLib.inf b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmm= BootMediaLib/PeiFirmwareBootMediaLib.inf new file mode 100644 index 0000000000..063c4027d3 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwa= reBootMediaLib.inf @@ -0,0 +1,38 @@ +## @file +# Firmware Boot Media Library +# +# The firmware boot media device is used to make system initialization dec= isions in the boot flow dependent +# upon firmware boot media. Note that the firmware boot media is the stora= ge media that the boot firmware is stored on. +# It is not the OS storage media which may be stored upon a different non-= volatile storage device. +# +# This library contains an implementation for the PEI boot phase. +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiFirmwareBootMediaLib + FILE_GUID =3D D3F7BD0B-3539-4F2D-AF98-EE32DBE7971F + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FirmwareBootMediaLib + +[Sources] + FirmwareBootMediaLib.c + PeiFirmwareBootMediaLib.c + +[Packages] + MdePkg/MdePkg.dec + IntelSiliconPkg/IntelSiliconPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + HobLib + +[Guids] + gFirmwareBootMediaHobGuid ## PRODUCES CONSUMES diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMedi= aLib.h b/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib= .h new file mode 100644 index 0000000000..aca9593a84 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/FirmwareBootMediaLib.h @@ -0,0 +1,106 @@ +/** @file + This library identifies the firmware boot media device. + + The firmware boot media device is used to make system initialization dec= isions in the boot flow dependent + upon firmware boot media. Note that the firmware boot media is the stora= ge media that the boot firmware is stored on. + It is not the OS storage media which may be stored upon a different non-= volatile storage device. + +Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _FIRMWARE_BOOT_MEDIA_LIB_H_ +#define _FIRMWARE_BOOT_MEDIA_LIB_H_ + +#include + +typedef enum { + FwBootMediaSpi, + FwBootMediaUfs, + FwBootMediaEmmc, + FwBootMediaNvme, + FwBootMediaMax +} FW_BOOT_MEDIA_TYPE; + +typedef struct { + FW_BOOT_MEDIA_TYPE BootMedia; +} FW_BOOT_MEDIA_HOB_DATA; + +/** + Determines the current platform firmware boot media device. + + @param[out] FwBootMediaType The current platform Boot Media type. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_NOT_FOUND The boot media type could not be found. +**/ +EFI_STATUS +EFIAPI +GetFirmwareBootMediaType ( + OUT FW_BOOT_MEDIA_TYPE *FwBootMediaType + ); + +/** + Indicates whether the boot media is presently known. + + Note: Very early in boot this data may not be available. + + @retval TRUE Boot media is known + @retval FALSE Boot media is not known +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsKnown ( + VOID + ); + +/** + Determines if the platform firmware is booting from SPI. + + @retval TRUE Platform firmware is booting from SPI + @retval FALSE Platform firmware is booting from a non-SPI device o= r the boot media is unknown +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsSpi ( + VOID + ); + +/** + Determines if the platform firmware is booting from UFS. + + @retval TRUE Platform firmware is booting from UFS + @retval FALSE Platform firmware is booting from a non-UFS device o= r the boot media is unknown +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsUfs ( + VOID + ); + +/** + Determines if the platform firmware is booting from eMMC. + + @retval TRUE Platform firmware is booting from eMMC + @retval FALSE Platform firmware is booting from a non-eMMC device = or the boot media is unknown +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsEmmc ( + VOID + ); + +/** + Determines if the platform firmware is booting from NVMe. + + @retval TRUE Platform firmware is booting from NVMe. + @retval FALSE Platform firmware is booting from a non-NVMe device = or the boot media is unknown +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsNvme ( + VOID + ); + +#endif diff --git a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/Dx= eSmmFirmwareBootMediaLib.c b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSm= mBootMediaLib/DxeSmmFirmwareBootMediaLib.c new file mode 100644 index 0000000000..1e3876afb3 --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFir= mwareBootMediaLib.c @@ -0,0 +1,107 @@ +/** @file + This library identifies the firmware boot media device. + + The firmware boot media device is used to make system initialization dec= isions in the boot flow dependent + upon firmware boot media. Note that the firmware boot media is the stora= ge media that the boot firmware is stored on. + It is not the OS storage media which may be stored upon a different non-= volatile storage device. + + This file contains implementation specific to the DXE and SMM boot phase= s. + +Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +STATIC FW_BOOT_MEDIA_TYPE mFwBootMedia =3D FwBootMediaMax; + +/** + Determines the current platform firmware boot media device. + + @param[out] FwBootMediaType The current platform Boot Media type. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_NOT_FOUND The boot media type could not be found. +**/ +EFI_STATUS +EFIAPI +GetFirmwareBootMediaType ( + OUT FW_BOOT_MEDIA_TYPE *FwBootMediaType + ) +{ + if (mFwBootMedia =3D=3D FwBootMediaMax) { + return EFI_NOT_FOUND; + } + + *FwBootMediaType =3D mFwBootMedia; + return EFI_SUCCESS; +} + +/** + Determines if the boot media is presently known. + + Note: Very early in boot this data may not be available. + + @retval TRUE Boot media is known + @retval FALSE Boot media is not known +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsKnown ( + VOID + ) +{ + return mFwBootMedia !=3D FwBootMediaMax; +} + +/** + The library constructor. + + This constructor depends upon gFirmwareBootMediaHobGuid. + It should be produced by the platform in the HOB producer phase. + + @param[in] ImageHandle The firmware allocated handle for the = UEFI image. + @param[in] SystemTable A pointer to the EFI system table. + + @retval EFI_SUCCESS The constructor executed successfully. + @retval EFI_NOT_FOUND The gFirmwareBootMediaHobGuid HOB coul= d not be located + or the boot media type is invalid. +**/ +EFI_STATUS +EFIAPI +DxeSmmFirmwareBootMediaLibInit ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + FW_BOOT_MEDIA_HOB_DATA *BootMediaHobData; + FW_BOOT_MEDIA_TYPE BootMediaType; + EFI_HOB_GUID_TYPE *GuidHobPtr; + + GuidHobPtr =3D GetFirstGuidHob (&gFirmwareBootMediaHobGuid); + if (GuidHobPtr =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "The firmware boot media HOB does not exist!\n")); + ASSERT (GuidHobPtr !=3D NULL); + return EFI_NOT_FOUND; + } + + BootMediaHobData =3D (FW_BOOT_MEDIA_HOB_DATA *) GET_GUID_HOB_DATA (GuidH= obPtr); + if (BootMediaHobData =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + BootMediaType =3D BootMediaHobData->BootMedia; + + if (BootMediaType >=3D FwBootMediaMax) { + DEBUG ((DEBUG_ERROR, "The firmware boot media HOB specifies an invalid= media type.\n")); + return EFI_NOT_FOUND; + } + + mFwBootMedia =3D BootMediaType; + + return EFI_SUCCESS; +} diff --git a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/Fi= rmwareBootMediaLib.c b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootM= ediaLib/FirmwareBootMediaLib.c new file mode 100644 index 0000000000..11a14d172d --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/FirmwareB= ootMediaLib.c @@ -0,0 +1,109 @@ +/** @file + This library identifies the firmware boot media device. + + The firmware boot media device is used to make system initialization dec= isions in the boot flow dependent + upon firmware boot media. Note that the firmware boot media is the stora= ge media that the boot firmware is stored on. + It is not the OS storage media which may be stored upon a different non-= volatile storage device. + + This file contains library implementation common to all boot phases. + +Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +/** + Determines if the platform firmware is booting from SPI. + + @retval TRUE Platform firmware is booting from SPI + @retval FALSE Platform firmware is booting from a non-SPI device o= r the boot media is unknown +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsSpi ( + VOID + ) +{ + EFI_STATUS Status; + FW_BOOT_MEDIA_TYPE BootMedia; + + Status =3D GetFirmwareBootMediaType (&BootMedia); + if (EFI_ERROR (Status) || BootMedia !=3D FwBootMediaSpi) { + return FALSE; + } else { + return TRUE; + } +} + +/** + Determines if the platform firmware is booting from UFS. + + @retval TRUE Platform firmware is booting from UFS + @retval FALSE Platform firmware is booting from a non-UFS device o= r the boot media is unknown +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsUfs ( + VOID + ) +{ + EFI_STATUS Status; + FW_BOOT_MEDIA_TYPE BootMedia; + + Status =3D GetFirmwareBootMediaType (&BootMedia); + if (EFI_ERROR (Status) || BootMedia !=3D FwBootMediaUfs) { + return FALSE; + } else { + return TRUE; + } +} + +/** + Determines if the platform firmware is booting from eMMC. + + @retval TRUE Platform firmware is booting from eMMC + @retval FALSE Platform firmware is booting from a non-eMMC device = or the boot media is unknown +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsEmmc ( + VOID + ) +{ + EFI_STATUS Status; + FW_BOOT_MEDIA_TYPE BootMedia; + + Status =3D GetFirmwareBootMediaType (&BootMedia); + if (EFI_ERROR (Status) || BootMedia !=3D FwBootMediaEmmc) { + return FALSE; + } else { + return TRUE; + } +} + +/** + Determines if the platform firmware is booting from NVMe. + + @retval TRUE Platform firmware is booting from NVMe. + @retval FALSE Platform firmware is booting from a non-NVMe device = or the boot media is unknown +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsNvme ( + VOID + ) +{ + EFI_STATUS Status; + FW_BOOT_MEDIA_TYPE BootMedia; + + Status =3D GetFirmwareBootMediaType (&BootMedia); + if (EFI_ERROR (Status) || BootMedia !=3D FwBootMediaNvme) { + return FALSE; + } else { + return TRUE; + } +} diff --git a/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/Pe= iFirmwareBootMediaLib.c b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBo= otMediaLib/PeiFirmwareBootMediaLib.c new file mode 100644 index 0000000000..14478e0dbe --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwa= reBootMediaLib.c @@ -0,0 +1,82 @@ +/** @file + This library identifies the firmware boot media device. + + The firmware boot media device is used to make system initialization dec= isions in the boot flow dependent + upon firmware boot media. Note that the firmware boot media is the stora= ge media that the boot firmware is stored on. + It is not the OS storage media which may be stored upon a different non-= volatile storage device. + + This file contains implementation specific to the PEI boot phase. + +Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +/** + Determines the current platform firmware boot media device. + + @param[out] FwBootMediaType The current platform Boot Media type. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_NOT_FOUND The boot media type could not be found. +**/ +EFI_STATUS +EFIAPI +GetFirmwareBootMediaType ( + OUT FW_BOOT_MEDIA_TYPE *FwBootMediaType + ) +{ + FW_BOOT_MEDIA_HOB_DATA *BootMediaHobData; + EFI_HOB_GUID_TYPE *GuidHobPtr; + + GuidHobPtr =3D GetFirstGuidHob (&gFirmwareBootMediaHobGuid); + if (GuidHobPtr =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "The firmware boot media HOB does not exist!\n"= )); + ASSERT (GuidHobPtr !=3D NULL); + return EFI_NOT_FOUND; + } + + BootMediaHobData =3D (FW_BOOT_MEDIA_HOB_DATA *) GET_GUID_HOB_DATA (GuidH= obPtr); + if (BootMediaHobData =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + if (BootMediaHobData->BootMedia >=3D FwBootMediaMax) { + DEBUG ((DEBUG_ERROR, "The firmware boot media HOB specifies an invalid= media type.\n")); + return EFI_NOT_FOUND; + } + *FwBootMediaType =3D BootMediaHobData->BootMedia; + + return EFI_SUCCESS; +} + +/** + Determines if the boot media is presently known. + + Note: Very early in boot this data may not be available. + + @retval TRUE Boot media is known + @retval FALSE Boot media is not known +**/ +BOOLEAN +EFIAPI +FirmwareBootMediaIsKnown ( + VOID + ) +{ + EFI_STATUS Status; + FW_BOOT_MEDIA_TYPE BootMedia; + + BootMedia =3D FwBootMediaMax; + Status =3D GetFirmwareBootMediaType (&BootMedia); + if (EFI_ERROR (Status) || BootMedia =3D=3D FwBootMediaMax) { + return FALSE; + } else { + return TRUE; + } +} --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48482): https://edk2.groups.io/g/devel/message/48482 Mute This Topic: https://groups.io/mt/34396660/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 18:07:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48483+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48483+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1570210173; cv=none; d=zoho.com; s=zohoarc; b=NkqlXG00SmHJ5YE+bKCjjr7LnMpF1ZhswCBUMB25wFig24p6BX0HqWoVbmRzEKGxtASk/SYu2xs1PJAA2c1iGduli/ZrOcKGN6LV/6PqJEJjZ5zDpEUPSkP2F4/9ZSRFj7UxnU9P8WSXfDic7q2zL3fXOeSlUBtin7CmRzH8DKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570210173; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=hsYhwSOamTu8Xob0v4szrNcRlCcrOhHQ276/eaabAS8=; b=SqVxwo/+Q5PR5uu66NNjp/gFrDe+1JytJYO8yZnXmEzHGs32MUsKvdlfPt3WbrTjXAOZfjnt4wUem1RwKfOleqxvdrSV8dHcWcPkWNxZL9yqLvJwWEg/uNYEZ1Sx1WoJJkKCTUkWHSIvWlMB4PK5fpoNZanqlrseBKpQR0o4iwI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48483+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570210173742198.44286772123598; Fri, 4 Oct 2019 10:29:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id o2WuYY1788612xdwZaIAa4AL; Fri, 04 Oct 2019 10:29:32 -0700 X-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 X-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:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,257,1566889200"; d="scan'208";a="186324620" X-Received: from makuback-desk1.amr.corp.intel.com ([10.7.159.162]) by orsmga008.jf.intel.com with ESMTP; 04 Oct 2019 10:29:31 -0700 From: "Kubacki, Michael A" To: devel@edk2.groups.io Cc: Eric Dong , Liming Gao Subject: [edk2-devel] [edk2-platforms][PATCH V2 2/3] BoardModulePkg/FirmwareBootMediaInfoLib: Add library Date: Fri, 4 Oct 2019 10:29:23 -0700 Message-Id: <20191004172924.20240-3-michael.a.kubacki@intel.com> In-Reply-To: <20191004172924.20240-1-michael.a.kubacki@intel.com> References: <20191004172924.20240-1-michael.a.kubacki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.a.kubacki@intel.com X-Gm-Message-State: 0GCMQ5sW6KRQMy0Se3wELoc6x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570210172; bh=1K/Cj4VUEXJydXeTM5twbfko0tgNnJ8bYMSGDr/COx0=; h=Cc:Date:From:Reply-To:Subject:To; b=rwpnfRUouY8CAS23PkqKwZOwyYlp6XIpJ5zffVkvZ/4Eo+wtdPhYQzQEuaaSYqKL4kW YTcBxS4T098BzZoNhsDbzB9sydBPR6Bm/l5SyYCDj7n/TgOtfHTdvsuWKpU8c2RW08fPJ +7zcXDSfO+pO3Ca9moqr1/sTgu0DTWsCwuU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2229 Introduces a new library class FirmwareBootMediaInfoLib that is used to report the firmware boot media device. A default library instance is provided that always returns the firmware boot media is SPI flash. For platforms with other firmware boot media options, a board-specific instance of this library should be used instead to provide the correct firmware boot media device information. Cc: Eric Dong Cc: Liming Gao Signed-off-by: Michael Kubacki Reviewed-by: Eric Dong --- Platform/Intel/BoardModulePkg/BoardModulePkg.dec = | 3 ++ Platform/Intel/BoardModulePkg/BoardModulePkg.dsc = | 3 ++ Platform/Intel/BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/PeiFirmw= areBootMediaInfoLib.inf | 35 ++++++++++++++++++++ Platform/Intel/BoardModulePkg/Include/Library/FirmwareBootMediaInfoLib.h = | 26 +++++++++++++++ Platform/Intel/BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/PeiFirmw= areBootMediaInfoLib.c | 24 ++++++++++++++ 5 files changed, 91 insertions(+) diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec b/Platform/In= tel/BoardModulePkg/BoardModulePkg.dec index 6f13945ca8..f96fb09aa1 100644 --- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec +++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec @@ -33,6 +33,9 @@ ## @libraryclass Provide services to get BIOS ID information. BiosIdLib|Include/Library/BiosIdLib.h =20 + ## @libraryclass Provides a service to determine the firmware boot m= edia device. + FirmwareBootMediaInfoLib|Include/Library/FirmwareBootMediaInfoLib.h + [Guids] ## Include Include/Guid/BiosId.h gBiosIdGuid =3D { 0xC3E36D09, 0x8294, 0x4b97, { 0xA8, 0x57, 0xD5, 0x28, = 0x8F, 0xE3, 0x3E, 0x28 } } diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc b/Platform/In= tel/BoardModulePkg/BoardModulePkg.dsc index 734ead9be8..3d605cf876 100644 --- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc +++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc @@ -33,6 +33,7 @@ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf =20 [LibraryClasses.common.PEIM] + FirmwareBootMediaLib|IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFi= rmwareBootMediaLib.inf HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAlloc= ationLib.inf =20 @@ -40,6 +41,7 @@ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/= PeiServicesTablePointerLibIdt.inf =20 [LibraryClasses.common.DXE_DRIVER] + FirmwareBootMediaLib|IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSm= mFirmwareBootMediaLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf =20 @@ -77,3 +79,4 @@ BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf =20 + BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/PeiFirmwareBootMediaI= nfoLib.inf diff --git a/Platform/Intel/BoardModulePkg/Library/PeiFirmwareBootMediaInfo= Lib/PeiFirmwareBootMediaInfoLib.inf b/Platform/Intel/BoardModulePkg/Library= /PeiFirmwareBootMediaInfoLib/PeiFirmwareBootMediaInfoLib.inf new file mode 100644 index 0000000000..637aeca2af --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/Pei= FirmwareBootMediaInfoLib.inf @@ -0,0 +1,35 @@ +## @file +# Firmware Boot Media Info Library +# +# This library identifies firmware boot media device information used in t= he boot flow for system initialization +# decisions dependent upon the firmware boot media. +# +# This library instance provides a default implementation of the FirmwareB= ootMediaInfoLib library class that always +# returns SPI flash as the boot media device. For any system firmware in w= hich this is not the case, an instance +# of this library class should be provided that returns the correct boot m= edia for the platform. +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiFirmwareBootMediaInfoLib + FILE_GUID =3D 91CC29F5-AEAD-4108-9E91-C8DECDC1C654 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FirmwareBootMediaInfoLib + +[Sources] + PeiFirmwareBootMediaInfoLib.c + +[Packages] + MdePkg/MdePkg.dec + IntelSiliconPkg/IntelSiliconPkg.dec + BoardModulePkg/BoardModulePkg.dec + +[LibraryClasses] + BaseLib + FirmwareBootMediaLib diff --git a/Platform/Intel/BoardModulePkg/Include/Library/FirmwareBootMedi= aInfoLib.h b/Platform/Intel/BoardModulePkg/Include/Library/FirmwareBootMedi= aInfoLib.h new file mode 100644 index 0000000000..b08f21ac74 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Include/Library/FirmwareBootMediaInfoLi= b.h @@ -0,0 +1,26 @@ +/** @file + This library identifies the firmware boot media device. + +Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _FIRMWARE_BOOT_MEDIA_INFO_LIB_H_ +#define _FIRMWARE_BOOT_MEDIA_INFO_LIB_H_ + +#include +#include + +/** + Identifies the firmware boot media type for the current boot. + + @retval BOOT_MEDIA_TYPE The boot media type. A value of FwBootMediaTyp= eMax indicates the firmware boot media + information is unavailable. +**/ +FW_BOOT_MEDIA_TYPE +IdentifyFirmwareBootMediaType ( + VOID + ); + +#endif diff --git a/Platform/Intel/BoardModulePkg/Library/PeiFirmwareBootMediaInfo= Lib/PeiFirmwareBootMediaInfoLib.c b/Platform/Intel/BoardModulePkg/Library/P= eiFirmwareBootMediaInfoLib/PeiFirmwareBootMediaInfoLib.c new file mode 100644 index 0000000000..0c29d96033 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/Pei= FirmwareBootMediaInfoLib.c @@ -0,0 +1,24 @@ +/** @file + This library identifies the firmware boot media device. + +Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +/** + Identifies the firmware boot media type for the current boot. + + @retval BOOT_MEDIA_TYPE The boot media type. A value of FwBootMediaTyp= eMax indicates the firmware boot media + information is unavailable. +**/ +FW_BOOT_MEDIA_TYPE +IdentifyFirmwareBootMediaType ( + VOID + ) +{ + return FwBootMediaSpi; +} --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48483): https://edk2.groups.io/g/devel/message/48483 Mute This Topic: https://groups.io/mt/34396662/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 18:07:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48484+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48484+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1570210174; cv=none; d=zoho.com; s=zohoarc; b=DwCX3NHxb3Du21M96YOya9XOxnMqPcv4lTJkNkchAQm33rLkdfYiMTGPef8LVQfRC0c9U9PxBm0Y+nw/WH9xxzDxYJaEfdmNPj1qOWTFqmWJZkHu4zPtMiJKqaapfjORCPiGA73ciu3Cciwe/sZ89+lT/P8F4hfk7jCHR3LsG1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570210174; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=VW/JgZinTjDT79NFXdVYzWl1FsUAQysdFdc7osJRmiI=; b=lYBcMiNvphVCX90Enb5O8UcVKA0RT6O5nQv8Cae+6zDL0b46r68+1KyjMi5P8jF6Eld80+gahgUSexbVmmlTanBqlLbaZa1H6C+D2t5Rr8W9Us4Mh645f5M1uP6vBBWk49Cp6smOIHDRGfwkNAFrPyTAIafKrOrZEn/5X7EaPeI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48484+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157021017406755.93487485645244; Fri, 4 Oct 2019 10:29:34 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WHqgYY1788612xgBd417Wt5w; Fri, 04 Oct 2019 10:29:33 -0700 X-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 X-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" X-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-devel] [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> In-Reply-To: <20191004172924.20240-1-michael.a.kubacki@intel.com> References: <20191004172924.20240-1-michael.a.kubacki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.a.kubacki@intel.com X-Gm-Message-State: QNmmLvdyVUAXNi75LdurR5etx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570210173; bh=dl7/kf1PUlxnzEGpPM4nWwTw8PRUchJGRHgNRPYqgQE=; h=Cc:Date:From:Reply-To:Subject:To; b=EB6mr+aq1Tphda9WG9t8A2gJsg0gnO75txUGIi754V2mZ0ZxblXNqkVfJu39sVK5LIi Xp4C9x1FQtHwREQrRpai/GsevxMRanL4fy0Sia0iH1CeuY/vwcixmlkR91OPtq8fujAqX 43JGHnuV+7+wOyb8BJLlt4gjgZeFueDGJgQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2229 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 Reviewed-by: Eric Dong --- Platform/Intel/BoardModulePkg/BoardModulePkg.dsc = | 3 + Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoP= ei.inf | 46 ++++++++++++ Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoP= ei.c | 76 ++++++++++++++++++++ 3 files changed, 125 insertions(+) diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc b/Platform/In= tel/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 =20 [LibraryClasses.common.PEIM] FirmwareBootMediaLib|IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFi= rmwareBootMediaLib.inf + FirmwareBootMediaInfoLib|BoardModulePkg/Library/PeiFirmwareBootMediaInfo= Lib/PeiFirmwareBootMediaInfoLib.inf HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAlloc= ationLib.inf =20 @@ -73,6 +75,7 @@ ##########################################################################= ######################### =20 [Components] + BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMediaInfoPei.inf BoardModulePkg/Library/CmosAccessLib/CmosAccessLib.inf BoardModulePkg/Library/PlatformCmosAccessLibNull/PlatformCmosAccessLibNu= ll.inf =20 diff --git a/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBo= otMediaInfoPei.inf b/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/Fi= rmwareBootMediaInfoPei.inf new file mode 100644 index 0000000000..a81932f2a1 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMedia= InfoPei.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 t= ype may simply be set to a single firmware +# boot media device with no run-time logic required. In any case, this mod= ule 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 =3D 0x00010017 + BASE_NAME =3D FirmwareBootMediaInfoPei + FILE_GUID =3D A8F14FA9-FC88-45F4-A622-F06E6C56E632 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D PEIM + ENTRY_POINT =3D 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/FirmwareBo= otMediaInfoPei.c b/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/Firm= wareBootMediaInfoPei.c new file mode 100644 index 0000000000..7a71071053 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/FirmwareBootMediaInfo/FirmwareBootMedia= InfoPei.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 t= ype may simply be set to a single firmware + boot media device with no run-time logic required. In any case, this mod= ule 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 suc= cessfully. + @retval EFI_NOT_FOUND The firmware boot media device information c= ould not be found to produce the + the firmware boot media HOB. +**/ +EFI_STATUS +EFIAPI +ProduceFirmwareBootMediaHob ( + VOID + ) +{ + FW_BOOT_MEDIA_HOB_DATA FwBootMediaHobData; + + FwBootMediaHobData.BootMedia =3D IdentifyFirmwareBootMediaType (); + if (FwBootMediaHobData.BootMedia =3D=3D 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 =3D ProduceFirmwareBootMediaHob (); + ASSERT_EFI_ERROR (Status); + + return Status; +} --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48484): https://edk2.groups.io/g/devel/message/48484 Mute This Topic: https://groups.io/mt/34396663/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-