]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c
MdeModulePkg/Esrt: Add ESRT_FW_TYPE_SYSTEMFIRMWARE check.
[mirror_edk2.git] / MdeModulePkg / Universal / EsrtDxe / EsrtImpl.c
index f6d1e97451477348a5bb279549ccc2619b306eb2..35a237e3cce039d2958aee38077160ef6e486a13 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