From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: rangasai.v.chaganty@intel.com) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by groups.io with SMTP; Sun, 06 Oct 2019 18:45:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Oct 2019 18:45:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,265,1566889200"; d="scan'208";a="394188740" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 06 Oct 2019 18:45:45 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 6 Oct 2019 18:45:46 -0700 Received: from fmsmsx108.amr.corp.intel.com ([169.254.9.205]) by FMSMSX153.amr.corp.intel.com ([169.254.9.127]) with mapi id 14.03.0439.000; Sun, 6 Oct 2019 18:45:45 -0700 From: "Chaganty, Rangasai V" To: "Kubacki, Michael A" , "devel@edk2.groups.io" CC: "Ni, Ray" Subject: Re: [edk2-platforms][PATCH V2 1/3] IntelSiliconPkg/FirmwareBootMediaLib: Add library Thread-Topic: [edk2-platforms][PATCH V2 1/3] IntelSiliconPkg/FirmwareBootMediaLib: Add library Thread-Index: AQHVetlIE0CfYZT6AUCkaFY11+aOLqdOas1g Date: Mon, 7 Oct 2019 01:45:44 +0000 Message-ID: References: <20191004172924.20240-1-michael.a.kubacki@intel.com> <20191004172924.20240-2-michael.a.kubacki@intel.com> In-Reply-To: <20191004172924.20240-2-michael.a.kubacki@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGMyNWYxZTctMzNkOC00MTAwLTlkMzAtNzM4YmY5NzI3YWRlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSEFNQzZIVnhVOFhXS3M4cnZuN043UGVKdE9NXC9PRmdWRHFwYU5vXC9rNHVveDF5WkVhcVwvWmFVQUVqVXJ2bDFEdSJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Return-Path: rangasai.v.chaganty@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Sai Chaganty -----Original Message----- From: Kubacki, Michael A=20 Sent: Friday, October 04, 2019 10:29 AM To: devel@edk2.groups.io Cc: Chaganty, Rangasai V ; Ni, Ray Subject: [edk2-platforms][PATCH V2 1/3] IntelSiliconPkg/FirmwareBootMediaLi= b: Add library 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 firmwa= re 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 conditiona= lly based on the firmware boot media must use this library API. Cc: Sai Chaganty Cc: Ray Ni Signed-off-by: Michael Kubacki --- 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=20 +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,=20 + 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=20 +reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -80,6 +80,8 @@ IntelSiliconPkg/Feature/VTd/PlatformVTdInfoSamplePei/PlatformVTdInfoSamp= lePei.inf IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdateDxe.in= f IntelSiliconPkg/Feature/Capsule/Library/MicrocodeFlashAccessLibNull/Micr= ocodeFlashAccessLibNull.inf + =20 + IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/PeiFirmwareBootMediaLib. + inf =20 + IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmwareBootMediaL + ib.inf =20 [BuildOptions] *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES diff --git a/Sil= icon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmmFirmwareBoot= MediaLib.inf b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/= DxeSmmFirmwareBootMediaLib.inf new file mode 100644 index 0000000000..83ed5f04af --- /dev/null +++ b/Silicon/Intel/IntelSiliconPkg/Library/PeiDxeSmmBootMediaLib/DxeSmm +++ FirmwareBootMediaLib.inf @@ -0,0 +1,43 @@ +## @file +# Firmware Boot Media Library +# +# The firmware boot media device is used to make system initialization=20 +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 sto= red 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.
# # =20 +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/PeiFir +++ mwareBootMediaLib.inf @@ -0,0 +1,38 @@ +## @file +# Firmware Boot Media Library +# +# The firmware boot media device is used to make system initialization=20 +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 sto= red 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.
# # =20 +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=20 + 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 sto= red 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/DxeSmm +++ FirmwareBootMediaLib.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=20 + 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 sto= red 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=20 + (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=20 + (GuidHobPtr); 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/Firmwa +++ reBootMediaLib.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=20 + 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 sto= red 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/PeiFir +++ mwareBootMediaLib.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=20 + 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 sto= red 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=20 + (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=20 + (GuidHobPtr); 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; + } +} -- 2.16.2.windows.1