summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2011-05-17 12:13:35 +0000
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2011-05-17 12:13:35 +0000
commitdeff65a4fd3769550a583d7cec1c2fcf9ba65d28 (patch)
tree00a7de5ed53dcecef2fa8e988368602793321c3d
parentef3f88727a63eac873b7b8d4d5e569173855e0ca (diff)
downloadedk2-platforms-deff65a4fd3769550a583d7cec1c2fcf9ba65d28.tar.xz
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
-rw-r--r--MdeModulePkg/Core/Dxe/FwVol/Ffs.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
index 5eb22d0ac5..2bd4405cf1 100644
--- a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
+++ b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
@@ -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) {