/* Searches the FFS file for a section by its type */
EFI_STATUS FvBufUnifyBlockSizes(IN OUT VOID *Fv, IN UINTN BlockSize)
/* Searches the FFS file for a section by its type */
EFI_STATUS FvBufUnifyBlockSizes(IN OUT VOID *Fv, IN UINTN BlockSize)
{
  EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
  EFI_FV_BLOCK_MAP_ENTRY *blk = hdr->BlockMap;
  UINT32 Size;
  Size = 0;
  while( blk->Length != 0 ||
         blk->NumBlocks != 0
       ) {
    Size = Size + (blk->Length * blk->NumBlocks);
    blk++;
    if ((UINT8*)blk > ((UINT8*)hdr + hdr->HeaderLength)) {
      return EFI_VOLUME_CORRUPTED;
    }
  }
  if ((Size % BlockSize) != 0) {
    return EFI_INVALID_PARAMETER;
  }
  CommonLibBinderSetMem (
    &hdr->BlockMap,
    (UINTN)blk - (UINTN)&hdr->BlockMap,
    0
    );
  hdr->BlockMap[0].Length = (UINT32)BlockSize;
  hdr->BlockMap[0].NumBlocks = Size / (UINT32)BlockSize;
  return EFI_SUCCESS;
}