+ //\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