/* Calculates the checksum of the header of a file. The header is a zero byte checksum, so zero means header is good */
STATIC UINT8 CalculateHeaderChecksum(IN EFI_FFS_FILE_HEADER *FileHeader)
/* Calculates the checksum of the header of a file. The header is a zero byte checksum, so zero means header is good */
STATIC UINT8 CalculateHeaderChecksum(IN EFI_FFS_FILE_HEADER *FileHeader)
{
  UINT8  *Ptr;
  UINTN  Index;
  UINT8  Sum;
  Sum = 0;
  Ptr = (UINT8 *)FileHeader;
  for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
    Sum = (UINT8)(Sum + Ptr[Index]);
    Sum = (UINT8)(Sum + Ptr[Index+1]);
    Sum = (UINT8)(Sum + Ptr[Index+2]);
    Sum = (UINT8)(Sum + Ptr[Index+3]);
  }
  for ( ; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
    Sum = (UINT8)(Sum + Ptr[Index]);
  }
  Sum = (UINT8)(Sum - FileHeader->State);
  Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);
  return Sum;
}