CalculateSum8() and CalculateSum16() defined in BaseLib are used to calculate checksum.

Signed-off-by: lzeng14
Reviewed-by: rsun3

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11674 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lzeng14 2011-05-17 12:13:35 +00:00
parent ef3f88727a
commit deff65a4fd
1 changed files with 4 additions and 20 deletions

View File

@ -1,7 +1,7 @@
/** @file
FFS file access utilities.
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -105,18 +105,9 @@ VerifyFvHeaderChecksum (
IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
)
{
UINT32 Index;
UINT32 HeaderLength;
UINT16 Checksum;
UINT16 *Ptr;
HeaderLength = FvHeader->HeaderLength;
Ptr = (UINT16 *)FvHeader;
Checksum = 0;
for (Index = 0; Index < HeaderLength / sizeof (UINT16); Index++) {
Checksum = (UINT16)(Checksum + Ptr[Index]);
}
Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength);
if (Checksum == 0) {
return TRUE;
@ -140,16 +131,9 @@ VerifyHeaderChecksum (
IN EFI_FFS_FILE_HEADER *FfsHeader
)
{
UINT32 Index;
UINT8 *Ptr;
UINT8 HeaderChecksum;
Ptr = (UINT8 *)FfsHeader;
HeaderChecksum = 0;
for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) {
HeaderChecksum = (UINT8)(HeaderChecksum + Ptr[Index]);
}
UINT8 HeaderChecksum;
HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));
HeaderChecksum = (UINT8) (HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File);
if (HeaderChecksum == 0) {