From: Jiewen Yao Date: Wed, 21 Sep 2016 02:17:33 +0000 (+0800) Subject: MdeModulePkg/Esrt: Add ESRT_FW_TYPE_SYSTEMFIRMWARE check. X-Git-Tag: edk2-stable201903~5292 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=ab3aac14abcbfbed32e6b6c19327deb5e69b1e12 MdeModulePkg/Esrt: Add ESRT_FW_TYPE_SYSTEMFIRMWARE check. The previous ESRT driver unconditionally treat FMP to be ESRT_FW_TYPE_DEVICEFIRMWARE. EDKII System Capsule reuses FMP, but it is ESRT_FW_TYPE_SYSTEMFIRMWARE. Add check to ImageTypeId check to see if it is ESRT_FW_TYPE_SYSTEMFIRMWARE. Cc: Feng Tian Cc: Star Zeng Cc: Michael D Kinney Cc: Liming Gao Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao Reviewed-by: Liming Gao Reviewed-by: Michael Kinney Tested-by: Michael Kinney --- diff --git a/MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf b/MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf index 8fbc75bfcf..2c66f15399 100644 --- a/MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf +++ b/MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf @@ -4,7 +4,7 @@ # This driver produces EsrtManagement protocol to manage cache ESRT repository for FMP/Non-FMP instances. # ESRT table based on repository is published on gEfiEventReadyToBootGuid. # -# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -64,6 +64,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxFmpEsrtCacheNum ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdMaxNonFmpEsrtCacheNum ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid ## CONSUMES [Depex] gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid diff --git a/MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c b/MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c index f6d1e97451..35a237e3cc 100644 --- a/MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c +++ b/MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c @@ -1,7 +1,7 @@ /** @file Esrt management implementation. -Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -390,6 +390,35 @@ EXIT: return Status; } +/** + Return if this FMP is a system FMP or a device FMP, based upon FmpImageInfo. + + @param[in] FmpImageInfo A pointer to EFI_FIRMWARE_IMAGE_DESCRIPTOR + + @return TRUE It is a system FMP. + @return FALSE It is a device FMP. +**/ +BOOLEAN +IsSystemFmp ( + IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo + ) +{ + GUID *Guid; + UINTN Count; + UINTN Index; + + Guid = PcdGetPtr(PcdSystemFmpCapsuleImageTypeIdGuid); + Count = PcdGetSize(PcdSystemFmpCapsuleImageTypeIdGuid)/sizeof(GUID); + + for (Index = 0; Index < Count; Index++, Guid++) { + if (CompareGuid(&FmpImageInfo->ImageTypeId, Guid)) { + return TRUE; + } + } + + return FALSE; +} + /** Init one ESRT entry according to input FmpImageInfo (V1, V2, V3) . @@ -407,7 +436,11 @@ SetEsrtEntryFromFmpInfo ( { EsrtEntry->FwVersion = FmpImageInfo->Version; EsrtEntry->FwClass = FmpImageInfo->ImageTypeId; - EsrtEntry->FwType = ESRT_FW_TYPE_DEVICEFIRMWARE; + if (IsSystemFmp(FmpImageInfo)) { + EsrtEntry->FwType = ESRT_FW_TYPE_SYSTEMFIRMWARE; + } else { + EsrtEntry->FwType = ESRT_FW_TYPE_DEVICEFIRMWARE; + } EsrtEntry->LowestSupportedFwVersion = 0; EsrtEntry->CapsuleFlags = 0; EsrtEntry->LastAttemptVersion = 0;