+ //\r
+ // Get the FirmwareVolumeBlock protocol on that handle\r
+ //\r
+ FvNameGuidIsFound = FALSE;\r
+ Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolumeBlockProtocolGuid, (VOID **)&Fvb);\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Get the full FV header based on FVB protocol.\r
+ //\r
+ ASSERT (Fvb != NULL);\r
+ Status = GetFwVolHeader (Fvb, &FwVolHeader);\r
+ if (!EFI_ERROR (Status)) {\r
+ ASSERT (FwVolHeader != NULL);\r
+ if (VerifyFvHeaderChecksum (FwVolHeader) && FwVolHeader->ExtHeaderOffset != 0) {\r
+ ExtHeaderOffset = (UINT32) FwVolHeader->ExtHeaderOffset;\r
+ BlockMap = FwVolHeader->BlockMap;\r
+ LbaIndex = 0;\r
+ LbaOffset = 0;\r
+ //\r
+ // Find LbaIndex and LbaOffset for FV extension header based on BlockMap.\r
+ //\r
+ while ((BlockMap->NumBlocks != 0) || (BlockMap->Length != 0)) {\r
+ for (Index = 0; Index < BlockMap->NumBlocks && ExtHeaderOffset >= BlockMap->Length; Index ++) {\r
+ ExtHeaderOffset -= BlockMap->Length;\r
+ LbaIndex ++;\r
+ }\r
+ //\r
+ // Check whether FvExtHeader is crossing the multi block range.\r
+ //\r
+ if (Index < BlockMap->NumBlocks) {\r
+ LbaOffset = ExtHeaderOffset;\r
+ break;\r
+ }\r
+ BlockMap++;\r
+ }\r
+ //\r
+ // Read FvNameGuid from FV extension header.\r
+ //\r
+ Status = ReadFvbData (Fvb, &LbaIndex, &LbaOffset, sizeof (FvNameGuid), (UINT8 *) &FvNameGuid);\r
+ if (!EFI_ERROR (Status)) {\r
+ FvNameGuidIsFound = TRUE;\r
+ }\r
+ }\r
+ CoreFreePool (FwVolHeader);\r
+ }\r
+ }\r
+\r
+ if (FvNameGuidIsFound) {\r
+ //\r
+ // Check whether the FV image with the found FvNameGuid has been processed.\r
+ //\r
+ for (Link = mFvHandleList.ForwardLink; Link != &mFvHandleList; Link = Link->ForwardLink) {\r
+ KnownHandle = CR(Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE);\r
+ if (CompareGuid (&FvNameGuid, &KnownHandle->FvNameGuid)) {\r
+ DEBUG ((EFI_D_ERROR, "FvImage on FvHandle %p and %p has the same FvNameGuid %g.\n", FvHandle, KnownHandle->Handle, FvNameGuid));\r
+ return NULL;\r
+ }\r
+ }\r
+ }\r
+\r
+ KnownHandle = AllocateZeroPool (sizeof (KNOWN_HANDLE));\r