MdeModulePkg/CapsuleLib: Fix runtime issue
[mirror_edk2.git] / MdeModulePkg / Library / DxeCapsuleLibFmp / DxeCapsuleLib.c
index 6344214..9ed0be3 100644 (file)
@@ -1453,33 +1453,44 @@ IsNestedFmpCapsule (
   EFI_SYSTEM_RESOURCE_ENTRY  Entry;\r
 \r
   EsrtGuidFound = FALSE;\r
-\r
-  //\r
-  // Check ESRT protocol\r
-  //\r
-  Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtProtocol);\r
-  if (!EFI_ERROR(Status)) {\r
-    Status = EsrtProtocol->GetEsrtEntry(&CapsuleHeader->CapsuleGuid, &Entry);\r
-    if (!EFI_ERROR(Status)) {\r
-      EsrtGuidFound = TRUE;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Check ESRT configuration table\r
-  //\r
-  if (!EsrtGuidFound) {\r
-    Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt);\r
-    if (!EFI_ERROR(Status)) {\r
-      ASSERT (Esrt != NULL);\r
-      EsrtEntry = (VOID *)(Esrt + 1);\r
-      for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) {\r
+  if (mIsVirtualAddrConverted) {\r
+    if(mEsrtTable != NULL) {\r
+      EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);\r
+      for (Index = 0; Index < mEsrtTable->FwResourceCount ; Index++, EsrtEntry++) {\r
         if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {\r
           EsrtGuidFound = TRUE;\r
           break;\r
         }\r
       }\r
     }\r
+  } else {\r
+    //\r
+    // Check ESRT protocol\r
+    //\r
+    Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtProtocol);\r
+    if (!EFI_ERROR(Status)) {\r
+      Status = EsrtProtocol->GetEsrtEntry(&CapsuleHeader->CapsuleGuid, &Entry);\r
+      if (!EFI_ERROR(Status)) {\r
+        EsrtGuidFound = TRUE;\r
+      }\r
+    }\r
+\r
+    //\r
+    // Check ESRT configuration table\r
+    //\r
+    if (!EsrtGuidFound) {\r
+      Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt);\r
+      if (!EFI_ERROR(Status)) {\r
+        ASSERT (Esrt != NULL);\r
+        EsrtEntry = (VOID *)(Esrt + 1);\r
+        for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) {\r
+          if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {\r
+            EsrtGuidFound = TRUE;\r
+            break;\r
+          }\r
+        }\r
+      }\r
+    }\r
   }\r
   if (!EsrtGuidFound) {\r
     return FALSE;\r