MdeModulePkg/Esrt: Add ESRT_FW_TYPE_SYSTEMFIRMWARE check.
authorJiewen Yao <jiewen.yao@intel.com>
Wed, 21 Sep 2016 02:17:33 +0000 (10:17 +0800)
committerJiewen Yao <jiewen.yao@intel.com>
Tue, 8 Nov 2016 14:37:03 +0000 (22:37 +0800)
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 <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Tested-by: Michael Kinney <michael.d.kinney@intel.com>
MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c

index 8fbc75b..2c66f15 100644 (file)
@@ -4,7 +4,7 @@
 #  This driver produces EsrtManagement protocol to manage cache ESRT repository for FMP/Non-FMP instances.\r
 #  ESRT table based on repository is published on gEfiEventReadyToBootGuid.\r
 #\r
-#  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
@@ -64,6 +64,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxFmpEsrtCacheNum                  ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxNonFmpEsrtCacheNum               ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag ## CONSUMES\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid     ## CONSUMES\r
 \r
 [Depex]\r
   gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid\r
index f6d1e97..35a237e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Esrt management implementation.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -390,6 +390,35 @@ EXIT:
   return Status;\r
 }\r
 \r
+/**\r
+  Return if this FMP is a system FMP or a device FMP, based upon FmpImageInfo.\r
+\r
+  @param[in] FmpImageInfo A pointer to EFI_FIRMWARE_IMAGE_DESCRIPTOR\r
+\r
+  @return TRUE  It is a system FMP.\r
+  @return FALSE It is a device FMP.\r
+**/\r
+BOOLEAN\r
+IsSystemFmp (\r
+  IN EFI_FIRMWARE_IMAGE_DESCRIPTOR   *FmpImageInfo\r
+  )\r
+{\r
+  GUID      *Guid;\r
+  UINTN     Count;\r
+  UINTN     Index;\r
+\r
+  Guid = PcdGetPtr(PcdSystemFmpCapsuleImageTypeIdGuid);\r
+  Count = PcdGetSize(PcdSystemFmpCapsuleImageTypeIdGuid)/sizeof(GUID);\r
+\r
+  for (Index = 0; Index < Count; Index++, Guid++) {\r
+    if (CompareGuid(&FmpImageInfo->ImageTypeId, Guid)) {\r
+      return TRUE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
 /**\r
   Init one ESRT entry according to input FmpImageInfo (V1, V2, V3) .\r
 \r
@@ -407,7 +436,11 @@ SetEsrtEntryFromFmpInfo (
 {\r
   EsrtEntry->FwVersion                = FmpImageInfo->Version;\r
   EsrtEntry->FwClass                  = FmpImageInfo->ImageTypeId;\r
-  EsrtEntry->FwType                   = ESRT_FW_TYPE_DEVICEFIRMWARE;\r
+  if (IsSystemFmp(FmpImageInfo)) {\r
+    EsrtEntry->FwType                   = ESRT_FW_TYPE_SYSTEMFIRMWARE;\r
+  } else {\r
+    EsrtEntry->FwType                   = ESRT_FW_TYPE_DEVICEFIRMWARE;\r
+  }\r
   EsrtEntry->LowestSupportedFwVersion = 0;\r
   EsrtEntry->CapsuleFlags             = 0;\r
   EsrtEntry->LastAttemptVersion       = 0;\r